}
SecurityToken securityToken = securityTokenProvider.getSecurityToken();
if (!(securityToken instanceof SecurityTokenReference)) {
throw new WSSecurityException(WSSecurityException.ErrorCode.UNSUPPORTED_SECURITY_TOKEN);
}
SecurityTokenReference securityTokenReference = (SecurityTokenReference) securityToken;
//todo analyse and fix me: the following statement could be problematic
inputProcessorChain.getDocumentContext().setIsInSignedContent(inputProcessorChain.getProcessors().indexOf(internalSignatureReferenceVerifier), internalSignatureReferenceVerifier);
XMLSecStartElement xmlSecStartElement = securityTokenReference.getXmlSecEvents().getLast().asStartElement();
internalSignatureReferenceVerifier.setStartElement(xmlSecStartElement);
Iterator<XMLSecEvent> xmlSecEventIterator = securityTokenReference.getXmlSecEvents().descendingIterator();
try {
while (xmlSecEventIterator.hasNext()) {
internalSignatureReferenceVerifier.processEvent(xmlSecEventIterator.next(), inputProcessorChain);
}
} catch (XMLStreamException e) {