private XMLSecEvent processEvent(InputProcessorChain inputProcessorChain, boolean headerEvent)
throws XMLStreamException, XMLSecurityException {
//did a execption occur during decryption in the decryption thread?
testAndThrowUncaughtException();
XMLSecEvent xmlSecEvent = XMLSecEventFactory.allocate(xmlStreamReader, parentXmlSecStartElement);
//here we request the next XMLEvent from the decryption thread
//instead from the processor-chain as we normally would do
switch (xmlSecEvent.getEventType()) {
case XMLStreamConstants.START_ELEMENT:
currentXMLStructureDepth++;
if (currentXMLStructureDepth > maximumAllowedXMLStructureDepth) {
throw new XMLSecurityException(
"secureProcessing.MaximumAllowedXMLStructureDepth",
maximumAllowedXMLStructureDepth
);
}
parentXmlSecStartElement = xmlSecEvent.asStartElement();
if (!rootElementProcessed) {
handleEncryptedElement(inputProcessorChain, parentXmlSecStartElement, this.inboundSecurityToken, encryptedDataType);
rootElementProcessed = true;
}
break;
case XMLStreamConstants.END_ELEMENT:
currentXMLStructureDepth--;
if (parentXmlSecStartElement != null) {
parentXmlSecStartElement = parentXmlSecStartElement.getParentXMLSecStartElement();
}
if (xmlSecEvent.asEndElement().getName().equals(wrapperElementName)) {
InputProcessorChain subInputProcessorChain = inputProcessorChain.createSubChain(this);
//skip EncryptedHeader Element when we processed it.
QName endElement;
if (encryptedHeader) {
endElement = XMLSecurityConstants.TAG_wsse11_EncryptedHeader;
} else {
endElement = XMLSecurityConstants.TAG_xenc_EncryptedData;
}
//read and discard XMLEvents until the EncryptedData structure
XMLSecEvent endEvent;
do {
subInputProcessorChain.reset();
if (headerEvent) {
endEvent = subInputProcessorChain.processHeaderEvent();
} else {
endEvent = subInputProcessorChain.processEvent();
}
}
while (!(endEvent.getEventType() == XMLStreamConstants.END_ELEMENT
&& endEvent.asEndElement().getName().equals(endElement)));
inputProcessorChain.getDocumentContext().unsetIsInEncryptedContent(this);
//...fetch the next (unencrypted) event
if (headerEvent) {