Package eu.europa.esig.dss.xml.utils
Class XMLCanonicalizer
java.lang.Object
eu.europa.esig.dss.xml.utils.XMLCanonicalizer
Contains a set of method for canonicalization of
org.w3c.dom.Node
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
This is the default canonicalization method used for production of signatures within DSS framework.static final String
This is the default canonicalization method for XMLDSIG used for signatures and timestamps (see XMLDSIG 4.4.3.2) when one is not defined. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
canCanonicalize
(String canonicalizationMethod) This method says if the framework can canonicalize an XML data with the provided method.byte[]
canonicalize
(byte[] toCanonicalizeBytes) This method canonicalizes the given array of bytes using the defined canonicalization method.byte[]
canonicalize
(InputStream inputStream) This method canonicalizes the givenInputStream
using the defined canonicalization method.byte[]
canonicalize
(Node node) This method canonicalizes the givenNode
using the defined canonicalization method.static XMLCanonicalizer
Creates in instance ofXMLCanonicalizer
to be used with default XMLDSig canonicalization method "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"static XMLCanonicalizer
createInstance
(String canonicalizationMethod) Creates in instance ofXMLCanonicalizer
with provided canonicalization method.static boolean
registerCanonicalizer
(String c14nAlgorithmURI) This method allows to register a canonicalizer.
-
Field Details
-
DEFAULT_DSS_C14N_METHOD
This is the default canonicalization method used for production of signatures within DSS framework. Another complication arises because of the way that the default canonicalization algorithm handles namespace declarations; frequently a signed XML document needs to be embedded in another document; in this case the original canonicalization algorithm will not yield the same result as if the document is treated alone. For this reason, the so-called Exclusive Canonicalization, which serializes XML namespace declarations independently of the surrounding XML, was created.- See Also:
-
DEFAULT_XMLDSIG_C14N_METHOD
This is the default canonicalization method for XMLDSIG used for signatures and timestamps (see XMLDSIG 4.4.3.2) when one is not defined.- See Also:
-
-
Method Details
-
createInstance
Creates in instance ofXMLCanonicalizer
to be used with default XMLDSig canonicalization method "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"- Returns:
XMLCanonicalizer
-
createInstance
Creates in instance ofXMLCanonicalizer
with provided canonicalization method. If the canonicalization method is null, the default XMLDSig canonicalization method "http://www.w3.org/TR/2001/REC-xml-c14n-20010315" will be used.- Parameters:
canonicalizationMethod
-String
canonicalization method to instantiate XML Canonicalizer with- Returns:
XMLCanonicalizer
-
canCanonicalize
This method says if the framework can canonicalize an XML data with the provided method.- Parameters:
canonicalizationMethod
- the canonicalization method to be checked- Returns:
- true if it is possible to canonicalize false otherwise
-
registerCanonicalizer
This method allows to register a canonicalizer.- Parameters:
c14nAlgorithmURI
- the URI of canonicalization algorithm- Returns:
- true if this set did not already contain the specified element
-
canonicalize
This method canonicalizes the givenInputStream
using the defined canonicalization method. NOTE: closes the stream after reading.- Parameters:
inputStream
-InputStream
to canonicalize- Returns:
- array of canonicalized bytes
- Throws:
DSSException
- if any error is encountered
-
canonicalize
This method canonicalizes the given array of bytes using the defined canonicalization method.- Parameters:
toCanonicalizeBytes
- array of bytes to canonicalize- Returns:
- array of canonicalized bytes
- Throws:
DSSException
- if any error is encountered
-
canonicalize
This method canonicalizes the givenNode
using the defined canonicalization method.- Parameters:
node
-Node
to canonicalize- Returns:
- array of canonicalized bytes
-