HttpMessageContext
contains all of the per-request state information and encapsulates the client request,
server response, container handler for authentication callbacks, and the subject representing the caller.
Modifier and Type | Method and Description |
---|---|
public void | |
public AuthenticationStatus | |
public AuthenticationStatus | Returns: AuthenticationStatus#SEND_CONTINUE a String specifying the pathname to the resource. path)Forwards to another resource (Jakarta Servlet, Jakarta Server Pages file, or HTML file) on the server. |
public AuthenticationParameters | Returns: the parameters that were provided with the SecurityContext#authenticate(AuthParameters) call, or a default instance. Never null.Returns the parameters that were provided with the SecurityContext#authenticate(AuthParameters) call. |
public Principal | Returns: The caller principalGets the Principal set by a call to notifyContainerAboutLogin(). |
public Subject | Returns: the subject for which authentication is to take place.Returns the subject for which authentication is to take place. |
public Set | |
public CallbackHandler | Returns: the handler that the runtime provided to this contextReturns the low level Jakarta Authentication handler that the runtime provided when creating this
|
public MessageInfo | Returns: the message info instance for the current request.Returns the the low level Jakarta Authentication message info instance for the current request. |
public HttpServletRequest | Returns: the request object associated with the current request.Returns the request object associated with the current request. |
public HttpServletResponse | Returns: the response object associated with the current request.Returns the response object associated with the current request. |
public boolean | Returns: true if SecurityContext#authenticate was called, false if not.Checks if the current call to an authentication mechanism is the result from the
application calling If SecurityContext#authenticate was not called, the authentication mechanism may have been invoked by the container at the start of a request. |
public boolean | Returns: true if a protected resource was requested, false if a public resource was requested.Checks if the currently requested resource is protected or not. |
public boolean | Returns: true if code has asked to register an authentication session, false otherwise.Check if the runtime has been asked to register an authentication session duing the current request. |
public AuthenticationStatus | Returns: AuthenticationStatus#SUCCESS the caller name that will become the caller principal callername, Set<String> the groups associated with the caller principal groups)Asks the container to register the given caller name and groups in order to make
them available to the application for use with Note that after this call returned, the authenticated identity will not be immediately active. |
public AuthenticationStatus | Returns: AuthenticationStatus#SUCCESS the Principal that will become the caller principal principal, Set<String> the groups associated with the caller principal groups)Asks the container to register the given caller principal and groups in order to make
them available to the application for use with Note that this call may result in the container establishing two caller principals to represent the caller's identity -- the Principal provided here as the principal parameter, and a second principal used as the container's representation of the caller identity. |
public AuthenticationStatus | Returns: AuthenticationStatus#SUCCESS if CredentialValidationResult#getStatus()
equals Status#VALID otherwise AuthenticationStatus#SEND_FAILURE a CredentialValidationResult which is inspected for its status and from which the principal and groups
are taken. result)Convenience method intended to pass the |
public AuthenticationStatus | Returns: AuthenticationStatus#SEND_CONTINUE the location to redirect to location)Sets the response status to SC_FOUND 302 (Found)
As a convenience this method returns SEND_CONTINUE, so this method can be used in
one fluent return statement from an |
public AuthenticationStatus | Returns: AuthenticationStatus#SEND_FAILURE Sets the response status to 404 (not found). |
public AuthenticationStatus | Returns: AuthenticationStatus#SEND_FAILURE Sets the response status to 401 (unauthorized). |
public void | setRegisterSession(String
the caller name for which authentication should be be remembered callerName, Set<String> the groups for which authentication should be remembered. groups)Asks the runtime to register an authentication session. |
public void | |
public void | |
public HttpMessageContext | Returns: the HttpMessageContext instance on which this method was called, useful for fluent style call call chains.the request object to be set. request)Sets the request object. |
cleanClientSubject | back to summary |
---|---|
public void cleanClientSubject() Convenience method to clean the subject associated with this context.
Cleaning this subject is done as defined by the Servlet Container Profile of Jakarta Authentication
for the ServerAuthModule#cleanSubject method and the
|
doNothing | back to summary |
---|---|
public AuthenticationStatus doNothing() Instructs the container to "do nothing". When intending to do nothing, a Jakarta Security authentication mechanism has to indicate this explicitly via its return value.
As a convenience this method returns NOT_DONE, so this method can be used in
one fluent return statement from an |
forward | back to summary |
---|---|
public AuthenticationStatus forward(String path) Forwards to another resource (Jakarta Servlet, Jakarta Server Pages file, or HTML file) on the server.
As a convenience this method returns SEND_CONTINUE, so this method can be used in
one fluent return statement from an
|
getAuthParameters | back to summary |
---|---|
public AuthenticationParameters getAuthParameters() Returns the parameters that were provided with the SecurityContext#authenticate(AuthParameters) call.
|
getCallerPrincipal | back to summary |
---|---|
public Principal getCallerPrincipal() Gets the Principal set by a call to notifyContainerAboutLogin().
|
getClientSubject | back to summary |
---|---|
public Subject getClientSubject() Returns the subject for which authentication is to take place. Note This is a low level object that most higher level code would not need to use directly.
|
getGroups | back to summary |
---|---|
public Set Gets the groups set by a call to notifyContainerAboutLogin(). |
getHandler | back to summary |
---|---|
public CallbackHandler getHandler() Returns the low level Jakarta Authentication handler that the runtime provided when creating this
Note This is a low level object that most higher level code would not need to use directly.
|
getMessageInfo | back to summary |
---|---|
public MessageInfo getMessageInfo() Returns the the low level Jakarta Authentication message info instance for the current request. Note This is a low level object that most higher level code would not need to use directly.
|
getRequest | back to summary |
---|---|
public HttpServletRequest getRequest() Returns the request object associated with the current request.
|
getResponse | back to summary |
---|---|
public HttpServletResponse getResponse() Returns the response object associated with the current request.
|
isAuthenticationRequest | back to summary |
---|---|
public boolean isAuthenticationRequest() Checks if the current call to an authentication mechanism is the result from the
application calling If SecurityContext#authenticate was not called, the authentication mechanism may have been invoked by the container at the start of a request.
|
isProtected | back to summary |
---|---|
public boolean isProtected() Checks if the currently requested resource is protected or not. A protected resource is a resource (e.g. a Jakarta
Servlet, Jakarta Faces page, Jakarta Server Pages page etc) for which a constraint has been defined in e.g.
|
isRegisterSession | back to summary |
---|---|
public boolean isRegisterSession() Check if the runtime has been asked to register an authentication session duing the current request.
|
notifyContainerAboutLogin | back to summary |
---|---|
public AuthenticationStatus notifyContainerAboutLogin(String callername, Set<String> groups) Asks the container to register the given caller name and groups in order to make
them available to the application for use with Note that after this call returned, the authenticated identity will not be immediately active. This will only take place (should no errors occur) after the authentication mechanism in which this call takes place returns control back to the container (runtime).
As a convenience this method returns SUCCESS, so this method can be used in
one fluent return statement from an
|
notifyContainerAboutLogin | back to summary |
---|---|
public AuthenticationStatus notifyContainerAboutLogin(Principal principal, Set<String> groups) Asks the container to register the given caller principal and groups in order to make
them available to the application for use with Note that this call may result in the container establishing two caller principals to represent the caller's identity -- the Principal provided here as the principal parameter, and a second principal used as the container's representation of the caller identity. A second principal is added only if the container uses a different Principal type to represent the caller. If the types are the same, only one Principal is added.
If a second principal is added, the value returned by
When two principals are added, the container's caller principal is returned from
Note that after this call returned, the authenticated identity will not be immediately active. This will only take place (should no errors occur) after the authentication mechanism in which this call takes place returns control back to the container (runtime).
As a convenience this method returns SUCCESS, so this method can be used in
one fluent return statement from an
|
notifyContainerAboutLogin | back to summary |
---|---|
public AuthenticationStatus notifyContainerAboutLogin(CredentialValidationResult result) Convenience method intended to pass the
If the outcome from the given
If the outcome from the given
|
redirect | back to summary |
---|---|
public AuthenticationStatus redirect(String location) Sets the response status to SC_FOUND 302 (Found)
As a convenience this method returns SEND_CONTINUE, so this method can be used in
one fluent return statement from an
|
responseNotFound | back to summary |
---|---|
public AuthenticationStatus responseNotFound() Sets the response status to 404 (not found).
As a convenience this method returns SEND_FAILURE, so this method can be used in
one fluent return statement from an |
responseUnauthorized | back to summary |
---|---|
public AuthenticationStatus responseUnauthorized() Sets the response status to 401 (unauthorized).
As a convenience this method returns SEND_FAILURE, so this method can be used in
one fluent return statement from an |
setRegisterSession | back to summary |
---|---|
public void setRegisterSession(String callerName, Set<String> groups) Asks the runtime to register an authentication session. This will automatically remember the logged-in status
as long as the current HTTP session remains valid. Without this being asked, a |
setRequest | back to summary |
---|---|
public void setRequest(HttpServletRequest request) Sets the request object.
|
setResponse | back to summary |
---|---|
public void setResponse(HttpServletResponse response) Set the response object.
|
withRequest | back to summary |
---|---|
public HttpMessageContext withRequest(HttpServletRequest request) Sets the request object.
|