Top Description Inners Fields Methods
org.eclipse.jetty.security

public Interface AuthenticationState

extends AuthenticationState
Known Direct Subinterfaces
org.eclipse.jetty.security.AuthenticationState.Succeeded, org.eclipse.jetty.security.AuthenticationState.ResponseSent, org.eclipse.jetty.security.AuthenticationState.Deferred
Known Direct Implementers
org.eclipse.jetty.security.AuthenticationState.ServeAs
Imports
java.security.Principal, org.eclipse.jetty.http.HttpException, .HttpStatus, .HttpURI, org.eclipse.jetty.security.IdentityService.RunAsToken, org.eclipse.jetty.security.authentication.LoginAuthenticator, org.eclipse.jetty.security.internal.DeferredAuthenticationState, org.eclipse.jetty.server.Request, .Response, org.eclipse.jetty.util.Callback

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 and Inner Type Summary

Modifier and TypeClass and Description
public static interface
AuthenticationState.Deferred

Authentication is Deferred, either so that credentials can later be passed with login(String, String, Request, Response); or that existing credentials on the request may be validated with authenticate(Request); or an authentication dialog can be advanced with authenticate(Request, Response, Callback).

public static interface
AuthenticationState.ResponseSent

Authentication Response sent state.

public static class
AuthenticationState.ServeAs

The SecurityHandler will use this to wrap the Request.

public static interface
AuthenticationState.Succeeded

A successful Authentication with User information.

Field Summary

Modifier and TypeField and Description
public static final AuthenticationState
CHALLENGE

Authentication challenge sent.

public static final AuthenticationState
SEND_FAILURE

Authentication failure sent.

public static final AuthenticationState
SEND_SUCCESS

Authentication success sent.

Method Summary

Modifier and TypeMethod and Description
public static AuthenticationState.Succeeded

Returns:

A Succeeded authentiction or null
authenticate
(Request
The request to query.
request
)

Get successful authentication for a request.

public static AuthenticationState.Succeeded

Returns:

A Succeeded authentication or null. If null is returned, then the callback will be completed.
authenticate
(Request
The request to query.
request
,
Response
The response to use for a challenge or error
response
,
Callback
The collback to complete if a challenge or error is sent.
callback
)

Get successful authentication for a request.

public static AuthenticationState.Deferred
defer(LoginAuthenticator loginAuthenticator)

public static AuthenticationState

Returns:

The authentication state of the request or null if none.
getAuthenticationState
(Request
The request to query
request
)

Get the authentication state of a request

public static Principal

Returns:

The UserPrincipal of any Succeeded authentication state, potential after validating a Deferred state.
getUserPrincipal
(Request
The request to query
request
)

Get the UserPrincipal of an authenticated request.

public static AuthenticationState.Succeeded

Returns:

A Succeeded authentiction or null
login
(String username, String password, Request
The request to query.
request
,
Response response)

Attempt to login a request using the passed credentials.

public static boolean
logout(Request request, Response response)

public static void
setAuthenticationState(Request
The request to update
request
,
AuthenticationState
the state to set on the request.
authenticationState
)

Set the authentication state of a request.

Inherited from org.eclipse.jetty.server.Request.AuthenticationState:
getUserPrincipal

Field Detail

CHALLENGEback to summary
public static final AuthenticationState CHALLENGE

Authentication challenge sent.

This convenience instance is for when an authentication challenge has been sent.

SEND_FAILUREback to summary
public static final AuthenticationState SEND_FAILURE

Authentication failure sent.

This convenience instance is for when an authentication failure has been sent.

SEND_SUCCESSback to summary
public static final AuthenticationState SEND_SUCCESS

Authentication success sent.

This convenience instance is for when an authentication success has been sent.

Method Detail

authenticateback to summary
public static AuthenticationState.Succeeded authenticate(Request request)

Get successful authentication for a request. If the AuthenticationState is Deferred, then an attempt to authenticate, but without sending a challenge.

Parameters
request:Request

The request to query.

Returns:AuthenticationState.Succeeded

A Succeeded authentiction or null

See Also
Deferred#authenticate(Request), if an authentication challenge should be sent.
authenticateback to summary
public static AuthenticationState.Succeeded authenticate(Request request, Response response, Callback callback)

Get successful authentication for a request. If the AuthenticationState is Deferred, then an attempt to authenticate, possibly sending a challenge. If authentication is not successful, then a HttpStatus#FORBIDDEN_403 response is sent.

Parameters
request:Request

The request to query.

response:Response

The response to use for a challenge or error

callback:Callback

The collback to complete if a challenge or error is sent.

Returns:AuthenticationState.Succeeded

A Succeeded authentication or null. If null is returned, then the callback will be completed.

See Also
Deferred#authenticate(Request, Response, Callback), if an authentication challenge should not be sent.
deferback to summary
public static AuthenticationState.Deferred defer(LoginAuthenticator loginAuthenticator)
getAuthenticationStateback to summary
public static AuthenticationState getAuthenticationState(Request request)

