Fields Summary |
---|
public static final String | ENCODINGThe output encoding of canonicalized data |
public static final String | XPATH_C14N_WITH_COMMENTS_SINGLE_NODEXPath Expresion for selecting every node and continuos comments joined in only one node |
public static final String | ALGO_ID_C14N_OMIT_COMMENTSThe URL defined in XML-SEC Rec for inclusive c14n without comments. |
public static final String | ALGO_ID_C14N_WITH_COMMENTSThe URL defined in XML-SEC Rec for inclusive c14n with comments. |
public static final String | ALGO_ID_C14N_EXCL_OMIT_COMMENTSThe URL defined in XML-SEC Rec for exclusive c14n without comments. |
public static final String | ALGO_ID_C14N_EXCL_WITH_COMMENTSThe URL defined in XML-SEC Rec for exclusive c14n with comments. |
static boolean | _alreadyInitialized |
static Map | _canonicalizerHash |
protected CanonicalizerSpi | canonicalizerSpi |
Methods Summary |
---|
public byte[] | canonicalize(byte[] inputBytes)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< .
ByteArrayInputStream bais = new ByteArrayInputStream(inputBytes);
InputSource in = new InputSource(bais);
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
dfactory.setNamespaceAware(true);
// needs to validate for ID attribute nomalization
dfactory.setValidating(true);
DocumentBuilder db = dfactory.newDocumentBuilder();
/*
* for some of the test vectors from the specification,
* there has to be a validatin parser for ID attributes, default
* attribute values, NMTOKENS, etc.
* Unfortunaltely, the test vectors do use different DTDs or
* even no DTD. So Xerces 1.3.1 fires many warnings about using
* ErrorHandlers.
*
* Text from the spec:
*
* The input octet stream MUST contain a well-formed XML document,
* but the input need not be validated. However, the attribute
* value normalization and entity reference resolution MUST be
* performed in accordance with the behaviors of a validating
* XML processor. As well, nodes for default attributes (declared
* in the ATTLIST with an AttValue but not specified) are created
* in each element. Thus, the declarations in the document type
* declaration are used to help create the canonical form, even
* though the document type declaration is not retained in the
* canonical form.
*
*/
db.setErrorHandler(new com.sun.org.apache.xml.internal.security.utils
.IgnoreAllErrorHandler());
Document document = db.parse(in);
byte result[] = this.canonicalizeSubtree(document);
return result;
|
public byte[] | canonicalizeSubtree(org.w3c.dom.Node node)Canonicalizes the subtree rooted by node .
return this.canonicalizerSpi.engineCanonicalizeSubTree(node);
|
public byte[] | canonicalizeSubtree(org.w3c.dom.Node node, java.lang.String inclusiveNamespaces)Canonicalizes the subtree rooted by node .
return this.canonicalizerSpi.engineCanonicalizeSubTree(node,
inclusiveNamespaces);
|
public byte[] | canonicalizeXPathNodeSet(org.w3c.dom.NodeList xpathNodeSet)Canonicalizes an XPath node set. The xpathNodeSet is treated
as a list of XPath nodes, not as a list of subtrees.
return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
|
public byte[] | canonicalizeXPathNodeSet(org.w3c.dom.NodeList xpathNodeSet, java.lang.String inclusiveNamespaces)Canonicalizes an XPath node set. The xpathNodeSet is treated
as a list of XPath nodes, not as a list of subtrees.
return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet,
inclusiveNamespaces);
|
public byte[] | canonicalizeXPathNodeSet(java.util.Set xpathNodeSet)Canonicalizes an XPath node set.
return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
|
public byte[] | canonicalizeXPathNodeSet(java.util.Set xpathNodeSet, java.lang.String inclusiveNamespaces)Canonicalizes an XPath node set.
return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet,
inclusiveNamespaces);
|
public java.lang.String | getImplementingCanonicalizerClass()Returns the name of the implementing {@link CanonicalizerSpi} class
return this.canonicalizerSpi.getClass().getName();
|
private static java.lang.Class | getImplementingClass(java.lang.String URI)Method getImplementingClass
return (Class) _canonicalizerHash.get(URI);
|
public boolean | getIncludeComments()Method getIncludeComments
return this.canonicalizerSpi.engineGetIncludeComments();
|
public static final com.sun.org.apache.xml.internal.security.c14n.Canonicalizer | getInstance(java.lang.String algorithmURI)Method getInstance
Canonicalizer c14nizer = new Canonicalizer(algorithmURI);
return c14nizer;
|
public final java.lang.String | getURI()Method getURI
return this.canonicalizerSpi.engineGetURI();
|
public static void | init()Method init
//J+
if (!Canonicalizer._alreadyInitialized) {
Canonicalizer._canonicalizerHash = new HashMap(10);
Canonicalizer._alreadyInitialized = true;
}
|
public void | notReset()Set the canonicalizator behaviour to not reset.
this.canonicalizerSpi.reset=false;
|
public static void | register(java.lang.String algorithmURI, java.lang.String implementingClass)Method register
// check whether URI is already registered
Class registeredClass = getImplementingClass(algorithmURI);
if (registeredClass != null) {
Object exArgs[] = { algorithmURI, registeredClass };
throw new AlgorithmAlreadyRegisteredException(
"algorithm.alreadyRegistered", exArgs);
}
try {
_canonicalizerHash.put(algorithmURI, Class.forName(implementingClass));
} catch (ClassNotFoundException e) {
throw new RuntimeException("c14n class not found");
}
|
public void | setWriter(java.io.OutputStream os)Sets the writter where the cannocalization ends. ByteArrayOutputStream if
none is setted.
this.canonicalizerSpi.setWriter(os);
|