Java Code Examples for com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput#setNodeSet()

The following examples show how to use com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput#setNodeSet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransformXPath.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Method enginePerformTransform
 * @inheritDoc
 * @param input
 *
 * @throws TransformationException
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
    try {
        /**
         * If the actual input is an octet stream, then the application MUST
         * convert the octet stream to an XPath node-set suitable for use by
         * Canonical XML with Comments. (A subsequent application of the
         * REQUIRED Canonical XML algorithm would strip away these comments.)
         *
         * ...
         *
         * The evaluation of this expression includes all of the document's nodes
         * (including comments) in the node-set representing the octet stream.
         */
        Element xpathElement =
            XMLUtils.selectDsNode(
                transformObject.getElement().getFirstChild(), Constants._TAG_XPATH, 0);

        if (xpathElement == null) {
            Object exArgs[] = { "ds:XPath", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
        }
        Node xpathnode = xpathElement.getChildNodes().item(0);
        String str = XMLUtils.getStrFromNode(xpathnode);
        input.setNeedsToBeExpanded(needsCircumvent(str));
        if (xpathnode == null) {
            throw new DOMException(
                DOMException.HIERARCHY_REQUEST_ERR, "Text must be in ds:Xpath"
            );
        }

        XPathFactory xpathFactory = XPathFactory.newInstance();
        XPathAPI xpathAPIInstance = xpathFactory.newXPathAPI();
        input.addNodeFilter(new XPathNodeFilter(xpathElement, xpathnode, str, xpathAPIInstance));
        input.setNodeSet(true);
        return input;
    } catch (DOMException ex) {
        throw new TransformationException("empty", ex);
    }
}
 
Example 2
Source File: TransformXPath.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Method enginePerformTransform
 * @inheritDoc
 * @param input
 *
 * @throws TransformationException
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
    try {
        /**
         * If the actual input is an octet stream, then the application MUST
         * convert the octet stream to an XPath node-set suitable for use by
         * Canonical XML with Comments. (A subsequent application of the
         * REQUIRED Canonical XML algorithm would strip away these comments.)
         *
         * ...
         *
         * The evaluation of this expression includes all of the document's nodes
         * (including comments) in the node-set representing the octet stream.
         */
        Element xpathElement =
            XMLUtils.selectDsNode(
                transformObject.getElement().getFirstChild(), Constants._TAG_XPATH, 0);

        if (xpathElement == null) {
            Object exArgs[] = { "ds:XPath", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
        }
        Node xpathnode = xpathElement.getChildNodes().item(0);
        String str = XMLUtils.getStrFromNode(xpathnode);
        input.setNeedsToBeExpanded(needsCircumvent(str));
        if (xpathnode == null) {
            throw new DOMException(
                DOMException.HIERARCHY_REQUEST_ERR, "Text must be in ds:Xpath"
            );
        }

        XPathFactory xpathFactory = XPathFactory.newInstance();
        XPathAPI xpathAPIInstance = xpathFactory.newXPathAPI();
        input.addNodeFilter(new XPathNodeFilter(xpathElement, xpathnode, str, xpathAPIInstance));
        input.setNodeSet(true);
        return input;
    } catch (DOMException ex) {
        throw new TransformationException("empty", ex);
    }
}
 
