public class SignatureAlgorithmValidator
extends java.lang.Object
Signature's signature and digest algorithm URI's against
a supplied algorithm whitelist and blacklist.
The evaluation is based on the Signature's underlying DOM structure, therefore the Signature must have a cached DOM before this validator is used.
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
ATTR_NAME_ALGORTHM
Local name of 'Algorithm' attribute.
|
private java.util.Collection<java.lang.String> |
blacklistedAlgorithmURIs
The collection of algorithm URI's which are blacklisted.
|
private static javax.xml.namespace.QName |
ELEMENT_NAME_DIGEST_METHOD
QName of 'ds:DigestMethod' element.
|
private static javax.xml.namespace.QName |
ELEMENT_NAME_REFERENCE
QName of 'ds:Reference' element.
|
private static javax.xml.namespace.QName |
ELEMENT_NAME_SIGNATURE_METHOD
QName of 'ds:SignatureMethod' element.
|
private static javax.xml.namespace.QName |
ELEMENT_NAME_SIGNED_INFO
QName of 'ds:SignedInfo' element.
|
private org.slf4j.Logger |
log
Logger.
|
private java.util.Collection<java.lang.String> |
whitelistedAlgorithmURIs
The collection of algorithm URI's which are whitelisted.
|
| Constructor and Description |
|---|
SignatureAlgorithmValidator(java.util.Collection<java.lang.String> whitelistAlgos,
java.util.Collection<java.lang.String> blacklistAlgos)
Constructor.
|
SignatureAlgorithmValidator(SignatureValidationParameters params)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkDOM(Signature signature)
Check that Signature XMLObject has a cached DOM Element.
|
protected java.util.List<java.lang.String> |
getDigestMethods(Signature signatureXMLObject)
Get the list of Signature Reference DigestMethod algorithm URIs.
|
protected java.lang.String |
getSignatureAlgorithm(Signature signatureXMLObject)
Get the signature algorithm.
|
void |
validate(Signature signature)
Validate the algorithms in the signature.
|
protected void |
validateAlgorithmURI(java.lang.String algorithmURI)
Validate the supplied algorithm URI against the configured whitelist and blacklist.
|
private static final javax.xml.namespace.QName ELEMENT_NAME_SIGNED_INFO
private static final javax.xml.namespace.QName ELEMENT_NAME_SIGNATURE_METHOD
private static final javax.xml.namespace.QName ELEMENT_NAME_REFERENCE
private static final javax.xml.namespace.QName ELEMENT_NAME_DIGEST_METHOD
private static final java.lang.String ATTR_NAME_ALGORTHM
private org.slf4j.Logger log
private java.util.Collection<java.lang.String> whitelistedAlgorithmURIs
private java.util.Collection<java.lang.String> blacklistedAlgorithmURIs
public SignatureAlgorithmValidator(@Nonnull
SignatureValidationParameters params)
params - signature validation parameters containing the whitelist and blacklistpublic SignatureAlgorithmValidator(@Nullable
java.util.Collection<java.lang.String> whitelistAlgos,
@Nullable
java.util.Collection<java.lang.String> blacklistAlgos)
whitelistAlgos - the algorithm whitelistblacklistAlgos - the algorithm blacklistpublic void validate(@Nonnull
Signature signature)
throws SignatureException
signature - signature to validateSignatureException - if validation failsprotected void checkDOM(@Nonnull
Signature signature)
throws SignatureException
signature - the signature to evaluateSignatureException - if signature does not have a cached DOM Element@Nonnull
protected java.lang.String getSignatureAlgorithm(@Nonnull
Signature signatureXMLObject)
throws SignatureException
signatureXMLObject - the signature to evaluateSignatureException - if signature algorithm can not be resolved@Nonnull
protected java.util.List<java.lang.String> getDigestMethods(@Nonnull
Signature signatureXMLObject)
throws SignatureException
signatureXMLObject - the signature to evaluateSignatureException - if a DigestMethod is found to have a null or empty Algorithm attributeprotected void validateAlgorithmURI(@Nonnull
java.lang.String algorithmURI)
throws SignatureException
algorithmURI - the algorithm URI to evaluateSignatureException - if the algorithm URI does not satisfy the whitelist/blacklist policy