当前位置: 首页>>代码示例>>Java>>正文


Java CanonicalizationException类代码示例

本文整理汇总了Java中org.apache.xml.security.c14n.CanonicalizationException的典型用法代码示例。如果您正苦于以下问题:Java CanonicalizationException类的具体用法?Java CanonicalizationException怎么用?Java CanonicalizationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CanonicalizationException类属于org.apache.xml.security.c14n包,在下文中一共展示了CanonicalizationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: enginePerformTransform

import org.apache.xml.security.c14n.CanonicalizationException; //导入依赖的package包/类
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws CanonicalizationException {
    Canonicalizer20010315OmitComments c14n = new Canonicalizer20010315OmitComments();
    c14n.setSecureValidation(secureValidation);
    if (os != null) {
        c14n.setWriter(os);
    }
    byte[] result = null;
    result = c14n.engineCanonicalize(input);         		         	
    XMLSignatureInput output = new XMLSignatureInput(result);
    output.setSecureValidation(secureValidation);
    if (os != null) {
        output.setOutputStream(os);
    }
    return output;
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:18,代码来源:TransformC14N.java

示例2: enginePerformTransform

import org.apache.xml.security.c14n.CanonicalizationException; //导入依赖的package包/类
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transform
) throws CanonicalizationException {
    Canonicalizer11_OmitComments c14n = new Canonicalizer11_OmitComments();
    c14n.setSecureValidation(secureValidation);
    if (os != null) {
        c14n.setWriter(os);
    }
    byte[] result = null;
    result = c14n.engineCanonicalize(input);         		         	
    XMLSignatureInput output = new XMLSignatureInput(result);
    output.setSecureValidation(secureValidation);
    if (os != null) {
        output.setOutputStream(os);
    }
    return output;
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:18,代码来源:TransformC14N11.java

示例3: enginePerformTransform

import org.apache.xml.security.c14n.CanonicalizationException; //导入依赖的package包/类
/** @inheritDoc */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws CanonicalizationException {

    Canonicalizer20010315WithComments c14n = new Canonicalizer20010315WithComments();
    c14n.setSecureValidation(secureValidation);
    if (os != null) {
        c14n.setWriter(os);
    }

    byte[] result = null;
    result = c14n.engineCanonicalize(input);         		         	
    XMLSignatureInput output = new XMLSignatureInput(result);
    output.setSecureValidation(secureValidation);
    if (os != null) {
        output.setOutputStream(os);
    }
    return output;
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:21,代码来源:TransformC14NWithComments.java

示例4: enginePerformTransform

import org.apache.xml.security.c14n.CanonicalizationException; //导入依赖的package包/类
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transform
) throws CanonicalizationException {

    Canonicalizer11_WithComments c14n = new Canonicalizer11_WithComments();
    c14n.setSecureValidation(secureValidation);
    if (os != null) {
        c14n.setWriter(os);
    }

    byte[] result = null;
    result = c14n.engineCanonicalize(input);         		         	
    XMLSignatureInput output = new XMLSignatureInput(result);
    output.setSecureValidation(secureValidation);
    if (os != null) {
        output.setOutputStream(os);
    }
    return output;
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:20,代码来源:TransformC14N11_WithComments.java

示例5: getNodeSet

import org.apache.xml.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");
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:33,代码来源:XMLSignatureInput.java

示例6: toString

import org.apache.xml.security.c14n.CanonicalizationException; //导入依赖的package包/类
/**
 * Method toString
 * @inheritDoc
 */
public String toString() {
    if (isNodeSet()) {
        return "XMLSignatureInput/NodeSet/" + inputNodeSet.size()
               + " nodes/" + getSourceURI();
    }
    if (isElement()) {
        return "XMLSignatureInput/Element/" + subNode
            + " exclude "+ excludeNode + " comments:"
            + excludeComments +"/" + getSourceURI();
    }
    try {
        return "XMLSignatureInput/OctetStream/" + getBytes().length
               + " octets/" + getSourceURI();
    } catch (IOException iex) {
        return "XMLSignatureInput/OctetStream//" + getSourceURI();
    } catch (CanonicalizationException cex) {
        return "XMLSignatureInput/OctetStream//" + getSourceURI();
    }
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:24,代码来源:XMLSignatureInput.java

示例7: getCanonicalizedOctetStream

import org.apache.xml.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());
        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();
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:27,代码来源:SignedInfo.java

示例8: signInOctetStream

import org.apache.xml.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.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);
        }
    }
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:30,代码来源:SignedInfo.java

示例9: assertNotRelativeNS

import org.apache.xml.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
        );
    }
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:27,代码来源:C14nHelper.java

示例10: test36subtree