Example 3
Source File: TransformXPath.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Method enginePerformTransform
 * @inheritDoc
 * @param input
 *
 * @throws TransformationException
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
    try {
        /**
         * If the actual input is an octet stream, then the application MUST
         * convert the octet stream to an XPath node-set suitable for use by
         * Canonical XML with Comments. (A subsequent application of the
         * REQUIRED Canonical XML algorithm would strip away these comments.)
         *
         * ...
         *
         * The evaluation of this expression includes all of the document's nodes
         * (including comments) in the node-set representing the octet stream.
         */
        Element xpathElement =
            XMLUtils.selectDsNode(
                transformObject.getElement().getFirstChild(), Constants._TAG_XPATH, 0);

        if (xpathElement == null) {
            Object exArgs[] = { "ds:XPath", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
        }
        Node xpathnode = xpathElement.getChildNodes().item(0);
        String str = XMLUtils.getStrFromNode(xpathnode);
        input.setNeedsToBeExpanded(needsCircumvent(str));
        if (xpathnode == null) {
            throw new DOMException(
                DOMException.HIERARCHY_REQUEST_ERR, "Text must be in ds:Xpath"
            );
        }

        XPathFactory xpathFactory = XPathFactory.newInstance();
        XPathAPI xpathAPIInstance = xpathFactory.newXPathAPI();
        input.addNodeFilter(new XPathNodeFilter(xpathElement, xpathnode, str, xpathAPIInstance));
        input.setNodeSet(true);
        return input;
    } catch (DOMException ex) {
        throw new TransformationException("empty", ex);
    }
}
 
Example 4
Source File: TransformXPath.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Method enginePerformTransform
 * @inheritDoc
 * @param input
 *
 * @throws TransformationException
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
    try {
        /**
         * If the actual input is an octet stream, then the application MUST
         * convert the octet stream to an XPath node-set suitable for use by
         * Canonical XML with Comments. (A subsequent application of the
         * REQUIRED Canonical XML algorithm would strip away these comments.)
         *
         * ...
         *
         * The evaluation of this expression includes all of the document's nodes
         * (including comments) in the node-set representing the octet stream.
         */
        Element xpathElement =
            XMLUtils.selectDsNode(
                transformObject.getElement().getFirstChild(), Constants._TAG_XPATH, 0);

        if (xpathElement == null) {
            Object exArgs[] = { "ds:XPath", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
        }
        Node xpathnode = xpathElement.getChildNodes().item(0);
        String str = XMLUtils.getStrFromNode(xpathnode);
        input.setNeedsToBeExpanded(needsCircumvent(str));
        if (xpathnode == null) {
            throw new DOMException(
                DOMException.HIERARCHY_REQUEST_ERR, "Text must be in ds:Xpath"
            );
        }

        XPathFactory xpathFactory = XPathFactory.newInstance();
        XPathAPI xpathAPIInstance = xpathFactory.newXPathAPI();
        input.addNodeFilter(new XPathNodeFilter(xpathElement, xpathnode, str, xpathAPIInstance));
        input.setNodeSet(true);
        return input;
    } catch (DOMException ex) {
        throw new TransformationException("empty", ex);
    }
}
 
Example 5
Source File: TransformXPath.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Method enginePerformTransform
 * @inheritDoc
 * @param input
 *
 * @throws TransformationException
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
    try {
        /**
         * If the actual input is an octet stream, then the application MUST
         * convert the octet stream to an XPath node-set suitable for use by
         * Canonical XML with Comments. (A subsequent application of the
         * REQUIRED Canonical XML algorithm would strip away these comments.)
         *
         * ...
         *
         * The evaluation of this expression includes all of the document's nodes
         * (including comments) in the node-set representing the octet stream.
         */
        Element xpathElement =
            XMLUtils.selectDsNode(
                transformObject.getElement().getFirstChild(), Constants._TAG_XPATH, 0);

        if (xpathElement == null) {
            Object exArgs[] = { "ds:XPath", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
        }
        Node xpathnode = xpathElement.getChildNodes().item(0);
        String str = XMLUtils.getStrFromNode(xpathnode);
        input.setNeedsToBeExpanded(needsCircumvent(str));
        if (xpathnode == null) {
            throw new DOMException(
                DOMException.HIERARCHY_REQUEST_ERR, "Text must be in ds:Xpath"
            );
        }

        XPathFactory xpathFactory = XPathFactory.newInstance();
        XPathAPI xpathAPIInstance = xpathFactory.newXPathAPI();
        input.addNodeFilter(new XPathNodeFilter(xpathElement, xpathnode, str, xpathAPIInstance));
        input.setNodeSet(true);
        return input;
    } catch (DOMException ex) {
        throw new TransformationException("empty", ex);
    }
}
 
