Class CanonicalizerBase

    • Field Detail

      • NODE_BEFORE_DOCUMENT_ELEMENT

        protected static final int NODE_BEFORE_DOCUMENT_ELEMENT
        See Also:
        Constant Field Values
      • NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT

        protected static final int NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT
        See Also:
        Constant Field Values
      • NODE_AFTER_DOCUMENT_ELEMENT

        protected static final int NODE_AFTER_DOCUMENT_ELEMENT
        See Also:
        Constant Field Values
      • END_PI

        private static final byte[] END_PI
      • BEGIN_PI

        private static final byte[] BEGIN_PI
      • END_COMM

        private static final byte[] END_COMM
      • BEGIN_COMM

        private static final byte[] BEGIN_COMM
      • XA

        private static final byte[] XA
      • X9

        private static final byte[] X9
      • QUOT

        private static final byte[] QUOT
      • XD

        private static final byte[] XD
      • GT

        private static final byte[] GT
      • LT

        private static final byte[] LT
      • END_TAG

        private static final byte[] END_TAG
      • AMP

        private static final byte[] AMP
      • EQUALS_STR

        private static final byte[] EQUALS_STR
      • includeComments

        private boolean includeComments
      • nodeFilter

        private java.util.List<NodeFilter> nodeFilter
      • xpathNodeSet

        private java.util.Set<org.w3c.dom.Node> xpathNodeSet
      • nullNode

        private org.w3c.dom.Attr nullNode
        The null xmlns definition.
    • Constructor Detail

      • CanonicalizerBase

        protected CanonicalizerBase​(boolean includeComments)
        Constructor CanonicalizerBase
        Parameters:
        includeComments -
    • Method Detail

      • engineCanonicalize

        public void engineCanonicalize​(XMLSignatureInput input,
                                       java.io.OutputStream writer,
                                       boolean secureValidation)
                                throws CanonicalizationException
        Canonicalizes a Subtree node.
        Parameters:
        input - the root of the subtree to canicalize
        writer - OutputStream to write the canonicalization result
        secureValidation - Whether secure validation is enabled
        Throws:
        CanonicalizationException
      • engineCanonicalizeSubTree

        protected void engineCanonicalizeSubTree​(org.w3c.dom.Node rootNode,
                                                 org.w3c.dom.Node excludeNode,
                                                 java.io.OutputStream writer)
                                          throws CanonicalizationException
        Canonicalizes a Subtree node.
        Parameters:
        rootNode - the root of the subtree to canonicalize
        excludeNode - a node to be excluded from the canonicalize operation
        writer - OutputStream to write the canonicalization result
        Throws:
        CanonicalizationException
      • canonicalizeSubTree

        private void canonicalizeSubTree​(org.w3c.dom.Node currentNode,
                                         NameSpaceSymbTable ns,
                                         org.w3c.dom.Node endnode,
                                         int documentLevel,
                                         org.w3c.dom.Node excludeNode,
                                         java.io.OutputStream writer)
                                  throws CanonicalizationException,
                                         java.io.IOException
        Method canonicalizeSubTree, this function is a recursive one.
        Parameters:
        currentNode -
        ns -
        endnode -
        documentLevel -
        excludeNode -
        writer - OutputStream to write the canonicalization result
        Throws:
        CanonicalizationException
        java.io.IOException
      • canonicalizeXPathNodeSet

        private void canonicalizeXPathNodeSet​(org.w3c.dom.Node currentNode,
                                              org.w3c.dom.Node endnode,
                                              java.io.OutputStream writer)
                                       throws CanonicalizationException,
                                              java.io.IOException
        Canonicalizes all the nodes included in the currentNode and contained in the xpathNodeSet field.
        Parameters:
        currentNode -
        endnode -
        writer - OutputStream to write the canonicalization result
        Throws:
        CanonicalizationException
        java.io.IOException
      • handleParent

        protected void handleParent​(org.w3c.dom.Element e,
                                    NameSpaceSymbTable ns)
      • getParentNameSpaces

        private void getParentNameSpaces​(org.w3c.dom.Element el,
                                         NameSpaceSymbTable ns)
        Adds to ns the definitions from the parent elements of el
        Parameters:
        el -
        ns -
      • outputAttributes

        abstract void outputAttributes​(org.w3c.dom.Element element,
                                       NameSpaceSymbTable ns,
                                       java.util.Map<java.lang.String,​byte[]> cache,
                                       java.io.OutputStream writer)
                                throws CanonicalizationException,
                                       org.w3c.dom.DOMException,
                                       java.io.IOException
        Output the attributes for this node in XPathNodeSet c14n.
        Parameters:
        element -
        ns -
        cache -
        writer - OutputStream to write the canonicalization result
        Throws:
        CanonicalizationException
        org.w3c.dom.DOMException
        java.io.IOException
      • outputAttributesSubtree

        abstract void outputAttributesSubtree​(org.w3c.dom.Element element,
                                              NameSpaceSymbTable ns,
                                              java.util.Map<java.lang.String,​byte[]> cache,
                                              java.io.OutputStream writer)
                                       throws CanonicalizationException,
                                              org.w3c.dom.DOMException,
                                              java.io.IOException
        Output the attributes for this node in a Subtree c14n.
        Parameters:
        element -
        ns -
        cache -
        writer - OutputStream to write the canonicalization result
        Throws:
        CanonicalizationException
        org.w3c.dom.DOMException
        java.io.IOException
      • outputAttrToWriter

        protected static final void outputAttrToWriter​(java.lang.String name,
                                                       java.lang.String value,
                                                       java.io.OutputStream writer,
                                                       java.util.Map<java.lang.String,​byte[]> cache)
                                                throws java.io.IOException
        Outputs an Attribute to the internal Writer. The string value of the node is modified by replacing
        • all ampersands with &amp;
        • all open angle brackets with &lt;
        • all quotation mark characters with &quot;
        • and the whitespace characters #x9, #xA, and #xD, with character references. The character references are written in uppercase hexadecimal with no leading zeroes (for example, #xD is represented by the character reference &#xD;)
        Parameters:
        name -
        value -
        writer -
        Throws:
        java.io.IOException
      • outputPItoWriter

        protected void outputPItoWriter​(org.w3c.dom.ProcessingInstruction currentPI,
                                        java.io.OutputStream writer,
                                        int position)
                                 throws java.io.IOException
        Outputs a PI to the internal Writer.
        Parameters:
        currentPI -
        writer - where to write the things
        Throws:
        java.io.IOException
      • outputCommentToWriter

        protected void outputCommentToWriter​(org.w3c.dom.Comment currentComment,
                                             java.io.OutputStream writer,
                                             int position)
                                      throws java.io.IOException
        Method outputCommentToWriter
        Parameters:
        currentComment -
        writer - writer where to write the things
        Throws:
        java.io.IOException
      • outputTextToWriter

        private static final void outputTextToWriter​(java.lang.String text,
                                                     java.io.OutputStream writer)
                                              throws java.io.IOException
        Outputs a Text of CDATA section to the internal Writer.
        Parameters:
        text -
        writer - writer where to write the things
        Throws:
        java.io.IOException
      • getNullNode

        protected org.w3c.dom.Attr getNullNode​(org.w3c.dom.Document ownerDocument)