com.sun.org.apache.xml.internal.security.transforms.Transform Java Examples

The following examples show how to use com.sun.org.apache.xml.internal.security.transforms.Transform. 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: TransformC14N11_WithComments.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: TransformC14NWithComments.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/** @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;
}
 
Example #3
Source File: ClassLoaderTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        File file = new File(BASE);
        URL[] urls = new URL[1];
        urls[0] = file.toURI().toURL();
        URLClassLoader ucl = new URLClassLoader(urls);
        Class<?> c = ucl.loadClass("MyTransform");
        Constructor<?> cons = c.getConstructor(new Class[] {});
        Object o = cons.newInstance();
        // Apache code swallows the ClassNotFoundExc, so we need to
        // check if the Transform has already been registered by registering
        // it again and catching an AlgorithmAlreadyRegisteredExc
        try {
            Transform.register(MyTransform.URI, "MyTransform");
            throw new Exception("ClassLoaderTest failed");
        } catch (AlgorithmAlreadyRegisteredException e) {
            // test passed
        }
    }
 
Example #4
Source File: TransformC14N11_WithComments.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #5
Source File: TransformEnvelopedSignature.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * @inheritDoc
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
    /**
     * 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.
     */

    Node signatureElement = transformObject.getElement();

    signatureElement = searchSignatureElement(signatureElement);
    input.setExcludeNode(signatureElement);
    input.addNodeFilter(new EnvelopedNodeFilter(signatureElement));
    return input;
}
 
Example #6
Source File: TransformC14NWithComments.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/** @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;
}
 
Example #7
Source File: TransformC14NWithComments.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/** @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;
}
 
Example #8
Source File: TransformC14NWithComments.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/** @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;
}
 
Example #9
Source File: TransformEnvelopedSignature.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @inheritDoc
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
    /**
     * 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.
     */

    Node signatureElement = transformObject.getElement();

    signatureElement = searchSignatureElement(signatureElement);
    input.setExcludeNode(signatureElement);
    input.addNodeFilter(new EnvelopedNodeFilter(signatureElement));
    return input;
}
 
Example #10
Source File: TransformC14NWithComments.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/** @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;
}
 
Example #11
Source File: TransformEnvelopedSignature.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * @inheritDoc
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
    /**
     * 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.
     */

    Node signatureElement = transformObject.getElement();

    signatureElement = searchSignatureElement(signatureElement);
    input.setExcludeNode(signatureElement);
    input.addNodeFilter(new EnvelopedNodeFilter(signatureElement));
    return input;
}
 
Example #12
Source File: TransformEnvelopedSignature.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @inheritDoc
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
    /**
     * 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.
     */

    Node signatureElement = transformObject.getElement();

    signatureElement = searchSignatureElement(signatureElement);
    input.setExcludeNode(signatureElement);
    input.addNodeFilter(new EnvelopedNodeFilter(signatureElement));
    return input;
}
 
Example #13
Source File: TransformC14NWithComments.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/** @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;
}
 
Example #14
Source File: ClassLoaderTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        File file = new File(BASE);
        URL[] urls = new URL[1];
        urls[0] = file.toURI().toURL();
        URLClassLoader ucl = new URLClassLoader(urls);
        Class<?> c = ucl.loadClass("MyTransform");
        Constructor<?> cons = c.getConstructor(new Class[] {});
        Object o = cons.newInstance();
        // Apache code swallows the ClassNotFoundExc, so we need to
        // check if the Transform has already been registered by registering
        // it again and catching an AlgorithmAlreadyRegisteredExc
        try {
            Transform.register(MyTransform.URI, "MyTransform");
            throw new Exception("ClassLoaderTest failed");
        } catch (AlgorithmAlreadyRegisteredException e) {
            // test passed
        }
    }
 
Example #15
Source File: TransformC14N11_WithComments.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #16
Source File: TransformC14N11_WithComments.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #17
Source File: TransformC14N11_WithComments.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #18
Source File: TransformC14N11_WithComments.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #19
Source File: TransformC14NWithComments.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/** @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;
}
 
Example #20
Source File: TransformC14NExclusiveWithComments.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #21
Source File: TransformXPointer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Method enginePerformTransform
 *
 * @param input
 * @return  {@link XMLSignatureInput} as the result of transformation
 * @throws TransformationException
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {

    Object exArgs[] = { implementedTransformURI };

    throw new TransformationException("signature.Transform.NotYetImplemented", exArgs);
}
 
Example #22
Source File: MyTransform.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public MyTransform() {
    try {
        System.out.println("Registering Transform");
        Transform.register(URI, "MyTransform");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #23
Source File: TransformC14NExclusive.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #24
Source File: TransformC14N11.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transform
) throws CanonicalizationException {
    Canonicalizer11_OmitComments c14n = new Canonicalizer11_OmitComments();
    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;
}
 
Example #25
Source File: TransformC14NExclusive.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
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);
    }
}
 
Example #26
Source File: MyTransform.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public MyTransform() {
    try {
        System.out.println("Registering Transform");
        Transform.register(URI, "MyTransform");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #27
Source File: TransformC14NExclusive.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #28
Source File: TransformC14NExclusiveWithComments.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #29
Source File: TransformXPointer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Method enginePerformTransform
 *
 * @param input
 * @return  {@link XMLSignatureInput} as the result of transformation
 * @throws TransformationException
 */
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {

    Object exArgs[] = { implementedTransformURI };

    throw new TransformationException("signature.Transform.NotYetImplemented", exArgs);
}
 
Example #30
Source File: TransformC14N.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected XMLSignatureInput enginePerformTransform(
    XMLSignatureInput input, OutputStream os, Transform transformObject
) throws CanonicalizationException {
    Canonicalizer20010315OmitComments c14n = new Canonicalizer20010315OmitComments();
    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;
}