Example 6
Source File: TransformXPath.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Method enginePerformTransform
 * @inheritDoc
 * @param input
 *
 * @throws TransformationException
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
    try {
        /**
         * If the actual input is an octet stream, then the application MUST
         * convert the octet stream to an XPath node-set suitable for use by
         * Canonical XML with Comments. (A subsequent application of the
         * REQUIRED Canonical XML algorithm would strip away these comments.)
         *
         * ...
         *
         * The evaluation of this expression includes all of the document's nodes
         * (including comments) in the node-set representing the octet stream.
         */
        Element xpathElement =
            XMLUtils.selectDsNode(
                transformObject.getElement().getFirstChild(), Constants._TAG_XPATH, 0);

        if (xpathElement == null) {
            Object exArgs[] = { "ds:XPath", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
        }
        Node xpathnode = xpathElement.getChildNodes().item(0);
        String str = XMLUtils.getStrFromNode(xpathnode);
        input.setNeedsToBeExpanded(needsCircumvent(str));
        if (xpathnode == null) {
            throw new DOMException(
                DOMException.HIERARCHY_REQUEST_ERR, "Text must be in ds:Xpath"
            );
        }

        XPathFactory xpathFactory = XPathFactory.newInstance();
        XPathAPI xpathAPIInstance = xpathFactory.newXPathAPI();
        input.addNodeFilter(new XPathNodeFilter(xpathElement, xpathnode, str, xpathAPIInstance));
        input.setNodeSet(true);
        return input;
    } catch (DOMException ex) {
        throw new TransformationException("empty", ex);
    }
}
 
Example 7
Source File: TransformXPath.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Method enginePerformTransform
 * @inheritDoc
 * @param input
 *
 * @throws TransformationException
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
    try {
        /**
         * If the actual input is an octet stream, then the application MUST
         * convert the octet stream to an XPath node-set suitable for use by
         * Canonical XML with Comments. (A subsequent application of the
         * REQUIRED Canonical XML algorithm would strip away these comments.)
         *
         * ...
         *
         * The evaluation of this expression includes all of the document's nodes
         * (including comments) in the node-set representing the octet stream.
         */
        Element xpathElement =
            XMLUtils.selectDsNode(
                transformObject.getElement().getFirstChild(), Constants._TAG_XPATH, 0);

        if (xpathElement == null) {
            Object exArgs[] = { "ds:XPath", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
        }
        Node xpathnode = xpathElement.getChildNodes().item(0);
        String str = XMLUtils.getStrFromNode(xpathnode);
        input.setNeedsToBeExpanded(needsCircumvent(str));
        if (xpathnode == null) {
            throw new DOMException(
                DOMException.HIERARCHY_REQUEST_ERR, "Text must be in ds:Xpath"
            );
        }

        XPathFactory xpathFactory = XPathFactory.newInstance();
        XPathAPI xpathAPIInstance = xpathFactory.newXPathAPI();
        input.addNodeFilter(new XPathNodeFilter(xpathElement, xpathnode, str, xpathAPIInstance));
        input.setNodeSet(true);
        return input;
    } catch (DOMException ex) {
        throw new TransformationException("empty", ex);
    }
}
 
