Class CanonicalizerBase
- java.lang.Object
-
- org.apache.xml.security.c14n.CanonicalizerSpi
-
- org.apache.xml.security.c14n.implementations.CanonicalizerBase
-
- Direct Known Subclasses:
Canonicalizer11
,Canonicalizer20010315
,Canonicalizer20010315Excl
,CanonicalizerPhysical
public abstract class CanonicalizerBase extends CanonicalizerSpi
Abstract base class for canonicalization algorithms.- Author:
- Christian Geuer-Pollmann
-
-
Field Summary
Fields Modifier and Type Field Description protected static AttrCompare
COMPARE
protected static int
NODE_AFTER_DOCUMENT_ELEMENT
protected static int
NODE_BEFORE_DOCUMENT_ELEMENT
protected static int
NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT
static java.lang.String
XML
static java.lang.String
XMLNS
-
Fields inherited from class org.apache.xml.security.c14n.CanonicalizerSpi
reset, secureValidation
-
-
Constructor Summary
Constructors Constructor Description CanonicalizerBase(boolean includeComments)
Constructor CanonicalizerBase
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
canonicalizeSubTree(org.w3c.dom.Node currentNode, NameSpaceSymbTable ns, org.w3c.dom.Node endnode, int documentLevel)
Method canonicalizeSubTree, this function is a recursive one.protected void
canonicalizeXPathNodeSet(org.w3c.dom.Node currentNode, org.w3c.dom.Node endnode)
Canonicalizes all the nodes included in the currentNode and contained in the xpathNodeSet field.byte[]
engineCanonicalize(XMLSignatureInput input)
Canonicalizes a Subtree node.byte[]
engineCanonicalizeSubTree(org.w3c.dom.Node rootNode)
Method engineCanonicalizeSubTreeprotected byte[]
engineCanonicalizeSubTree(org.w3c.dom.Node rootNode, org.w3c.dom.Node excludeNode)
Canonicalizes a Subtree node.byte[]
engineCanonicalizeXPathNodeSet(java.util.Set<org.w3c.dom.Node> xpathNodeSet)
Method engineCanonicalizeXPathNodeSetprotected org.w3c.dom.Attr
getNullNode(org.w3c.dom.Document ownerDocument)
protected void
getParentNameSpaces(org.w3c.dom.Element el, NameSpaceSymbTable ns)
Adds to ns the definitions from the parent elements of elprotected void
handleParent(org.w3c.dom.Element e, NameSpaceSymbTable ns)
protected boolean
isVisible(org.w3c.dom.Node currentNode)
protected int
isVisibleDO(org.w3c.dom.Node currentNode, int level)
protected int
isVisibleInt(org.w3c.dom.Node currentNode)
protected static void
outputAttrToWriter(java.lang.String name, java.lang.String value, java.io.OutputStream writer, java.util.Map<java.lang.String,byte[]> cache)
Outputs an Attribute to the internal Writer.protected void
outputCommentToWriter(org.w3c.dom.Comment currentComment, java.io.OutputStream writer, int position)
Method outputCommentToWriterprotected void
outputPItoWriter(org.w3c.dom.ProcessingInstruction currentPI, java.io.OutputStream writer, int position)
Outputs a PI to the internal Writer.protected static void
outputTextToWriter(java.lang.String text, java.io.OutputStream writer)
Outputs a Text of CDATA section to the internal Writer.void
setWriter(java.io.OutputStream writer)
Sets the writer where the canonicalization ends.-
Methods inherited from class org.apache.xml.security.c14n.CanonicalizerSpi
engineCanonicalize, engineCanonicalizeSubTree, engineCanonicalizeSubTree, engineCanonicalizeXPathNodeSet, engineCanonicalizeXPathNodeSet, engineCanonicalizeXPathNodeSet, engineGetIncludeComments, engineGetURI, isSecureValidation, setSecureValidation
-
-
-
-
Field Detail
-
XML
public static final java.lang.String XML
- See Also:
- Constant Field Values
-
XMLNS
public static final java.lang.String XMLNS
- See Also:
- Constant Field Values
-
COMPARE
protected static final AttrCompare COMPARE
-
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
-
-
Method Detail
-
engineCanonicalizeSubTree
public byte[] engineCanonicalizeSubTree(org.w3c.dom.Node rootNode) throws CanonicalizationException
Method engineCanonicalizeSubTree- Specified by:
engineCanonicalizeSubTree
in classCanonicalizerSpi
- Returns:
- the c14n bytes
- Throws:
CanonicalizationException
-
engineCanonicalizeXPathNodeSet
public byte[] engineCanonicalizeXPathNodeSet(java.util.Set<org.w3c.dom.Node> xpathNodeSet) throws CanonicalizationException
Method engineCanonicalizeXPathNodeSet- Specified by:
engineCanonicalizeXPathNodeSet
in classCanonicalizerSpi
- Returns:
- the c14n bytes
- Throws:
CanonicalizationException
-
engineCanonicalize
public byte[] engineCanonicalize(XMLSignatureInput input) throws CanonicalizationException
Canonicalizes a Subtree node.- Parameters:
input
- the root of the subtree to canicalize- Returns:
- The canonicalize stream.
- Throws:
CanonicalizationException
-
setWriter
public void setWriter(java.io.OutputStream writer)
Description copied from class:CanonicalizerSpi
Sets the writer where the canonicalization ends. ByteArrayOutputStream if none is set.- Specified by:
setWriter
in classCanonicalizerSpi
- Parameters:
writer
- The writer to set.
-
engineCanonicalizeSubTree
protected byte[] engineCanonicalizeSubTree(org.w3c.dom.Node rootNode, org.w3c.dom.Node excludeNode) throws CanonicalizationException
Canonicalizes a Subtree node.- Parameters:
rootNode
- the root of the subtree to canonicalizeexcludeNode
- a node to be excluded from the canonicalize operation- Returns:
- The canonicalize stream.
- Throws:
CanonicalizationException
-
canonicalizeSubTree
protected final void canonicalizeSubTree(org.w3c.dom.Node currentNode, NameSpaceSymbTable ns, org.w3c.dom.Node endnode, int documentLevel) throws CanonicalizationException, java.io.IOException
Method canonicalizeSubTree, this function is a recursive one.- Parameters:
currentNode
-ns
-endnode
-- Throws:
CanonicalizationException
java.io.IOException
-
canonicalizeXPathNodeSet
protected final void canonicalizeXPathNodeSet(org.w3c.dom.Node currentNode, org.w3c.dom.Node endnode) throws CanonicalizationException, java.io.IOException
Canonicalizes all the nodes included in the currentNode and contained in the xpathNodeSet field.- Parameters:
currentNode
-endnode
-- Throws:
CanonicalizationException
java.io.IOException
-
isVisibleDO
protected int isVisibleDO(org.w3c.dom.Node currentNode, int level)
-
isVisibleInt
protected int isVisibleInt(org.w3c.dom.Node currentNode)
-
isVisible
protected boolean isVisible(org.w3c.dom.Node currentNode)
-
handleParent
protected void handleParent(org.w3c.dom.Element e, NameSpaceSymbTable ns)
-
getParentNameSpaces
protected final void getParentNameSpaces(org.w3c.dom.Element el, NameSpaceSymbTable ns)
Adds to ns the definitions from the parent elements of el- Parameters:
el
-ns
-
-
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
&
- all open angle brackets (<) with
<
- all quotation mark characters with
"
- 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
)
- Parameters:
name
-value
-writer
-- Throws:
java.io.IOException
- all ampersands (&) with
-
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
protected 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)
-
-