Class CanonicalizerPhysical
- java.lang.Object
-
- org.apache.xml.security.c14n.CanonicalizerSpi
-
- org.apache.xml.security.c14n.implementations.CanonicalizerBase
-
- org.apache.xml.security.c14n.implementations.CanonicalizerPhysical
-
public class CanonicalizerPhysical extends CanonicalizerBase
Serializes the physical representation of the subtree. All the attributes present in the subtree are emitted. The attributes are sorted within an element, with the namespace declarations appearing before the regular attributes. This algorithm is not a true canonicalization since equivalent subtrees may produce different output. It is therefore unsuitable for digital signatures. This same property makes it ideal for XML Encryption Syntax and Processing, because the decrypted XML content will share the same physical representation as the original XML content that was encrypted.
-
-
Field Summary
-
Fields inherited from class org.apache.xml.security.c14n.implementations.CanonicalizerBase
COMPARE, NODE_AFTER_DOCUMENT_ELEMENT, NODE_BEFORE_DOCUMENT_ELEMENT, NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT, XML, XML_LANG_URI, XMLNS, XMLNS_URI
-
Fields inherited from class org.apache.xml.security.c14n.CanonicalizerSpi
reset, secureValidation
-
-
Constructor Summary
Constructors Constructor Description CanonicalizerPhysical()Constructor Canonicalizer20010315
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcircumventBugIfNeeded(XMLSignatureInput input)byte[]engineCanonicalizeSubTree(org.w3c.dom.Node rootNode, java.lang.String inclusiveNamespaces)Always throws a CanonicalizationException.byte[]engineCanonicalizeSubTree(org.w3c.dom.Node rootNode, java.lang.String inclusiveNamespaces, boolean propagateDefaultNamespace)Always throws a CanonicalizationException.byte[]engineCanonicalizeXPathNodeSet(java.util.Set<org.w3c.dom.Node> xpathNodeSet, java.lang.String inclusiveNamespaces)Always throws a CanonicalizationException.booleanengineGetIncludeComments()Returns true if comments are includedjava.lang.StringengineGetURI()Returns the URI of this engine.protected voidhandleParent(org.w3c.dom.Element e, NameSpaceSymbTable ns)protected 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.protected voidoutputAttributesSubtree(org.w3c.dom.Element element, NameSpaceSymbTable ns, java.util.Map<java.lang.String,byte[]> cache)Output the Attr[]s for the given element.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.-
Methods inherited from class org.apache.xml.security.c14n.implementations.CanonicalizerBase
canonicalizeSubTree, canonicalizeXPathNodeSet, engineCanonicalize, engineCanonicalizeSubTree, engineCanonicalizeSubTree, engineCanonicalizeXPathNodeSet, getNullNode, getParentNameSpaces, getWriter, isVisible, isVisibleDO, isVisibleInt, outputAttrToWriter, outputTextToWriter, setWriter
-
Methods inherited from class org.apache.xml.security.c14n.CanonicalizerSpi
engineCanonicalize, engineCanonicalizeXPathNodeSet, engineCanonicalizeXPathNodeSet, isSecureValidation, setSecureValidation
-
-
-
-
Method Detail
-
engineCanonicalizeXPathNodeSet
public byte[] engineCanonicalizeXPathNodeSet(java.util.Set<org.w3c.dom.Node> xpathNodeSet, java.lang.String inclusiveNamespaces) throws CanonicalizationExceptionAlways throws a CanonicalizationException.- Specified by:
engineCanonicalizeXPathNodeSetin classCanonicalizerSpi- Parameters:
xpathNodeSet-inclusiveNamespaces-- Returns:
- none it always fails
- Throws:
CanonicalizationException- always
-
engineCanonicalizeSubTree
public byte[] engineCanonicalizeSubTree(org.w3c.dom.Node rootNode, java.lang.String inclusiveNamespaces) throws CanonicalizationExceptionAlways throws a CanonicalizationException.- Specified by:
engineCanonicalizeSubTreein classCanonicalizerSpi- Parameters:
rootNode-inclusiveNamespaces-- Returns:
- none it always fails
- Throws:
CanonicalizationException
-
engineCanonicalizeSubTree
public byte[] engineCanonicalizeSubTree(org.w3c.dom.Node rootNode, java.lang.String inclusiveNamespaces, boolean propagateDefaultNamespace) throws CanonicalizationExceptionAlways throws a CanonicalizationException.- Specified by:
engineCanonicalizeSubTreein classCanonicalizerSpi- Parameters:
rootNode-inclusiveNamespaces-propagateDefaultNamespace- If true the default namespace will be propagated to the c14n-ized root element- Returns:
- none it always fails
- Throws:
CanonicalizationException
-
outputAttributesSubtree
protected 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 Attr[]s for the given element.
The code of this method is a copy ofoutputAttributes(Element, NameSpaceSymbTable, Map), whereas it takes into account that subtree-c14n is -- well -- subtree-based. So if the element in question isRoot of c14n, it's parent is not in the node set, as well as all other ancestors.- Specified by:
outputAttributesSubtreein classCanonicalizerBase- Parameters:
element-ns-cache-- Throws:
CanonicalizationExceptionorg.w3c.dom.DOMExceptionjava.io.IOException
-
outputAttributes
protected 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.IOExceptionDescription copied from class:CanonicalizerBaseOutput the attributes for this node in XPathNodeSet c14n.- Specified by:
outputAttributesin classCanonicalizerBase- Throws:
CanonicalizationExceptionorg.w3c.dom.DOMExceptionjava.io.IOException
-
circumventBugIfNeeded
protected void circumventBugIfNeeded(XMLSignatureInput input) throws CanonicalizationException, javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException
- Specified by:
circumventBugIfNeededin classCanonicalizerBase- Throws:
CanonicalizationExceptionjavax.xml.parsers.ParserConfigurationExceptionjava.io.IOExceptionorg.xml.sax.SAXException
-
handleParent
protected void handleParent(org.w3c.dom.Element e, NameSpaceSymbTable ns)- Overrides:
handleParentin classCanonicalizerBase
-
engineGetURI
public final java.lang.String engineGetURI()
Returns the URI of this engine.- Specified by:
engineGetURIin classCanonicalizerSpi- Returns:
- the URI
-
engineGetIncludeComments
public final boolean engineGetIncludeComments()
Returns true if comments are included- Specified by:
engineGetIncludeCommentsin classCanonicalizerSpi- Returns:
- true if comments are included
-
outputPItoWriter
protected void outputPItoWriter(org.w3c.dom.ProcessingInstruction currentPI, java.io.OutputStream writer, int position) throws java.io.IOExceptionDescription copied from class:CanonicalizerBaseOutputs a PI to the internal Writer.- Overrides:
outputPItoWriterin classCanonicalizerBasewriter- 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.IOExceptionDescription copied from class:CanonicalizerBaseMethod outputCommentToWriter- Overrides:
outputCommentToWriterin classCanonicalizerBasewriter- writer where to write the things- Throws:
java.io.IOException
-
-