Package org.eclipse.jetty.security
Interface AuthenticationState
- All Superinterfaces:
Request.AuthenticationState
- All Known Subinterfaces:
AuthenticationState.Deferred
,AuthenticationState.ResponseSent
,AuthenticationState.Succeeded
- All Known Implementing Classes:
AuthenticationState.ServeAs
,DeferredAuthenticationState
,LoginAuthenticator.LoggedOutAuthentication
,LoginAuthenticator.UserAuthenticationSent
,LoginAuthenticator.UserAuthenticationSucceeded
,SessionAuthentication
The Authentication state of a request.
The Authentication state can be one of several sub-types that reflects where the request is in the many different authentication cycles. Authentication might not yet be checked or it might be checked and failed, checked and deferred or succeeded.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Authentication is Deferred, either so that credentials can later be passed withAuthenticationState.Deferred.login(String, String, Request, Response)
; or that existing credentials on the request may be validated withAuthenticationState.Deferred.authenticate(Request)
; or an authentication dialog can be advanced withAuthenticationState.Deferred.authenticate(Request, Response, Callback)
.static interface
Authentication Response sent state.static class
TheSecurityHandler
will use this to wrap theRequest
.static interface
A successful Authentication with User information. -
Field Summary
Modifier and TypeFieldDescriptionstatic final AuthenticationState
Authentication challenge sent.static final AuthenticationState
Authentication failure sent.static final AuthenticationState
Authentication success sent. -
Method Summary
Modifier and TypeMethodDescriptionauthenticate
(Request request) Get successful authentication for a request.authenticate
(Request request, Response response, Callback callback) Get successful authentication for a request.static AuthenticationState.Deferred
defer
(LoginAuthenticator loginAuthenticator) static AuthenticationState
getAuthenticationState
(Request request) Get the authentication state of a requeststatic Principal
getUserPrincipal
(Request request) Get theUserPrincipal
of an authenticated request.Attempt to login a request using the passed credentials.static boolean
static void
setAuthenticationState
(Request request, AuthenticationState authenticationState) Set the authentication state of a request.Methods inherited from interface org.eclipse.jetty.server.Request.AuthenticationState
getUserPrincipal
-
Field Details
-
CHALLENGE
Authentication challenge sent.This convenience instance is for when an authentication challenge has been sent.
-
SEND_FAILURE
Authentication failure sent.This convenience instance is for when an authentication failure has been sent.
-
SEND_SUCCESS
Authentication success sent.This convenience instance is for when an authentication success has been sent.
-
-
Method Details
-
getAuthenticationState
Get the authentication state of a request- Parameters:
request
- The request to query- Returns:
- The authentication state of the request or null if none.
-
setAuthenticationState
Set the authentication state of a request.- Parameters:
request
- The request to updateauthenticationState
- the state to set on the request.
-
getUserPrincipal
Get theUserPrincipal
of an authenticated request. If theAuthenticationState
isAuthenticationState.Deferred
, then an attempt to validate is made and theAuthenticationState
of the request is updated.- Parameters:
request
- The request to query- Returns:
- The
UserPrincipal
of anyAuthenticationState.Succeeded
authentication state, potential after validating aAuthenticationState.Deferred
state. - See Also:
-
authenticate
Get successful authentication for a request. If theAuthenticationState
isAuthenticationState.Deferred
, then an attempt to authenticate, but without sending a challenge.- Parameters:
request
- The request to query.- Returns:
- A
AuthenticationState.Succeeded
authentiction or null - See Also:
-
authenticate
static AuthenticationState.Succeeded authenticate(Request request, Response response, Callback callback) Get successful authentication for a request. If theAuthenticationState
isAuthenticationState.Deferred
, then an attempt to authenticate, possibly sending a challenge. If authentication is not successful, then aHttpStatus.FORBIDDEN_403
response is sent.- Parameters:
request
- The request to query.response
- The response to use for a challenge or errorcallback
- The collback to complete if a challenge or error is sent.- Returns:
- A
AuthenticationState.Succeeded
authentication or null. If null is returned, then the callback will be completed. - See Also:
-
login
static AuthenticationState.Succeeded login(String username, String password, Request request, Response response) Attempt to login a request using the passed credentials. The currentAuthenticationState
must beAuthenticationState.Deferred
.- Parameters:
request
- The request to query.- Returns:
- A
AuthenticationState.Succeeded
authentiction or null - See Also:
-
logout
-
defer
-