AppserverIo\Appserver\ServletEngine\Authenticator\FormAuthenticator::login PHP Метод

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

Tries the login the passed username/password combination for the login configuration.
public login ( string $username, string $password, AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest ) : AppserverIo\Psr\Security\PrincipalInterface
$username string The username used to login
$password string The password used to authenticate the user
$servletRequest AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface The servlet request instance
Результат AppserverIo\Psr\Security\PrincipalInterface The authenticated user principal
    public function login(string $username, string $password, HttpServletRequestInterface $servletRequest)
    {
        // load the realm to authenticate this request for
        /** @var AppserverIo\Appserver\ServletEngine\Security\RealmInterface $realm */
        $realm = $this->getAuthenticationManager()->getRealm($this->getRealmName());
        // authenticate the request and initialize the user principal
        $userPrincipal = $realm->authenticate($username, $password);
        // query whether or not we can authenticate the user
        if ($userPrincipal == null) {
            throw new ServletException(sprintf('Can\'t authenticate user %s', $username));
        }
        // return's the user principal
        return $userPrincipal;
    }