Thruway\Authentication\AuthenticationManager::onHelloAuthHandler PHP Метод

onHelloAuthHandler() приватный Метод

Call the RPC URI that has been registered to handle Authentication Hello Messages
private onHelloAuthHandler ( $authMethod, $authMethodInfo, Realm $realm, Session $session, Thruway\Message\HelloMessage $msg )
$authMethod
$authMethodInfo
$realm Thruway\Realm
$session Thruway\Session
$msg Thruway\Message\HelloMessage
    private function onHelloAuthHandler($authMethod, $authMethodInfo, Realm $realm, Session $session, HelloMessage $msg)
    {
        $authDetails = new AuthenticationDetails();
        $authDetails->setAuthMethod($authMethod);
        $helloDetails = $msg->getDetails();
        if (isset($helloDetails->authid)) {
            $authDetails->setAuthId($helloDetails->authid);
        }
        $session->setAuthenticationDetails($authDetails);
        $sessionInfo = ["sessionId" => $session->getSessionId(), "realm" => $realm->getRealmName()];
        $onHelloSuccess = function ($res) use($realm, $session, $msg) {
            // this is handling the return of the onhello RPC call
            if (isset($res[0]) && $res[0] == "FAILURE") {
                $this->abortSessionUsingResponse($session, $res);
                return;
            }
            if (count($res) < 2) {
                $session->abort(new \stdClass(), "thruway.auth.invalid_response_to_hello");
                return;
            }
            switch ($res[0]) {
                case "CHALLENGE":
                    // TODO: validate challenge message
                    $authMethod = $res[1]->challenge_method;
                    $challenge = $res[1]->challenge;
                    $session->getAuthenticationDetails()->setChallenge($challenge);
                    $session->getAuthenticationDetails()->setChallengeDetails($res[1]);
                    $challengeDetails = $session->getAuthenticationDetails()->getChallengeDetails();
                    $session->sendMessage(new ChallengeMessage($authMethod, $challengeDetails));
                    break;
                case "NOCHALLENGE":
                    $details = new \stdClass();
                    $details->authid = $res[1]->authid;
                    $details->authmethod = $session->getAuthenticationDetails()->getAuthMethod();
                    if (isset($res[1]->_thruway_authextra)) {
                        $session->getAuthenticationDetails()->setAuthExtra($res[1]->_thruway_authextra);
                    }
                    $session->sendMessage(new WelcomeMessage($session->getSessionId(), $details));
                    break;
                default:
                    $session->abort(new \stdClass(), "thruway.error.authentication_failure");
            }
        };
        $onHelloError = function () use($session) {
            Logger::error($this, "onhello rejected the promise");
            $session->abort(new \stdClass(), "thruway.error.unknown");
        };
        $onHelloAuthHandler = $authMethodInfo['handlers']->onhello;
        //Make the OnHello Call
        $this->session->call($onHelloAuthHandler, [$msg, $sessionInfo])->then($onHelloSuccess, $onHelloError);
    }