javax.xml.crypto.OctetStreamData Java Examples

The following examples show how to use javax.xml.crypto.OctetStreamData. 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: ValidationTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #2
Source File: GenerationTests.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #3
Source File: ValidationTests.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #4
Source File: GenerationTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #5
Source File: ValidationTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #6
Source File: GenerationTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #7
Source File: ErrorHandlerPermissions.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
        throws URIReferenceException {
    // return static content
    return new OctetStreamData(new ByteArrayInputStream(
            "<test>test</test>".getBytes()), ref.getURI(),
            ref.getType());
}
 
Example #8
Source File: ValidationTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #9
Source File: GenerationTests.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #10
Source File: ValidationTests.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #11
Source File: GenerationTests.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #12
Source File: ValidationTests.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #13
Source File: GenerationTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #14
Source File: ValidationTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #15
Source File: GenerationTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #16
Source File: ValidationTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #17
Source File: GenerationTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #18
Source File: ErrorHandlerPermissions.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
        throws URIReferenceException {
    // return static content
    return new OctetStreamData(new ByteArrayInputStream(
            "<test>test</test>".getBytes()), ref.getURI(),
            ref.getType());
}
 
Example #19
Source File: ValidationTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #20
Source File: GenerationTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #21
Source File: ValidationTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #22
Source File: BaseOpenApiGeneratorExampleTest.java    From syndesis with Apache License 2.0 5 votes vote down vote up
private static String c14Xml(final String xml) {
    if (xml == null) {
        return null;
    }

    try {
        final DocumentBuilder documentBuilder = DOCUMENT_BUILDER_FACTORY.newDocumentBuilder();
        final Document document = documentBuilder.parse(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)));

        final TransformService transformation = TransformService.getInstance(CanonicalizationMethod.EXCLUSIVE_WITH_COMMENTS, "DOM");

        transformation.init(null);

        final NodeList allElements = document.getElementsByTagName("*");
        final List<Node> elements = new ArrayList<>();
        for (int i = 0; i < allElements.getLength(); i++) {
            elements.add(allElements.item(i));
        }

        final OctetStreamData data = (OctetStreamData) transformation.transform((NodeSetData) elements::iterator, null);

        try (final InputStream stream = data.getOctetStream()) {

            final byte[] buffy = new byte[stream.available()];
            stream.read(buffy);

            return new String(buffy, StandardCharsets.UTF_8);
        }
    } catch (GeneralSecurityException | TransformException | SAXException | IOException | ParserConfigurationException e) {
        throw new AssertionError(e);
    }
}
 
Example #23
Source File: GenerationTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #24
Source File: ErrorHandlerPermissions.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
        throws URIReferenceException {
    // return static content
    return new OctetStreamData(new ByteArrayInputStream(
            "<test>test</test>".getBytes()), ref.getURI(),
            ref.getType());
}
 
Example #25
Source File: ValidationTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #26
Source File: GenerationTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #27
Source File: ValidationTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #28
Source File: GenerationTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #29
Source File: ValidationTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}
 
Example #30
Source File: GenerationTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Data dereference(final URIReference ref, XMLCryptoContext ctx)
throws URIReferenceException {
    String uri = ref.getURI();
    if (uri.equals(STYLESHEET) || uri.equals(STYLESHEET_B64)) {
        try {
            FileInputStream fis = new FileInputStream(new File
                (DATA_DIR, uri.substring(uri.lastIndexOf('/'))));
            return new OctetStreamData(fis,ref.getURI(),ref.getType());
        } catch (Exception e) { throw new URIReferenceException(e); }
    }

    // fallback on builtin deref
    return defaultUd.dereference(ref, ctx);
}