AppserverIo\Appserver\ServletEngine\Http\Request::login PHP Method

login() public method

Validate the provided username and password in the password validation realm used by the web container login mechanism configured for the ServletContext.
public login ( string $username, string $password ) : void
$username string The username to login
$password string The password used to authenticate the user
return void
    public function login(string $username, string $password)
    {
        // query whether or not we're already authenticated or not
        if ($this->getAuthType() != null || $this->getRemoteUser() != null || $this->getUserPrincipal() != null) {
            throw new ServletException('Already authenticated');
        }
        // load the authentication manager and try to authenticate this request
        /** @var \AppserverIo\Appserver\ServletEngine\Authentication\AuthenticationManagerInterface $authenticationManager */
        if ($authenticationManager = $this->getAuthenticationManager()) {
            // try to load the authentication managers default authenticator
            if (($authenticator = $authenticationManager->getAuthenticator()) == null) {
                throw new ServletException('Can\'t find default authenticator');
            }
            // authenticate the passed username/password combination
            $authenticator->login($username, $password, $this);
        }
    }