Package org.apache.xml.security.c14n
Class Canonicalizer
java.lang.Object
org.apache.xml.security.c14n.Canonicalizer
- Author:
- Christian Geuer-Pollmann
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The URL defined in XML-SEC Rec for exclusive c14n without comments.static final String
The URL defined in XML-SEC Rec for exclusive c14n with comments.static final String
The URL defined in XML-SEC Rec for inclusive c14n without comments.static final String
The URL defined in XML-SEC Rec for inclusive c14n with comments.protected CanonicalizerSpi
static final String
The output encoding of canonicalized datastatic final String
XPath Expresion for selecting every node and continuos comments joined in only one node -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
canonicalize
(byte[] inputBytes) This method tries to canonicalize the given bytes.byte[]
canonicalizeSubtree
(Node node) Canonicalizes the subtree rooted bynode
.byte[]
canonicalizeSubtree
(Node node, String inclusiveNamespaces) Canonicalizes the subtree rooted bynode
.byte[]
canonicalizeXPathNodeSet
(Set xpathNodeSet) Canonicalizes an XPath node set.byte[]
canonicalizeXPathNodeSet
(Set xpathNodeSet, String inclusiveNamespaces) Canonicalizes an XPath node set.byte[]
canonicalizeXPathNodeSet
(NodeList xpathNodeSet) Canonicalizes an XPath node set.byte[]
canonicalizeXPathNodeSet
(NodeList xpathNodeSet, String inclusiveNamespaces) Canonicalizes an XPath node set.Returns the name of the implementingCanonicalizerSpi
classboolean
Method getIncludeCommentsstatic final Canonicalizer
getInstance
(String algorithmURI) Method getInstancefinal String
getURI()
Method getURIstatic void
init()
Method initvoid
notReset()
Set the canonicalizator behaviour to not reset.static void
Method registervoid
Sets the writter where the cannocalization ends.
-
Field Details
-
ENCODING
The output encoding of canonicalized data- See Also:
-
XPATH_C14N_WITH_COMMENTS_SINGLE_NODE
XPath Expresion for selecting every node and continuos comments joined in only one node- See Also:
-
ALGO_ID_C14N_OMIT_COMMENTS
The URL defined in XML-SEC Rec for inclusive c14n without comments.- See Also:
-
ALGO_ID_C14N_WITH_COMMENTS
The URL defined in XML-SEC Rec for inclusive c14n with comments.- See Also:
-
ALGO_ID_C14N_EXCL_OMIT_COMMENTS
The URL defined in XML-SEC Rec for exclusive c14n without comments.- See Also:
-
ALGO_ID_C14N_EXCL_WITH_COMMENTS
The URL defined in XML-SEC Rec for exclusive c14n with comments.- See Also:
-
canonicalizerSpi
-
-
Method Details
-
init
public static void init()Method init -
getInstance
public static final Canonicalizer getInstance(String algorithmURI) throws InvalidCanonicalizerException Method getInstance- Parameters:
algorithmURI
-- Returns:
- a Conicicalizer instance ready for the job
- Throws:
InvalidCanonicalizerException
-
register
public static void register(String algorithmURI, String implementingClass) throws AlgorithmAlreadyRegisteredException Method register- Parameters:
algorithmURI
-implementingClass
-- Throws:
AlgorithmAlreadyRegisteredException
-
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 ParserConfigurationException, IOException, SAXException, CanonicalizationException This 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:
CanonicalizationException
IOException
ParserConfigurationException
SAXException
-
canonicalizeSubtree
Canonicalizes the subtree rooted bynode
.- Parameters:
node
- The node to canicalize- Returns:
- the result of the c14n.
- Throws:
CanonicalizationException
-
canonicalizeSubtree
public byte[] canonicalizeSubtree(Node node, String inclusiveNamespaces) throws CanonicalizationException Canonicalizes the subtree rooted bynode
.- Parameters:
node
-inclusiveNamespaces
-- Returns:
- the result of the c14n.
- Throws:
CanonicalizationException
-
canonicalizeXPathNodeSet
Canonicalizes an XPath node set. ThexpathNodeSet
is 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(NodeList xpathNodeSet, String inclusiveNamespaces) throws CanonicalizationException Canonicalizes an XPath node set. ThexpathNodeSet
is 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
Canonicalizes an XPath node set.- Parameters:
xpathNodeSet
-- Returns:
- the result of the c14n.
- Throws:
CanonicalizationException
-
canonicalizeXPathNodeSet
public byte[] canonicalizeXPathNodeSet(Set xpathNodeSet, String inclusiveNamespaces) throws CanonicalizationException Canonicalizes an XPath node set.- Parameters:
xpathNodeSet
-inclusiveNamespaces
-- Returns:
- the result of the c14n.
- Throws:
CanonicalizationException
-
setWriter
Sets the writter where the cannocalization ends. ByteArrayOutputStream if none is setted.- Parameters:
os
-
-
getImplementingCanonicalizerClass
Returns the name of the implementingCanonicalizerSpi
class- Returns:
- the name of the implementing
CanonicalizerSpi
class
-
notReset
public void notReset()Set the canonicalizator behaviour to not reset.
-