本文整理汇总了Java中org.apache.xml.security.c14n.InvalidCanonicalizerException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidCanonicalizerException类的具体用法?Java InvalidCanonicalizerException怎么用?Java InvalidCanonicalizerException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvalidCanonicalizerException类属于org.apache.xml.security.c14n包,在下文中一共展示了InvalidCanonicalizerException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transform
import org.apache.xml.security.c14n.InvalidCanonicalizerException; //导入依赖的package包/类
@Override
public Data transform(Data data, XMLCryptoContext xc)
throws TransformException
{
// ignore comments if dereferencing same-document URI that require
// you to omit comments, even if the Transform says otherwise -
// this is to be compliant with section 4.3.3.3 of W3C Rec.
if (data instanceof DOMSubTreeData) {
DOMSubTreeData subTree = (DOMSubTreeData)data;
if (subTree.excludeComments()) {
try {
apacheCanonicalizer = Canonicalizer.getInstance
(CanonicalizationMethod.EXCLUSIVE);
boolean secVal = Utils.secureValidation(xc);
apacheCanonicalizer.setSecureValidation(secVal);
} catch (InvalidCanonicalizerException ice) {
throw new TransformException
("Couldn't find Canonicalizer for: " +
CanonicalizationMethod.EXCLUSIVE + ": " +
ice.getMessage(), ice);
}
}
}
return canonicalize(data, xc);
}
示例2: transform
import org.apache.xml.security.c14n.InvalidCanonicalizerException; //导入依赖的package包/类
@Override
public Data transform(Data data, XMLCryptoContext xc)
throws TransformException {
// ignore comments if dereferencing same-document URI that requires
// you to omit comments, even if the Transform says otherwise -
// this is to be compliant with section 4.3.3.3 of W3C Rec.
if (data instanceof DOMSubTreeData) {
DOMSubTreeData subTree = (DOMSubTreeData) data;
if (subTree.excludeComments()) {
try {
apacheCanonicalizer = Canonicalizer.getInstance
(CanonicalizationMethod.INCLUSIVE);
boolean secVal = Utils.secureValidation(xc);
apacheCanonicalizer.setSecureValidation(secVal);
} catch (InvalidCanonicalizerException ice) {
throw new TransformException
("Couldn't find Canonicalizer for: " +
CanonicalizationMethod.INCLUSIVE + ": " +
ice.getMessage(), ice);
}
}
}
return canonicalize(data, xc);
}
示例3: transform
import org.apache.xml.security.c14n.InvalidCanonicalizerException; //导入依赖的package包/类
@Override
public Data transform(Data data, XMLCryptoContext xc)
throws TransformException {
// ignore comments if dereferencing same-document URI that requires
// you to omit comments, even if the Transform says otherwise -
// this is to be compliant with section 4.3.3.3 of W3C Rec.
if (data instanceof DOMSubTreeData) {
DOMSubTreeData subTree = (DOMSubTreeData) data;
if (subTree.excludeComments()) {
try {
apacheCanonicalizer = Canonicalizer.getInstance(C14N_11);
boolean secVal = Utils.secureValidation(xc);
apacheCanonicalizer.setSecureValidation(secVal);
} catch (InvalidCanonicalizerException ice) {
throw new TransformException
("Couldn't find Canonicalizer for: " +
C14N_11 + ": " + ice.getMessage(), ice);
}
}
}
return canonicalize(data, xc);
}
示例4: getCanonicalizedOctetStream
import org.apache.xml.security.c14n.InvalidCanonicalizerException; //导入依赖的package包/类
/**
* Returns getCanonicalizedOctetStream
*
* @return the canonicalization result octet stream of <code>SignedInfo</code> element
* @throws CanonicalizationException
* @throws InvalidCanonicalizerException
* @throws XMLSecurityException
*/
public byte[] getCanonicalizedOctetStream()
throws CanonicalizationException, InvalidCanonicalizerException, XMLSecurityException {
if (this.c14nizedBytes == null) {
Canonicalizer c14nizer =
Canonicalizer.getInstance(this.getCanonicalizationMethodURI());
c14nizer.setSecureValidation(isSecureValidation());
String inclusiveNamespaces = this.getInclusiveNamespaces();
if (inclusiveNamespaces == null) {
this.c14nizedBytes = c14nizer.canonicalizeSubtree(getElement());
} else {
this.c14nizedBytes = c14nizer.canonicalizeSubtree(getElement(), inclusiveNamespaces);
}
}
// make defensive copy
return this.c14nizedBytes.clone();
}
示例5: signInOctetStream
import org.apache.xml.security.c14n.InvalidCanonicalizerException; //导入依赖的package包/类
/**
* Output the C14n stream to the given OutputStream.
* @param os
* @throws CanonicalizationException
* @throws InvalidCanonicalizerException
* @throws XMLSecurityException
*/
public void signInOctetStream(OutputStream os)
throws CanonicalizationException, InvalidCanonicalizerException, XMLSecurityException {
if (this.c14nizedBytes == null) {
Canonicalizer c14nizer =
Canonicalizer.getInstance(this.getCanonicalizationMethodURI());
c14nizer.setSecureValidation(isSecureValidation());
c14nizer.setWriter(os);
String inclusiveNamespaces = this.getInclusiveNamespaces();
if (inclusiveNamespaces == null) {
c14nizer.canonicalizeSubtree(getElement());
} else {
c14nizer.canonicalizeSubtree(getElement(), inclusiveNamespaces);
}
} else {
try {
os.write(this.c14nizedBytes);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
示例6: testSetOctetStreamGetOctetStream
import org.apache.xml.security.c14n.InvalidCanonicalizerException; //导入依赖的package包/类
@org.junit.Test
public void testSetOctetStreamGetOctetStream()
throws IOException, CanonicalizationException, InvalidCanonicalizerException {
InputStream inputStream =
new ByteArrayInputStream(_octetStreamTextInput.getBytes("UTF-8"));
XMLSignatureInput input = new XMLSignatureInput(inputStream);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream res = input.getOctetStream();
int off = 0;
while (res.available() > 0) {
byte array[] = new byte[1024];
int len = res.read(array);
baos.write(array, off, len);
off += len;
}
byte resBytes[] = baos.toByteArray();
String resString = new String(resBytes, "UTF-8");
assertTrue(resString.equals(_octetStreamTextInput));
}
示例7: test221
import org.apache.xml.security.c14n.InvalidCanonicalizerException; //导入依赖的package包/类
/**
* Method test221
*
* @throws CanonicalizationException
* @throws FileNotFoundException
* @throws IOException
* @throws InvalidCanonicalizerException
* @throws ParserConfigurationException
* @throws SAXException
* @throws TransformerException
* @throws XMLSecurityException
* @throws XMLSignatureException
*/
@org.junit.Test
public void test221()
throws IOException, FileNotFoundException, SAXException,
ParserConfigurationException, CanonicalizationException,
InvalidCanonicalizerException, TransformerException,
XMLSignatureException, XMLSecurityException {
Document doc =
this.db.parse(
getAbsolutePath("src/test/resources/org/apache/xml/security/c14n/inExcl/example2_2_1.xml")
);
Node root = doc.getElementsByTagNameNS("http://example.net", "elem2").item(0);
Canonicalizer20010315 c = new Canonicalizer20010315WithComments();
byte[] reference = JavaUtils.getBytesFromFile(getAbsolutePath(
"src/test/resources/org/apache/xml/security/c14n/inExcl/example2_2_1_c14nized.xml"));
byte[] result = c.engineCanonicalizeSubTree(root);
boolean equals = java.security.MessageDigest.isEqual(reference, result);
assertTrue(equals);
}
示例8: test222
import org.apache.xml.security.c14n.InvalidCanonicalizerException; //导入依赖的package包/类
/**
* Method test222
*
* @throws CanonicalizationException
* @throws FileNotFoundException
* @throws IOException
* @throws InvalidCanonicalizerException
* @throws ParserConfigurationException
* @throws SAXException
* @throws TransformerException
* @throws XMLSecurityException
* @throws XMLSignatureException
*/
@org.junit.Test
public void test222()
throws IOException, FileNotFoundException, SAXException,
ParserConfigurationException, CanonicalizationException,
InvalidCanonicalizerException, TransformerException,
XMLSignatureException, XMLSecurityException {
Document doc =
this.db.parse(getAbsolutePath(
"src/test/resources/org/apache/xml/security/c14n/inExcl/example2_2_2.xml")
);
Node root = doc.getElementsByTagNameNS("http://example.net", "elem2").item(0);
Canonicalizer20010315 c = new Canonicalizer20010315WithComments();
byte[] reference = JavaUtils.getBytesFromFile(getAbsolutePath(
"src/test/resources/org/apache/xml/security/c14n/inExcl/example2_2_2_c14nized.xml"));
byte[] result = c.engineCanonicalizeSubTree(root);
boolean equals = java.security.MessageDigest.isEqual(reference, result);
assertTrue(equals);
}
示例9: test221excl
import org.apache.xml.security.c14n.InvalidCanonicalizerException; //导入依赖的package包/类
/**
* Method test221excl
*
* @throws CanonicalizationException
* @throws FileNotFoundException
* @throws IOException
* @throws InvalidCanonicalizerException
* @throws ParserConfigurationException
* @throws SAXException
* @throws TransformerException
* @throws XMLSecurityException
* @throws XMLSignatureException
*/
@org.junit.Test
public void test221excl()
throws IOException, FileNotFoundException, SAXException,
ParserConfigurationException, CanonicalizationException,
InvalidCanonicalizerException, TransformerException,
XMLSignatureException, XMLSecurityException {
Document doc =
this.db.parse(getAbsolutePath(
"src/test/resources/org/apache/xml/security/c14n/inExcl/example2_2_1.xml"));
Node root = doc.getElementsByTagNameNS("http://example.net", "elem2").item(0);
Canonicalizer20010315Excl c = new Canonicalizer20010315ExclWithComments();
byte[] reference = JavaUtils.getBytesFromFile(getAbsolutePath(
"src/test/resources/org/apache/xml/security/c14n/inExcl/example2_2_c14nized_exclusive.xml"));
byte[] result = c.engineCanonicalizeSubTree(root);
boolean equals = java.security.MessageDigest.isEqual(reference, result);
assertTrue(equals);
}
示例10: test222excl
import org.apache.xml.security.c14n.InvalidCanonicalizerException; //导入依赖的package包/类
/**
* Method test222excl
*
* @throws CanonicalizationException
* @throws FileNotFoundException
* @throws IOException
* @throws InvalidCanonicalizerException
* @throws ParserConfigurationException
* @throws SAXException
* @throws TransformerException
* @throws XMLSecurityException
* @throws XMLSignatureException
*/
@org.junit.Test
public void test222excl()
throws IOException, FileNotFoundException, SAXException,
ParserConfigurationException, CanonicalizationException,
InvalidCanonicalizerException, TransformerException,
XMLSignatureException, XMLSecurityException {
Document doc =
this.db.parse(getAbsolutePath(
"src/test/resources/org/apache/xml/security/c14n/inExcl/example2_2_2.xml"));
Node root = doc.getElementsByTagNameNS("http://example.net", "elem2").item(0);
Canonicalizer20010315Excl c = new Canonicalizer20010315ExclWithComments();
byte[] reference = JavaUtils.getBytesFromFile(getAbsolutePath(
"src/test/resources/org/apache/xml/security/c14n/inExcl/example2_2_c14nized_exclusive.xml") );
byte[] result = c.engineCanonicalizeSubTree(root);
boolean equals = java.security.MessageDigest.isEqual(reference, result);
assertTrue(equals);
}
示例11: test31withCommentsSubtree
import org.apache.xml.security.c14n.InvalidCanonicalizerException; //导入依赖的package包/类
/**
* 3.1 PIs, Comments, and Outside of Document Element
*
* @throws CanonicalizationException
* @throws FileNotFoundException
* @throws IOException
* @throws InvalidCanonicalizerException
* @throws ParserConfigurationException
* @throws SAXException
* @throws TransformerException
* @throws XPathExpressionException
*/
@org.junit.Test
public void test31withCommentsSubtree()
throws IOException, FileNotFoundException, SAXException,
ParserConfigurationException, CanonicalizationException,
InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri =
"3.1: PIs, Comments, and Outside of Document Element. (commented)";
String fileIn = prefix + "in/31_input.xml";
String fileRef = prefix + "in/31_c14n-comments.xml";
String fileOut = prefix + "out/xpath_31_output-comments.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS;
boolean validating = true;
String xpath = null;
assertTrue(descri,
c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
示例12: test31withCommentsSubset
import org.apache.xml.security.c14n.InvalidCanonicalizerException; //导入依赖的package包/类
/**
* 3.1 PIs, Comments, and Outside of Document Element
*
* @throws CanonicalizationException
* @throws FileNotFoundException
* @throws IOException
* @throws InvalidCanonicalizerException
* @throws ParserConfigurationException
* @throws SAXException
* @throws TransformerException
* @throws XPathExpressionException
*/
@org.junit.Test
public void test31withCommentsSubset()
throws IOException, FileNotFoundException, SAXException,
ParserConfigurationException, CanonicalizationException,
InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri =
"3.1: PIs, Comments, and Outside of Document Element. (commented)";
String fileIn = prefix + "in/31_input.xml";
String fileRef = prefix + "in/31_c14n-comments.xml";
String fileOut = prefix + "out/xpath_31_output-comments.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS;
boolean validating = true;
String xpath = Canonicalizer.XPATH_C14N_WITH_COMMENTS_SINGLE_NODE;
assertTrue(descri,
c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
示例13: test31subtree
import org.apache.xml.security.c14n.InvalidCanonicalizerException; //导入依赖的package包/类
/**
* 3.1 PIs, Comments, and Outside of Document Element
*
* @throws CanonicalizationException
* @throws FileNotFoundException
* @throws IOException
* @throws InvalidCanonicalizerException
* @throws ParserConfigurationException
* @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-OutsideDoc">the example from the spec</A>
* @throws TransformerException
* @throws XPathExpressionException
*/
@org.junit.Test
public void test31subtree()
throws IOException, FileNotFoundException, SAXException,
ParserConfigurationException, CanonicalizationException,
InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri =
"3.1: PIs, Comments, and Outside of Document Element. (uncommented)";
String fileIn = prefix + "in/31_input.xml";
String fileRef = prefix + "in/31_c14n.xml";
String fileOut = prefix + "out/xpath_31_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
boolean validating = true;
String xpath = null;
assertTrue(descri,
c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
示例14: test31subset
import org.apache.xml.security.c14n.InvalidCanonicalizerException; //导入依赖的package包/类
/**
* 3.1 PIs, Comments, and Outside of Document Element
*
* @throws CanonicalizationException
* @throws FileNotFoundException
* @throws IOException
* @throws InvalidCanonicalizerException
* @throws ParserConfigurationException
* @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-OutsideDoc">the example from the spec</A>
* @throws TransformerException
* @throws XPathExpressionException
*/
@org.junit.Test
public void test31subset()
throws IOException, FileNotFoundException, SAXException,
ParserConfigurationException, CanonicalizationException,
InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri =
"3.1: PIs, Comments, and Outside of Document Element. (uncommented)";
String fileIn = prefix + "in/31_input.xml";
String fileRef = prefix + "in/31_c14n.xml";
String fileOut = prefix + "out/xpath_31_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
boolean validating = true;
String xpath = Canonicalizer.XPATH_C14N_WITH_COMMENTS_SINGLE_NODE;
assertTrue(descri,
c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
示例15: test32subtree
import org.apache.xml.security.c14n.InvalidCanonicalizerException; //导入依赖的package包/类
/**
* 3.2 Whitespace in Document Content
*
* @throws CanonicalizationException
* @throws FileNotFoundException
* @throws IOException
* @throws InvalidCanonicalizerException
* @throws ParserConfigurationException
* @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-WhitespaceInContent">the example from the spec</A>
* @throws TransformerException
* @throws XPathExpressionException
*/
@org.junit.Test
public void test32subtree()
throws IOException, FileNotFoundException, SAXException,
ParserConfigurationException, CanonicalizationException,
InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri = "3.2 Whitespace in Document Content. (uncommented)";
String fileIn = prefix + "in/32_input.xml";
String fileRef = prefix + "in/32_c14n.xml";
String fileOut = prefix + "out/xpath_32_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
boolean validating = true;
String xpath = null;
assertTrue(descri,
c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}