Class DigestGenerator


  • public class DigestGenerator
    extends Object
    Helper class to provide the functionality of the digest value generation. This is an implementation of the DOMHASH algorithm on OM.
    • Field Detail

      • md5DigestAlgorithm

        public static final String md5DigestAlgorithm
        String representing the MD5 digest algorithm
        See Also:
        Constant Field Values
      • shaDigestAlgorithm

        public static final String shaDigestAlgorithm
        String representing the SHA digest algorithm
        See Also:
        Constant Field Values
      • sha1DigestAlgorithm

        public static final String sha1DigestAlgorithm
        String representing the SHA1 digest algorithm
        See Also:
        Constant Field Values
    • Constructor Detail

      • DigestGenerator

        public DigestGenerator()
    • Method Detail

      • getDigest

        public byte[] getDigest​(OMDocument document,
                                String digestAlgorithm)
                         throws OMException
        This method is an overloaded method for the digest generation for OMDocument
        Parameters:
        document -
        digestAlgorithm -
        Returns:
        Returns a byte array representing the calculated digest
        Throws:
        OMException
      • getDigest

        public byte[] getDigest​(OMNode node,
                                String digestAlgorithm)
        This method is an overloaded method for the digest generation for OMNode
        Parameters:
        node -
        digestAlgorithm -
        Returns:
        Returns a byte array representing the calculated digest value
      • getDigest

        public byte[] getDigest​(OMElement element,
                                String digestAlgorithm)
                         throws OMException
        This method is an overloaded method for the digest generation for OMElement
        Parameters:
        element -
        digestAlgorithm -
        Returns:
        Returns a byte array representing the calculated digest value
        Throws:
        OMException
      • getDigest

        public byte[] getDigest​(OMProcessingInstruction pi,
                                String digestAlgorithm)
                         throws OMException
        This method is an overloaded method for the digest generation for OMProcessingInstruction
        Parameters:
        pi -
        digestAlgorithm -
        Returns:
        Returns a byte array representing the calculated digest value
        Throws:
        OMException
      • getDigest

        public byte[] getDigest​(OMAttribute attribute,
                                String digestAlgorithm)
                         throws OMException
        This method is an overloaded method for the digest generation for OMAttribute
        Parameters:
        attribute -
        digestAlgorithm -
        Returns:
        Returns a byte array representing the calculated digest value
        Throws:
        OMException
      • getDigest

        public byte[] getDigest​(OMText text,
                                String digestAlgorithm)
                         throws OMException
        This method is an overloaded method for the digest generation for OMText
        Parameters:
        text -
        digestAlgorithm -
        Returns:
        Returns a byte array representing the calculated digest value
        Throws:
        OMException
      • getExpandedName

        public String getExpandedName​(OMElement element)
        This method is an overloaded method for getting the expanded name namespaceURI followed by the local name for OMElement
        Parameters:
        element -
        Returns:
        Returns the expanded name of OMElement
      • getExpandedName

        public String getExpandedName​(OMAttribute attribute)
        This method is an overloaded method for getting the expanded name namespaceURI followed by the local name for OMAttribute
        Parameters:
        attribute -
        Returns:
        Returns the expanded name of the OMAttribute
      • getAttributesWithoutNS

        public Collection<OMAttribute> getAttributesWithoutNS​(OMElement element)
        Gets the collection of attributes which are none namespace declarations for an OMElement
        Parameters:
        element -
        Returns:
        Returns the collection of attributes which are none namespace declarations
      • getValidElements

        public Collection<OMNode> getValidElements​(OMDocument document)
        Gets the valid element collection of an OMDocument. OMElement and OMProcessingInstruction only
        Parameters:
        document -
        Returns:
        Returns a collection of OMProcessingInstructions and OMElements
      • getStringRepresentation

        public String getStringRepresentation​(byte[] array)
        Gets the String representation of the byte array
        Parameters:
        array -
        Returns:
        Returns the String of the byte
      • compareOMNode

        public boolean compareOMNode​(OMNode node,
                                     OMNode comparingNode,
                                     String digestAlgorithm)
        Compares two OMNodes for the XML equality
        Parameters:
        node -
        comparingNode -
        digestAlgorithm -
        Returns:
        Returns true if the OMNode XML contents are equal
      • compareOMDocument

        public boolean compareOMDocument​(OMDocument document,
                                         OMDocument comparingDocument,
                                         String digestAlgorithm)
        Compares two OMDocuments for the XML equality
        Parameters:
        document -
        comparingDocument -
        digestAlgorithm -
        Returns:
        Returns true if the OMDocument XML content are equal
      • compareOMAttribute

        public boolean compareOMAttribute​(OMAttribute attribute,
                                          OMAttribute comparingAttribute,
                                          String digestAlgorithm)
        Compares two OMAttributes for the XML equality
        Parameters:
        attribute -
        comparingAttribute -
        digestAlgorithm -
        Returns:
        Returns true if the OMDocument XML content are equal