throw new WSSecurityException(
WSSecurityException.FAILED_CHECK, null, null, e
);
}
WSDataRef dataRef = new WSDataRef();
dataRef.setWsuId(elem.getAttributeNS(null, "Id"));
dataRef.setAlgorithm(symEncAlgo);
dataRef.setContent(false);
Node decryptedNode;
if (previousSibling == null) {
decryptedNode = parent.getFirstChild();
} else {
decryptedNode = previousSibling.getNextSibling();
}
if (decryptedNode != null && Node.ELEMENT_NODE == decryptedNode.getNodeType()) {
dataRef.setProtectedElement((Element)decryptedNode);
}
dataRef.setXpath(ReferenceListProcessor.getXPath(decryptedNode));
if (decryptedNode != null
&& decryptedNode.getParentNode().getLocalName().equals(WSConstants.ENCRYPED_ASSERTION_LN)
&& decryptedNode.getParentNode().getNamespaceURI().equals(WSConstants.SAML2_NS)) {
Node soapHeader = decryptedNode.getParentNode().getParentNode();
soapHeader.replaceChild(decryptedNode, decryptedNode.getParentNode());
}
WSSecurityEngineResult result =
new WSSecurityEngineResult(WSConstants.ENCR, Collections.singletonList(dataRef));
result.put(WSSecurityEngineResult.TAG_ID, elem.getAttributeNS(null, "Id"));
wsDocInfo.addResult(result);
wsDocInfo.addTokenElement(elem);
List<WSSecurityEngineResult> completeResults =
new ArrayList<WSSecurityEngineResult>();
if (encrKeyResults != null) {
completeResults.addAll(encrKeyResults);
}
completeResults.add(result);
WSSConfig wssConfig = request.getWssConfig();
if (wssConfig != null) {
// Get hold of the plain text element
Element decryptedElem = dataRef.getProtectedElement();
QName el = new QName(decryptedElem.getNamespaceURI(), decryptedElem.getLocalName());
Processor proc = request.getWssConfig().getProcessor(el);
if (proc != null) {
if (log.isDebugEnabled()) {
log.debug("Processing decrypted element with: " + proc.getClass().getName());