Class AudienceClaimsValidator
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
net.shibboleth.oidc.jwt.claims.AbstractClaimsValidator
net.shibboleth.oidc.security.jwt.claims.impl.AudienceClaimsValidator
- All Implemented Interfaces:
ClaimsValidator,Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent
- Direct Known Subclasses:
AuthenticationAudienceClaimsValidator
Verifies the Audience (aud) claim contains the appropriate value.
The audience is determined at runtime using an appropriate strategy.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BiFunction<ProfileRequestContext,JWTClaimsSet, Set<String>> A strategy to lookup a list of additional audiences expected in the 'aud' claim.private booleanAllow a missing aud claim.Strategy to find the audience value from the context.private booleanIf enabled, any extra audience must be contained in the List returned from the additionalAudiencesLookupStrategy. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voiddoValidate(JWTClaimsSet claims, ProfileRequestContext context) Perform validation of the given claims supported by the supplied context.resolveAcceptedAudiences(JWTClaimsSet claims, ProfileRequestContext context) Resolve the set of accepted audiences.voidsetAdditionalAudiencesLookupStrategy(BiFunction<ProfileRequestContext, JWTClaimsSet, Set<String>> strategy) Set the strategy used to lookup the list of additional audiences to find in the 'aud' claim.voidsetAllowMissing(boolean flag) Set whether a missing 'aud' claim is valid or not.voidSet the audience lookup strategy.voidsetExtraAudienceValidation(boolean flag) Set whether to enable extra audience validation.Methods inherited from class net.shibboleth.oidc.jwt.claims.AbstractClaimsValidator
setActivationCondition, validateMethods inherited from class net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
setIdMethods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentExceptionMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, 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.IdentifiableComponent
setIdMethods inherited from interface net.shibboleth.shared.component.IdentifiedComponent
getId
-
Field Details
-
audienceLookupStrategy
@NonnullAfterInit private BiFunction<ProfileRequestContext,JWTClaimsSet, audienceLookupStrategyString> Strategy to find the audience value from the context. -
additionalAudiencesLookupStrategy
@Nonnull private BiFunction<ProfileRequestContext,JWTClaimsSet, additionalAudiencesLookupStrategySet<String>> A strategy to lookup a list of additional audiences expected in the 'aud' claim. If they are not found, the token is rejected. -
allowMissing
private boolean allowMissingAllow a missing aud claim. -
extraAudienceValidation
private boolean extraAudienceValidationIf enabled, any extra audience must be contained in the List returned from the additionalAudiencesLookupStrategy. Defaults to false.
-
-
Constructor Details
-
AudienceClaimsValidator
public AudienceClaimsValidator()Constructor.
-
-
Method Details
-
doInitialize
- Overrides:
doInitializein classAbstractIdentifiedInitializableComponent- Throws:
ComponentInitializationException
-
setAudienceLookupStrategy
public void setAudienceLookupStrategy(@Nonnull BiFunction<ProfileRequestContext, JWTClaimsSet, String> strategy) Set the audience lookup strategy.- Parameters:
strategy- the strategy.
-
setAdditionalAudiencesLookupStrategy
public void setAdditionalAudiencesLookupStrategy(@Nonnull BiFunction<ProfileRequestContext, JWTClaimsSet, Set<String>> strategy) Set the strategy used to lookup the list of additional audiences to find in the 'aud' claim.- Parameters:
strategy- the strategy- Since:
- 2.2.0
-
setAllowMissing
public void setAllowMissing(boolean flag) Set whether a missing 'aud' claim is valid or not.Defaults to false.
- Parameters:
flag- flag to set- Since:
- 2.1.0
-
setExtraAudienceValidation
public void setExtraAudienceValidation(boolean flag) Set whether to enable extra audience validation.Defaults to false.
- Parameters:
flag- the flag to set- Since:
- 2.2.0
-
resolveAcceptedAudiences
@Nonnull @NotEmpty protected Set<String> resolveAcceptedAudiences(@Nonnull JWTClaimsSet claims, @Nonnull ProfileRequestContext context) throws JWTValidationException Resolve the set of accepted audiences. This method is mostly a hook for classes extending this validator: in this case it simply returns the resolved single accepted audience in the set.- Parameters:
claims- the claims fed for the audience lookup strategycontext- the profile request context fed for the audience lookup strategy- Returns:
- the set containing the accepted audience claim
- Throws:
JWTValidationException- if the audience value could not be resolved via lookup strategy
-
doValidate
protected void doValidate(@Nonnull JWTClaimsSet claims, @Nonnull ProfileRequestContext context) throws JWTValidationException Perform validation of the given claims supported by the supplied context.- Specified by:
doValidatein classAbstractClaimsValidator- Parameters:
claims- the claims to validate.context- the profile request context.- Throws:
JWTValidationException- when validation is unsuccessful due to a failed attempt
-