Class BaseSignedJWTTrustEngine<TrustBasisType>
- java.lang.Object
-
- net.shibboleth.oidc.security.impl.BaseSignedJWTTrustEngine<TrustBasisType>
-
- Type Parameters:
TrustBasisType- the trust basis type
- All Implemented Interfaces:
TrustEngine<com.nimbusds.jwt.SignedJWT>
- Direct Known Subclasses:
ExplicitKeySignedJWTTrustEngine
public abstract class BaseSignedJWTTrustEngine<TrustBasisType> extends Object implements TrustEngine<com.nimbusds.jwt.SignedJWT>
ATrustEngineimplementation for Signed JSON Web Tokens.- Since:
- 2.2.0
-
-
Field Summary
Fields Modifier and Type Field Description private JOSEObjectCredentialResolverjoseObjectCredentialResolverResolver of credentials from JOSEObject headers.private org.slf4j.LoggerlogLogger.
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseSignedJWTTrustEngine(JOSEObjectCredentialResolver joseObjectResolver)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcheckParams(com.nimbusds.jwt.SignedJWT signedJWT, CriteriaSet trustBasisCriteria)Check the signed JWT and supplied criteria for required values.protected abstract booleandoValidate(com.nimbusds.jwt.SignedJWT signedJWT, CriteriaSet trustBasisCriteria)Validate the signed JWT using the supplied trust criteria.protected abstract booleanevaluateTrust(Credential untrustedCredential, TrustBasisType trustBasis)Evaluate the untrusted KeyInfo-derived credential with respect to the specified trusted information.private static com.nimbusds.jose.JWSVerifierinitializeVerifier(com.nimbusds.jose.Algorithm algorithm, Credential credential)Initializes aJWSVerifierfor the given algorithm, using the providedCredential.protected Collection<Credential>resolveTokenCredentials(com.nimbusds.jwt.SignedJWT signedJWT)Resolve any credentials indicated in the token, such as by inline JWK.booleanvalidate(com.nimbusds.jwt.SignedJWT signedJWT, CriteriaSet trustBasisCriteria)protected booleanvalidate(com.nimbusds.jwt.SignedJWT signedJWT, TrustBasisType trustBasis)Attempt to establish trust by resolving token verification credentials from the token itself.protected booleanverifySignature(com.nimbusds.jwt.SignedJWT signedJWT, Credential credential)Attempt to verify a signature using the key from the supplied credential.
-
-
-
Field Detail
-
log
private final org.slf4j.Logger log
Logger.
-
joseObjectCredentialResolver
private final JOSEObjectCredentialResolver joseObjectCredentialResolver
Resolver of credentials from JOSEObject headers.
-
-
Constructor Detail
-
BaseSignedJWTTrustEngine
protected BaseSignedJWTTrustEngine(@Nonnull JOSEObjectCredentialResolver joseObjectResolver)Constructor.- Parameters:
joseObjectResolver- resolver of credentials from JOSEObject headers.
-
-
Method Detail
-
validate
public boolean validate(@Nonnull com.nimbusds.jwt.SignedJWT signedJWT, @Nonnull CriteriaSet trustBasisCriteria) throws SecurityException- Specified by:
validatein interfaceTrustEngine<TrustBasisType>- Throws:
SecurityException
-
doValidate
protected abstract boolean doValidate(@Nonnull com.nimbusds.jwt.SignedJWT signedJWT, @Nonnull CriteriaSet trustBasisCriteria) throws SecurityExceptionValidate the signed JWT using the supplied trust criteria.- Parameters:
signedJWT- the signed JWT to validatetrustBasisCriteria- criteria used to describe and/or resolve the information which serves as the basis for trust evaluation- Returns:
- true if signature is valid and trusted, false otherwise
- Throws:
SecurityException- if there is a fatal error evaluating the signature
-
validate
protected boolean validate(@Nonnull com.nimbusds.jwt.SignedJWT signedJWT, @Nullable TrustBasisType trustBasis) throws SecurityExceptionAttempt to establish trust by resolving token verification credentials from the token itself. If any credentials so resolved correctly verify the signature, attempt to establish trust using subclass-specific trust logic against trusted information as implemented inevaluateTrust(Credential, Object).- Parameters:
signedJWT- the signed JWT to evaluatetrustBasis- the information which serves as the basis for trust evaluation- Returns:
- true if the signature is verified by any token-derived credential which can be established as trusted, otherwise false
- Throws:
SecurityException- if an error occurs during signature verification or trust processing
-
verifySignature
protected boolean verifySignature(@Nonnull com.nimbusds.jwt.SignedJWT signedJWT, @Nonnull Credential credential) throws SecurityExceptionAttempt to verify a signature using the key from the supplied credential.- Parameters:
signedJWT- the JWT on which to attempt verificationcredential- the credential containing the candidate validation key- Returns:
- true if the signature can be verified using the key from the credential, otherwise false
- Throws:
SecurityException- if there is a fatal error evaluating the signature
-
initializeVerifier
private static com.nimbusds.jose.JWSVerifier initializeVerifier(com.nimbusds.jose.Algorithm algorithm, Credential credential) throws com.nimbusds.jose.JOSEExceptionInitializes aJWSVerifierfor the given algorithm, using the providedCredential.- Parameters:
algorithm- The algorithm used for deciding the verifier.credential- The credential to be used for the verifier.- Returns:
- A corresponding verifier, or null if no supported found.
- Throws:
com.nimbusds.jose.JOSEException- If the credential doesn't meet the verifier requirements.
-
evaluateTrust
protected abstract boolean evaluateTrust(@Nonnull Credential untrustedCredential, @Nullable TrustBasisType trustBasis) throws SecurityExceptionEvaluate the untrusted KeyInfo-derived credential with respect to the specified trusted information.- Parameters:
untrustedCredential- the untrusted credential being evaluatedtrustBasis- the information which serves as the basis for trust evaluation- Returns:
- true if the trust can be established for the untrusted credential, otherwise false
- Throws:
SecurityException- if an error occurs during trust processing
-
checkParams
protected void checkParams(@Nonnull com.nimbusds.jwt.SignedJWT signedJWT, @Nonnull CriteriaSet trustBasisCriteria) throws SecurityExceptionCheck the signed JWT and supplied criteria for required values.- Parameters:
signedJWT- the signed JWT to be evaluatedtrustBasisCriteria- the set of trusted credential criteria- Throws:
SecurityException- thrown if required values are absent or otherwise invalid
-
resolveTokenCredentials
@Nonnull protected Collection<Credential> resolveTokenCredentials(@Nonnull com.nimbusds.jwt.SignedJWT signedJWT) throws SecurityException
Resolve any credentials indicated in the token, such as by inline JWK.- Parameters:
signedJWT- the signed JWT to be evaluated- Returns:
- a collection of credentials derived from the token, may be empty
- Throws:
SecurityException- thrown if here is a fatal exception resolving credentials
-
-