import org.apache.xml.security.c14n.CanonicalizationException; //导入依赖的package包/类
/**
 * 3.6 UTF-8 Encoding
 *
 * @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-UTF8">the example from the spec</A>
 * @throws TransformerException
 * @throws XPathExpressionException
 */
@org.junit.Test
public void test36subtree()
    throws IOException, FileNotFoundException, SAXException,
    ParserConfigurationException, CanonicalizationException,
    InvalidCanonicalizerException, TransformerException, XPathExpressionException {
    String descri = "3.6 UTF-8 Encoding. (uncommented)";
    String fileIn = prefix + "in/36_input.xml";
    String fileRef = prefix + "in/36_c14n.xml";
    String fileOut = prefix + "out/xpath_36_output.xml";
    String c14nURI = Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS;
    boolean validating = true;
    String xpath = null;

    assertTrue(descri,
               c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:30,代码来源:Canonicalizer11Test.java

示例11: test37

import org.apache.xml.security.c14n.CanonicalizationException; //导入依赖的package包/类
/**
 * 3.7 Document Subsets
 *
 * @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-DocSubsets">the example from the spec</A>
 * @throws TransformerException
 * @throws XPathExpressionException
 */
@org.junit.Test
public void test37()
    throws IOException, FileNotFoundException, SAXException,
    ParserConfigurationException, CanonicalizationException,
    InvalidCanonicalizerException, TransformerException, XPathExpressionException {
    String descri = "3.7 Document Subsets. (uncommented)";
    String fileIn = prefix + "in/37_input.xml";
    String fileRef = prefix + "in/37_c14n.xml";
    String fileOut = prefix + "out/xpath_37_output.xml";
    String c14nURI = Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS;
    boolean validating = true;

    Map<String, String> namespace = new HashMap<String, String>();
    namespace.put("ietf", "http://www.ietf.org");
    String xpath =
        "(//. | //@* | //namespace::*)"
        + "[ "
        + "self::ietf:e1 or "
        + "(parent::ietf:e1 and not(self::text() or self::e2)) or "
        + "count(id(\"E3\")|ancestor-or-self::node()) = count(ancestor-or-self::node()) "
        + "]";

    assertTrue(descri,
               c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath, namespace));
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:39,代码来源:Canonicalizer11Test.java

示例12: handleAttributesSubtree

import org.apache.xml.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();
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:38,代码来源:CanonicalizerPhysical.java

示例13: obtainReferenceElement

import org.apache.xml.security.c14n.CanonicalizationException; //导入依赖的package包/类
/**
 * Resolve the Element effectively represented by the XML signature input source.
 *
 * @param resource
 * @return the Element effectively represented by the XML signature input source.
 * @throws CanonicalizationException
 * @throws ParserConfigurationException
 * @throws IOException
 * @throws SAXException
 * @throws KeyResolverException
 */
private Element obtainReferenceElement(XMLSignatureInput resource)
    throws CanonicalizationException, ParserConfigurationException,
    IOException, SAXException, KeyResolverException {

    Element e;
    if (resource.isElement()){
        e = (Element) resource.getSubNode();
    } else if (resource.isNodeSet()) {
        log.debug("De-reference of KeyInfoReference returned an unsupported NodeSet");
        return null;
    } else {
        // Retrieved resource is a byte stream
        byte inputBytes[] = resource.getBytes();
        e = getDocFromBytes(inputBytes, this.secureValidation);
    }
    return e;
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:29,代码来源:KeyInfoReferenceResolver.java

示例14: obtainReferenceElement

import org.apache.xml.security.c14n.CanonicalizationException; //导入依赖的package包/类
private static Element obtainReferenceElement(XMLSignatureInput resource, boolean secureValidation)
    throws CanonicalizationException, ParserConfigurationException,
    IOException, SAXException, KeyResolverException {
    Element e;
    if (resource.isElement()){
        e = (Element) resource.getSubNode();
    } else if (resource.isNodeSet()) {
        // Retrieved resource is a nodeSet
        e = getDocumentElement(resource.getNodeSet());
    } else {
        // Retrieved resource is an inputStream
        byte inputBytes[] = resource.getBytes();
        e = getDocFromBytes(inputBytes, secureValidation);
        // otherwise, we parse the resource, create an Element and delegate
        if (log.isDebugEnabled()) {
            log.debug("we have to parse " + inputBytes.length + " bytes");
        }
    }
    return e;
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:21,代码来源:RetrievalMethodResolver.java

示例15: testSetOctetStreamGetOctetStream

import org.apache.xml.security.c14n.CanonicalizationException; //导入依赖的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));
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:24,代码来源:XMLSignatureInputTest.java


注:本文中的org.apache.xml.security.c14n.CanonicalizationException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。