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


Java XPathFilterParameterSpec类代码示例

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


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

示例1: unmarshalParams

import javax.xml.crypto.dsig.spec.XPathFilterParameterSpec; //导入依赖的package包/类
private void unmarshalParams(Element paramsElem) {
    String xPath = paramsElem.getFirstChild().getNodeValue();
    // create a Map of namespace prefixes
    NamedNodeMap attributes = paramsElem.getAttributes();
    if (attributes != null) {
        int length = attributes.getLength();
        Map<String, String> namespaceMap =
            new HashMap<String, String>(length);
        for (int i = 0; i < length; i++) {
            Attr attr = (Attr)attributes.item(i);
            String prefix = attr.getPrefix();
            if (prefix != null && prefix.equals("xmlns")) {
                namespaceMap.put(attr.getLocalName(), attr.getValue());
            }
        }
        this.params = new XPathFilterParameterSpec(xPath, namespaceMap);
    } else {
        this.params = new XPathFilterParameterSpec(xPath);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:DOMXPathTransform.java

示例2: marshalParams

import javax.xml.crypto.dsig.spec.XPathFilterParameterSpec; //导入依赖的package包/类
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
    throws MarshalException
{
    super.marshalParams(parent, context);
    XPathFilterParameterSpec xp =
        (XPathFilterParameterSpec)getParameterSpec();
    Element xpathElem = DOMUtils.createElement(ownerDoc, "XPath",
         XMLSignature.XMLNS, DOMUtils.getSignaturePrefix(context));
    xpathElem.appendChild(ownerDoc.createTextNode(xp.getXPath()));

    // add namespace attributes, if necessary
    @SuppressWarnings("unchecked")
    Set<Map.Entry<String, String>> entries =
        xp.getNamespaceMap().entrySet();
    for (Map.Entry<String, String> entry : entries) {
        xpathElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" +
                                 entry.getKey(),
                                 entry.getValue());
    }

    transformElem.appendChild(xpathElem);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:DOMXPathTransform.java

示例3: marshalParams

import javax.xml.crypto.dsig.spec.XPathFilterParameterSpec; //导入依赖的package包/类
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
    throws MarshalException
{
    super.marshalParams(parent, context);
    XPathFilterParameterSpec xp =
        (XPathFilterParameterSpec)getParameterSpec();
    Element xpathElem = DOMUtils.createElement(ownerDoc, "XPath",
         XMLSignature.XMLNS, DOMUtils.getSignaturePrefix(context));
    xpathElem.appendChild(ownerDoc.createTextNode(xp.getXPath()));

    // add namespace attributes, if necessary
    Set<Map.Entry<String, String>> entries =
        xp.getNamespaceMap().entrySet();
    for (Map.Entry<String, String> entry : entries) {
        xpathElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" +
                                 entry.getKey(),
                                 entry.getValue());
    }

    transformElem.appendChild(xpathElem);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:DOMXPathTransform.java

示例4: marshalParams

import javax.xml.crypto.dsig.spec.XPathFilterParameterSpec; //导入依赖的package包/类
@Override
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
    throws MarshalException
{
    super.marshalParams(parent, context);
    XPathFilterParameterSpec xp =
        (XPathFilterParameterSpec)getParameterSpec();
    Element xpathElem = DOMUtils.createElement(ownerDoc, "XPath",
         XMLSignature.XMLNS, DOMUtils.getSignaturePrefix(context));
    xpathElem.appendChild(ownerDoc.createTextNode(xp.getXPath()));

    // add namespace attributes, if necessary
    @SuppressWarnings("unchecked")
    Set<Map.Entry<String, String>> entries =
        xp.getNamespaceMap().entrySet();
    for (Map.Entry<String, String> entry : entries) {
        xpathElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" +
                                 entry.getKey(),
                                 entry.getValue());
    }

    transformElem.appendChild(xpathElem);
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:24,代码来源:DOMXPathTransform.java

示例5: testExceptionXpathsToIdAttributesNameAndXPathSet

import javax.xml.crypto.dsig.spec.XPathFilterParameterSpec; //导入依赖的package包/类
@Test
public void testExceptionXpathsToIdAttributesNameAndXPathSet() throws Exception {

    XmlSignerEndpoint endpoint = getSignatureEncpointForSignException();
    MockEndpoint mock = setupExceptionMock();
    try {
        endpoint.setParentXpath(getNodeSerachXPath());
        List<XPathFilterParameterSpec> xpaths = Collections.singletonList(XmlSignatureHelper.getXpathFilter("/ns:root/a/@ID", null));
        endpoint.setXpathsToIdAttributes(xpaths);
        sendBody("direct:signexceptions", payload);
        assertMockEndpointsSatisfied();
        checkThrownException(
                mock,
                XmlSignatureException.class,
                "The configuration of the XML signer component is wrong. " + //
                        "The parent XPath //pre:root for an enveloped signature and the XPATHs to ID attributes for a detached signature are specified. You must not specify both parameters.",
                null);
    } finally {
        endpoint.setParentXpath(null);
        endpoint.setXpathsToIdAttributes(null);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:XmlSignatureTest.java

示例6: unmarshalParams

import javax.xml.crypto.dsig.spec.XPathFilterParameterSpec; //导入依赖的package包/类
private void unmarshalParams(Element paramsElem) {
    String xPath = paramsElem.getFirstChild().getNodeValue();
    // create a Map of namespace prefixes
    NamedNodeMap attributes = paramsElem.getAttributes();
    if (attributes != null) {
        int length = attributes.getLength();
        Map namespaceMap = new HashMap(length);
        for (int i = 0; i < length; i++) {
            Attr attr = (Attr) attributes.item(i);
            String prefix = attr.getPrefix();
            if (prefix != null && prefix.equals("xmlns")) {
                namespaceMap.put(attr.getLocalName(), attr.getValue());
            }
        }
        this.params = new XPathFilterParameterSpec(xPath, namespaceMap);
    } else {
        this.params = new XPathFilterParameterSpec(xPath);
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:20,代码来源:DOMXPathTransform.java

示例7: marshalParams

import javax.xml.crypto.dsig.spec.XPathFilterParameterSpec; //导入依赖的package包/类
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
    throws MarshalException {

    super.marshalParams(parent, context);
    XPathFilterParameterSpec xp =
        (XPathFilterParameterSpec) getParameterSpec();
    Element xpathElem = DOMUtils.createElement
        (ownerDoc, "XPath", XMLSignature.XMLNS,
         DOMUtils.getSignaturePrefix(context));
    xpathElem.appendChild(ownerDoc.createTextNode(xp.getXPath()));

    // add namespace attributes, if necessary
    Iterator i = xp.getNamespaceMap().entrySet().iterator();
    while (i.hasNext()) {
        Map.Entry entry = (Map.Entry) i.next();
        xpathElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:"
            + (String) entry.getKey(), (String) entry.getValue());
    }

    transformElem.appendChild(xpathElem);
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:22,代码来源:DOMXPathTransform.java

示例8: init

import javax.xml.crypto.dsig.spec.XPathFilterParameterSpec; //导入依赖的package包/类
public void init(TransformParameterSpec params)
    throws InvalidAlgorithmParameterException
{
    if (params == null) {
        throw new InvalidAlgorithmParameterException("params are required");
    } else if (!(params instanceof XPathFilterParameterSpec)) {
        throw new InvalidAlgorithmParameterException
            ("params must be of type XPathFilterParameterSpec");
    }
    this.params = params;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:DOMXPathTransform.java

示例9: init

import javax.xml.crypto.dsig.spec.XPathFilterParameterSpec; //导入依赖的package包/类
@Override
public void init(TransformParameterSpec params)
    throws InvalidAlgorithmParameterException
{
    if (params == null) {
        throw new InvalidAlgorithmParameterException("params are required");
    } else if (!(params instanceof XPathFilterParameterSpec)) {
        throw new InvalidAlgorithmParameterException
            ("params must be of type XPathFilterParameterSpec");
    }
    this.params = params;
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:13,代码来源:DOMXPathTransform.java

示例10: getOutputNodeViaXPath

import javax.xml.crypto.dsig.spec.XPathFilterParameterSpec; //导入依赖的package包/类
protected Node getOutputNodeViaXPath(Input input) throws Exception { //NOPMD
    checkSearchValueNotNull(input);
    checkSearchValueOfType(XPathFilterParameterSpec.class, input);
    XPathFilterParameterSpec xpathFilter = (XPathFilterParameterSpec) input.getOutputNodeSearch();
    XPathExpression expr = XmlSignatureHelper.getXPathExpression(xpathFilter);
    NodeList nodes = (NodeList) expr.evaluate(input.getMessageBodyDocument(), XPathConstants.NODESET);
    if (nodes == null || nodes.getLength() == 0) {
        throw new XmlSignatureException(
                String.format(
                        "Cannot extract root node for the output document from the XML signature document. No node found for XPATH %s as specified in the output node search.",
                        xpathFilter.getXPath()));
    }
    if (nodes.getLength() > 1) {
        throw new XmlSignatureException(
                String.format(
                        "Cannot extract root node for the output document from the XML signature document. XPATH %s as specified in the output node search results into more than one child.",
                        xpathFilter.getXPath()));

    }
    Node result = nodes.item(0);
    if (Node.ELEMENT_NODE == result.getNodeType() || Node.TEXT_NODE == result.getNodeType()
            || Node.DOCUMENT_NODE == result.getNodeType()) {
        return result;
    }
    throw new XmlSignatureException(String.format("Cannot extract root node for the output document from the XML signature document. "
            + "XPATH %s as specified in the output node search results into a node which has the wrong type.", xpathFilter.getXPath()));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:28,代码来源:DefaultXmlSignature2Message.java

示例11: getXPathExpression

import javax.xml.crypto.dsig.spec.XPathFilterParameterSpec; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static XPathExpression getXPathExpression(XPathFilterParameterSpec xpathFilter) throws XPathExpressionException {

    XPathFactory factory = XPathFactory.newInstance();
    XPath xpath = factory.newXPath();
    if (xpathFilter.getNamespaceMap() != null) {
        xpath.setNamespaceContext(new XPathNamespaceContext(xpathFilter.getNamespaceMap()));
    }
    return xpath.compile(xpathFilter.getXPath());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:XmlSignatureHelper.java

示例12: getXpathToIdAttributes

import javax.xml.crypto.dsig.spec.XPathFilterParameterSpec; //导入依赖的package包/类
protected List<XPathFilterParameterSpec> getXpathToIdAttributes(Message message) {

        @SuppressWarnings("unchecked")
        List<XPathFilterParameterSpec> result = (List<XPathFilterParameterSpec>) message
                .getHeader(XmlSignatureConstants.HEADER_XPATHS_TO_ID_ATTRIBUTES);
        if (result == null) {
            result = getConfiguration().getXpathsToIdAttributes();
        }
        return result;
    }
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:XmlSignerProcessor.java

示例13: getParentForEnvelopedCase

import javax.xml.crypto.dsig.spec.XPathFilterParameterSpec; //导入依赖的package包/类
protected Element getParentForEnvelopedCase(Document doc, Message inMessage) throws Exception { //NOPMD
    if (getConfiguration().getParentXpath() != null) {
        XPathFilterParameterSpec xp = getConfiguration().getParentXpath();
        XPathExpression exp;
        try {
            exp = XmlSignatureHelper.getXPathExpression(xp);
        } catch (XPathExpressionException e) {
            throw new XmlSignatureException("The parent XPath " + getConfiguration().getParentXpath().getXPath() + " is wrongly configured: The XPath " + xp.getXPath() + " is invalid.", e);
        }
        NodeList list = (NodeList) exp.evaluate(doc.getDocumentElement(), XPathConstants.NODESET);
        if (list == null || list.getLength() == 0) {
            throw new XmlSignatureException("The parent XPath " + xp.getXPath() + " returned no result. Check the configuration of the XML signer component.");
        }
        int length = list.getLength();
        for (int i = 0; i < length; i++) {
            Node node = list.item(i);
            if (node.getNodeType() == Node.ELEMENT_NODE) {
                // return the first element
                return (Element)node;
            }
        }
        throw new XmlSignatureException("The parent XPath " + xp.getXPath() + " returned no element. Check the configuration of the XML signer component.");
    } else {
        // parent local name is not null!
        NodeList parents = doc.getElementsByTagNameNS(getConfiguration().getParentNamespace(), getConfiguration().getParentLocalName());
        if (parents == null || parents.getLength() == 0) {
            throw new XmlSignatureFormatException(
                    String.format(
                            "Incoming message has wrong format: The parent element with the local name %s and the namespace %s was not found in the message to build an enveloped XML signature.",
                            getConfiguration().getParentLocalName(), getConfiguration().getParentNamespace()));
        }
        // return the first element
        return (Element) parents.item(0);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:36,代码来源:XmlSignerProcessor.java


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