}
private boolean lookInBufferedHeaders(EncryptedData ed, HashMap<String, String> currentParentNS) throws XWSSecurityException, XMLStreamException {
if (bufferedHeaders.size() > 0) {
for (int i = 0; i < bufferedHeaders.size(); i++) {
SecurityHeaderElement bufShe = (SecurityHeaderElement) bufferedHeaders.get(i);
if (MessageConstants.ENCRYPTEDKEY_LNAME.equals(bufShe.getLocalPart()) &&
MessageConstants.XENC_NS.equals(bufShe.getNamespaceURI())) {
EncryptedKey ek = ((EncryptedKey) bufShe);
if (ek.getPendingReferenceList() != null && ek.getPendingReferenceList().contains(ed.getId())) {
//for policy verification
if (ek.getPolicy() != null) {
ek.getPolicy().setKeyBinding(ek.getInferredKB());
}
if (!ed.hasCipherReference()) {
XMLStreamReader decryptedData = ed.getDecryptedData(ek.getKey(ed.getEncryptionAlgorithm()));
SecurityHeaderProcessor shp = new SecurityHeaderProcessor(context, currentParentNS, staxIF, creator);
if (decryptedData.getEventType() != XMLStreamReader.START_ELEMENT) {
StreamUtil.moveToNextElement(decryptedData);
}
SecurityHeaderElement she = shp.createHeader(decryptedData);
encIds.put(ed.getId(), she.getId());
edAlgos.put(ed.getId(), ed.getEncryptionAlgorithm());
//addSecurityHeader(she);
ek.getPendingReferenceList().remove(ed.getId());
checkDecryptedData(she, ek.getPolicy());
} else {
// handle encrypted attachment here
byte[] decryptedMimeData = ed.getDecryptedMimeData(ek.getKey(ed.getEncryptionAlgorithm()));
Attachment as = new AttachmentImpl(ed.getAttachmentContentId(), decryptedMimeData, ed.getAttachmentMimeType());
securityContext.getDecryptedAttachmentSet().add(as);
ek.getPendingReferenceList().remove(ed.getId());
}
return true;
}
} else if (MessageConstants.XENC_REFERENCE_LIST_LNAME.equals(bufShe.getLocalPart()) &&
MessageConstants.XENC_NS.equals(bufShe.getNamespaceURI())) {
ReferenceListHeader refList = (ReferenceListHeader) bufShe;
if (refList.getPendingReferenceList().contains(ed.getId())) {
//for policy verification
refList.getPolicy().setKeyBinding(ed.getInferredKB());
//
if (!ed.hasCipherReference()) {
XMLStreamReader decryptedData = ed.getDecryptedData();
if (decryptedData.getEventType() != XMLStreamReader.START_ELEMENT) {
StreamUtil.moveToNextElement(decryptedData);
}
SecurityHeaderProcessor shp = new SecurityHeaderProcessor(context, currentParentNS, staxIF, creator);
SecurityHeaderElement she = shp.createHeader(decryptedData);
encIds.put(ed.getId(), she.getId());
edAlgos.put(ed.getId(), ed.getEncryptionAlgorithm());
//addSecurityHeader(she);
refList.getPendingReferenceList().remove(ed.getId());
checkDecryptedData(she, refList.getPolicy());
} else {