Class ChainingJWTClaimsValidator
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
net.shibboleth.oidc.security.jwt.claims.impl.ChainingJWTClaimsValidator
- All Implemented Interfaces:
ClaimsValidator,Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent
@ThreadSafeAfterInit
public class ChainingJWTClaimsValidator
extends AbstractIdentifiableInitializableComponent
implements ClaimsValidator
A
ClaimsValidator implementation that validates a JWT claims set from a chain
of configured validators.
Normally, validation terminates when one of the validators throws a JWTValidationException.
If no JWTValidationException is thrown, the claims set is 'valid'.
Optionally this can be toggled such that any of the validators succeeeding implies overall success.
Note, does not represent a chain of responsibility pattern despite the name.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<ClaimsValidator>List of claim validators.private final org.slf4j.LoggerClass logger.private booleanRequire all of the validators to be successful. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidvoidsetClaimValidators(List<ClaimsValidator> validators) Set the list of validators to use.voidsetRequireAll(boolean flag) Set whether to require all validators to be successful.voidvalidate(JWTClaimsSet claims, ProfileRequestContext context) Validate all, or part of, the given JWT claims set.Methods 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
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
claimValidators
List of claim validators. Ordering is not important. -
requireAll
private boolean requireAllRequire all of the validators to be successful.
-
-
Constructor Details
-
ChainingJWTClaimsValidator
public ChainingJWTClaimsValidator()Constructor.
-
-
Method Details
-
doInitialize
- Overrides:
doInitializein classAbstractIdentifiedInitializableComponent- Throws:
ComponentInitializationException
-
setRequireAll
public void setRequireAll(boolean flag) Set whether to require all validators to be successful.Defaults to true.
- Parameters:
flag- flag to set
-
setClaimValidators
Set the list of validators to use.- Parameters:
validators- validators to use
-
validate
public void validate(@Nullable JWTClaimsSet claims, @Nonnull ProfileRequestContext context) throws JWTValidationException Validate all, or part of, the given JWT claims set. Can take supporting information from the given context tree.Throws an exception if validation fails.
- Specified by:
validatein interfaceClaimsValidator- Parameters:
claims- the claims to validate.context- the profile request context.- Throws:
JWTValidationException- when validation is unsuccessful due to a failed attempt
-