Class FallbackAuthContext
- java.lang.Object
-
- org.forgerock.caf.authentication.framework.FallbackAuthContext
-
- All Implemented Interfaces:
AsyncServerAuthContext,AuthContextWithState
public final class FallbackAuthContext extends Object implements AsyncServerAuthContext, AuthContextWithState
An
AsyncServerAuthContextwhich manages aListofAsyncServerAuthModules that are in a desired order of preference for authenticating incoming request messages.Order matters as one and only one auth module can successfully authenticate the request message. Each
AsyncServerAuthModuleis called in order to authenticate the request message and processing stops after the first auth module that successfully authenticates the request message, or returns a failed promise with anAuthenticationException.Order does not matter when securing the as only the auth module that successfully authenticated the incoming request message will get the opportunity to secure the response message.
- Since:
- 2.0.0
-
-
Constructor Summary
Constructors Constructor Description FallbackAuthContext(org.slf4j.Logger logger, List<AsyncServerAuthModule> authModules)Creates a newFallbackAuthContextmanaging the providedAsyncServerAuthModules.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Promise<Void,AuthenticationException>cleanSubject(MessageContext context, Subject clientSubject)Calls eachAsyncServerAuthContextin parallel to clean the client subject and only return a successful promise if all complete successfully otherwise returns the first exception in a failed promise.org.forgerock.caf.authentication.framework.FallbackAuthContext.FallbackAuthContextStatecreateAuthenticationState()Creates an instance of a specific type ofAuthenticationState.Promise<javax.security.auth.message.AuthStatus,AuthenticationException>secureResponse(MessageContext context, Subject serviceSubject)Secures the response message using the sameAsyncServerAuthModulethat authenticated the incoming request message.StringtoString()A short but useful description of this authentication context.Promise<javax.security.auth.message.AuthStatus,AuthenticationException>validateRequest(MessageContext context, Subject clientSubject, Subject serviceSubject)Authenticates the incoming request message by calling eachAsyncServerAuthModulein order until an auth module returns anAuthStatusvalue other thanSEND_FAILURE, or returns anAuthenticationExceptionor the end of the module list is reached.
-
-
-
Constructor Detail
-
FallbackAuthContext
public FallbackAuthContext(org.slf4j.Logger logger, List<AsyncServerAuthModule> authModules)Creates a newFallbackAuthContextmanaging the providedAsyncServerAuthModules.- Parameters:
logger- TheLoggerinstance.authModules- TheListofAsyncServerAuthModules.
-
-
Method Detail
-
validateRequest
public Promise<javax.security.auth.message.AuthStatus,AuthenticationException> validateRequest(MessageContext context, Subject clientSubject, Subject serviceSubject)
Authenticates the incoming request message by calling each
AsyncServerAuthModulein order until an auth module returns anAuthStatusvalue other thanSEND_FAILURE, or returns anAuthenticationExceptionor the end of the module list is reached.If the end of the module list is reached then an
AuthStatusvalue ofSEND_FAILUREis returned.- Specified by:
validateRequestin interfaceAsyncServerAuthContext- Parameters:
context- The message context for this request.clientSubject- ASubjectthat represents the subject of this request.serviceSubject- ASubjectthat represents the subject for the server ornull. It may be used to secure the message response.- Returns:
A
Promisethat will be completed, as some point in the future, with either a successful value or a failure value.A successfully completed
Promisewill contain anAuthStatusrepresenting the completion status of the message processing. SeeServerAuth.validateRequest( javax.security.auth.message.MessageInfo, Subject, Subject)for the allowedAuthStatusvalues.A failed completed
Promisewill contain anAuthenticationExceptionwhen the message processing failed without establishing a failure response message in theMessageContext.- See Also:
AuthStatus,ServerAuth.validateRequest( javax.security.auth.message.MessageInfo, Subject, Subject)
-
secureResponse
public Promise<javax.security.auth.message.AuthStatus,AuthenticationException> secureResponse(MessageContext context, Subject serviceSubject)
Secures the response message using the same
AsyncServerAuthModulethat authenticated the incoming request message.If no
AsyncServerAuthModuleauthenticated the incoming request message, then this method should not have been called and a failed promise will be return with anAuthenticationException.- Specified by:
secureResponsein interfaceAsyncServerAuthContext- Parameters:
context- The message context for this request.serviceSubject- ASubjectthat represents the subject for the server ornull. It may be used to secure the message response.- Returns:
A
Promisethat will be completed, as some point in the future, with either a successful value or a failure value.A successfully completed
Promisewill contain anAuthStatusrepresenting the completion status of the processing. SeeServerAuth.secureResponse( javax.security.auth.message.MessageInfo, Subject)for the allowedAuthStatusvalues. NoteAuthStatus.SEND_CONTINUEis not supported by this interfaceA failed completed
Promisewill contain anAuthenticationExceptionwhen the message processing failed without establishing a failure response message in theMessageContext.- See Also:
AuthStatus,ServerAuth.secureResponse( javax.security.auth.message.MessageInfo, Subject)
-
cleanSubject
public Promise<Void,AuthenticationException> cleanSubject(MessageContext context, Subject clientSubject)
Calls eachAsyncServerAuthContextin parallel to clean the client subject and only return a successful promise if all complete successfully otherwise returns the first exception in a failed promise.- Specified by:
cleanSubjectin interfaceAsyncServerAuthContext- Parameters:
context- The message context for this request.clientSubject- ASubjectthat represents the subject of this request.- Returns:
- A
Promisethat will be completed, as some point in the future, with either a successful value or a failure value. A successfully completedPromisewill contain no value and a failed completedPromisewill contain anAuthenticationExceptionif an error occurs during theSubjectprocessing. - See Also:
ServerAuth.cleanSubject( javax.security.auth.message.MessageInfo, Subject)
-
createAuthenticationState
public org.forgerock.caf.authentication.framework.FallbackAuthContext.FallbackAuthContextState createAuthenticationState()
Description copied from interface:AuthContextWithStateCreates an instance of a specific type of
AuthenticationState.Must return a new
AuthenticationStateinstance for each invocation.- Specified by:
createAuthenticationStatein interfaceAuthContextWithState- Returns:
- A new
AuthenticationStateinstance.
-
toString
public String toString()
Description copied from interface:AsyncServerAuthContextA short but useful description of this authentication context. Description should include at least the IDs of the module this context manages.- Specified by:
toStringin interfaceAsyncServerAuthContext- Overrides:
toStringin classObject
-
-