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
FieldsModifier and TypeFieldDescriptionstatic final StringThis is the default canonicalization method used for production of signatures within DSS framework.static final StringThis 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 booleancanCanonicalize(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 givenInputStreamusing the defined canonicalization method.byte[]canonicalize(Node node) This method canonicalizes the givenNodeusing the defined canonicalization method.static XMLCanonicalizerCreates in instance ofXMLCanonicalizerto be used with default XMLDSig canonicalization method "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"static XMLCanonicalizercreateInstance(String canonicalizationMethod) Creates in instance ofXMLCanonicalizerwith provided canonicalization method.static booleanregisterCanonicalizer(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 ofXMLCanonicalizerto be used with default XMLDSig canonicalization method "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"- Returns:
XMLCanonicalizer
-
createInstance
Creates in instance ofXMLCanonicalizerwith 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-Stringcanonicalization 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 givenInputStreamusing the defined canonicalization method. NOTE: closes the stream after reading.- Parameters:
inputStream-InputStreamto 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 givenNodeusing the defined canonicalization method.- Parameters:
node-Nodeto canonicalize- Returns:
- array of canonicalized bytes
-