Example 8
Source File: TransformXPath.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Method enginePerformTransform
 * @inheritDoc
 * @param input
 *
 * @throws TransformationException
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
    try {
        /**
         * If the actual input is an octet stream, then the application MUST
         * convert the octet stream to an XPath node-set suitable for use by
         * Canonical XML with Comments. (A subsequent application of the
         * REQUIRED Canonical XML algorithm would strip away these comments.)
         *
         * ...
         *
         * The evaluation of this expression includes all of the document's nodes
         * (including comments) in the node-set representing the octet stream.
         */
        Element xpathElement =
            XMLUtils.selectDsNode(
                transformObject.getElement().getFirstChild(), Constants._TAG_XPATH, 0);

        if (xpathElement == null) {
            Object exArgs[] = { "ds:XPath", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
        }
        Node xpathnode = xpathElement.getChildNodes().item(0);
        String str = XMLUtils.getStrFromNode(xpathnode);
        input.setNeedsToBeExpanded(needsCircumvent(str));
        if (xpathnode == null) {
            throw new DOMException(
                DOMException.HIERARCHY_REQUEST_ERR, "Text must be in ds:Xpath"
            );
        }

        XPathFactory xpathFactory = XPathFactory.newInstance();
        XPathAPI xpathAPIInstance = xpathFactory.newXPathAPI();
        input.addNodeFilter(new XPathNodeFilter(xpathElement, xpathnode, str, xpathAPIInstance));
        input.setNodeSet(true);
        return input;
    } catch (DOMException ex) {
        throw new TransformationException("empty", ex);
    }
}
 
Example 9
Source File: TransformXPath.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Method enginePerformTransform
 * @inheritDoc
 * @param input
 *
 * @throws TransformationException
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
    try {
        /**
         * If the actual input is an octet stream, then the application MUST
         * convert the octet stream to an XPath node-set suitable for use by
         * Canonical XML with Comments. (A subsequent application of the
         * REQUIRED Canonical XML algorithm would strip away these comments.)
         *
         * ...
         *
         * The evaluation of this expression includes all of the document's nodes
         * (including comments) in the node-set representing the octet stream.
         */
        Element xpathElement =
            XMLUtils.selectDsNode(
                transformObject.getElement().getFirstChild(), Constants._TAG_XPATH, 0);

        if (xpathElement == null) {
            Object exArgs[] = { "ds:XPath", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
        }
        Node xpathnode = xpathElement.getChildNodes().item(0);
        String str = XMLUtils.getStrFromNode(xpathnode);
        input.setNeedsToBeExpanded(needsCircumvent(str));
        if (xpathnode == null) {
            throw new DOMException(
                DOMException.HIERARCHY_REQUEST_ERR, "Text must be in ds:Xpath"
            );
        }

        XPathFactory xpathFactory = XPathFactory.newInstance();
        XPathAPI xpathAPIInstance = xpathFactory.newXPathAPI();
        input.addNodeFilter(new XPathNodeFilter(xpathElement, xpathnode, str, xpathAPIInstance));
        input.setNodeSet(true);
        return input;
    } catch (DOMException ex) {
        throw new TransformationException("empty", ex);
    }
}
 
Example 10
Source File: TransformXPath.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Method enginePerformTransform
 * @inheritDoc
 * @param input
 *
 * @throws TransformationException
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
    try {
        /**
         * If the actual input is an octet stream, then the application MUST
         * convert the octet stream to an XPath node-set suitable for use by
         * Canonical XML with Comments. (A subsequent application of the
         * REQUIRED Canonical XML algorithm would strip away these comments.)
         *
         * ...
         *
         * The evaluation of this expression includes all of the document's nodes
         * (including comments) in the node-set representing the octet stream.
         */
        Element xpathElement =
            XMLUtils.selectDsNode(
                transformObject.getElement().getFirstChild(), Constants._TAG_XPATH, 0);

        if (xpathElement == null) {
            Object exArgs[] = { "ds:XPath", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
        }
        Node xpathnode = xpathElement.getChildNodes().item(0);
        String str = XMLUtils.getStrFromNode(xpathnode);
        input.setNeedsToBeExpanded(needsCircumvent(str));
        if (xpathnode == null) {
            throw new DOMException(
                DOMException.HIERARCHY_REQUEST_ERR, "Text must be in ds:Xpath"
            );
        }

        XPathFactory xpathFactory = XPathFactory.newInstance();
        XPathAPI xpathAPIInstance = xpathFactory.newXPathAPI();
        input.addNodeFilter(new XPathNodeFilter(xpathElement, xpathnode, str, xpathAPIInstance));
        input.setNodeSet(true);
        return input;
    } catch (DOMException ex) {
        throw new TransformationException("empty", ex);
    }
}
 
