Class CanonicalizerBase
- java.lang.Object
-
- org.apache.xml.security.c14n.CanonicalizerSpi
-
- org.apache.xml.security.c14n.implementations.CanonicalizerBase
-
- Direct Known Subclasses:
Canonicalizer20010315,Canonicalizer20010315Excl,CanonicalizerPhysical
public abstract class CanonicalizerBase extends CanonicalizerSpi
Abstract base class for canonicalization algorithms. Please note that these implementations are NOT thread safe - please see the following JIRA for more information: https://issues.apache.org/jira/browse/SANTUARIO-463
-
-
Field Summary
Fields Modifier and Type Field Description private static byte[]AMPprivate static byte[]BEGIN_COMMprivate static byte[]BEGIN_PIprotected static AttrCompareCOMPAREprivate static byte[]END_COMMprivate static byte[]END_PIprivate static byte[]END_TAGprivate static byte[]EQUALS_STRprivate org.w3c.dom.NodeexcludeNodeThe node to be skipped/excluded from the DOM tree in subtree canonicalizations.private static byte[]GTprivate booleanincludeCommentsprivate static byte[]LTprotected static intNODE_AFTER_DOCUMENT_ELEMENTprotected static intNODE_BEFORE_DOCUMENT_ELEMENTprotected static intNODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENTprivate java.util.List<NodeFilter>nodeFilterprivate org.w3c.dom.AttrnullNodeThe null xmlns definition.private static byte[]QUOTprivate java.io.OutputStreamwriterprivate static byte[]X9private static byte[]XAprivate static byte[]XDstatic java.lang.StringXMLstatic java.lang.StringXML_LANG_URIstatic java.lang.StringXMLNSstatic java.lang.StringXMLNS_URIprivate java.util.Set<org.w3c.dom.Node>xpathNodeSet-
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 Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcanonicalizeSubTree(org.w3c.dom.Node currentNode, NameSpaceSymbTable ns, org.w3c.dom.Node endnode, int documentLevel)Method canonicalizeSubTree, this function is a recursive one.protected voidcanonicalizeXPathNodeSet(org.w3c.dom.Node currentNode, org.w3c.dom.Node endnode)Canonicalizes all the nodes included in the currentNode and contained in the xpathNodeSet field.(package private) abstract voidcircumventBugIfNeeded(XMLSignatureInput input)byte[]engineCanonicalize(XMLSignatureInput input)Canonicalizes a Subtree node.byte[]engineCanonicalizeSubTree(org.w3c.dom.Node rootNode)Method engineCanonicalizeSubTree C14n a node tree.protected 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 engineCanonicalizeXPathNodeSet C14n a nodesetprivate byte[]engineCanonicalizeXPathNodeSetInternal(org.w3c.dom.Node doc)protected org.w3c.dom.AttrgetNullNode(org.w3c.dom.Document ownerDocument)protected voidgetParentNameSpaces(org.w3c.dom.Element el, NameSpaceSymbTable ns)Adds to ns the definitions from the parent elements of elprotected java.io.OutputStreamgetWriter()protected voidhandleParent(org.w3c.dom.Element e, NameSpaceSymbTable ns)protected booleanisVisible(org.w3c.dom.Node currentNode)protected intisVisibleDO(org.w3c.dom.Node currentNode, int level)protected intisVisibleInt(org.w3c.dom.Node currentNode)(package private) abstract voidoutputAttributes(org.w3c.dom.Element element, NameSpaceSymbTable ns, java.util.Map<java.lang.String,byte[]> cache)Output the attributes for this node in XPathNodeSet c14n.(package private) abstract voidoutputAttributesSubtree(org.w3c.dom.Element element, NameSpaceSymbTable ns, java.util.Map<java.lang.String,byte[]> cache)Output the attributes for this node in a Subtree c14n.protected static voidoutputAttrToWriter(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 voidoutputCommentToWriter(org.w3c.dom.Comment currentComment, java.io.OutputStream writer, int position)Method outputCommentToWriterprotected voidoutputPItoWriter(org.w3c.dom.ProcessingInstruction currentPI, java.io.OutputStream writer, int position)Outputs a PI to the internal Writer.protected static voidoutputTextToWriter(java.lang.String text, java.io.OutputStream writer)Outputs a Text of CDATA section to the internal Writer.voidsetWriter(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
-
XMLNS_URI
public static final java.lang.String XMLNS_URI
- See Also:
- Constant Field Values
-
XML_LANG_URI
public static final java.lang.String XML_LANG_URI
- See Also:
- Constant Field Values
-
COMPARE
protected static final AttrCompare COMPARE
-
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
-
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
-
nodeFilter
private java.util.List<NodeFilter> nodeFilter
-
includeComments
private boolean includeComments
-
xpathNodeSet
private java.util.Set<org.w3c.dom.Node> xpathNodeSet
-
excludeNode
private org.w3c.dom.Node excludeNode
The node to be skipped/excluded from the DOM tree in subtree canonicalizations.
-
writer
private java.io.OutputStream writer
-
nullNode
private org.w3c.dom.Attr nullNode
The null xmlns definition.
-
-
Method Detail
-
engineCanonicalizeSubTree
public byte[] engineCanonicalizeSubTree(org.w3c.dom.Node rootNode) throws CanonicalizationExceptionMethod engineCanonicalizeSubTree C14n a node tree.- Specified by:
engineCanonicalizeSubTreein classCanonicalizerSpi- Parameters:
rootNode-- Returns:
- the c14n bytes
- Throws:
CanonicalizationException
-
engineCanonicalizeXPathNodeSet
public byte[] engineCanonicalizeXPathNodeSet(java.util.Set<org.w3c.dom.Node> xpathNodeSet) throws CanonicalizationExceptionMethod engineCanonicalizeXPathNodeSet C14n a nodeset- Specified by:
engineCanonicalizeXPathNodeSetin classCanonicalizerSpi- Parameters:
xpathNodeSet-- 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:CanonicalizerSpiSets the writer where the canonicalization ends. ByteArrayOutputStream if none is set.- Specified by:
setWriterin classCanonicalizerSpi- Parameters:
writer- The writer to set.
-
getWriter
protected java.io.OutputStream getWriter()
-
engineCanonicalizeSubTree
protected byte[] engineCanonicalizeSubTree(org.w3c.dom.Node rootNode, org.w3c.dom.Node excludeNode) throws CanonicalizationExceptionCanonicalizes 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.IOExceptionMethod canonicalizeSubTree, this function is a recursive one.- Parameters:
currentNode-ns-endnode-- Throws:
CanonicalizationExceptionjava.io.IOException
-
engineCanonicalizeXPathNodeSetInternal
private byte[] engineCanonicalizeXPathNodeSetInternal(org.w3c.dom.Node doc) throws CanonicalizationException- Throws:
CanonicalizationException
-
canonicalizeXPathNodeSet
protected final void canonicalizeXPathNodeSet(org.w3c.dom.Node currentNode, org.w3c.dom.Node endnode) throws CanonicalizationException, java.io.IOExceptionCanonicalizes all the nodes included in the currentNode and contained in the xpathNodeSet field.- Parameters:
currentNode-endnode-- Throws:
CanonicalizationExceptionjava.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-
-
outputAttributes
abstract void outputAttributes(org.w3c.dom.Element element, NameSpaceSymbTable ns, java.util.Map<java.lang.String,byte[]> cache) throws CanonicalizationException, org.w3c.dom.DOMException, java.io.IOExceptionOutput the attributes for this node in XPathNodeSet c14n.- Parameters:
element-ns-cache-- Throws:
CanonicalizationExceptionorg.w3c.dom.DOMExceptionjava.io.IOException
-
outputAttributesSubtree
abstract void outputAttributesSubtree(org.w3c.dom.Element element, NameSpaceSymbTable ns, java.util.Map<java.lang.String,byte[]> cache) throws CanonicalizationException, org.w3c.dom.DOMException, java.io.IOExceptionOutput the attributes for this node in a Subtree c14n.- Parameters:
element-ns-cache-- Throws:
CanonicalizationExceptionorg.w3c.dom.DOMExceptionjava.io.IOException
-
circumventBugIfNeeded
abstract void circumventBugIfNeeded(XMLSignatureInput input) throws CanonicalizationException, javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException
- Throws:
CanonicalizationExceptionjavax.xml.parsers.ParserConfigurationExceptionjava.io.IOExceptionorg.xml.sax.SAXException
-
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.IOExceptionOutputs 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,#xDis 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.IOExceptionOutputs 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.IOExceptionMethod 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.IOExceptionOutputs 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)
-
-