public final class XMLSignature
extends java.lang.Object
http://www.w3.org/TR/xmldsig-core/
Modifier and Type | Method and Description |
---|---|
boolean |
addCertificate(JAPCertificate a_certificate) |
void |
clearCertificates() |
int |
countSignatures()
Returns how many signatures the document has.
|
static java.lang.String |
getEncodedHashValue(org.w3c.dom.Element nodeToHash)
Same method as getHashValueOfElement,
except the String returned is already Base64-encoded
necessary to avoid discrepancies between the results of getHashValueOfElement
between the BI(Java) and PIG (Ruby/Java-bridge)
|
static java.lang.String |
getHashValueOfElement(org.w3c.dom.Node nodeToHash)
getHashValueOfElement: takes an XML node and returns its hash value
|
MultiCertPath |
getMultiCertPath() |
static XMLSignature |
getUnverified(org.w3c.dom.Node a_node)
Gets the signature from a node if present.
|
static XMLSignature |
getVerified(org.w3c.dom.Node a_node,
int a_documentType,
java.util.Vector a_directCertificatePaths)
Creates a new XMLSignature from the node and creates a new MultiCertPath object.
|
org.w3c.dom.Element[] |
getXMLElements(org.w3c.dom.Document a_doc)
Returns all
|
java.lang.String |
getXORofSKIs()
This method is used by the checkId()-methods of the database classes,
that compare the id of a given entry with the SubjectKeyIdentifier of
the associated cert(s).
|
boolean |
isVerified()
The Signature is verified if the MultiCertPath is verified.
|
static XMLSignature |
multiSign(org.w3c.dom.Node a_node,
java.util.Vector a_privateKeys,
int a_documentClass)
Signs an XML node with multiple keys and creates a new XMLSignature from the signature.
|
static boolean |
removeSignatureFrom(org.w3c.dom.Node a_node)
Removes the signature from an XML node if a signature exists.
|
static XMLSignature |
sign(org.w3c.dom.Node a_node,
IMyPrivateKey a_privateKey,
int a_documentClass)
Signs an XML node and creates a new XMLSignature from the signature.
|
static XMLSignature |
sign(org.w3c.dom.Node a_node,
PKCS12 a_certificate,
int a_documentClass)
Signs an XML node and creates a new XMLSignature from the signature.
|
static byte[] |
toCanonical(org.w3c.dom.Node inputNode) |
static byte[] |
toCanonical(org.w3c.dom.Node inputNode,
boolean a_bKeepSpaces)
Creates a byte array from an XML node tree.
|
static byte[] |
toCanonical(org.w3c.dom.Node a_inputNode,
java.util.Vector a_excludedNodes) |
static byte[] |
toCanonicalDeprecated(org.w3c.dom.Node a_inputNode)
Is only used if no digest value is found.
|
static java.lang.String |
toCanonicalString(org.w3c.dom.Element input)
same as toCanonical(Node):byte[], except returning a String
only necessary for use in Ruby (since handling a Java byte array in Ruby wouldnt work)
|
static XMLSignature |
verify(org.w3c.dom.Node a_node,
IMyPublicKey a_publicKey)
Verifies the signature of an XML node and creates a new XMLSignature
from a valid signature.
|
static boolean |
verifyFast(org.w3c.dom.Node a_node,
IMyPublicKey a_publicKey)
Only verifies the signatures of an XML node with the given key.
|
static boolean |
verifyFast(org.w3c.dom.Node a_node,
java.util.Vector a_publicKeys)
Only verifies the signatures of an XML node with the given keys.
|
public int countSignatures()
public MultiCertPath getMultiCertPath()
public java.lang.String getXORofSKIs()
anon.infoservice.AbstractCertifiedDatabaseEntry.checkId()
,
anon.infoservice.AbstractDistributableCertifiedDatabaseEntry.checkId()
public boolean isVerified()
true
if the MultiCertPath is verified.public static XMLSignature sign(org.w3c.dom.Node a_node, PKCS12 a_certificate, int a_documentClass) throws XMLParseException
a_node
- an XML nodea_certificate
- a certificate to sign the signatureXMLParseException
- if the node could not be signed because it could not be
properly transformed into bytespublic boolean addCertificate(JAPCertificate a_certificate)
public static XMLSignature sign(org.w3c.dom.Node a_node, IMyPrivateKey a_privateKey, int a_documentClass) throws XMLParseException
a_node
- an XML nodea_privateKey
- a private key to sign the signatureXMLParseException
- if the node could not be signed because it could not be
properly transformed into bytespublic static XMLSignature multiSign(org.w3c.dom.Node a_node, java.util.Vector a_privateKeys, int a_documentClass) throws XMLParseException
a_node
- an XML nodea_privateKey
- a private key to sign the signatureXMLParseException
- if the node could not be signed because it could not be
properly transformed into bytespublic static java.lang.String getHashValueOfElement(org.w3c.dom.Node nodeToHash)
nodeToHash
- Nodepublic static java.lang.String getEncodedHashValue(org.w3c.dom.Element nodeToHash)
nodeToHash
- Nodepublic static XMLSignature getVerified(org.w3c.dom.Node a_node, int a_documentType, java.util.Vector a_directCertificatePaths) throws XMLParseException, java.security.SignatureException
a_node
- Node A signed XML node.a_documentType
- The document-Type of the node.a_directCertificates
- A Vector of CertPaths to verify the signature, if there are no
appended certificatesXMLParseException
- if a signature element exists, but the element
has an invalid structurejava.security.SignatureException
- if we found no verifier for one Signature, because the right cert was not
appended or cached or the Signature is wrong. In either way we do not know
which cert to take for calculating the the XORed ID.public static boolean verifyFast(org.w3c.dom.Node a_node, java.util.Vector a_publicKeys)
true
is returned.a_node
- an XML nodea_publicKey
- a public key to verify the signaturepublic static boolean verifyFast(org.w3c.dom.Node a_node, IMyPublicKey a_publicKey)
true
is returned.a_node
- an XML nodea_publicKey
- a public key to verify the signaturepublic static XMLSignature verify(org.w3c.dom.Node a_node, IMyPublicKey a_publicKey) throws XMLParseException
a_node
- an XML nodea_publicKey
- a public key to verify the signatureXMLParseException
- if a signature element exists, but the element
has an invalid structurepublic static XMLSignature getUnverified(org.w3c.dom.Node a_node) throws XMLParseException
a_node
- an XML nodeXMLParseException
- if the signature is present but has an invalid XML structurepublic static boolean removeSignatureFrom(org.w3c.dom.Node a_node)
a_node
- an XML Nodepublic void clearCertificates()
public static byte[] toCanonical(org.w3c.dom.Node a_inputNode, java.util.Vector a_excludedNodes) throws XMLParseException
XMLParseException
public static byte[] toCanonicalDeprecated(org.w3c.dom.Node a_inputNode)
a_inputNode
- Nodepublic static byte[] toCanonical(org.w3c.dom.Node inputNode) throws XMLParseException
XMLParseException
public static byte[] toCanonical(org.w3c.dom.Node inputNode, boolean a_bKeepSpaces) throws XMLParseException
inputNode
- The node (incl. the whole tree) which is flattened to a byte array.XMLParseException
- if the node could not be properly transformed into bytespublic static java.lang.String toCanonicalString(org.w3c.dom.Element input)
inputNode
- NodeXMLParseException
public org.w3c.dom.Element[] getXMLElements(org.w3c.dom.Document a_doc)
a_doc
- Copyright © 2023. All rights reserved.