Example 11
Source File: TransformXPath.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Method enginePerformTransform
 * @inheritDoc
 * @param input
 *
 * @throws TransformationException
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
    try {
        /**
         * If the actual input is an octet stream, then the application MUST
         * convert the octet stream to an XPath node-set suitable for use by
         * Canonical XML with Comments. (A subsequent application of the
         * REQUIRED Canonical XML algorithm would strip away these comments.)
         *
         * ...
         *
         * The evaluation of this expression includes all of the document's nodes
         * (including comments) in the node-set representing the octet stream.
         */
        Element xpathElement =
            XMLUtils.selectDsNode(
                transformObject.getElement().getFirstChild(), Constants._TAG_XPATH, 0);

        if (xpathElement == null) {
            Object exArgs[] = { "ds:XPath", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
        }
        Node xpathnode = xpathElement.getChildNodes().item(0);
        String str = XMLUtils.getStrFromNode(xpathnode);
        input.setNeedsToBeExpanded(needsCircumvent(str));
        if (xpathnode == null) {
            throw new DOMException(
                DOMException.HIERARCHY_REQUEST_ERR, "Text must be in ds:Xpath"
            );
        }

        XPathFactory xpathFactory = XPathFactory.newInstance();
        XPathAPI xpathAPIInstance = xpathFactory.newXPathAPI();
        input.addNodeFilter(new XPathNodeFilter(xpathElement, xpathnode, str, xpathAPIInstance));
        input.setNodeSet(true);
        return input;
    } catch (DOMException ex) {
        throw new TransformationException("empty", ex);
    }
}
 
Example 12
Source File: TransformXPath.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Method enginePerformTransform
 * @inheritDoc
 * @param input
 *
 * @throws TransformationException
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
    try {
        /**
         * If the actual input is an octet stream, then the application MUST
         * convert the octet stream to an XPath node-set suitable for use by
         * Canonical XML with Comments. (A subsequent application of the
         * REQUIRED Canonical XML algorithm would strip away these comments.)
         *
         * ...
         *
         * The evaluation of this expression includes all of the document's nodes
         * (including comments) in the node-set representing the octet stream.
         */
        Element xpathElement =
            XMLUtils.selectDsNode(
                transformObject.getElement().getFirstChild(), Constants._TAG_XPATH, 0);

        if (xpathElement == null) {
            Object exArgs[] = { "ds:XPath", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
        }
        Node xpathnode = xpathElement.getChildNodes().item(0);
        String str = XMLUtils.getStrFromNode(xpathnode);
        input.setNeedsToBeExpanded(needsCircumvent(str));
        if (xpathnode == null) {
            throw new DOMException(
                DOMException.HIERARCHY_REQUEST_ERR, "Text must be in ds:Xpath"
            );
        }

        XPathFactory xpathFactory = XPathFactory.newInstance();
        XPathAPI xpathAPIInstance = xpathFactory.newXPathAPI();
        input.addNodeFilter(new XPathNodeFilter(xpathElement, xpathnode, str, xpathAPIInstance));
        input.setNodeSet(true);
        return input;
    } catch (DOMException ex) {
        throw new TransformationException("empty", ex);
    }
}
 
Example 13
Source File: TransformXPath.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Method enginePerformTransform
 * @inheritDoc
 * @param input
 *
 * @throws TransformationException
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
    try {
        /**
         * If the actual input is an octet stream, then the application MUST
         * convert the octet stream to an XPath node-set suitable for use by
         * Canonical XML with Comments. (A subsequent application of the
         * REQUIRED Canonical XML algorithm would strip away these comments.)
         *
         * ...
         *
         * The evaluation of this expression includes all of the document's nodes
         * (including comments) in the node-set representing the octet stream.
         */
        Element xpathElement =
            XMLUtils.selectDsNode(
                transformObject.getElement().getFirstChild(), Constants._TAG_XPATH, 0);

        if (xpathElement == null) {
            Object exArgs[] = { "ds:XPath", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
        }
        Node xpathnode = xpathElement.getChildNodes().item(0);
        String str = XMLUtils.getStrFromNode(xpathnode);
        input.setNeedsToBeExpanded(needsCircumvent(str));
        if (xpathnode == null) {
            throw new DOMException(
                DOMException.HIERARCHY_REQUEST_ERR, "Text must be in ds:Xpath"
            );
        }

        XPathFactory xpathFactory = XPathFactory.newInstance();
        XPathAPI xpathAPIInstance = xpathFactory.newXPathAPI();
        input.addNodeFilter(new XPathNodeFilter(xpathElement, xpathnode, str, xpathAPIInstance));
        input.setNodeSet(true);
        return input;
    } catch (DOMException ex) {
        throw new TransformationException("empty", ex);
    }
}
 