Get the authentication state of a request

Parameters
request:Request

The request to query

Returns:AuthenticationState

The authentication state of the request or null if none.

getUserPrincipalback to summary
public static Principal getUserPrincipal(Request request)

Get the UserPrincipal of an authenticated request. If the AuthenticationState is Deferred, then an attempt to validate is made and the AuthenticationState of the request is updated.

Parameters
request:Request

The request to query

Returns:Principal

The UserPrincipal of any Succeeded authentication state, potential after validating a Deferred state.

See Also
authenticate(Request)
loginback to summary
public static AuthenticationState.Succeeded login(String username, String password, Request request, Response response)

Attempt to login a request using the passed credentials. The current AuthenticationState must be Deferred.

Parameters
request:Request

The request to query.

Returns:AuthenticationState.Succeeded

A Succeeded authentiction or null

See Also
Deferred#login(String, String, Request, Response)
logoutback to summary
public static boolean logout(Request request, Response response)
setAuthenticationStateback to summary
public static void setAuthenticationState(Request request, AuthenticationState authenticationState)

Set the authentication state of a request.

Parameters
request:Request

The request to update

authenticationState:AuthenticationState

the state to set on the request.

org.eclipse.jetty.security back to summary

public Interface AuthenticationState.Deferred

extends AuthenticationState
Known Direct Implementers
org.eclipse.jetty.security.authentication.LoginAuthenticator.LoggedOutAuthentication, org.eclipse.jetty.security.internal.DeferredAuthenticationState

Authentication is Deferred, either so that credentials can later be passed with login(String, String, Request, Response); or that existing credentials on the request may be validated with authenticate(Request); or an authentication dialog can be advanced with authenticate(Request, Response, Callback).

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
AuthenticationState.Deferred.DeferredResponse

A tag interface used to identify a Response that might be passed to Authenticator#validateRequest(Request, Response, Callback) while doing deferred authentication when a challenge cannot be sent.

Field Summary

Inherited from org.eclipse.jetty.security.AuthenticationState:
CHALLENGESEND_FAILURESEND_SUCCESS

Method Summary

Modifier and TypeMethod and Description
public AuthenticationState.Succeeded

Returns:

A Succeeded authentication or null
authenticate
(Request
The request to authenticate
request
)

Hides org.eclipse.jetty.security.AuthenticationState.authenticate.

Authenticate the request using any credentials already associated with the request.

public AuthenticationState

Returns:

The next AuthenticationState, if it is ResponseSent, then the callback will be completed.
authenticate
(Request
The request to authenticate
request
,
Response
The response to use for a challenge.
response
,
Callback
The callback to complete if a challenge is sent
callback
)

Hides org.eclipse.jetty.security.AuthenticationState.authenticate.

Authenticate the request using any credentials already associated with the request or challenging if necessary.

public IdentityService.Association
getAssociation()

Returns: Any org.eclipse.jetty.security.IdentityService.Association created during deferred authentication.

public static boolean
isDeferred(Response
the response
response
)

Returns: true if this response is from a deferred call to authenticate(Request)

public AuthenticationState.Succeeded

Returns:

A Succeeded authentication or null
login
(String
The username to validate
username
,
Object
The credential to validate
password
,
Request
The request to authenticate
request
,
Response
The response, which may be updated if the session ID is changed.
response
)

Authenticate the request with the passed credentials

public void
logout(Request
The authenticated request
request
,
Response
The associated response, which may be updated to clear a session ID.
response
)

Hides org.eclipse.jetty.security.AuthenticationState.logout.

Logout the authenticated user.

Inherited from org.eclipse.jetty.security.AuthenticationState:
defergetAuthenticationStategetUserPrincipalloginsetAuthenticationState

Method Detail

authenticateback to summary
public AuthenticationState.Succeeded authenticate(Request request)

Hides org.eclipse.jetty.security.AuthenticationState.authenticate.

Authenticate the request using any credentials already associated with the request. No challenge can be sent. If the login is successful, then the IdentityService#associate(UserIdentity, RunAsToken) method is used and the returned org.eclipse.jetty.security.IdentityService.Association is made available via getAssociation().

Parameters
request:Request

The request to authenticate

Returns:AuthenticationState.Succeeded

A Succeeded authentication or null

See Also
getAssociation()
authenticateback to summary
public AuthenticationState authenticate(Request request, Response response, Callback callback)

Hides org.eclipse.jetty.security.AuthenticationState.authenticate.

Authenticate the request using any credentials already associated with the request or challenging if necessary. If the login is successful, then the IdentityService#associate(UserIdentity, RunAsToken) method is used and the returned org.eclipse.jetty.security.IdentityService.Association is made available via getAssociation().

Parameters
request:Request

The request to authenticate

response:Response

The response to use for a challenge.

callback:Callback

The callback to complete if a challenge is sent

Returns:AuthenticationState

The next AuthenticationState, if it is ResponseSent, then the callback will be completed.

