AppserverIo\Appserver\ServletEngine\Security\Realm::authenticateByUsernameAndCallbackHandler PHP Метод

authenticateByUsernameAndCallbackHandler() публичный Метод

Finally tries to authenticate the user with the passed name.
public authenticateByUsernameAndCallbackHandler ( string $username, AppserverIo\Psr\Security\Auth\Callback\CallbackHandlerInterface $callbackHandler ) : AppserverIo\Security\PrincipalInterface | null
$username string The name of the user to authenticate
$callbackHandler AppserverIo\Psr\Security\Auth\Callback\CallbackHandlerInterface The callback handler used to load the credentials
Результат AppserverIo\Security\PrincipalInterface | null The authenticated user principal
    public function authenticateByUsernameAndCallbackHandler(string $username, CallbackHandlerInterface $callbackHandler)
    {
        try {
            // initialize the subject and the configuration
            $subject = new Subject();
            $configuration = $this->getConfiguration();
            // initialize the LoginContext and try to login the user
            $loginContext = new LoginContext($subject, $callbackHandler, $configuration);
            $loginContext->login();
            // create and return a new Principal of the authenticated user
            return $this->createPrincipal($username, $subject, $loginContext);
        } catch (\Exception $e) {
            // add the exception to the stack
            $this->getExceptionStack()->add($e);
            // load the system logger and debug log the exception
            /** @var \Psr\Log\LoggerInterface $systemLogger */
            if ($systemLogger = $this->getAuthenticationManager()->getApplication()->getNamingDirectory()->search(NamingDirectoryKeys::SYSTEM_LOGGER)) {
                $systemLogger->error($e->__toString());
            }
        }
    }