Class OpenIdConnectModule
- java.lang.Object
-
- org.forgerock.jaspi.modules.openid.OpenIdConnectModule
-
- All Implemented Interfaces:
AsyncServerAuthModule
public class OpenIdConnectModule extends Object implements AsyncServerAuthModule
OpenID Connect module that allows access when a valid OpenID Connect JWT which our server trusts is presented in the specific header field.
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONNECTION_TIMEOUT_KEY
Lookup key for the configured HTTP connection's connection timeout for this module.static String
HEADER_KEY
Lookup key for the configured HTTP header used by this module to locate JWSs.static String
READ_TIMEOUT_KEY
Lookup key for the configured HTTP connection's read timeout for this module.static String
RESOLVERS_KEY
Lookup key for the configured resolvers which will be used by this module.
-
Constructor Summary
Constructors Constructor Description OpenIdConnectModule()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Promise<Void,AuthenticationException>
cleanSubject(MessageInfoContext messageInfo, Subject subject)
Nothing to clean.String
getModuleId()
Gets the ID of the module to be used in creating authentication audit logs to uniquely identify the authentication module and its outcome when processing a request message.Collection<Class<?>>
getSupportedMessageTypes()
Gets theCollection
ofClass
objects of the message types supported by the module.void
initialize(javax.security.auth.message.MessagePolicy requestPolicy, javax.security.auth.message.MessagePolicy responsePolicy, CallbackHandler callbackHandler, Map<String,Object> config)
Initialize this module with request and response message policies to enforce, aCallbackHandler
, and any module specific configuration properties.Promise<javax.security.auth.message.AuthStatus,AuthenticationException>
secureResponse(MessageInfoContext messageInfo, Subject subject)
Sends SEND_SUCCESS automatically.Promise<javax.security.auth.message.AuthStatus,AuthenticationException>
validateRequest(MessageInfoContext messageInfo, Subject clientSubject, Subject serviceSubject)
Attempts to retrieve the value of the specified OpenID Connect header from the messageInfo, then converts this to a Jwt and attempts to decrypt.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.forgerock.caf.authentication.api.AsyncServerAuthModule
toString
-
-
-
-
Field Detail
-
READ_TIMEOUT_KEY
public static final String READ_TIMEOUT_KEY
Lookup key for the configured HTTP connection's read timeout for this module.- See Also:
- Constant Field Values
-
CONNECTION_TIMEOUT_KEY
public static final String CONNECTION_TIMEOUT_KEY
Lookup key for the configured HTTP connection's connection timeout for this module.- See Also:
- Constant Field Values
-
HEADER_KEY
public static final String HEADER_KEY
Lookup key for the configured HTTP header used by this module to locate JWSs.- See Also:
- Constant Field Values
-
RESOLVERS_KEY
public static final String RESOLVERS_KEY
Lookup key for the configured resolvers which will be used by this module.- See Also:
- Constant Field Values
-
-
Method Detail
-
getModuleId
public String getModuleId()
Description copied from interface:AsyncServerAuthModule
Gets the ID of the module to be used in creating authentication audit logs to uniquely identify the authentication module and its outcome when processing a request message.- Specified by:
getModuleId
in interfaceAsyncServerAuthModule
- Returns:
- The ID of the module.
-
initialize
public void initialize(javax.security.auth.message.MessagePolicy requestPolicy, javax.security.auth.message.MessagePolicy responsePolicy, CallbackHandler callbackHandler, Map<String,Object> config) throws AuthenticationException
Initialize this module with request and response message policies to enforce, a
CallbackHandler
, and any module specific configuration properties.The request policy and the response policy must not both be null.
- Specified by:
initialize
in interfaceAsyncServerAuthModule
- Parameters:
requestPolicy
- The request policy this module must enforce, ornull
.responsePolicy
- The response policy this module must enforce, ornull
.callbackHandler
-CallbackHandler
used to request information.config
- AMap
of module-specific configuration properties.- Throws:
AuthenticationException
- when module initialization fails, including for the case where the options argument contains elements that are not supported by the module.
-
validateRequest
public Promise<javax.security.auth.message.AuthStatus,AuthenticationException> validateRequest(MessageInfoContext messageInfo, Subject clientSubject, Subject serviceSubject)
Attempts to retrieve the value of the specified OpenID Connect header from the messageInfo, then converts this to a Jwt and attempts to decrypt. If both these steps succeed, we verify the Jwt through theOpenIdResolver
interface to ensure that we are the intended audience, the token has not expired and the issuer was an expected source. If all of these validate, we return SUCCESS, otherwise SEND_FAILURE.- Specified by:
validateRequest
in interfaceAsyncServerAuthModule
- Parameters:
messageInfo
- The message context info for this request.clientSubject
- ASubject
that represents the subject of this request.serviceSubject
- ASubject
that represents the subject for the server ornull
. It may be used to secure the message response.- Returns:
- A Promise completed with AuthStatus.SUCCESS if everything validates or with AuthStatus.SEND_FAILURE in the case of a failure, or completed with an exception if there are issues handling the request caused by improper config.
- See Also:
AuthStatus
,ServerAuth.validateRequest( javax.security.auth.message.MessageInfo, Subject, Subject)
-
secureResponse
public Promise<javax.security.auth.message.AuthStatus,AuthenticationException> secureResponse(MessageInfoContext messageInfo, Subject subject)
Sends SEND_SUCCESS automatically. As we're on our way out of the system at this point, there's no need to hold them up, or append anything new to the response.- Specified by:
secureResponse
in interfaceAsyncServerAuthModule
- Parameters:
messageInfo
- The message context info for this request.subject
- ASubject
that represents the subject for the server ornull
. It may be used to secure the message response.- Returns:
A
Promise
that will be completed, as some point in the future, with either a successful value or a failure value.A successfully completed
Promise
will contain anAuthStatus
representing the completion status of the processing. SeeServerAuth.secureResponse( javax.security.auth.message.MessageInfo, Subject)
for the allowedAuthStatus
values. NoteAuthStatus.SEND_CONTINUE
is not supported by this interfaceA failed completed
Promise
will contain anAuthenticationException
when the message processing failed without establishing a failure response message in theMessageContextInfo
.- See Also:
AuthStatus
,ServerAuth.secureResponse( javax.security.auth.message.MessageInfo, Subject)
-
cleanSubject
public Promise<Void,AuthenticationException> cleanSubject(MessageInfoContext messageInfo, Subject subject)
Nothing to clean.- Specified by:
cleanSubject
in interfaceAsyncServerAuthModule
- Parameters:
messageInfo
- The message context info for this request.subject
- ASubject
that represents the subject of this request.- Returns:
- A
Promise
that will be completed, as some point in the future, with either a successful value or a failure value. A successfully completedPromise
will contain no value and a failed completedPromise
will contain anAuthenticationException
if an error occurs during theSubject
processing. - See Also:
ServerAuth.cleanSubject( javax.security.auth.message.MessageInfo, Subject)
-
getSupportedMessageTypes
public Collection<Class<?>> getSupportedMessageTypes()
Gets theCollection
ofClass
objects of the message types supported by the module.- Specified by:
getSupportedMessageTypes
in interfaceAsyncServerAuthModule
- Returns:
- A
Collection
ofClass
objects, with at least on element defining the message type(s) supported by the module.
-
-