本文整理汇总了Java中com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException类的典型用法代码示例。如果您正苦于以下问题:Java CanonicalizationException类的具体用法?Java CanonicalizationException怎么用?Java CanonicalizationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CanonicalizationException类属于com.sun.org.apache.xml.internal.security.c14n包,在下文中一共展示了CanonicalizationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: enginePerformTransform
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; //导入依赖的package包/类
/** @inheritDoc */
protected XMLSignatureInput enginePerformTransform(
XMLSignatureInput input, OutputStream os, Transform transformObject
) throws CanonicalizationException {
Canonicalizer20010315WithComments c14n = new Canonicalizer20010315WithComments();
if (os != null) {
c14n.setWriter(os);
}
byte[] result = null;
result = c14n.engineCanonicalize(input);
XMLSignatureInput output = new XMLSignatureInput(result);
if (os != null) {
output.setOutputStream(os);
}
return output;
}
示例2: getNodeSet
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; //导入依赖的package包/类
/**
* Returns the node set from input which was specified as the parameter of
* {@link XMLSignatureInput} constructor
* @param circumvent
*
* @return the node set
* @throws SAXException
* @throws IOException
* @throws ParserConfigurationException
* @throws CanonicalizationException
*/
public Set<Node> getNodeSet(boolean circumvent) throws ParserConfigurationException,
IOException, SAXException, CanonicalizationException {
if (inputNodeSet != null) {
return inputNodeSet;
}
if (inputOctetStreamProxy == null && subNode != null) {
if (circumvent) {
XMLUtils.circumventBug2650(XMLUtils.getOwnerDocument(subNode));
}
inputNodeSet = new LinkedHashSet<Node>();
XMLUtils.getSet(subNode, inputNodeSet, excludeNode, excludeComments);
return inputNodeSet;
} else if (isOctetStream()) {
convertToNodes();
Set<Node> result = new LinkedHashSet<Node>();
XMLUtils.getSet(subNode, result, null, false);
return result;
}
throw new RuntimeException("getNodeSet() called but no input data present");
}
示例3: signInOctetStream
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; //导入依赖的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.setWriter(os);
String inclusiveNamespaces = this.getInclusiveNamespaces();
if (inclusiveNamespaces == null) {
c14nizer.canonicalizeSubtree(this.constructionElement);
} else {
c14nizer.canonicalizeSubtree(this.constructionElement, inclusiveNamespaces);
}
} else {
try {
os.write(this.c14nizedBytes);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
示例4: enginePerformTransform
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; //导入依赖的package包/类
protected XMLSignatureInput enginePerformTransform(
XMLSignatureInput input, OutputStream os, Transform transform
) throws CanonicalizationException {
Canonicalizer11_WithComments c14n = new Canonicalizer11_WithComments();
if (os != null) {
c14n.setWriter(os);
}
byte[] result = null;
result = c14n.engineCanonicalize(input);
XMLSignatureInput output = new XMLSignatureInput(result);
if (os != null) {
output.setOutputStream(os);
}
return output;
}
示例5: assertNotRelativeNS
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; //导入依赖的package包/类
/**
* This method throws an exception if the Attribute value contains
* a relative URI.
*
* @param attr
* @throws CanonicalizationException
*/
public static void assertNotRelativeNS(Attr attr) throws CanonicalizationException {
if (attr == null) {
return;
}
String nodeAttrName = attr.getNodeName();
boolean definesDefaultNS = nodeAttrName.equals("xmlns");
boolean definesNonDefaultNS = nodeAttrName.startsWith("xmlns:");
if ((definesDefaultNS || definesNonDefaultNS) && namespaceIsRelative(attr)) {
String parentName = attr.getOwnerElement().getTagName();
String attrValue = attr.getValue();
Object exArgs[] = { parentName, nodeAttrName, attrValue };
throw new CanonicalizationException(
"c14n.Canonicalizer.RelativeNamespace", exArgs
);
}
}
示例6: handleAttributesSubtree
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; //导入依赖的package包/类
/**
* Returns the Attr[]s to be output for the given element.
* <br>
* The code of this method is a copy of {@link #handleAttributes(Element,
* NameSpaceSymbTable)},
* 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.
*
* @param element
* @param ns
* @return the Attr[]s to be output
* @throws CanonicalizationException
*/
@Override
protected Iterator<Attr> handleAttributesSubtree(Element element, NameSpaceSymbTable ns)
throws CanonicalizationException {
if (!element.hasAttributes()) {
return null;
}
// result will contain all the attrs declared directly on that element
final SortedSet<Attr> result = this.result;
result.clear();
if (element.hasAttributes()) {
NamedNodeMap attrs = element.getAttributes();
int attrsLength = attrs.getLength();
for (int i = 0; i < attrsLength; i++) {
Attr attribute = (Attr) attrs.item(i);
result.add(attribute);
}
}
return result.iterator();
}
示例7: enginePerformTransform
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; //导入依赖的package包/类
protected XMLSignatureInput enginePerformTransform(
XMLSignatureInput input, OutputStream os, Transform transformObject
) throws CanonicalizationException {
try {
String inclusiveNamespaces = null;
if (transformObject.length(
InclusiveNamespaces.ExclusiveCanonicalizationNamespace,
InclusiveNamespaces._TAG_EC_INCLUSIVENAMESPACES) == 1
) {
Element inclusiveElement =
XMLUtils.selectNode(
transformObject.getElement().getFirstChild(),
InclusiveNamespaces.ExclusiveCanonicalizationNamespace,
InclusiveNamespaces._TAG_EC_INCLUSIVENAMESPACES,
0
);
inclusiveNamespaces =
new InclusiveNamespaces(
inclusiveElement, transformObject.getBaseURI()
).getInclusiveNamespaces();
}
Canonicalizer20010315ExclWithComments c14n =
new Canonicalizer20010315ExclWithComments();
if (os != null) {
c14n.setWriter(os);
}
byte[] result = c14n.engineCanonicalize(input, inclusiveNamespaces);
XMLSignatureInput output = new XMLSignatureInput(result);
return output;
} catch (XMLSecurityException ex) {
throw new CanonicalizationException("empty", ex);
}
}
示例8: enginePerformTransform
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; //导入依赖的package包/类
protected XMLSignatureInput enginePerformTransform(
XMLSignatureInput input, OutputStream os, Transform transformObject
) throws CanonicalizationException {
try {
String inclusiveNamespaces = null;
if (transformObject.length(
InclusiveNamespaces.ExclusiveCanonicalizationNamespace,
InclusiveNamespaces._TAG_EC_INCLUSIVENAMESPACES) == 1
) {
Element inclusiveElement =
XMLUtils.selectNode(
transformObject.getElement().getFirstChild(),
InclusiveNamespaces.ExclusiveCanonicalizationNamespace,
InclusiveNamespaces._TAG_EC_INCLUSIVENAMESPACES,
0
);
inclusiveNamespaces =
new InclusiveNamespaces(
inclusiveElement, transformObject.getBaseURI()).getInclusiveNamespaces();
}
Canonicalizer20010315ExclOmitComments c14n =
new Canonicalizer20010315ExclOmitComments();
if (os != null) {
c14n.setWriter(os);
}
byte[] result = c14n.engineCanonicalize(input, inclusiveNamespaces);
XMLSignatureInput output = new XMLSignatureInput(result);
if (os != null) {
output.setOutputStream(os);
}
return output;
} catch (XMLSecurityException ex) {
throw new CanonicalizationException("empty", ex);
}
}
示例9: checkForRelativeNamespace
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; //导入依赖的package包/类
/**
* This method throws a CanonicalizationException if the supplied Element
* contains any relative namespaces.
*
* @param ctxNode
* @throws CanonicalizationException
* @see C14nHelper#assertNotRelativeNS(Attr)
*/
public static void checkForRelativeNamespace(Element ctxNode)
throws CanonicalizationException {
if (ctxNode != null) {
NamedNodeMap attributes = ctxNode.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
C14nHelper.assertNotRelativeNS((Attr) attributes.item(i));
}
} else {
throw new CanonicalizationException("Called checkForRelativeNamespace() on null");
}
}
示例10: getRawCertificate
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; //导入依赖的package包/类
private static X509Certificate getRawCertificate(XMLSignatureInput resource)
throws CanonicalizationException, IOException, CertificateException {
byte inputBytes[] = resource.getBytes();
// if the resource stores a raw certificate, we have to handle it
CertificateFactory certFact =
CertificateFactory.getInstance(XMLX509Certificate.JCA_CERT_ID);
X509Certificate cert = (X509Certificate)
certFact.generateCertificate(new ByteArrayInputStream(inputBytes));
return cert;
}
示例11: convertToNodes
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; //导入依赖的package包/类
void convertToNodes() throws CanonicalizationException,
ParserConfigurationException, IOException, SAXException {
if (dfactory == null) {
dfactory = DocumentBuilderFactory.newInstance();
dfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
dfactory.setValidating(false);
dfactory.setNamespaceAware(true);
}
DocumentBuilder db = dfactory.newDocumentBuilder();
// select all nodes, also the comments.
try {
db.setErrorHandler(new com.sun.org.apache.xml.internal.security.utils.IgnoreAllErrorHandler());
Document doc = db.parse(this.getOctetStream());
this.subNode = doc;
} catch (SAXException ex) {
// if a not-wellformed nodeset exists, put a container around it...
ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write("<container>".getBytes("UTF-8"));
baos.write(this.getBytes());
baos.write("</container>".getBytes("UTF-8"));
byte result[] = baos.toByteArray();
Document document = db.parse(new ByteArrayInputStream(result));
this.subNode = document.getDocumentElement().getFirstChild().getFirstChild();
} finally {
if (this.inputOctetStreamProxy != null) {
this.inputOctetStreamProxy.close();
}
this.inputOctetStreamProxy = null;
this.bytes = null;
}
}
示例12: getCanonicalizedOctetStream
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; //导入依赖的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());
this.c14nizedBytes =
c14nizer.canonicalizeSubtree(this.constructionElement);
}
// make defensive copy
return this.c14nizedBytes.clone();
}
示例13: checkTraversability
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; //导入依赖的package包/类
/**
* This method throws a CanonicalizationException if the supplied Document
* is not able to be traversed using a TreeWalker.
*
* @param document
* @throws CanonicalizationException
*/
public static void checkTraversability(Document document)
throws CanonicalizationException {
if (!document.isSupported("Traversal", "2.0")) {
Object exArgs[] = {document.getImplementation().getClass().getName() };
throw new CanonicalizationException(
"c14n.Canonicalizer.TraversalNotSupported", exArgs
);
}
}
示例14: circumventBugIfNeeded
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; //导入依赖的package包/类
protected void circumventBugIfNeeded(XMLSignatureInput input)
throws CanonicalizationException, ParserConfigurationException,
IOException, SAXException {
if (!input.isNeedsToBeExpanded() || inclusiveNSSet.isEmpty() || inclusiveNSSet.isEmpty()) {
return;
}
Document doc = null;
if (input.getSubNode() != null) {
doc = XMLUtils.getOwnerDocument(input.getSubNode());
} else {
doc = XMLUtils.getOwnerDocument(input.getNodeSet());
}
XMLUtils.circumventBug2650(doc);
}
示例15: circumventBugIfNeeded
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; //导入依赖的package包/类
protected void circumventBugIfNeeded(XMLSignatureInput input)
throws CanonicalizationException, ParserConfigurationException,
IOException, SAXException {
if (!input.isNeedsToBeExpanded()) {
return;
}
Document doc = null;
if (input.getSubNode() != null) {
doc = XMLUtils.getOwnerDocument(input.getSubNode());
} else {
doc = XMLUtils.getOwnerDocument(input.getNodeSet());
}
XMLUtils.circumventBug2650(doc);
}