See Also
getAssociation()
getAssociationback to summary
public IdentityService.Association getAssociation()
Returns:IdentityService.Association

Any org.eclipse.jetty.security.IdentityService.Association created during deferred authentication.

See Also
authenticate(Request, Response, Callback), authenticate(Request)
isDeferredback to summary
public static boolean isDeferred(Response response)
Parameters
response:Response

the response

Returns:boolean

true if this response is from a deferred call to authenticate(Request)

loginback to summary
public AuthenticationState.Succeeded login(String username, Object password, Request request, Response response)

Authenticate the request with the passed credentials

Parameters
username:String

The username to validate

password:Object

The credential to validate

request:Request

The request to authenticate

response:Response

The response, which may be updated if the session ID is changed.

Returns:AuthenticationState.Succeeded

A Succeeded authentication or null

logoutback to summary
public void logout(Request request, Response response)

Hides org.eclipse.jetty.security.AuthenticationState.logout.

Logout the authenticated user.

Parameters
request:Request

The authenticated request

response:Response

The associated response, which may be updated to clear a session ID.

org.eclipse.jetty.security back to summary

public Interface AuthenticationState.Deferred.DeferredResponse

extends Response

A tag interface used to identify a Response that might be passed to Authenticator#validateRequest(Request, Response, Callback) while doing deferred authentication when a challenge cannot be sent.
See Also
authenticate(Request)
org.eclipse.jetty.security back to summary

public Interface AuthenticationState.ResponseSent

extends AuthenticationState
Known Direct Implementers
org.eclipse.jetty.security.authentication.LoginAuthenticator.UserAuthenticationSent

Authentication Response sent state. Responses are sent by authenticators either to issue an authentication challenge or on successful authentication in order to redirect the user to the original URL.

Field Summary

Inherited from org.eclipse.jetty.security.AuthenticationState:
CHALLENGESEND_FAILURESEND_SUCCESS

Method Summary

Inherited from org.eclipse.jetty.security.AuthenticationState:
authenticateauthenticatedefergetAuthenticationStategetUserPrincipalloginlogoutsetAuthenticationState
org.eclipse.jetty.security back to summary

public Class AuthenticationState.ServeAs

extends Object
implements AuthenticationState
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.security.AuthenticationState, org.eclipse.jetty.server.Request.AuthenticationState

The SecurityHandler will use this to wrap the Request. And then will return a Deferred authentication to bypass security constraints.

Field Summary

Modifier and TypeField and Description
private final HttpURI

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Request
wrap(Request request)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_uriback to summary
private final HttpURI _uri

Constructor Detail

ServeAsback to summary
public ServeAs(HttpURI uri)

Method Detail

wrapback to summary
public Request wrap(Request request)
org.eclipse.jetty.security back to summary

public Interface AuthenticationState.Succeeded

extends AuthenticationState
Known Direct Implementers
org.eclipse.jetty.security.authentication.LoginAuthenticator.UserAuthenticationSucceeded

A successful Authentication with User information.

Field Summary

Inherited from org.eclipse.jetty.security.AuthenticationState:
CHALLENGESEND_FAILURESEND_SUCCESS

Method Summary

Modifier and TypeMethod and Description
public String
getAuthenticationType()

Returns: The method used to authenticate the user.

public UserIdentity
getUserIdentity()

Returns: The UserIdentity of the authenticated user.

public default Principal
public boolean
isUserInRole(String
The role to check.
role
)

Returns: True if the user is in the passed role

public void
logout(Request
the request
request
,
Response
the response
response
)

Hides org.eclipse.jetty.security.AuthenticationState.logout.

Remove any user information that may be present in the request such that a call to getUserPrincipal/getRemoteUser will return null.

Inherited from org.eclipse.jetty.security.AuthenticationState:
authenticateauthenticatedefergetAuthenticationStategetUserPrincipalloginsetAuthenticationState

Method Detail

getAuthenticationTypeback to summary
public String getAuthenticationType()
Returns:String

The method used to authenticate the user.

getUserIdentityback to summary
public UserIdentity getUserIdentity()
Returns:UserIdentity

The UserIdentity of the authenticated user.

getUserPrincipalback to summary
public default Principal getUserPrincipal()

Overrides default org.eclipse.jetty.server.Request.AuthenticationState.getUserPrincipal.

Returns:Principal

Doc from org.eclipse.jetty.server.Request.AuthenticationState.getUserPrincipal.

The authenticated user Principal, or null if the Authentication is in a non-authenticated state.

Annotations
@Override
isUserInRoleback to summary
public boolean isUserInRole(String role)
Parameters
role:String

The role to check.

Returns:boolean

True if the user is in the passed role

logoutback to summary
public void logout(Request request, Response response)

Hides org.eclipse.jetty.security.AuthenticationState.logout.

Remove any user information that may be present in the request such that a call to getUserPrincipal/getRemoteUser will return null.

Parameters
request:Request

the request

response:Response

the response