PHP Class AppserverIo\Appserver\ServletEngine\Authenticator\FormAuthenticator

Inheritance: extends AbstractAuthenticator
显示文件 Open project: appserver-io/appserver

Protected Properties

Property Type Description
$password string The password to authenticate the user with.

Public Methods

Method Description
authenticate ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : boolean Try to authenticate the user making this request, based on the specified login configuration.
getPassword ( ) : AppserverIo\Lang\String Returns the parsed password.
login ( string $username, string $password, AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest ) : AppserverIo\Psr\Security\PrincipalInterface Tries the login the passed username/password combination for the login configuration.
logout ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest ) : void Logout the actual user from the session.

Protected Methods

Method Description
forwardToErrorPage ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : void Forward's the request to the configured error page.
forwardToFormRequest ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : void Forward's the request to the stored one or, if the user has not been on any page before, the application's base URL.
forwardToLoginPage ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : void Forward's the request to the configured login page.
matchRequest ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest ) : boolean Does this request match the saved one, so that it must be the redirect we signaled after successful authentication?
onCache ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : void Will be invoked to handle a cached authentication request.
onCredentials ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : void Will be invoked to load the credentials from the request.
onFailure ( AppserverIo\Appserver\ServletEngine\Security\RealmInterface $realm, AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : void Will be invoked when login fails for some reasons.
onLogin ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : void Will be invoked to request authentication.
onResubmit ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : void Will be invoked when login will be re-submitted.
onSuccess ( AppserverIo\Psr\Security\PrincipalInterface $userPrincipal, AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : void Will be invoked on a successfull login.
register ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse, AppserverIo\Psr\Security\PrincipalInterface $userPrincipal ) : void Register's the user principal and the authenticytion in the request and session.
restoreRequest ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpSessionInterface $session ) : void Populates the passed request with the request data of the original request found in the also passed session.
saveRequest ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpSessionInterface $session ) : void Stores the data of the passed request in the also passed session.

Method Details

authenticate() public method

Return TRUE if any specified constraint has been satisfied, or FALSE if we have created a response challenge already.
public authenticate ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : boolean
$servletRequest AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface The servlet request instance
$servletResponse AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface The servlet response instance
return boolean TRUE if authentication has already been processed on a request before, else FALSE

forwardToErrorPage() protected method

Forward's the request to the configured error page.
protected forwardToErrorPage ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : void
$servletRequest AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface The servlet request instance
$servletResponse AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface The servlet response instance
return void

forwardToFormRequest() protected method

Forward's the request to the stored one or, if the user has not been on any page before, the application's base URL.
protected forwardToFormRequest ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : void
$servletRequest AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface The servlet request instance
$servletResponse AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface The servlet response instance
return void

forwardToLoginPage() protected method

Forward's the request to the configured login page.
protected forwardToLoginPage ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : void
$servletRequest AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface The servlet request instance
$servletResponse AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface The servlet response instance
return void

getPassword() public method

Returns the parsed password.
public getPassword ( ) : AppserverIo\Lang\String
return AppserverIo\Lang\String The password

login() public method

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
return AppserverIo\Psr\Security\PrincipalInterface The authenticated user principal

logout() public method

Logout the actual user from the session.
public logout ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest ) : void
$servletRequest AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface The servlet request instance
return void

matchRequest() protected method

Does this request match the saved one, so that it must be the redirect we signaled after successful authentication?
protected matchRequest ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest ) : boolean
$servletRequest AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface The servlet request instance
return boolean TRUE if the request matches the saved one, else FALSE

onCache() protected method

Will be invoked to handle a cached authentication request.
protected onCache ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : void
$servletRequest AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface The servlet request instance
$servletResponse AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface The servlet response instance
return void

onCredentials() protected method

Will be invoked to load the credentials from the request.
protected onCredentials ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : void
$servletRequest AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface The servlet request instance
$servletResponse AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface The servlet response instance
return void

onFailure() protected method

Will be invoked when login fails for some reasons.
protected onFailure ( AppserverIo\Appserver\ServletEngine\Security\RealmInterface $realm, AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : void
$realm AppserverIo\Appserver\ServletEngine\Security\RealmInterface The realm instance containing the exception stack
$servletRequest AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface The servlet request instance
$servletResponse AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface The servlet response instance
return void

onLogin() protected method

Will be invoked to request authentication.
protected onLogin ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : void
$servletRequest AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface The servlet request instance
$servletResponse AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface The servlet response instance
return void

onResubmit() protected method

Will be invoked when login will be re-submitted.
protected onResubmit ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : void
$servletRequest AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface The servlet request instance
$servletResponse AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface The servlet response instance
return void

onSuccess() protected method

Will be invoked on a successfull login.
protected onSuccess ( AppserverIo\Psr\Security\PrincipalInterface $userPrincipal, AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse ) : void
$userPrincipal AppserverIo\Psr\Security\PrincipalInterface The user principal logged into the system
$servletRequest AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface The servlet request instance
$servletResponse AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface The servlet response instance
return void

register() protected method

Register's the user principal and the authenticytion in the request and session.
protected register ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse, AppserverIo\Psr\Security\PrincipalInterface $userPrincipal ) : void
$servletRequest AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface The servlet request instance
$servletResponse AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface The servlet response instance
$userPrincipal AppserverIo\Psr\Security\PrincipalInterface The actual user principal
return void

restoreRequest() protected method

Populates the passed request with the request data of the original request found in the also passed session.
protected restoreRequest ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpSessionInterface $session ) : void
$servletRequest AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface The servlet request instance
$session AppserverIo\Psr\Servlet\Http\HttpSessionInterface The session instance
return void

saveRequest() protected method

Stores the data of the passed request in the also passed session.
protected saveRequest ( AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest, AppserverIo\Psr\Servlet\Http\HttpSessionInterface $session ) : void
$servletRequest AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface The servlet request instance
$session AppserverIo\Psr\Servlet\Http\HttpSessionInterface The session instance
return void

Property Details

$password protected_oe property

The password to authenticate the user with.
protected string $password
return string