use of org.apache.xml.security.stax.impl.transformer.TransformBase64Decode in project santuario-java by apache.
the class TransformBase64DecodeTest method testXMLSecEventToOutputStreamStreamAPI.
@Test
public void testXMLSecEventToOutputStreamStreamAPI() throws Exception {
TransformBase64Decode transformBase64Decode = new TransformBase64Decode();
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
transformBase64Decode.setOutputStream(byteArrayOutputStream);
XMLEventReader xmlSecEventReader = xmlInputFactory.createXMLEventReader(this.getClass().getClassLoader().getResourceAsStream("ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext-base64.xml"));
XMLSecEvent xmlSecEvent = null;
while (xmlSecEventReader.hasNext()) {
xmlSecEvent = (XMLSecEvent) xmlSecEventReader.nextEvent();
if (xmlSecEvent.isStartElement() && xmlSecEvent.asStartElement().getName().equals(new QName("urn:example:po", "PaymentInfo"))) {
break;
}
}
while (xmlSecEventReader.hasNext()) {
transformBase64Decode.transform(xmlSecEvent);
if (xmlSecEvent.isEndElement() && xmlSecEvent.asEndElement().getName().equals(new QName("urn:example:po", "PaymentInfo"))) {
break;
}
xmlSecEvent = (XMLSecEvent) xmlSecEventReader.nextEvent();
}
transformBase64Decode.doFinal();
Assert.assertEquals(153, byteArrayOutputStream.size());
}
Aggregations