Example 14
Source File: TransformXPath.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Method enginePerformTransform
 * @inheritDoc
 * @param input
 *
 * @throws TransformationException
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
    try {
        /**
         * If the actual input is an octet stream, then the application MUST
         * convert the octet stream to an XPath node-set suitable for use by
         * Canonical XML with Comments. (A subsequent application of the
         * REQUIRED Canonical XML algorithm would strip away these comments.)
         *
         * ...
         *
         * The evaluation of this expression includes all of the document's nodes
         * (including comments) in the node-set representing the octet stream.
         */
        Element xpathElement =
            XMLUtils.selectDsNode(
                transformObject.getElement().getFirstChild(), Constants._TAG_XPATH, 0);

        if (xpathElement == null) {
            Object exArgs[] = { "ds:XPath", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
        }
        Node xpathnode = xpathElement.getChildNodes().item(0);
        String str = XMLUtils.getStrFromNode(xpathnode);
        input.setNeedsToBeExpanded(needsCircumvent(str));
        if (xpathnode == null) {
            throw new DOMException(
                DOMException.HIERARCHY_REQUEST_ERR, "Text must be in ds:Xpath"
            );
        }

        XPathFactory xpathFactory = XPathFactory.newInstance();
        XPathAPI xpathAPIInstance = xpathFactory.newXPathAPI();
        input.addNodeFilter(new XPathNodeFilter(xpathElement, xpathnode, str, xpathAPIInstance));
        input.setNodeSet(true);
        return input;
    } catch (DOMException ex) {
        throw new TransformationException("empty", ex);
    }
}
 
Example 15
Source File: TransformXPath.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Method enginePerformTransform
 * @inheritDoc
 * @param input
 *
 * @throws TransformationException
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
    try {
        /**
         * If the actual input is an octet stream, then the application MUST
         * convert the octet stream to an XPath node-set suitable for use by
         * Canonical XML with Comments. (A subsequent application of the
         * REQUIRED Canonical XML algorithm would strip away these comments.)
         *
         * ...
         *
         * The evaluation of this expression includes all of the document's nodes
         * (including comments) in the node-set representing the octet stream.
         */
        Element xpathElement =
            XMLUtils.selectDsNode(
                transformObject.getElement().getFirstChild(), Constants._TAG_XPATH, 0);

        if (xpathElement == null) {
            Object exArgs[] = { "ds:XPath", "Transform" };

            throw new TransformationException("xml.WrongContent", exArgs);
        }
        Node xpathnode = xpathElement.getChildNodes().item(0);
        String str = XMLUtils.getStrFromNode(xpathnode);
        input.setNeedsToBeExpanded(needsCircumvent(str));
        if (xpathnode == null) {
            throw new DOMException(
                DOMException.HIERARCHY_REQUEST_ERR, "Text must be in ds:Xpath"
            );
        }

        XPathFactory xpathFactory = XPathFactory.newInstance();
        XPathAPI xpathAPIInstance = xpathFactory.newXPathAPI();
        input.addNodeFilter(new XPathNodeFilter(xpathElement, xpathnode, str, xpathAPIInstance));
        input.setNodeSet(true);
        return input;
    } catch (DOMException ex) {
        throw new TransformationException("empty", ex);
    }
}