// process SAML Token
ReplayCache replayCache = null;
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
replayCache = securityProperties.getSamlOneTimeUseReplayCache();
InboundWSSec wsSecIn = WSSec.getInboundWSSec(securityProperties);
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
Assert.assertNotNull(document);
}
// now process SAML Token again
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
securityProperties.setSamlOneTimeUseReplayCache(replayCache);
InboundWSSec wsSecIn = WSSec.getInboundWSSec(securityProperties);
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
try {
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
Assert.fail("Exception expected");
} catch (XMLStreamException e) {