Module org.apache.santuario.xmlsec
Class CanonicalizerBase
java.lang.Object
org.apache.xml.security.c14n.CanonicalizerSpi
org.apache.xml.security.c14n.implementations.CanonicalizerBase
- Direct Known Subclasses:
Canonicalizer20010315,Canonicalizer20010315Excl,CanonicalizerPhysical
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
FieldsModifier and TypeFieldDescriptionprivate static final byte[]private static final byte[]private static final byte[]protected static final AttrCompareprivate static final byte[]private static final byte[]private static final byte[]private static final byte[]private static final byte[]private booleanprivate static final byte[]protected static final intprotected static final intprotected static final intprivate List<NodeFilter>private AttrThe null xmlns definition.private static final byte[]private static final byte[]private static final byte[]private static final byte[]static final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCanonicalizerBase(boolean includeComments) Constructor CanonicalizerBase -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcanonicalizeSubTree(Node currentNode, NameSpaceSymbTable ns, Node endnode, int documentLevel, Node excludeNode, OutputStream writer) Method canonicalizeSubTree, this function is a recursive one.private voidcanonicalizeXPathNodeSet(Node currentNode, Node endnode, OutputStream writer) Canonicalizes all the nodes included in the currentNode and contained in the xpathNodeSet field.(package private) abstract voidvoidengineCanonicalize(XMLSignatureInput input, OutputStream writer, boolean secureValidation) Canonicalizes a Subtree node.voidengineCanonicalizeSubTree(Node rootNode, OutputStream writer) Method engineCanonicalizeSubTree C14n a node tree.protected voidengineCanonicalizeSubTree(Node rootNode, Node excludeNode, OutputStream writer) Canonicalizes a Subtree node.voidengineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet, OutputStream writer) Method engineCanonicalizeXPathNodeSet C14n a nodesetprivate voidengineCanonicalizeXPathNodeSetInternal(Node doc, OutputStream writer) protected AttrgetNullNode(Document ownerDocument) private voidAdds to ns the definitions from the parent elements of elprotected voidprotected booleanprotected intisVisibleDO(Node currentNode, int level) protected intisVisibleInt(Node currentNode) (package private) abstract voidoutputAttributes(Element element, NameSpaceSymbTable ns, Map<String, byte[]> cache, OutputStream writer) Output the attributes for this node in XPathNodeSet c14n.(package private) abstract voidoutputAttributesSubtree(Element element, NameSpaceSymbTable ns, Map<String, byte[]> cache, OutputStream writer) Output the attributes for this node in a Subtree c14n.protected static final voidoutputAttrToWriter(String name, String value, OutputStream writer, Map<String, byte[]> cache) Outputs an Attribute to the internal Writer.protected voidoutputCommentToWriter(Comment currentComment, OutputStream writer, int position) Method outputCommentToWriterprotected voidoutputPItoWriter(ProcessingInstruction currentPI, OutputStream writer, int position) Outputs a PI to the internal Writer.private static final voidoutputTextToWriter(String text, OutputStream writer) Outputs a Text of CDATA section to the internal Writer.Methods inherited from class org.apache.xml.security.c14n.CanonicalizerSpi
engineCanonicalize, engineCanonicalizeSubTree, engineCanonicalizeSubTree, engineCanonicalizeXPathNodeSet, engineGetURI
-
Field Details
-
XML
- See Also:
-
XMLNS
- See Also:
-
XMLNS_URI
- See Also:
-
XML_LANG_URI
- See Also:
-
COMPARE
-
NODE_BEFORE_DOCUMENT_ELEMENT
protected static final int NODE_BEFORE_DOCUMENT_ELEMENT- See Also:
-
NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT
protected static final int NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT- See Also:
-
NODE_AFTER_DOCUMENT_ELEMENT
protected static final int NODE_AFTER_DOCUMENT_ELEMENT- See Also:
-
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
-
xpathNodeSet
-
nullNode
The null xmlns definition.
-
-
Constructor Details
-
CanonicalizerBase
protected CanonicalizerBase(boolean includeComments) Constructor CanonicalizerBase- Parameters:
includeComments-
-
-
Method Details
-
engineCanonicalizeSubTree
public void engineCanonicalizeSubTree(Node rootNode, OutputStream writer) throws CanonicalizationException Method engineCanonicalizeSubTree C14n a node tree.- Specified by:
engineCanonicalizeSubTreein classCanonicalizerSpi- Parameters:
rootNode-writer- OutputStream to write the canonicalization result- Throws:
CanonicalizationException
-
engineCanonicalizeXPathNodeSet
public void engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet, OutputStream writer) throws CanonicalizationException Method engineCanonicalizeXPathNodeSet C14n a nodeset- Specified by:
engineCanonicalizeXPathNodeSetin classCanonicalizerSpi- Parameters:
xpathNodeSet-writer- OutputStream to write the canonicalization result- Throws:
CanonicalizationException
-
engineCanonicalize
public void engineCanonicalize(XMLSignatureInput input, OutputStream writer, boolean secureValidation) throws CanonicalizationException Canonicalizes a Subtree node.- Parameters:
input- the root of the subtree to canicalizewriter- OutputStream to write the canonicalization resultsecureValidation- Whether secure validation is enabled- Throws:
CanonicalizationException
-
engineCanonicalizeSubTree
protected void engineCanonicalizeSubTree(Node rootNode, Node excludeNode, OutputStream writer) throws CanonicalizationException Canonicalizes a Subtree node.- Parameters:
rootNode- the root of the subtree to canonicalizeexcludeNode- a node to be excluded from the canonicalize operationwriter- OutputStream to write the canonicalization result- Throws:
CanonicalizationException
-
canonicalizeSubTree
private void canonicalizeSubTree(Node currentNode, NameSpaceSymbTable ns, Node endnode, int documentLevel, Node excludeNode, OutputStream writer) throws CanonicalizationException, IOException Method canonicalizeSubTree, this function is a recursive one.- Parameters:
currentNode-ns-endnode-documentLevel-excludeNode-writer- OutputStream to write the canonicalization result- Throws:
CanonicalizationExceptionIOException
-
engineCanonicalizeXPathNodeSetInternal
private void engineCanonicalizeXPathNodeSetInternal(Node doc, OutputStream writer) throws CanonicalizationException - Throws:
CanonicalizationException
-
canonicalizeXPathNodeSet
private void canonicalizeXPathNodeSet(Node currentNode, Node endnode, OutputStream writer) throws CanonicalizationException, 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:
CanonicalizationExceptionIOException
-
isVisibleDO
- Throws:
CanonicalizationException
-
isVisibleInt
- Throws:
CanonicalizationException
-
isVisible
- Throws:
CanonicalizationException
-
handleParent
-
getParentNameSpaces
Adds to ns the definitions from the parent elements of el- Parameters:
el-ns-
-
outputAttributes
abstract void outputAttributes(Element element, NameSpaceSymbTable ns, Map<String, byte[]> cache, OutputStream writer) throws CanonicalizationException, DOMException, IOExceptionOutput the attributes for this node in XPathNodeSet c14n.- Parameters:
element-ns-cache-writer- OutputStream to write the canonicalization result- Throws:
CanonicalizationExceptionDOMExceptionIOException
-
outputAttributesSubtree
abstract void outputAttributesSubtree(Element element, NameSpaceSymbTable ns, Map<String, byte[]> cache, OutputStream writer) throws CanonicalizationException, DOMException, IOExceptionOutput the attributes for this node in a Subtree c14n.- Parameters:
element-ns-cache-writer- OutputStream to write the canonicalization result- Throws:
CanonicalizationExceptionDOMExceptionIOException
-
circumventBugIfNeeded
- Throws:
XMLParserExceptionIOException
-
outputAttrToWriter
protected static final void outputAttrToWriter(String name, String value, OutputStream writer, Map<String, byte[]> cache) throws 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:
IOException
- all ampersands with
-
outputPItoWriter
protected void outputPItoWriter(ProcessingInstruction currentPI, OutputStream writer, int position) throws IOException Outputs a PI to the internal Writer.- Parameters:
currentPI-writer- where to write the things- Throws:
IOException
-
outputCommentToWriter
protected void outputCommentToWriter(Comment currentComment, OutputStream writer, int position) throws IOException Method outputCommentToWriter- Parameters:
currentComment-writer- writer where to write the things- Throws:
IOException
-
outputTextToWriter
Outputs a Text of CDATA section to the internal Writer.- Parameters:
text-writer- writer where to write the things- Throws:
IOException
-
getNullNode
-