Class BuildAccessToken
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.profile.action.AbstractProfileAction
org.opensaml.profile.action.AbstractConditionalProfileAction
net.shibboleth.idp.profile.AbstractProfileAction
net.shibboleth.idp.plugin.oidc.op.profile.impl.AbstractOIDCResponseAction
net.shibboleth.idp.plugin.oidc.op.oauth2.profile.impl.BuildAccessToken
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent,ProfileAction,Aware,MessageSource,MessageSourceAware,Action
Action that creates an Access Token, and stores it to an
AccessTokenContext.
There are various cases handled across different grant types and orders of operation. The token may be produced solely for a third-party service to consume, or may also or instead be usable with the OP's UserInfo endpoint.
The action supports either opaque access tokens sealed under the IdP's secret key, or the RFC 9068 standard for JWT-based tokens.
-
Field Summary
FieldsModifier and TypeFieldDescriptionStrategy used to create the subcontext to hold the token.private AccessTokenContextAccess token context.private Function<ProfileRequestContext,Duration> Strategy used to obtain the access token lifetime.private Function<ProfileRequestContext,String> Strategy used to obtain the access token type to issue.private Predicate<ProfileRequestContext>Condition used to determine whether to always issue bearer access token.private com.nimbusds.openid.connect.sdk.AuthenticationRequestAuthentication request in the case of such.private Function<ProfileRequestContext,com.nimbusds.oauth2.sdk.id.ClientID> Strategy used to obtain the original client ID.Strategy used to locate theOIDCAuthenticationResponseConsentContext.private Predicate<ProfileRequestContext>Predicate used to check if consent is enabled with a givenProfileRequestContext.private DataSealerSealer to use for opaque tokens.private IdentifierGenerationStrategyThe generator to use.Strategy used to locate theIdentifierGenerationStrategyto use.private Function<ProfileRequestContext,String> Strategy used to obtain the response issuer value.private booleanUse a JWT for the token.private org.slf4j.LoggerClass logger.private BiFunction<ProfileRequestContext,Map<String, Object>, Map<String, Object>> The strategy used for manipulating the token claims set.private com.fasterxml.jackson.databind.ObjectMapperObject mapper used for pretty-printing JWT contents.private org.slf4j.LoggerUsed to log protocol messages.private SubjectContextSubject context.Strategy used to locate theOIDCAuthenticationResponseTokenClaimsContext.private TokenClaimsSetAuthorize Code / Refresh Token the access token is based on, if any.private Collection<AccessTokenClaimsSetDecorator>Autowired claims set decorators.private Function<ProfileRequestContext,BiFunction<ProfileRequestContext, Map<String, Object>, Map<String, Object>>> Lookup function to supply strategy bi-function for manipulating token claims set.private booleanThe xmlSafe-flag passed to the identifier generator. -
Constructor Summary
ConstructorsConstructorDescriptionBuildAccessToken(Collection<AccessTokenClaimsSetDecorator> freeDecorators) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoExecute(ProfileRequestContext profileRequestContext) protected voidprotected booleandoPreExecute(ProfileRequestContext profileRequestContext) private com.nimbusds.jwt.JWTClaimsSetsealClaims(com.nimbusds.jwt.JWTClaimsSet claims) Rewrites a plaintext claimsset to hide custom claims used solely by the OP.voidSet the strategy used to create theAccessTokenContextto use.voidSet the strategy used to obtain the access token lifetime.voidSet the strategy used to obtain the access token type.voidSet the condition used to determine whether to always issue bearer access token.voidsetClientIDLookupStrategy(Function<ProfileRequestContext, com.nimbusds.oauth2.sdk.id.ClientID> strategy) Set the strategy used to locate the originalClientIDfrom the request.voidsetConsentEnabledPredicate(Predicate<ProfileRequestContext> predicate) Set the predicate used to check if consent is enabled with a givenProfileRequestContext.voidsetDataSealer(DataSealer sealer) SetDataSealerto use for opaque tokens.voidsetIdentifierGeneratorLookupStrategy(Function<ProfileRequestContext, IdentifierGenerationStrategy> strategy) Set the strategy used to locate theIdentifierGenerationStrategyto use.voidSet the strategy used to locate the issuer value to use.voidsetObjectMapper(com.fasterxml.jackson.databind.ObjectMapper mapper) Set the object mapper used for pretty-printing JWT contents.voidsetOIDCAuthenticationResponseConsentContextLookupStrategy(Function<ProfileRequestContext, OIDCAuthenticationResponseConsentContext> strategy) Set the strategy used to locate theOIDCAuthenticationResponseConsentContextassociated with a givenProfileRequestContext.voidsetOIDCAuthenticationResponseTokenClaimsContextLookupStrategy(Function<ProfileRequestContext, OIDCAuthenticationResponseTokenClaimsContext> strategy) Set the strategy used to locate theOIDCAuthenticationResponseTokenClaimsContextassociated with a givenProfileRequestContext.voidsetTokenClaimsSetManipulationStrategyLookupStrategy(Function<ProfileRequestContext, BiFunction<ProfileRequestContext, Map<String, Object>, Map<String, Object>>> strategy) Set the lookup function to supply strategy bi-function for manipulating token claims set.voidsetXmlSafeIdentifier(boolean flag) Set the xmlSafe-flag passed to the identifier generatorMethods inherited from class net.shibboleth.idp.plugin.oidc.op.profile.impl.AbstractOIDCResponseAction
getMetadataContext, getOidcResponseContextMethods inherited from class net.shibboleth.idp.profile.AbstractProfileAction
doExecute, execute, getBean, getBean, getMessage, getMessage, getMessage, getParameter, getParameter, getProfileContextLookupStrategy, getRequestContext, getResult, setMessageSource, setProfileContextLookupStrategyMethods inherited from class org.opensaml.profile.action.AbstractConditionalProfileAction
getActivationCondition, setActivationConditionMethods inherited from class org.opensaml.profile.action.AbstractProfileAction
doPostExecute, doPostExecute, ensureHttpServletRequest, ensureHttpServletResponse, execute, getHttpServletRequest, getHttpServletRequestSupplier, getHttpServletResponse, getHttpServletResponseSupplier, getLogPrefix, isPreExecuteCalled, setHttpServletRequestSupplier, setHttpServletResponseSupplierMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, 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 org.slf4j.Logger logClass logger. -
protocolMessageLog
@Nonnull private org.slf4j.Logger protocolMessageLogUsed to log protocol messages. -
dataSealer
Sealer to use for opaque tokens. -
issuerLookupStrategy
Strategy used to obtain the response issuer value. -
clientIDLookupStrategy
@Nonnull private Function<ProfileRequestContext,com.nimbusds.oauth2.sdk.id.ClientID> clientIDLookupStrategyStrategy used to obtain the original client ID. -
accessTokenTypeLookupStrategy
Strategy used to obtain the access token type to issue. -
accessTokenLifetimeLookupStrategy
Strategy used to obtain the access token lifetime. -
idGeneratorLookupStrategy
@Nonnull private Function<ProfileRequestContext,IdentifierGenerationStrategy> idGeneratorLookupStrategyStrategy used to locate theIdentifierGenerationStrategyto use. -
tokenClaimsContextLookupStrategy
@Nonnull private Function<ProfileRequestContext,OIDCAuthenticationResponseTokenClaimsContext> tokenClaimsContextLookupStrategyStrategy used to locate theOIDCAuthenticationResponseTokenClaimsContext. -
consentContextLookupStrategy
@Nonnull private Function<ProfileRequestContext,OIDCAuthenticationResponseConsentContext> consentContextLookupStrategyStrategy used to locate theOIDCAuthenticationResponseConsentContext. -
consentEnabledPredicate
Predicate used to check if consent is enabled with a givenProfileRequestContext. -
accessTokenContextCreationStrategy
@Nonnull private Function<ProfileRequestContext,AccessTokenContext> accessTokenContextCreationStrategyStrategy used to create the subcontext to hold the token. -
tokenClaimsSetManipulationStrategyLookupStrategy
@Nonnull private Function<ProfileRequestContext,BiFunction<ProfileRequestContext, tokenClaimsSetManipulationStrategyLookupStrategyMap<String, Object>, Map<String, Object>>> Lookup function to supply strategy bi-function for manipulating token claims set. -
alwaysIssueBearerAccessTokenCondition
Condition used to determine whether to always issue bearer access token. -
manipulationStrategy
@Nullable private BiFunction<ProfileRequestContext,Map<String, manipulationStrategyObject>, Map<String, Object>> The strategy used for manipulating the token claims set. -
tokenClaimsSetDecorators
Autowired claims set decorators. -
objectMapper
Object mapper used for pretty-printing JWT contents. -
tokenClaimsSet
Authorize Code / Refresh Token the access token is based on, if any. -
authenticationRequest
@Nullable private com.nimbusds.openid.connect.sdk.AuthenticationRequest authenticationRequestAuthentication request in the case of such. -
subjectCtx
Subject context. -
jwtTokenType
private boolean jwtTokenTypeUse a JWT for the token. -
idGenerator
The generator to use. -
accessTokenCtx
Access token context. -
xmlSafeIdentifier
private boolean xmlSafeIdentifierThe xmlSafe-flag passed to the identifier generator.
-
-
Constructor Details
-
BuildAccessToken
@Autowired public BuildAccessToken(@Nullable Collection<AccessTokenClaimsSetDecorator> freeDecorators) Constructor.- Parameters:
freeDecorators- free-standing decorators to add
-
-
Method Details
-
setAccessTokenTypeLookupStrategy
public void setAccessTokenTypeLookupStrategy(@Nonnull Function<ProfileRequestContext, String> strategy) Set the strategy used to obtain the access token type.- Parameters:
strategy- lookup strategy
-
setAccessTokenLifetimeLookupStrategy
public void setAccessTokenLifetimeLookupStrategy(@Nonnull Function<ProfileRequestContext, Duration> strategy) Set the strategy used to obtain the access token lifetime.- Parameters:
strategy- lookup strategy
-
setIdentifierGeneratorLookupStrategy
public void setIdentifierGeneratorLookupStrategy(@Nonnull Function<ProfileRequestContext, IdentifierGenerationStrategy> strategy) Set the strategy used to locate theIdentifierGenerationStrategyto use.- Parameters:
strategy- lookup strategy
-
setIssuerLookupStrategy
Set the strategy used to locate the issuer value to use.- Parameters:
strategy- lookup strategy
-
setClientIDLookupStrategy
public void setClientIDLookupStrategy(@Nonnull Function<ProfileRequestContext, com.nimbusds.oauth2.sdk.id.ClientID> strategy) Set the strategy used to locate the originalClientIDfrom the request.- Parameters:
strategy- lookup strategy
-
setOIDCAuthenticationResponseTokenClaimsContextLookupStrategy
public void setOIDCAuthenticationResponseTokenClaimsContextLookupStrategy(@Nonnull Function<ProfileRequestContext, OIDCAuthenticationResponseTokenClaimsContext> strategy) Set the strategy used to locate theOIDCAuthenticationResponseTokenClaimsContextassociated with a givenProfileRequestContext.- Parameters:
strategy- lookup strategy
-
setOIDCAuthenticationResponseConsentContextLookupStrategy
public void setOIDCAuthenticationResponseConsentContextLookupStrategy(@Nonnull Function<ProfileRequestContext, OIDCAuthenticationResponseConsentContext> strategy) Set the strategy used to locate theOIDCAuthenticationResponseConsentContextassociated with a givenProfileRequestContext.- Parameters:
strategy- lookup strategy
-
setConsentEnabledPredicate
Set the predicate used to check if consent is enabled with a givenProfileRequestContext.- Parameters:
predicate- predicate used to check if consent is enabled with a givenProfileRequestContext.
-
setAccessTokenContextCreationStrategy
public void setAccessTokenContextCreationStrategy(@Nonnull Function<ProfileRequestContext, AccessTokenContext> strategy) Set the strategy used to create theAccessTokenContextto use.- Parameters:
strategy- creation strategy
-
setTokenClaimsSetManipulationStrategyLookupStrategy
public void setTokenClaimsSetManipulationStrategyLookupStrategy(@Nonnull Function<ProfileRequestContext, BiFunction<ProfileRequestContext, Map<String, Object>, Map<String, Object>>> strategy) Set the lookup function to supply strategy bi-function for manipulating token claims set.- Parameters:
strategy- What to set
-
setObjectMapper
public void setObjectMapper(@Nonnull com.fasterxml.jackson.databind.ObjectMapper mapper) Set the object mapper used for pretty-printing JWT contents.- Parameters:
mapper- What to set.- Since:
- 4.1.0
-
setXmlSafeIdentifier
public void setXmlSafeIdentifier(boolean flag) Set the xmlSafe-flag passed to the identifier generator- Parameters:
flag- xmlSafe-flag
-
setAlwaysIssueBearerAccessTokenCondition
public void setAlwaysIssueBearerAccessTokenCondition(@Nonnull Predicate<ProfileRequestContext> condition) Set the condition used to determine whether to always issue bearer access token.- Parameters:
condition- condition to use- Since:
- 4.2.0
-
doInitialize
- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
doPreExecute
- Overrides:
doPreExecutein classAbstractOIDCResponseAction
-
doExecute
- Overrides:
doExecutein classAbstractProfileAction
-
sealClaims
@Nonnull private com.nimbusds.jwt.JWTClaimsSet sealClaims(@Nonnull com.nimbusds.jwt.JWTClaimsSet claims) throws DataSealerException, ParseException Rewrites a plaintext claimsset to hide custom claims used solely by the OP.- Parameters:
claims- the input claims- Returns:
- a rewritten claims set to use for the access token
- Throws:
ParseException- if unable to parse a claims setDataSealerException- if unable to seal the custom claims