javax.xml.crypto.dsig.TransformService Java Examples
The following examples show how to use
javax.xml.crypto.dsig.TransformService.
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: BaseOpenApiGeneratorExampleTest.java From syndesis with Apache License 2.0 | 5 votes |
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 #2
Source File: UnknownProvider.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws NoSuchAlgorithmException { try { TransformService ts = TransformService.getInstance( Transform.BASE64, "DOM", "SomeProviderThatDoesNotExist"); } catch(NoSuchProviderException e) { // this is expected } }