ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1770722 - in /webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message: WSSecDKEncrypt.java WSSecEncrypt.java
Date Mon, 21 Nov 2016 17:00:14 GMT
Author: coheigea
Date: Mon Nov 21 17:00:14 2016
New Revision: 1770722

URL: http://svn.apache.org/viewvc?rev=1770722&view=rev
Log:
Fixing last merge

Modified:
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKEncrypt.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.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=1770722&r1=1770721&r2=1770722&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
Mon Nov 21 17:00:14 2016
@@ -51,8 +51,6 @@ public class WSSecDKEncrypt extends WSSe
     
     private Serializer encryptionSerializer;
     
-    private WSSecHeader securityHeader;
-
     public WSSecDKEncrypt() {
         super();
     }
@@ -66,8 +64,6 @@ public class WSSecDKEncrypt extends WSSe
 
     public Document build(Document doc, WSSecHeader secHeader) throws WSSecurityException
{
 
-        securityHeader = secHeader;
-        
         //
         // Setup the encrypted key
         //
@@ -77,7 +73,7 @@ public class WSSecDKEncrypt extends WSSe
         //
         prependDKElementToHeader(secHeader);
 
-        Element externRefList = encrypt();
+        Element externRefList = encrypt(secHeader);
 
         addAttachmentEncryptedDataElements(secHeader);
 
@@ -98,11 +94,19 @@ public class WSSecDKEncrypt extends WSSe
     }
 
     public Element encrypt() throws WSSecurityException {
+        return encrypt(null);
+    }
+    
+    public Element encrypt(WSSecHeader secHeader) throws WSSecurityException {
         if (getParts().isEmpty()) {
             getParts().add(WSSecurityUtil.getDefaultEncryptionPart(document));
         }
 
-        return encryptForExternalRef(null, getParts());
+        return encryptForExternalRef(null, getParts(), secHeader);
+    }
+    
+    public Element encryptForExternalRef(Element dataRef, List<WSEncryptionPart> references)
{
+        return encryptForExternalRef(dataRef, references);
     }
 
     /**
@@ -123,10 +127,11 @@ public class WSSecDKEncrypt extends WSSe
      *
      * @param dataRef A <code>xenc:Reference</code> element or <code>null</code>
      * @param references A list containing WSEncryptionPart objects
+     * @param secHeader the security header element to hold the encrypted key element.
      * @return Returns the updated <code>xenc:Reference</code> element
      * @throws WSSecurityException
      */
-    public Element encryptForExternalRef(Element dataRef, List<WSEncryptionPart> references)
+    public Element encryptForExternalRef(Element dataRef, List<WSEncryptionPart> references,
WSSecHeader secHeader)
         throws WSSecurityException {
 
         KeyInfo keyInfo = createKeyInfo();
@@ -135,7 +140,7 @@ public class WSSecDKEncrypt extends WSSe
 
         List<String> encDataRefs =
             WSSecEncrypt.doEncryption(
-                document, securityHeader, getIdAllocator(), keyInfo, key, symEncAlgo, references,
callbackLookup,
+                document, secHeader, getIdAllocator(), keyInfo, key, symEncAlgo, references,
callbackLookup,
                 attachmentCallbackHandler, attachmentEncryptedDataElements, storeBytesInAttachment,
                 encryptionSerializer
             );

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java?rev=1770722&r1=1770721&r2=1770722&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java
Mon Nov 21 17:00:14 2016
@@ -108,8 +108,6 @@ public class WSSecEncrypt extends WSSecE
     
     private Serializer encryptionSerializer;
     
-    private WSSecHeader securityHeader;
-
     public WSSecEncrypt() {
         super();
     }
@@ -200,7 +198,6 @@ public class WSSecEncrypt extends WSSecE
     public Document build(Document doc, Crypto crypto, WSSecHeader secHeader)
         throws WSSecurityException {
         doDebug = LOG.isDebugEnabled();
-        securityHeader = secHeader;
 
         prepare(doc, crypto);
 
@@ -208,7 +205,7 @@ public class WSSecEncrypt extends WSSecE
             LOG.debug("Beginning Encryption...");
         }
 
-        Element refs = encrypt();
+        Element refs = encrypt(secHeader);
 
         addAttachmentEncryptedDataElements(secHeader);
         if (getEncryptedKeyElement() != null) {
@@ -226,11 +223,22 @@ public class WSSecEncrypt extends WSSecE
     }
 
     public Element encrypt() throws WSSecurityException {
+        return encrypt(null);
+    }
+    
+    public Element encrypt(WSSecHeader secHeader) throws WSSecurityException {
         if (getParts().isEmpty()) {
             getParts().add(WSSecurityUtil.getDefaultEncryptionPart(document));
         }
 
-        return encryptForRef(null, getParts());
+        return encryptForRef(null, getParts(), secHeader);
+    }
+    
+    public Element encryptForRef(
+        Element dataRef,
+        List<WSEncryptionPart> references
+    ) throws WSSecurityException {
+        return encryptForRef(dataRef, references, null);
     }
 
     /**
@@ -251,12 +259,14 @@ public class WSSecEncrypt extends WSSecE
      *
      * @param dataRef A <code>xenc:Reference</code> element or <code>null</code>
      * @param references A list containing WSEncryptionPart objects
+     * @param secHeader The WSSecHeader instance
      * @return Returns the updated <code>xenc:Reference</code> element
      * @throws WSSecurityException
      */
     public Element encryptForRef(
         Element dataRef,
-        List<WSEncryptionPart> references
+        List<WSEncryptionPart> references,
+        WSSecHeader secHeader
     ) throws WSSecurityException {
         KeyInfo keyInfo = createKeyInfo();
         //the sun/oracle jce provider doesn't like a foreign SecretKey impl.
@@ -265,7 +275,7 @@ public class WSSecEncrypt extends WSSecE
         SecretKeySpec secretKeySpec = new SecretKeySpec(symmetricKey.getEncoded(), symmetricKey.getAlgorithm());
         List<String> encDataRefs =
             doEncryption(
-                document, securityHeader, getIdAllocator(), keyInfo, secretKeySpec, getSymmetricEncAlgorithm(),
references,
+                document, secHeader, getIdAllocator(), keyInfo, secretKeySpec, getSymmetricEncAlgorithm(),
references,
                     callbackLookup, attachmentCallbackHandler, attachmentEncryptedDataElements,
                     storeBytesInAttachment
             );
@@ -699,7 +709,7 @@ public class WSSecEncrypt extends WSSecE
         String xencEncryptedDataId = idAllocator.createId("ED-", elementToEncrypt);
         try {
             if ("Header".equals(modifier)
-                && elementToEncrypt.getParentNode().equals(securityHeader.getSecurityHeader().getParentNode()))
{
+                && elementToEncrypt.getParentNode().equals(WSSecurityUtil.getSOAPHeader(doc)))
{
                 createEncryptedHeaderElement(doc, securityHeader, elementToEncrypt, idAllocator);
             }
 



Mime
View raw message