use of javax.xml.crypto.dsig.TransformService in project jdk8u_jdk by JetBrains.
the class NullParent method main.
public static void main(String[] args) throws Exception {
String[] transforms = new String[] { Transform.BASE64, Transform.ENVELOPED, Transform.XPATH, Transform.XPATH2, Transform.XSLT, CanonicalizationMethod.EXCLUSIVE, CanonicalizationMethod.EXCLUSIVE_WITH_COMMENTS, CanonicalizationMethod.INCLUSIVE, CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS };
for (String transform : transforms) {
System.out.println("Testing " + transform);
TransformService ts = TransformService.getInstance(transform, "DOM");
try {
ts.init(null, null);
throw new Exception("init must throw NullPointerException " + "when the parent parameter is null");
} catch (NullPointerException npe) {
}
try {
ts.marshalParams(null, null);
throw new Exception("marshalParams must throw " + "NullPointerException when the parent " + "parameter is null");
} catch (NullPointerException npe) {
}
}
}
use of javax.xml.crypto.dsig.TransformService in project syndesis by syndesisio.
the class BaseSwaggerGeneratorExampleTest method c14Xml.
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);
}
}
Aggregations