final class XMLSignatureValidator extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
XMLSignatureValidator.ValidationException
Exception class representing a failure to validate.
|
| Modifier and Type | Field and Description |
|---|---|
private Set<String> |
blacklistedDigests
Set of blacklisted digest algorithms.
|
private Set<String> |
blacklistedSignatureMethods
Set of blacklisted signature methods.
|
private boolean |
emptyReferencePermitted
Whether an empty reference is permitted.
|
private Logger |
log
Class logger.
|
private PublicKey |
verificationKey
Public key used to verify signatures.
|
| Constructor and Description |
|---|
XMLSignatureValidator(PublicKey key,
Set<String> blacklistDigests,
Set<String> blacklistSignatureMethods,
boolean emptyRefPermitted)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
private Reference |
extractReference(XMLSignature signature)
Extract the reference within the provided XML signature while ensuring that there
is only one such reference, and that (if appropriate) it is not empty.
|
Element |
getSignatureElement(Element docElement)
Gets the signature element from the document.
|
private void |
markIdAttribute(Element docElement,
Reference reference)
Reconcile the given reference with the document element, by making sure that
the appropriate attribute is marked as an ID attribute.
|
private void |
validateSignatureReference(Element docElement,
Reference ref)
Validates the reference within the XML signature by performing the following checks.
|
private void |
validateSignatureReferenceUri(Element expectedSignedNode,
Reference reference)
Validates that the element resolved by the signature validation layer is the same as the
element resolved by the DOM layer.
|
private void |
validateSignatureTransforms(Reference reference)
Validate the transforms included in the Signature Reference.
|
void |
verifySignature(Element docElement,
Element signatureElement)
Verifies that the signature on a document is valid.
|
private final Logger log
private final PublicKey verificationKey
private final Set<String> blacklistedDigests
private final Set<String> blacklistedSignatureMethods
private final boolean emptyReferencePermitted
XMLSignatureValidator(@Nonnull PublicKey key, @Nullable Set<String> blacklistDigests, @Nullable Set<String> blacklistSignatureMethods, boolean emptyRefPermitted)
key - public key with which to verify signaturesblacklistDigests - set of blacklisted digest algorithm URIs, or nullblacklistSignatureMethods - set of blacklisted signature method URIs, or nullemptyRefPermitted - true if empty references are permittedprivate void markIdAttribute(@Nonnull Element docElement, @Nonnull Reference reference) throws XMLSignatureValidator.ValidationException
docElement - document element whose appropriate attribute should be markedreference - reference which references the document elementXMLSignatureValidator.ValidationException - if the reference is neither empty nor to a fragmentpublic void verifySignature(@Nonnull Element docElement, @Nonnull Element signatureElement) throws XMLSignatureValidator.ValidationException
docElement - document element whose signature will be validatedsignatureElement - element containing the signature to be validatedXMLSignatureValidator.ValidationException - if any of a number of invalid conditions are detectedprivate Reference extractReference(@Nonnull XMLSignature signature) throws XMLSignatureValidator.ValidationException
signature - signature to extract the reference fromXMLSignatureValidator.ValidationException - if a reference could not be extractedprivate void validateSignatureReference(@Nonnull Element docElement, @Nonnull Reference ref) throws XMLSignatureValidator.ValidationException
docElement - document elementref - reference to be verifiedXMLSignatureValidator.ValidationException - if any of the checks failprivate void validateSignatureReferenceUri(@Nonnull Element expectedSignedNode, @Nonnull Reference reference) throws XMLSignatureValidator.ValidationException
expectedSignedNode - the node expected as the result of the referencereference - the reference to be validatedXMLSignatureValidator.ValidationException - if validation failsprivate void validateSignatureTransforms(@Nonnull Reference reference) throws XMLSignatureValidator.ValidationException
reference - the Signature reference containing the transforms to evaluateXMLSignatureValidator.ValidationException - if the transforms are incorrect@Nullable public Element getSignatureElement(@Nonnull Element docElement) throws XMLSignatureValidator.ValidationException
docElement - document element from which to pull the signatureXMLSignatureValidator.ValidationException - if more than one signature element is presentCopyright © 1999–2016. All rights reserved.