Class JWTCredentialValidator
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.idp.authn.AbstractCredentialValidator
net.shibboleth.idp.plugin.oidc.op.authn.impl.JWTCredentialValidator
- All Implemented Interfaces:
CredentialValidator,PrincipalSupportingComponent,Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent
A validator that handles authentication via signed JWT.
For now, implemented via Nimbus APIs.
TODO: there will be additional validation checks added once implemented on the older branch-
Nested Class Summary
Nested classes/interfaces inherited from interface net.shibboleth.idp.authn.CredentialValidator
CredentialValidator.ErrorHandler, CredentialValidator.WarningHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Function<ProfileRequestContext,ClaimsValidator> Strategy used to obtainClaimsValidator.Strategy that will returnOAuth2ClientAuthenticationContext.private final org.slf4j.LoggerClass logger.private booleanWhether to save the JWT in the Java Subject's public credentials.Strategy used to locate theSecurityParametersContextto use for verification. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected SubjectdoValidate(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext, CredentialValidator.WarningHandler warningHandler, CredentialValidator.ErrorHandler errorHandler) protected SubjectpopulateSubject(ClientID clientId, SignedJWT token) Builds a subject with "standard" content from the validation.voidSet the strategy used to locateClaimsValidatorused.voidsetOAuth2ClientAuthenticationLookupStrategy(Function<ProfileRequestContext, OAuth2ClientAuthenticationContext> strategy) Set the strategy used to return theOAuth2ClientAuthenticationContext.voidsetSaveTokenToCredentialSet(boolean flag) Set whether to save the JWT in the Java Subject's public credentials.voidsetSecurityParametersLookupStrategy(Function<ProfileRequestContext, SecurityParametersContext> strategy) Set the strategy used to locate theSecurityParametersContextto use.protected voidvalidateJWTClaims(ProfileRequestContext profileRequestContext, SignedJWT jwt, ClientID clientId) Validates the contents of the given JWT against the requirements set in the OIDC core specification section 9.Methods inherited from class net.shibboleth.idp.authn.AbstractCredentialValidator
getLogPrefix, getSupportedPrincipals, isAcceptable, populateSubject, setActivationCondition, setId, setSupportedPrincipals, validateMethods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
doInitialize, 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.IdentifiedComponent
getId
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
clientAuthContextLookupStrategy
@Nonnull private Function<ProfileRequestContext,OAuth2ClientAuthenticationContext> clientAuthContextLookupStrategyStrategy that will returnOAuth2ClientAuthenticationContext. -
securityParametersLookupStrategy
@Nonnull private Function<ProfileRequestContext,SecurityParametersContext> securityParametersLookupStrategyStrategy used to locate theSecurityParametersContextto use for verification. -
claimsValidatorLookupStrategy
Strategy used to obtainClaimsValidator. -
saveTokenToCredentialSet
private boolean saveTokenToCredentialSetWhether to save the JWT in the Java Subject's public credentials.
-
-
Constructor Details
-
JWTCredentialValidator
public JWTCredentialValidator()Constructor.
-
-
Method Details
-
setOAuth2ClientAuthenticationLookupStrategy
public void setOAuth2ClientAuthenticationLookupStrategy(@Nonnull Function<ProfileRequestContext, OAuth2ClientAuthenticationContext> strategy) Set the strategy used to return theOAuth2ClientAuthenticationContext.- Parameters:
strategy- lookup strategy
-
setSecurityParametersLookupStrategy
public void setSecurityParametersLookupStrategy(@Nonnull Function<ProfileRequestContext, SecurityParametersContext> strategy) Set the strategy used to locate theSecurityParametersContextto use.- Parameters:
strategy- lookup strategy
-
setClaimsValidatorLookupStrategy
public void setClaimsValidatorLookupStrategy(@Nonnull Function<ProfileRequestContext, ClaimsValidator> strategy) Set the strategy used to locateClaimsValidatorused.- Parameters:
strategy- lookup strategy
-
setSaveTokenToCredentialSet
public void setSaveTokenToCredentialSet(boolean flag) Set whether to save the JWT in the Java Subject's public credentials.Defaults to true
- Parameters:
flag- flag to set
-
doValidate
@Nullable protected Subject doValidate(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext, @Nullable CredentialValidator.WarningHandler warningHandler, @Nullable CredentialValidator.ErrorHandler errorHandler) throws Exception - Specified by:
doValidatein classAbstractCredentialValidator- Throws:
Exception
-
validateJWTClaims
protected void validateJWTClaims(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull SignedJWT jwt, @Nonnull ClientID clientId) throws ParseException, JWTValidationException Validates the contents of the given JWT against the requirements set in the OIDC core specification section 9.- Parameters:
jwt- JWT to be validatedclientId- client ID from which the JWT is coming fromprofileRequestContext- profile request context- Throws:
ParseException- if unable to parse the claim setJWTValidationException- if the claims fail to validate
-
populateSubject
@Nonnull protected Subject populateSubject(@Nonnull @NotEmpty ClientID clientId, @Nonnull SignedJWT token) Builds a subject with "standard" content from the validation.- Parameters:
clientId- client IDtoken- the token validated- Returns:
- the decorated subject
-