use of org.apache.xml.security.stax.impl.InboundSecurityContextImpl 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.InboundSecurityContextImpl 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.InboundSecurityContextImpl 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);
}
use of org.apache.xml.security.stax.impl.InboundSecurityContextImpl in project santuario-java by apache.
the class SecurityTokenFactoryImplTest method testKeyNameTokenWithSignatureVerificationKeySet.
@Test
public void testKeyNameTokenWithSignatureVerificationKeySet() throws Exception {
SecurityTokenFactory factory = new SecurityTokenFactoryImpl();
SecurityTokenConstants.KeyUsage keyUsage = SecurityTokenConstants.KeyUsage_Signature_Verification;
xmlSecurityProperties.addKeyNameMapping("mykey", loadPublicKey("dsa.key", "DSA"));
xmlSecurityProperties.setSignatureVerificationKey(loadPublicKey("rsa.key", "RSA"));
InboundSecurityContext inboundSecurityContext = new InboundSecurityContextImpl();
InboundSecurityToken token = factory.getSecurityToken(keyInfoType, keyUsage, xmlSecurityProperties, inboundSecurityContext);
assertEquals(KeyIdentifier_KeyName, token.getKeyIdentifier());
assertNotNull(token.getPublicKey());
assertEquals("RSA", token.getPublicKey().getAlgorithm());
}
Aggregations