Class InitializeOAuth2ClientAuthenticationMethodHandler
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.messaging.handler.AbstractMessageHandler
net.shibboleth.idp.plugin.authn.oidc.rp.impl.InitializeOAuth2ClientAuthenticationMethodHandler
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent,MessageHandler
An
action that resolves the Client Authentication method for the chosen
upstream OpenID Provider (issuer) from the profile configuration, and adds it to the
OAuth2ClientAuthenticationContext.
If a JWT client authentication type, the security parameters context is used to create a signed JWT client assertion.
- Event:
EventIds.PROCEED_EVENT_ID,IdPEventIds.INVALID_PROFILE_CONFIG,EventIds.INVALID_PROFILE_CTX,IdPEventIds.INVALID_RELYING_PARTY_CONFIG- Postcondition:
- Add the
ClientAuthenticationMethodto theOAuth2ClientAuthenticationContext
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringThe stashed client authentication method to use.private ClientSecretCredentialThe stashed client_secret to use if required.private StringThe stashed client identifier for this request.private SecurityParametersContextStashed security parameters context for JWT Bearer Token client authentication methods.private DurationThe offset to add to the 'exp' claim time for JWT client authentication methods.private final org.slf4j.LoggerClass logger.The stashed OAuth2 client authentication context.The strategy used to lookup or create theOAuth2ClientAuthenticationContextfor storing the client authentication.private Function<MessageContext,OIDCPeerEntityContext> Strategy to resolve the OIDC entity context class.private OIDCPeerEntityContextThe stashed peer entity context.private static final ParentProfileRequestContextLookup<MessageContext>Lookup function for parent ProfileRequestContext.Applicable stashed profile configuration.private com.nimbusds.openid.connect.sdk.op.OIDCProviderMetadataThe stashed provider metadata.Lookup strategy to locate the OP metadata to use.Lookup function for relying party context.Strategy used to look up theSecurityParametersContextto set the parameters for. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate com.nimbusds.jwt.SignedJWTbuildClientAuthenticationJwt(MessageContext messageContext) Build a signed JWT bearer token for client authentication using the populated security parameters.private com.nimbusds.jwt.JWTClaimsSetbuildClientAuthenticationJwtClaims(MessageContext messageContext) Build the claim values required for a client authentication bearer JWT.protected voiddoInvoke(MessageContext messageContext) protected booleandoPreInvoke(MessageContext messageContext) voidsetJwtBearerExpiryOffset(Duration expiry) Set the JWT expiry time offset for appropriate client authentication methods.voidsetOAuth2ClientAuthenticationContextLookupStrategy(Function<MessageContext, OAuth2ClientAuthenticationContext> strgy) Set the strategy to lookup theOAuth2ClientAuthenticationContextfrom theMessageContext.voidSet the lookup strategy to find theOIDCPeerEntityContext.voidSet the lookup strategy to locate the OpenID providers metadata.voidSet lookup strategy for relying party context.voidsetSecurityParametersContextLookupStrategy(Function<MessageContext, SecurityParametersContext> strategy) Set the strategy used to look up theSecurityParametersContext.private voidCheck the populated security context is using the correct algorithm family for client_secret_jwt client authentication.private voidCheck the populated security context is using the correct algorithm family for private_key_jwt client authentication.Methods inherited from class org.opensaml.messaging.handler.AbstractMessageHandler
doPostInvoke, doPostInvoke, getActivationCondition, getLogPrefix, invoke, isPreInvokeCalled, setActivationConditionMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, doInitialize, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.shared.component.InitializableComponent
initialize, isInitialized
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
PRC_LOOKUP
Lookup function for parent ProfileRequestContext. -
oauth2ClientAuthenticationContextLookupStrategy
@Nonnull private Function<MessageContext,OAuth2ClientAuthenticationContext> oauth2ClientAuthenticationContextLookupStrategyThe strategy used to lookup or create theOAuth2ClientAuthenticationContextfor storing the client authentication. -
oauth2ClientAuthenticationContext
The stashed OAuth2 client authentication context. -
providerMetadataLookupStrategy
@Nonnull private Function<MessageContext,OIDCProviderMetadataContext> providerMetadataLookupStrategyLookup strategy to locate the OP metadata to use. -
relyingPartyContextLookupStrategy
@Nonnull private Function<ProfileRequestContext,RelyingPartyContext> relyingPartyContextLookupStrategyLookup function for relying party context. -
oidcPeerEntityContextLookupStrategy
Strategy to resolve the OIDC entity context class. -
profileConfiguration
Applicable stashed profile configuration. -
securityParametersContextLookupStrategy
@Nonnull private Function<MessageContext,SecurityParametersContext> securityParametersContextLookupStrategyStrategy used to look up theSecurityParametersContextto set the parameters for. -
jwtBearerExpiryOffset
The offset to add to the 'exp' claim time for JWT client authentication methods. Default is 30 seconds. -
jwtBearerClientAuthSecurityParameters
Stashed security parameters context for JWT Bearer Token client authentication methods. Can benullif those client authentication methods are not used. -
providerMetadata
The stashed provider metadata. -
clientCredential
The stashed client_secret to use if required. -
clientAuthMethod
The stashed client authentication method to use. -
clientId
The stashed client identifier for this request. -
peerEntityContext
The stashed peer entity context.
-
-
Constructor Details
-
InitializeOAuth2ClientAuthenticationMethodHandler
public InitializeOAuth2ClientAuthenticationMethodHandler()Constructor.
-
-
Method Details
-
setOidcPeerEntityContextLookupStrategy
public void setOidcPeerEntityContextLookupStrategy(Function<MessageContext, OIDCPeerEntityContext> strategy) Set the lookup strategy to find theOIDCPeerEntityContext.- Parameters:
strategy- the strategy to set.- Since:
- 2.3.0
-
setJwtBearerExpiryOffset
Set the JWT expiry time offset for appropriate client authentication methods.- Parameters:
expiry- the JWT 'exp' claim offset
-
setProviderMetadataLookupStrategy
public void setProviderMetadataLookupStrategy(@Nonnull Function<MessageContext, OIDCProviderMetadataContext> strategy) Set the lookup strategy to locate the OpenID providers metadata.- Parameters:
strategy- the strategy.
-
setSecurityParametersContextLookupStrategy
public void setSecurityParametersContextLookupStrategy(@Nonnull Function<MessageContext, SecurityParametersContext> strategy) Set the strategy used to look up theSecurityParametersContext.- Parameters:
strategy- lookup strategy
-
setRelyingPartyContextLookupStrategy
public void setRelyingPartyContextLookupStrategy(@Nonnull Function<ProfileRequestContext, RelyingPartyContext> strategy) Set lookup strategy for relying party context.- Parameters:
strategy- lookup strategy
-
setOAuth2ClientAuthenticationContextLookupStrategy
public void setOAuth2ClientAuthenticationContextLookupStrategy(@Nonnull Function<MessageContext, OAuth2ClientAuthenticationContext> strgy) Set the strategy to lookup theOAuth2ClientAuthenticationContextfrom theMessageContext.- Parameters:
strgy- the strategy.
-
doPreInvoke
protected boolean doPreInvoke(@Nonnull MessageContext messageContext) throws MessageHandlerException - Overrides:
doPreInvokein classAbstractMessageHandler- Throws:
MessageHandlerException
-
doInvoke
- Specified by:
doInvokein classAbstractMessageHandler- Throws:
MessageHandlerException
-
verifySuitableClientSecretJWTSecurityContext
Check the populated security context is using the correct algorithm family for client_secret_jwt client authentication.- Throws:
MessageHandlerException- if the wrong algorithm family is specified in the security context
-
verifySuitablePrivateKetJWTSecurityContext
Check the populated security context is using the correct algorithm family for private_key_jwt client authentication.- Throws:
MessageHandlerException- if the wrong algorithm family is specified in the security context
-
buildClientAuthenticationJwtClaims
@Nonnull private com.nimbusds.jwt.JWTClaimsSet buildClientAuthenticationJwtClaims(@Nonnull MessageContext messageContext) throws MessageHandlerException Build the claim values required for a client authentication bearer JWT. By default, the audience is set to the issuer identifier of the OP, but there is a flag that allows this to be changed to the token endpoint URL, which was the previous default.- Parameters:
messageContext- the message context- Returns:
- the constructed JWT claims set
- Throws:
MessageHandlerException- on error constructing the JWT
-
buildClientAuthenticationJwt
@Nonnull private com.nimbusds.jwt.SignedJWT buildClientAuthenticationJwt(@Nonnull MessageContext messageContext) throws MessageHandlerException Build a signed JWT bearer token for client authentication using the populated security parameters. Relies on the correct 'alg' and credential existing in the security context ahead of time for the correct SignedJWT to be returned e.g. for either client_secret_jwt or private_key_jwt.- Parameters:
messageContext- the message context- Returns:
- a signed JWT bearer token, or throws an exception if there was an error during construction
- Throws:
MessageHandlerException- on error constructing the JWT
-