Author: coheigea
Date: Thu Jun 18 11:04:18 2015
New Revision: 1686183
URL: http://svn.apache.org/r1686183
Log:
WSS-541 Copy the attachment handing code from the sign/encrypt routines to the
derived key versions
Modified:
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java
Modified:
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java?rev=1686183&r1=1686182&r2=1686183&view=diff
==============================================================================
---
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java
(original)
+++
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java
Thu Jun 18 11:04:18 2015
@@ -19,6 +19,7 @@
package org.apache.wss4j.dom.message;
+import java.util.ArrayList;
import java.util.List;
import javax.crypto.SecretKey;
@@ -44,11 +45,20 @@ public class WSSecDKEncrypt extends WSSe
private String symEncAlgo = WSConstants.AES_128;
private int derivedKeyLength = -1;
+
+ private List<Element> attachmentEncryptedDataElements;
public WSSecDKEncrypt() {
super();
}
-
+
+ @Override
+ public void prepare(Document doc) throws WSSecurityException {
+ super.prepare(doc);
+
+ attachmentEncryptedDataElements = new ArrayList<>();
+ }
+
public Document build(Document doc, WSSecHeader secHeader) throws
WSSecurityException {
//
@@ -61,6 +71,16 @@ public class WSSecDKEncrypt extends WSSe
prependDKElementToHeader(secHeader);
Element externRefList = encrypt();
+
+ if (attachmentEncryptedDataElements != null) {
+ for (int i = 0; i < attachmentEncryptedDataElements.size(); i++) {
+ Element encryptedData = attachmentEncryptedDataElements.get(i);
+ WSSecurityUtil.prependChildElement(
+ secHeader.getSecurityHeader(), encryptedData
+ );
+ }
+ }
+
addExternalRefElement(externRefList, secHeader);
return doc;
@@ -104,7 +124,7 @@ public class WSSecDKEncrypt extends WSSe
List<String> encDataRefs =
WSSecEncrypt.doEncryption(
- document, getIdAllocator(), keyInfo, key, symEncAlgo,
references, callbackLookup
+ document, getIdAllocator(), keyInfo, key, symEncAlgo,
references, callbackLookup, attachmentCallbackHandler,
attachmentEncryptedDataElements
);
if (dataRef == null) {
dataRef =
@@ -178,5 +198,8 @@ public class WSSecDKEncrypt extends WSSe
public void setDerivedKeyLength(int keyLength) {
derivedKeyLength = keyLength;
}
-
+
+ public List<Element> getAttachmentEncryptedDataElements() {
+ return attachmentEncryptedDataElements;
+ }
}