Class BaseSignedJWTTrustEngine<TrustBasisType>
java.lang.Object
net.shibboleth.oidc.security.impl.BaseSignedJWTTrustEngine<TrustBasisType>
- Type Parameters:
TrustBasisType- the trust basis type
- All Implemented Interfaces:
TrustEngine<SignedJWT>
- Direct Known Subclasses:
ExplicitKeySignedJWTTrustEngine,TokenAsymmetricKeyTrustEngine
public abstract class BaseSignedJWTTrustEngine<TrustBasisType>
extends Object
implements TrustEngine<SignedJWT>
A
TrustEngine implementation for Signed JSON Web Tokens.- Since:
- 2.2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final JOSEObjectCredentialResolverResolver of credentials from JOSEObject headers.private final org.slf4j.LoggerLogger. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseSignedJWTTrustEngine(JOSEObjectCredentialResolver joseObjectResolver) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckParams(SignedJWT signedJWT, CriteriaSet trustBasisCriteria) Check the signed JWT and supplied criteria for required values.protected abstract booleandoValidate(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 JWSVerifierinitializeVerifier(Algorithm algorithm, Credential credential) Initializes aJWSVerifierfor the given algorithm, using the providedCredential.protected Collection<Credential>resolveTokenCredentials(SignedJWT signedJWT) Resolve any credentials indicated in the token, such as by inline JWK.booleanvalidate(SignedJWT signedJWT, CriteriaSet trustBasisCriteria) protected booleanvalidate(SignedJWT signedJWT, TrustBasisType trustBasis) Attempt to establish trust by resolving token verification credentials from the token itself.protected booleanverifySignature(SignedJWT signedJWT, Credential credential) Attempt to verify a signature using the key from the supplied credential.
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logLogger. -
joseObjectCredentialResolver
Resolver of credentials from JOSEObject headers.
-
-
Constructor Details
-
BaseSignedJWTTrustEngine
Constructor.- Parameters:
joseObjectResolver- resolver of credentials from JOSEObject headers.
-
-
Method Details
-
validate
protected boolean validate(@Nonnull SignedJWT signedJWT, @Nullable TrustBasisType trustBasis) throws SecurityException Attempt 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 SignedJWT signedJWT, @Nonnull Credential credential) throws SecurityException Attempt 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 JWSVerifier initializeVerifier(Algorithm algorithm, Credential credential) throws JOSEException Initializes 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:
JOSEException- If the credential doesn't meet the verifier requirements.
-
evaluateTrust
protected abstract boolean evaluateTrust(@Nonnull Credential untrustedCredential, @Nullable TrustBasisType trustBasis) throws SecurityException Evaluate 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
-
resolveTokenCredentials
@Nonnull protected Collection<Credential> resolveTokenCredentials(@Nonnull 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