Class BaseSignatureTrustEngine<TrustBasisType>
java.lang.Object
org.opensaml.xmlsec.signature.support.impl.BaseSignatureTrustEngine<TrustBasisType>
- Type Parameters:
TrustBasisType- the type of trusted information which has been resolved and which will serve as the basis for trust evaluation
- All Implemented Interfaces:
TrustEngine<Signature>,SignatureTrustEngine
- Direct Known Subclasses:
ExplicitKeySignatureTrustEngine,PKIXSignatureTrustEngine
public abstract class BaseSignatureTrustEngine<TrustBasisType>
extends Object
implements SignatureTrustEngine
A base implementation of
SignatureTrustEngine which evaluates the validity and trustworthiness of XML and raw
signatures.
When processing XML signatures, the supplied KeyInfoCredentialResolver will be used to resolve credential(s) containing the (advisory) signing key from the KeyInfo element of the Signature, if present. If any of these credentials do contain the valid signing key, they will be evaluated for trustworthiness against trusted information, which will be resolved in an implementation-specific manner.
Subclasses are required to implement evaluateTrust(Credential, Object) using an implementation-specific
trust model.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final KeyInfoCredentialResolverKeyInfo credential resolver used to obtain the signing credential from a Signature's KeyInfo.private final org.slf4j.LoggerClass logger. -
Constructor Summary
ConstructorsConstructorDescriptionBaseSignatureTrustEngine(KeyInfoCredentialResolver keyInfoResolver) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckParams(Signature signature, CriteriaSet trustBasisCriteria) Check the signature and credential criteria for required values.protected voidcheckParamsRaw(byte[] signature, byte[] content, String algorithmURI, CriteriaSet trustBasisCriteria) Check the signature and credential criteria for required values.protected abstract booleandoValidate(byte[] signature, byte[] content, String algorithmURI, CriteriaSet trustBasisCriteria, Credential candidateCredential) Determines whether a raw signature over specified content is valid and signed by a trusted credential.protected abstract booleandoValidate(Signature signature, CriteriaSet trustBasisCriteria) Validate the signature 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.Get the KeyInfoCredentialResolver instance used to resolve (advisory) signing credential information from KeyInfo elements contained within a Signature element.final booleanvalidate(byte[] signature, byte[] content, String algorithmURI, CriteriaSet trustBasisCriteria, Credential candidateCredential) Determines whether a raw signature over specified content is valid and signed by a trusted credential.final booleanvalidate(Signature signature, CriteriaSet trustBasisCriteria) Validates the token against trusted information obtained in an implementation-specific manner.protected booleanvalidate(Signature signature, TrustBasisType trustBasis) Attempt to establish trust by resolving signature verification credentials from the Signature's KeyInfo.protected booleanverifySignature(Signature signature, Credential credential) Attempt to verify a signature using the key from the supplied credential.
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
keyInfoCredentialResolver
KeyInfo credential resolver used to obtain the signing credential from a Signature's KeyInfo.
-
-
Constructor Details
-
BaseSignatureTrustEngine
Constructor.- Parameters:
keyInfoResolver- KeyInfo credential resolver used to obtain the (advisory) signing credential from a Signature's KeyInfo element.
-
-
Method Details
-
getKeyInfoResolver
Get the KeyInfoCredentialResolver instance used to resolve (advisory) signing credential information from KeyInfo elements contained within a Signature element. Note that credential(s) obtained via this resolver are not themselves trusted. They must be evaluated against the trusted credential information obtained from the trusted credential resolver.- Specified by:
getKeyInfoResolverin interfaceSignatureTrustEngine- Returns:
- a KeyInfoCredentialResolver instance
-
validate
protected boolean validate(@Nonnull Signature signature, @Nullable TrustBasisType trustBasis) throws SecurityException Attempt to establish trust by resolving signature verification credentials from the Signature's KeyInfo. 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:
signature- the Signature to evaluatetrustBasis- the information which serves as the basis for trust evaluation- Returns:
- true if the signature is verified by any KeyInfo-derived credential which can be established as trusted, otherwise false
- Throws:
SecurityException- if an error occurs during signature verification or trust processing
-
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
-
verifySignature
Attempt to verify a signature using the key from the supplied credential.- Parameters:
signature- the signature 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
-