Package org.apache.xml.security.c14n
Class Canonicalizer
- java.lang.Object
-
- org.apache.xml.security.c14n.Canonicalizer
-
public class Canonicalizer extends java.lang.Object- Author:
- Christian Geuer-Pollmann
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringALGO_ID_C14N_EXCL_OMIT_COMMENTSThe URL defined in XML-SEC Rec for exclusive c14n without comments.static java.lang.StringALGO_ID_C14N_EXCL_WITH_COMMENTSThe URL defined in XML-SEC Rec for exclusive c14n with comments.static java.lang.StringALGO_ID_C14N_OMIT_COMMENTSThe URL defined in XML-SEC Rec for inclusive c14n without comments.static java.lang.StringALGO_ID_C14N_WITH_COMMENTSThe URL defined in XML-SEC Rec for inclusive c14n with comments.protected CanonicalizerSpicanonicalizerSpistatic java.lang.StringENCODINGThe output encoding of canonicalized datastatic java.lang.StringXPATH_C14N_WITH_COMMENTS_SINGLE_NODEXPath Expresion for selecting every node and continuos comments joined in only one node
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]canonicalize(byte[] inputBytes)This method tries to canonicalize the given bytes.byte[]canonicalizeSubtree(org.w3c.dom.Node node)Canonicalizes the subtree rooted bynode.byte[]canonicalizeSubtree(org.w3c.dom.Node node, java.lang.String inclusiveNamespaces)Canonicalizes the subtree rooted bynode.byte[]canonicalizeXPathNodeSet(java.util.Set xpathNodeSet)Canonicalizes an XPath node set.byte[]canonicalizeXPathNodeSet(java.util.Set xpathNodeSet, java.lang.String inclusiveNamespaces)Canonicalizes an XPath node set.byte[]canonicalizeXPathNodeSet(org.w3c.dom.NodeList xpathNodeSet)Canonicalizes an XPath node set.byte[]canonicalizeXPathNodeSet(org.w3c.dom.NodeList xpathNodeSet, java.lang.String inclusiveNamespaces)Canonicalizes an XPath node set.java.lang.StringgetImplementingCanonicalizerClass()Returns the name of the implementingCanonicalizerSpiclassbooleangetIncludeComments()Method getIncludeCommentsstatic CanonicalizergetInstance(java.lang.String algorithmURI)Method getInstancejava.lang.StringgetURI()Method getURIstatic voidinit()Method initvoidnotReset()Set the canonicalizator behaviour to not reset.static voidregister(java.lang.String algorithmURI, java.lang.String implementingClass)Method registervoidsetWriter(java.io.OutputStream os)Sets the writter where the cannocalization ends.
-
-
-
Field Detail
-
ENCODING
public static final java.lang.String ENCODING
The output encoding of canonicalized data- See Also:
- Constant Field Values
-
XPATH_C14N_WITH_COMMENTS_SINGLE_NODE
public static final java.lang.String XPATH_C14N_WITH_COMMENTS_SINGLE_NODE
XPath Expresion for selecting every node and continuos comments joined in only one node- See Also:
- Constant Field Values
-
ALGO_ID_C14N_OMIT_COMMENTS
public static final java.lang.String ALGO_ID_C14N_OMIT_COMMENTS
The URL defined in XML-SEC Rec for inclusive c14n without comments.- See Also:
- Constant Field Values
-
ALGO_ID_C14N_WITH_COMMENTS
public static final java.lang.String ALGO_ID_C14N_WITH_COMMENTS
The URL defined in XML-SEC Rec for inclusive c14n with comments.- See Also:
- Constant Field Values
-
ALGO_ID_C14N_EXCL_OMIT_COMMENTS
public static final java.lang.String ALGO_ID_C14N_EXCL_OMIT_COMMENTS
The URL defined in XML-SEC Rec for exclusive c14n without comments.- See Also:
- Constant Field Values
-
ALGO_ID_C14N_EXCL_WITH_COMMENTS
public static final java.lang.String ALGO_ID_C14N_EXCL_WITH_COMMENTS
The URL defined in XML-SEC Rec for exclusive c14n with comments.- See Also:
- Constant Field Values
-
canonicalizerSpi
protected CanonicalizerSpi canonicalizerSpi
-
-
Method Detail
-
init
public static void init()
Method init
-
getInstance
public static final Canonicalizer getInstance(java.lang.String algorithmURI) throws InvalidCanonicalizerException
Method getInstance- Parameters:
algorithmURI-- Returns:
- a Conicicalizer instance ready for the job
- Throws:
InvalidCanonicalizerException
-
register
public static void register(java.lang.String algorithmURI, java.lang.String implementingClass) throws AlgorithmAlreadyRegisteredExceptionMethod register- Parameters:
algorithmURI-implementingClass-- Throws:
AlgorithmAlreadyRegisteredException
-
getURI
public final java.lang.String getURI()
Method getURI- Returns:
- the URI defined for this c14n instance.
-
getIncludeComments
public boolean getIncludeComments()
Method getIncludeComments- Returns:
- true if the c14n respect the comments.
-
canonicalize
public byte[] canonicalize(byte[] inputBytes) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException, CanonicalizationExceptionThis method tries to canonicalize the given bytes. It's possible to even canonicalize non-wellformed sequences if they are well-formed after being wrapped with a>a<...>/a<.- Parameters:
inputBytes-- Returns:
- the result of the conicalization.
- Throws:
CanonicalizationExceptionjava.io.IOExceptionjavax.xml.parsers.ParserConfigurationExceptionorg.xml.sax.SAXException
-
canonicalizeSubtree
public byte[] canonicalizeSubtree(org.w3c.dom.Node node) throws CanonicalizationExceptionCanonicalizes the subtree rooted bynode.- Parameters:
node- The node to canicalize- Returns:
- the result of the c14n.
- Throws:
CanonicalizationException
-
canonicalizeSubtree
public byte[] canonicalizeSubtree(org.w3c.dom.Node node, java.lang.String inclusiveNamespaces) throws CanonicalizationExceptionCanonicalizes the subtree rooted bynode.- Parameters:
node-inclusiveNamespaces-- Returns:
- the result of the c14n.
- Throws:
CanonicalizationException
-
canonicalizeXPathNodeSet
public byte[] canonicalizeXPathNodeSet(org.w3c.dom.NodeList xpathNodeSet) throws CanonicalizationExceptionCanonicalizes an XPath node set. ThexpathNodeSetis treated as a list of XPath nodes, not as a list of subtrees.- Parameters:
xpathNodeSet-- Returns:
- the result of the c14n.
- Throws:
CanonicalizationException
-
canonicalizeXPathNodeSet
public byte[] canonicalizeXPathNodeSet(org.w3c.dom.NodeList xpathNodeSet, java.lang.String inclusiveNamespaces) throws CanonicalizationExceptionCanonicalizes an XPath node set. ThexpathNodeSetis treated as a list of XPath nodes, not as a list of subtrees.- Parameters:
xpathNodeSet-inclusiveNamespaces-- Returns:
- the result of the c14n.
- Throws:
CanonicalizationException
-
canonicalizeXPathNodeSet
public byte[] canonicalizeXPathNodeSet(java.util.Set xpathNodeSet) throws CanonicalizationExceptionCanonicalizes an XPath node set.- Parameters:
xpathNodeSet-- Returns:
- the result of the c14n.
- Throws:
CanonicalizationException
-
canonicalizeXPathNodeSet
public byte[] canonicalizeXPathNodeSet(java.util.Set xpathNodeSet, java.lang.String inclusiveNamespaces) throws CanonicalizationExceptionCanonicalizes an XPath node set.- Parameters:
xpathNodeSet-inclusiveNamespaces-- Returns:
- the result of the c14n.
- Throws:
CanonicalizationException
-
setWriter
public void setWriter(java.io.OutputStream os)
Sets the writter where the cannocalization ends. ByteArrayOutputStream if none is setted.- Parameters:
os-
-
getImplementingCanonicalizerClass
public java.lang.String getImplementingCanonicalizerClass()
Returns the name of the implementingCanonicalizerSpiclass- Returns:
- the name of the implementing
CanonicalizerSpiclass
-
notReset
public void notReset()
Set the canonicalizator behaviour to not reset.
-
-