Module jpms_dss_xml

Class XMLCanonicalizer

java.lang.Object
eu.europa.esig.dss.xml.utils.XMLCanonicalizer

public class XMLCanonicalizer extends Object
Contains a set of method for canonicalization of org.w3c.dom.Node
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static 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 Type
    Method
    Description
    static 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[]
    This method canonicalizes the given InputStream using the defined canonicalization method.
    byte[]
    This method canonicalizes the given Node using the defined canonicalization method.
    Creates in instance of XMLCanonicalizer to be used with default XMLDSig canonicalization method "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
    createInstance(String canonicalizationMethod)
    Creates in instance of XMLCanonicalizer with provided canonicalization method.
    static boolean
    registerCanonicalizer(String c14nAlgorithmURI)
    This method allows to register a canonicalizer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_DSS_C14N_METHOD

      public static final String 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

      public static final String 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

      public static XMLCanonicalizer createInstance()
      Creates in instance of XMLCanonicalizer to be used with default XMLDSig canonicalization method "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
      Returns:
      XMLCanonicalizer
    • createInstance

      public static XMLCanonicalizer createInstance(String canonicalizationMethod)
      Creates in instance of XMLCanonicalizer 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

      public static boolean canCanonicalize(String canonicalizationMethod)
      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

      public static boolean registerCanonicalizer(String c14nAlgorithmURI)
      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

      public byte[] canonicalize(InputStream inputStream) throws eu.europa.esig.dss.model.DSSException
      This method canonicalizes the given InputStream using the defined canonicalization method. NOTE: closes the stream after reading.
      Parameters:
      inputStream - InputStream to canonicalize
      Returns:
      array of canonicalized bytes
      Throws:
      eu.europa.esig.dss.model.DSSException - if any error is encountered
    • canonicalize

      public byte[] canonicalize(byte[] toCanonicalizeBytes) throws eu.europa.esig.dss.model.DSSException
      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:
      eu.europa.esig.dss.model.DSSException - if any error is encountered
    • canonicalize

      public byte[] canonicalize(Node node)
      This method canonicalizes the given Node using the defined canonicalization method.
      Parameters:
      node - Node to canonicalize
      Returns:
      array of canonicalized bytes