use of org.apache.xml.security.stax.impl.InputProcessorChainImpl in project santuario-java by apache.
the class InputProcessorChainTest method testAddProcessorPhase1.
@Test
public void testAddProcessorPhase1() {
InputProcessorChainImpl inputProcessorChain = new InputProcessorChainImpl(new InboundSecurityContextImpl());
AbstractInputProcessor inputProcessor1 = new AbstractInputProcessor() {
};
inputProcessorChain.addProcessor(inputProcessor1);
AbstractInputProcessor inputProcessor2 = new AbstractInputProcessor() {
};
inputProcessorChain.addProcessor(inputProcessor2);
AbstractInputProcessor inputProcessor3 = new AbstractInputProcessor() {
};
inputProcessorChain.addProcessor(inputProcessor3);
Assert.assertEquals(inputProcessorChain.getProcessors().get(0), inputProcessor3);
Assert.assertEquals(inputProcessorChain.getProcessors().get(1), inputProcessor2);
Assert.assertEquals(inputProcessorChain.getProcessors().get(2), inputProcessor1);
}
use of org.apache.xml.security.stax.impl.InputProcessorChainImpl in project santuario-java by apache.
the class InputProcessorChainTest method testAddProcessorBeforeAndAfter1.
@Test
public void testAddProcessorBeforeAndAfter1() {
InputProcessorChainImpl inputProcessorChain = new InputProcessorChainImpl(new InboundSecurityContextImpl());
AbstractInputProcessor inputProcessor1 = new AbstractInputProcessor() {
};
inputProcessorChain.addProcessor(inputProcessor1);
AbstractInputProcessor inputProcessor2 = new AbstractInputProcessor() {
};
inputProcessorChain.addProcessor(inputProcessor2);
AbstractInputProcessor inputProcessor3 = new AbstractInputProcessor() {
};
inputProcessorChain.addProcessor(inputProcessor3);
AbstractInputProcessor inputProcessor4 = new AbstractInputProcessor() {
};
inputProcessorChain.addProcessor(inputProcessor4);
AbstractInputProcessor inputProcessor5 = new AbstractInputProcessor() {
};
inputProcessor5.addBeforeProcessor("");
inputProcessor5.addAfterProcessor(inputProcessor3.getClass().getName());
inputProcessorChain.addProcessor(inputProcessor5);
AbstractInputProcessor inputProcessor6 = new AbstractInputProcessor() {
};
inputProcessor6.addBeforeProcessor(inputProcessor5.getClass().getName());
inputProcessor6.addAfterProcessor("");
inputProcessorChain.addProcessor(inputProcessor6);
Assert.assertEquals(inputProcessorChain.getProcessors().get(0), inputProcessor4);
Assert.assertEquals(inputProcessorChain.getProcessors().get(1), inputProcessor5);
Assert.assertEquals(inputProcessorChain.getProcessors().get(2), inputProcessor6);
Assert.assertEquals(inputProcessorChain.getProcessors().get(3), inputProcessor3);
Assert.assertEquals(inputProcessorChain.getProcessors().get(4), inputProcessor2);
Assert.assertEquals(inputProcessorChain.getProcessors().get(5), inputProcessor1);
}
use of org.apache.xml.security.stax.impl.InputProcessorChainImpl in project santuario-java by apache.
the class XMLSecurityStreamReaderTest method testIdentityTransformSource.
@Test
public void testIdentityTransformSource() throws Exception {
XMLSecurityProperties securityProperties = new XMLSecurityProperties();
InboundSecurityContextImpl securityContext = new InboundSecurityContextImpl();
InputProcessorChainImpl inputProcessorChain = new InputProcessorChainImpl(securityContext);
inputProcessorChain.addProcessor(new EventReaderProcessor());
XMLSecurityStreamReader xmlSecurityStreamReader = new XMLSecurityStreamReader(inputProcessorChain, securityProperties);
// use the sun internal TransformerFactory since the current xalan version don't know how to handle StaxSources:
TransformerFactory transformerFactory = TransformerFactory.newInstance("com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl", this.getClass().getClassLoader());
javax.xml.transform.Transformer transformer = transformerFactory.newTransformer();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
transformer.transform(new StAXSource(xmlSecurityStreamReader), new StreamResult(baos));
XMLAssert.assertXMLEqual(readTestFile(), baos.toString(StandardCharsets.UTF_8.name()));
}
use of org.apache.xml.security.stax.impl.InputProcessorChainImpl in project santuario-java by apache.
the class XMLSecurityStreamReaderTest method testPassThroughDocumentEvents.
@Test
public void testPassThroughDocumentEvents() throws Exception {
XMLSecurityProperties securityProperties = new XMLSecurityProperties();
securityProperties.setSkipDocumentEvents(false);
InboundSecurityContextImpl securityContext = new InboundSecurityContextImpl();
InputProcessorChainImpl inputProcessorChain = new InputProcessorChainImpl(securityContext);
inputProcessorChain.addProcessor(new EventReaderProcessor());
XMLSecurityStreamReader xmlSecurityStreamReader = new XMLSecurityStreamReader(inputProcessorChain, securityProperties);
int event = xmlSecurityStreamReader.next();
Assert.assertEquals(XMLStreamConstants.START_DOCUMENT, event);
}
use of org.apache.xml.security.stax.impl.InputProcessorChainImpl in project santuario-java by apache.
the class XMLSecurityStreamReaderTest method testSkipThroughDocumentEvents.
@Test
public void testSkipThroughDocumentEvents() throws Exception {
XMLSecurityProperties securityProperties = new XMLSecurityProperties();
securityProperties.setSkipDocumentEvents(true);
InboundSecurityContextImpl securityContext = new InboundSecurityContextImpl();
InputProcessorChainImpl inputProcessorChain = new InputProcessorChainImpl(securityContext);
inputProcessorChain.addProcessor(new EventReaderProcessor());
XMLSecurityStreamReader xmlSecurityStreamReader = new XMLSecurityStreamReader(inputProcessorChain, securityProperties);
int event = xmlSecurityStreamReader.next();
Assert.assertEquals(XMLStreamConstants.START_ELEMENT, event);
}
Aggregations