ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1771308 [1/4] - in /webservices/wss4j/trunk: integration/src/test/java/org/apache/wss4j/integration/test/kerberos/ ws-security-dom/src/main/java/org/apache/wss4j/dom/action/ ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/ ws-se...
Date Fri, 25 Nov 2016 12:31:20 GMT
Author: coheigea
Date: Fri Nov 25 12:31:19 2016
New Revision: 1771308

URL: http://svn.apache.org/viewvc?rev=1771308&view=rev
Log:
Finished refactoring

Modified:
    webservices/wss4j/trunk/integration/src/test/java/org/apache/wss4j/integration/test/kerberos/KerberosTest.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/AbstractDerivedAction.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/Action.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/CustomTokenAction.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/EncryptionAction.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/EncryptionDerivedAction.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SAMLTokenSignedAction.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SAMLTokenUnsignedAction.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureAction.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureConfirmationAction.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureDerivedAction.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/TimestampAction.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/UsernameTokenAction.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/UsernameTokenSignedAction.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/WSHandler.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecBase.java
    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/WSSecDKSign.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDerivedKeyBase.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncryptedKey.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSAMLToken.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSecurityContextToken.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignature.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureBase.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureConfirmation.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecTimestamp.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecUsernameToken.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/saml/WSSecSignatureSAML.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/AbstractSAMLCallbackHandler.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomAction.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CertificateStoreTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CryptoProviderTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CryptoTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/CustomActionProcessorTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/CustomTokenTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/AttachmentTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/CertErrorTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/DerivedKeyTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptedDataInHeaderTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionAlgorithmSuiteTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionGCMTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionPartsTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/EncryptionTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ModifiedRequestTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/NoSoapPrefixSignatureTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/PasswordEncryptorTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/PasswordTypeTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ReplayTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/RequireSignedEncryptedDataElementsTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SKISignatureTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/STRSignatureTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SecurityContextTokenTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureAKITest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureAlgorithmSuiteTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureCRLTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureCertConstraintsTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureCertTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureEncryptionTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureIssuerCertConstraintsTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureKeyValueTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignaturePartsTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignedBSTTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SymmetricSignatureTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/TimestampTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/UTDerivedKeyTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/UTSignatureTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/UsernameTokenTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/XOPAttachmentTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/token/BSTKerberosTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/FaultCodeTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/PrincipalTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/processor/EncryptedKeyDataRefTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/processor/ReferenceListDataRefTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlAlgorithmSuiteTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlAuthnTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlConditionsTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlNegativeTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlReferenceTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenCustomSignatureTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenDerivedTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenHOKTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenSVTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SignedSamlTokenHOKTest.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/validate/ValidatorTest.java
    webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/AttachmentTest.java
    webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/DerivedKeyTokenTest.java
    webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/EncDecryptionTest.java
    webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/SecurityContextTokenTest.java
    webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/SignatureEncryptionTest.java
    webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/SignatureTest.java
    webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/XOPAttachmentTest.java
    webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLCallbackHandlerImpl.java
    webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenHOKTest.java
    webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenReferenceTest.java
    webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenTest.java
    webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SamlTokenDerivedTest.java

Modified: webservices/wss4j/trunk/integration/src/test/java/org/apache/wss4j/integration/test/kerberos/KerberosTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/integration/src/test/java/org/apache/wss4j/integration/test/kerberos/KerberosTest.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/integration/src/test/java/org/apache/wss4j/integration/test/kerberos/KerberosTest.java (original)
+++ webservices/wss4j/trunk/integration/src/test/java/org/apache/wss4j/integration/test/kerberos/KerberosTest.java Fri Nov 25 12:31:19 2016
@@ -389,7 +389,7 @@ public class KerberosTest extends Abstra
         SecretKey secretKey = bst.getSecretKey();
         sign.setSecretKey(secretKey.getEncoded());
 
-        Document signedDoc = sign.build(doc, null);
+        Document signedDoc = sign.build(null);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -465,7 +465,7 @@ public class KerberosTest extends Abstra
         byte[] digestBytes = KeyUtils.generateDigest(bst.getToken());
         sign.setCustomTokenId(Base64.getMimeEncoder().encodeToString(digestBytes));
 
-        Document signedDoc = sign.build(doc, null);
+        Document signedDoc = sign.build(null);
 
         WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
@@ -540,7 +540,7 @@ public class KerberosTest extends Abstra
         builder.setCustomReferenceValue(WSConstants.WSS_GSS_KRB_V5_AP_REQ);
         builder.setEncKeyId(bst.getID());
 
-        Document encryptedDoc = builder.build(doc, null);
+        Document encryptedDoc = builder.build(null);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -611,7 +611,7 @@ public class KerberosTest extends Abstra
         builder.setCustomReferenceValue(WSConstants.WSS_GSS_KRB_V5_AP_REQ);
         builder.setEncKeyId(bst.getID());
 
-        Document encryptedDoc = builder.build(doc, null);
+        Document encryptedDoc = builder.build(null);
 
         WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
@@ -686,7 +686,7 @@ public class KerberosTest extends Abstra
         byte[] digestBytes = KeyUtils.generateDigest(bst.getToken());
         builder.setEncKeyId(Base64.getMimeEncoder().encodeToString(digestBytes));
 
-        Document encryptedDoc = builder.build(doc, null);
+        Document encryptedDoc = builder.build(null);
 
         WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
@@ -839,7 +839,7 @@ public class KerberosTest extends Abstra
             SecretKey secretKey = bst.getSecretKey();
             sign.setSecretKey(secretKey.getEncoded());
 
-            sign.build(doc, null);
+            sign.build(null);
             WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
             javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
@@ -935,7 +935,7 @@ public class KerberosTest extends Abstra
             byte[] digestBytes = KeyUtils.generateDigest(bst.getToken());
             sign.setCustomTokenId(Base64.getMimeEncoder().encodeToString(digestBytes));
 
-            sign.build(doc, null);
+            sign.build(null);
 
             WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
@@ -1103,7 +1103,7 @@ public class KerberosTest extends Abstra
             builder.setEncryptSymmKey(false);
             builder.setCustomReferenceValue(WSConstants.WSS_GSS_KRB_V5_AP_REQ);
             builder.setEncKeyId(bst.getID());
-            builder.build(doc, null);
+            builder.build(null);
             WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
             javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
@@ -1197,7 +1197,7 @@ public class KerberosTest extends Abstra
             byte[] digestBytes = KeyUtils.generateDigest(bst.getToken());
             builder.setEncKeyId(Base64.getMimeEncoder().encodeToString(digestBytes));
 
-            builder.build(doc, null);
+            builder.build(null);
 
             WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/AbstractDerivedAction.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/AbstractDerivedAction.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/AbstractDerivedAction.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/AbstractDerivedAction.java Fri Nov 25 12:31:19 2016
@@ -140,7 +140,7 @@ public abstract class AbstractDerivedAct
                 encrKeyBuilder.setMGFAlgorithm(mgfAlgorithm);
             }
 
-            encrKeyBuilder.prepare(doc, actionToken.getCrypto());
+            encrKeyBuilder.prepare(actionToken.getCrypto());
 
             byte[] ek = encrKeyBuilder.getEphemeralKey();
             String tokenIdentifier = encrKeyBuilder.getId();

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/Action.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/Action.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/Action.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/Action.java Fri Nov 25 12:31:19 2016
@@ -19,7 +19,6 @@
 
 package org.apache.wss4j.dom.action;
 
-import org.w3c.dom.Document;
 import org.apache.wss4j.common.SecurityActionToken;
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.dom.handler.RequestData;
@@ -33,7 +32,6 @@ public interface Action {
     void execute(
         WSHandler handler,
         SecurityActionToken actionToken,
-        Document doc,
         RequestData reqData
     ) throws WSSecurityException;
 

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/CustomTokenAction.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/CustomTokenAction.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/CustomTokenAction.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/CustomTokenAction.java Fri Nov 25 12:31:19 2016
@@ -22,7 +22,6 @@ package org.apache.wss4j.dom.action;
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
 
-import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.apache.wss4j.common.SecurityActionToken;
 import org.apache.wss4j.common.ext.WSPasswordCallback;
@@ -32,8 +31,7 @@ import org.apache.wss4j.dom.handler.WSHa
 
 public class CustomTokenAction implements Action {
 
-    public void execute(WSHandler handler, SecurityActionToken actionToken,
-                        Document doc, RequestData reqData)
+    public void execute(WSHandler handler, SecurityActionToken actionToken, RequestData reqData)
         throws WSSecurityException {
         CallbackHandler callbackHandler = reqData.getCallbackHandler();
         if (callbackHandler == null) {

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/EncryptionAction.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/EncryptionAction.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/EncryptionAction.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/EncryptionAction.java Fri Nov 25 12:31:19 2016
@@ -34,11 +34,9 @@ import org.apache.wss4j.dom.handler.Requ
 import org.apache.wss4j.dom.handler.WSHandler;
 import org.apache.wss4j.dom.handler.WSHandlerConstants;
 import org.apache.wss4j.dom.message.WSSecEncrypt;
-import org.w3c.dom.Document;
 
 public class EncryptionAction implements Action {
-    public void execute(WSHandler handler, SecurityActionToken actionToken,
-                        Document doc, RequestData reqData)
+    public void execute(WSHandler handler, SecurityActionToken actionToken, RequestData reqData)
             throws WSSecurityException {
         WSSecEncrypt wsEncrypt = new WSSecEncrypt(reqData.getSecHeader());
         wsEncrypt.setIdAllocator(reqData.getWssConfig().getIdAllocator());
@@ -123,7 +121,7 @@ public class EncryptionAction implements
         wsEncrypt.setStoreBytesInAttachment(reqData.isStoreBytesInAttachment());
 
         try {
-            wsEncrypt.build(doc, encryptionToken.getCrypto());
+            wsEncrypt.build(encryptionToken.getCrypto());
         } catch (WSSecurityException e) {
             throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e, "empty",
                                           new Object[] {"Error during encryption: "});

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/EncryptionDerivedAction.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/EncryptionDerivedAction.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/EncryptionDerivedAction.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/EncryptionDerivedAction.java Fri Nov 25 12:31:19 2016
@@ -40,8 +40,7 @@ import org.w3c.dom.Node;
 
 public class EncryptionDerivedAction extends AbstractDerivedAction implements Action {
 
-    public void execute(WSHandler handler, SecurityActionToken actionToken,
-                        Document doc, RequestData reqData)
+    public void execute(WSHandler handler, SecurityActionToken actionToken, RequestData reqData)
             throws WSSecurityException {
         CallbackHandler callbackHandler = reqData.getCallbackHandler();
         if (callbackHandler == null) {
@@ -80,6 +79,7 @@ public class EncryptionDerivedAction ext
             wsEncrypt.setDerivedKeyLength(encryptionToken.getDerivedKeyLength());
         }
 
+        Document doc = reqData.getSecHeader().getSecurityHeaderElement().getOwnerDocument();
         Element tokenElement =
             setupTokenReference(reqData, encryptionToken, wsEncrypt, passwordCallback, doc);
         wsEncrypt.setAttachmentCallbackHandler(reqData.getAttachmentCallbackHandler());
@@ -93,7 +93,7 @@ public class EncryptionDerivedAction ext
                 wsEncrypt.getParts().add(WSSecurityUtil.getDefaultEncryptionPart(doc));
             }
 
-            wsEncrypt.prepare(doc);
+            wsEncrypt.prepare();
 
             Element externRefList = wsEncrypt.encrypt();
 

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SAMLTokenSignedAction.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SAMLTokenSignedAction.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SAMLTokenSignedAction.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SAMLTokenSignedAction.java Fri Nov 25 12:31:19 2016
@@ -34,15 +34,13 @@ import org.apache.wss4j.dom.handler.Requ
 import org.apache.wss4j.dom.handler.WSHandler;
 import org.apache.wss4j.dom.handler.WSHandlerConstants;
 import org.apache.wss4j.dom.saml.WSSecSignatureSAML;
-import org.w3c.dom.Document;
 
 public class SAMLTokenSignedAction implements Action {
 
     private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(SAMLTokenSignedAction.class);
 
-    public void execute(WSHandler handler, SecurityActionToken actionToken,
-                        Document doc, RequestData reqData)
+    public void execute(WSHandler handler, SecurityActionToken actionToken, RequestData reqData)
             throws WSSecurityException {
         Crypto crypto = null;
 
@@ -121,7 +119,6 @@ public class SAMLTokenSignedAction imple
 
         try {
             wsSign.build(
-                    doc,
                     crypto,
                     samlAssertion,
                     samlCallback.getIssuerCrypto(),

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SAMLTokenUnsignedAction.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SAMLTokenUnsignedAction.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SAMLTokenUnsignedAction.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SAMLTokenUnsignedAction.java Fri Nov 25 12:31:19 2016
@@ -30,12 +30,10 @@ import org.apache.wss4j.dom.handler.Requ
 import org.apache.wss4j.dom.handler.WSHandler;
 import org.apache.wss4j.dom.handler.WSHandlerConstants;
 import org.apache.wss4j.dom.message.WSSecSAMLToken;
-import org.w3c.dom.Document;
 
 public class SAMLTokenUnsignedAction implements Action {
 
-    public void execute(WSHandler handler, SecurityActionToken actionToken,
-                        Document doc, RequestData reqData)
+    public void execute(WSHandler handler, SecurityActionToken actionToken, RequestData reqData)
             throws WSSecurityException {
         WSSecSAMLToken builder = new WSSecSAMLToken(reqData.getSecHeader());
         builder.setIdAllocator(reqData.getWssConfig().getIdAllocator());
@@ -68,6 +66,6 @@ public class SAMLTokenUnsignedAction imp
         }
 
         // add the SAMLAssertion Token to the SOAP Envelope
-        builder.build(doc, samlAssertion);
+        builder.build(samlAssertion);
     }
 }

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureAction.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureAction.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureAction.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureAction.java Fri Nov 25 12:31:19 2016
@@ -39,8 +39,7 @@ import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
 public class SignatureAction implements Action {
-    public void execute(WSHandler handler, SecurityActionToken actionToken,
-                        Document doc, RequestData reqData)
+    public void execute(WSHandler handler, SecurityActionToken actionToken, RequestData reqData)
             throws WSSecurityException {
         CallbackHandler callbackHandler = reqData.getCallbackHandler();
         if (callbackHandler == null) {
@@ -101,7 +100,7 @@ public class SignatureAction implements
         wsSign.setStoreBytesInAttachment(reqData.isStoreBytesInAttachment());
 
         try {
-            wsSign.prepare(doc, signatureToken.getCrypto());
+            wsSign.prepare(signatureToken.getCrypto());
 
             Element siblingElementToPrepend = null;
             boolean signBST = false;
@@ -141,6 +140,7 @@ public class SignatureAction implements
             List<WSEncryptionPart> parts = signatureToken.getParts();
             if (parts == null || parts.isEmpty()) {
                 parts = new ArrayList<>(1);
+                Document doc = reqData.getSecHeader().getSecurityHeaderElement().getOwnerDocument();
                 parts.add(WSSecurityUtil.getDefaultEncryptionPart(doc));
             }
 

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureConfirmationAction.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureConfirmationAction.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureConfirmationAction.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureConfirmationAction.java Fri Nov 25 12:31:19 2016
@@ -30,7 +30,6 @@ import org.apache.wss4j.dom.handler.WSHa
 import org.apache.wss4j.dom.handler.WSHandlerConstants;
 import org.apache.wss4j.dom.handler.WSHandlerResult;
 import org.apache.wss4j.dom.message.WSSecSignatureConfirmation;
-import org.w3c.dom.Document;
 
 import java.util.List;
 
@@ -39,8 +38,7 @@ public class SignatureConfirmationAction
         org.slf4j.LoggerFactory.getLogger(SignatureConfirmationAction.class);
 
     @SuppressWarnings("unchecked")
-    public void execute(WSHandler handler, SecurityActionToken actionToken,
-                        Document doc, RequestData reqData)
+    public void execute(WSHandler handler, SecurityActionToken actionToken, RequestData reqData)
             throws WSSecurityException {
         if (LOG.isDebugEnabled()) {
             LOG.debug("Perform Signature confirmation");
@@ -81,7 +79,7 @@ public class SignatureConfirmationAction
                         || WSConstants.ST_SIGNED == resultAction.intValue()
                         || WSConstants.UT_SIGN == resultAction.intValue())) {
                     byte[] sigVal = (byte[]) result.get(WSSecurityEngineResult.TAG_SIGNATURE_VALUE);
-                    wsc.build(doc, sigVal);
+                    wsc.build(sigVal);
                     signatureParts.add(new WSEncryptionPart(wsc.getId()));
                     signatureAdded = true;
                 }
@@ -89,7 +87,7 @@ public class SignatureConfirmationAction
         }
 
         if (!signatureAdded) {
-            wsc.build(doc, null);
+            wsc.build(null);
             signatureParts.add(new WSEncryptionPart(wsc.getId()));
         }
         handler.setProperty(

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureDerivedAction.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureDerivedAction.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureDerivedAction.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/SignatureDerivedAction.java Fri Nov 25 12:31:19 2016
@@ -41,8 +41,7 @@ import org.w3c.dom.Node;
 
 public class SignatureDerivedAction extends AbstractDerivedAction implements Action {
 
-    public void execute(WSHandler handler, SecurityActionToken actionToken,
-                        Document doc, RequestData reqData)
+    public void execute(WSHandler handler, SecurityActionToken actionToken, RequestData reqData)
             throws WSSecurityException {
         CallbackHandler callbackHandler = reqData.getCallbackHandler();
         if (callbackHandler == null) {
@@ -84,6 +83,7 @@ public class SignatureDerivedAction exte
             wsSign.setDerivedKeyLength(signatureToken.getDerivedKeyLength());
         }
 
+        Document doc = reqData.getSecHeader().getSecurityHeaderElement().getOwnerDocument();
         Element tokenElement =
             setupTokenReference(reqData, signatureToken, wsSign, passwordCallback, doc);
         wsSign.setAttachmentCallbackHandler(reqData.getAttachmentCallbackHandler());
@@ -97,7 +97,7 @@ public class SignatureDerivedAction exte
                 wsSign.getParts().add(WSSecurityUtil.getDefaultEncryptionPart(doc));
             }
 
-            wsSign.prepare(doc);
+            wsSign.prepare();
 
             List<javax.xml.crypto.dsig.Reference> referenceList = wsSign.addReferencesToSign(parts);
 

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/TimestampAction.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/TimestampAction.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/TimestampAction.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/TimestampAction.java Fri Nov 25 12:31:19 2016
@@ -24,12 +24,10 @@ import org.apache.wss4j.common.ext.WSSec
 import org.apache.wss4j.dom.handler.RequestData;
 import org.apache.wss4j.dom.handler.WSHandler;
 import org.apache.wss4j.dom.message.WSSecTimestamp;
-import org.w3c.dom.Document;
 
 public class TimestampAction implements Action {
 
-    public void execute(WSHandler handler, SecurityActionToken actionToken,
-                        Document doc, RequestData reqData)
+    public void execute(WSHandler handler, SecurityActionToken actionToken, RequestData reqData)
         throws WSSecurityException {
         //
         // add the Timestamp to the SOAP Envelope
@@ -39,6 +37,6 @@ public class TimestampAction implements
         timeStampBuilder.setPrecisionInMilliSeconds(reqData.isPrecisionInMilliSeconds());
         timeStampBuilder.setTimeToLive(reqData.getTimeStampTTL());
         timeStampBuilder.setWsTimeSource(reqData.getWssConfig().getCurrentTime());
-        timeStampBuilder.build(doc);
+        timeStampBuilder.build();
     }
 }

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/UsernameTokenAction.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/UsernameTokenAction.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/UsernameTokenAction.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/UsernameTokenAction.java Fri Nov 25 12:31:19 2016
@@ -28,12 +28,10 @@ import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.dom.handler.RequestData;
 import org.apache.wss4j.dom.handler.WSHandler;
 import org.apache.wss4j.dom.message.WSSecUsernameToken;
-import org.w3c.dom.Document;
 
 public class UsernameTokenAction implements Action {
 
-    public void execute(WSHandler handler, SecurityActionToken actionToken,
-                        Document doc, RequestData reqData)
+    public void execute(WSHandler handler, SecurityActionToken actionToken, RequestData reqData)
         throws WSSecurityException {
         String username = reqData.getUsername();
         String password = null;
@@ -66,6 +64,6 @@ public class UsernameTokenAction impleme
             builder.addCreated();
         }
 
-        builder.build(doc);
+        builder.build();
     }
 }

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/UsernameTokenSignedAction.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/UsernameTokenSignedAction.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/UsernameTokenSignedAction.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/action/UsernameTokenSignedAction.java Fri Nov 25 12:31:19 2016
@@ -45,8 +45,7 @@ import org.w3c.dom.Document;
  */
 
 public class UsernameTokenSignedAction implements Action {
-    public void execute(WSHandler handler, SecurityActionToken actionToken,
-                        Document doc, RequestData reqData)
+    public void execute(WSHandler handler, SecurityActionToken actionToken, RequestData reqData)
             throws WSSecurityException {
         CallbackHandler callbackHandler = reqData.getCallbackHandler();
         if (callbackHandler == null) {
@@ -71,7 +70,7 @@ public class UsernameTokenSignedAction i
         builder.setUserInfo(reqData.getUsername(), passwordCallback.getPassword());
         builder.addCreated();
         builder.addNonce();
-        builder.prepare(doc);
+        builder.prepare();
 
         // Now prepare to sign.
         // First step:  Get a WS Signature object and set config parameters
@@ -115,7 +114,7 @@ public class UsernameTokenSignedAction i
             sign.setSignatureAlgorithm(WSConstants.HMAC_SHA1);
         }
 
-        sign.prepare(doc, null);
+        sign.prepare(null);
 
         // prepend in this order: first the Signature Element and then the
         // UsernameToken Element. This way the server gets the UsernameToken
@@ -128,6 +127,7 @@ public class UsernameTokenSignedAction i
             parts = signatureToken.getParts();
         } else {
             parts = new ArrayList<>(1);
+            Document doc = reqData.getSecHeader().getSecurityHeaderElement().getOwnerDocument();
             parts.add(WSSecurityUtil.getDefaultEncryptionPart(doc));
         }
         List<javax.xml.crypto.dsig.Reference> referenceList = sign.addReferencesToSign(parts);

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/WSHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/WSHandler.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/WSHandler.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/handler/WSHandler.java Fri Nov 25 12:31:19 2016
@@ -196,7 +196,7 @@ public abstract class WSHandler {
             String done =
                 (String)getProperty(reqData.getMsgContext(), WSHandlerConstants.SIG_CONF_DONE);
             if (done == null) {
-                wssConfig.getAction(WSConstants.SC).execute(this, null, doc, reqData);
+                wssConfig.getAction(WSConstants.SC).execute(this, null, reqData);
             }
         }
 
@@ -228,7 +228,7 @@ public abstract class WSHandler {
 
             if (WSConstants.NO_SECURITY != actionToDo.getAction()) {
                 wssConfig.getAction(actionToDo.getAction()).execute(
-                    this, actionToDo.getActionToken(), doc, reqData);
+                    this, actionToDo.getActionToken(), reqData);
             }
         }
 

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecBase.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecBase.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecBase.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecBase.java Fri Nov 25 12:31:19 2016
@@ -51,9 +51,24 @@ public class WSSecBase {
     private WsuIdAllocator idAllocator;
     private final List<WSEncryptionPart> parts = new ArrayList<>();
     private final WSSecHeader securityHeader;
+    private final Document doc;
 
     public WSSecBase(WSSecHeader securityHeader) {
         this.securityHeader = securityHeader;
+        if (securityHeader != null && securityHeader.getSecurityHeaderElement() != null) {
+            doc = securityHeader.getSecurityHeaderElement().getOwnerDocument();
+        } else {
+            doc = null;
+        }
+    }
+    
+    public WSSecBase(Document doc) {
+        this.doc = doc;
+        securityHeader = new WSSecHeader(doc);
+    }
+    
+    protected Document getDocument() {
+        return doc;
     }
     
     public WSSecHeader getSecurityHeader() {

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=1771308&r1=1771307&r2=1771308&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 Fri Nov 25 12:31:19 2016
@@ -54,20 +54,24 @@ public class WSSecDKEncrypt extends WSSe
     public WSSecDKEncrypt(WSSecHeader securityHeader) {
         super(securityHeader);
     }
+    
+    public WSSecDKEncrypt(Document doc) {
+        super(doc);
+    }
 
     @Override
-    public void prepare(Document doc) throws WSSecurityException {
-        super.prepare(doc);
+    public void prepare() throws WSSecurityException {
+        super.prepare();
 
         attachmentEncryptedDataElements = new ArrayList<>();
     }
 
-    public Document build(Document doc) throws WSSecurityException {
+    public Document build() throws WSSecurityException {
 
         //
         // Setup the encrypted key
         //
-        prepare(doc);
+        prepare();
         //
         // prepend elements in the right order to the security header
         //
@@ -79,7 +83,7 @@ public class WSSecDKEncrypt extends WSSe
 
         addExternalRefElement(externRefList);
 
-        return doc;
+        return getDocument();
     }
 
     public void addAttachmentEncryptedDataElements() {
@@ -94,7 +98,7 @@ public class WSSecDKEncrypt extends WSSe
 
     public Element encrypt() throws WSSecurityException {
         if (getParts().isEmpty()) {
-            getParts().add(WSSecurityUtil.getDefaultEncryptionPart(document));
+            getParts().add(WSSecurityUtil.getDefaultEncryptionPart(getDocument()));
         }
 
         return encryptForExternalRef(null, getParts());
@@ -130,17 +134,17 @@ public class WSSecDKEncrypt extends WSSe
 
         List<String> encDataRefs =
             WSSecEncrypt.doEncryption(
-                document, getSecurityHeader(), getIdAllocator(), keyInfo, key, symEncAlgo, references, callbackLookup,
+                getDocument(), getSecurityHeader(), getIdAllocator(), keyInfo, key, symEncAlgo, references, callbackLookup,
                 attachmentCallbackHandler, attachmentEncryptedDataElements, storeBytesInAttachment,
                 encryptionSerializer
             );
         if (dataRef == null) {
             dataRef =
-                document.createElementNS(
+                getDocument().createElementNS(
                     WSConstants.ENC_NS, WSConstants.ENC_PREFIX + ":ReferenceList"
                 );
         }
-        return WSSecEncrypt.createDataRefList(document, dataRef, encDataRefs);
+        return WSSecEncrypt.createDataRefList(getDocument(), dataRef, encDataRefs);
     }
 
     /**
@@ -148,10 +152,10 @@ public class WSSecDKEncrypt extends WSSe
      * @throws ConversationException
      */
     private KeyInfo createKeyInfo() throws WSSecurityException {
-        KeyInfo keyInfo = new KeyInfo(document);
-        SecurityTokenReference secToken = new SecurityTokenReference(document);
+        KeyInfo keyInfo = new KeyInfo(getDocument());
+        SecurityTokenReference secToken = new SecurityTokenReference(getDocument());
         secToken.addWSSENamespace();
-        Reference ref = new Reference(document);
+        Reference ref = new Reference(getDocument());
         ref.setURI("#" + getId());
         String ns =
             ConversationConstants.getWSCNs(getWscVersion())

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKSign.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKSign.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKSign.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDKSign.java Fri Nov 25 12:31:19 2016
@@ -80,6 +80,11 @@ public class WSSecDKSign extends WSSecDe
         super(securityHeader);
         init();
     }
+    
+    public WSSecDKSign(Document doc) {
+        super(doc);
+        init();
+    }
 
     private void init() {
         // Try to install the Santuario Provider - fall back to the JDK provider if this does
@@ -91,11 +96,11 @@ public class WSSecDKSign extends WSSecDe
         }
     }
 
-    public Document build(Document doc) throws WSSecurityException {
+    public Document build() throws WSSecurityException {
 
-        prepare(doc);
+        prepare();
         if (getParts().isEmpty()) {
-            getParts().add(WSSecurityUtil.getDefaultEncryptionPart(document));
+            getParts().add(WSSecurityUtil.getDefaultEncryptionPart(getDocument()));
         } else {
             for (WSEncryptionPart part : getParts()) {
                 if ("STRTransform".equals(part.getName()) && part.getId() == null) {
@@ -112,12 +117,12 @@ public class WSSecDKSign extends WSSecDe
         //
         prependDKElementToHeader();
 
-        return doc;
+        return getDocument();
     }
 
-    public void prepare(Document doc) throws WSSecurityException {
-        super.prepare(doc);
-        wsDocInfo = new WSDocInfo(doc);
+    public void prepare() throws WSSecurityException {
+        super.prepare();
+        wsDocInfo = new WSDocInfo(getDocument());
         sig = null;
 
         try {
@@ -139,11 +144,11 @@ public class WSSecDKSign extends WSSecDe
 
         keyInfoUri = getIdAllocator().createSecureId("KI-", keyInfo);
 
-        secRef = new SecurityTokenReference(doc);
+        secRef = new SecurityTokenReference(getDocument());
         strUri = getIdAllocator().createSecureId("STR-", secRef);
         secRef.setID(strUri);
 
-        Reference ref = new Reference(document);
+        Reference ref = new Reference(getDocument());
         ref.setURI("#" + getId());
         String ns =
             ConversationConstants.getWSCNs(getWscVersion())
@@ -185,7 +190,7 @@ public class WSSecDKSign extends WSSecDe
     ) throws WSSecurityException {
         return
             addReferencesToSign(
-                document,
+                getDocument(),
                 references,
                 wsDocInfo,
                 signatureFactory,

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDerivedKeyBase.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDerivedKeyBase.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDerivedKeyBase.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecDerivedKeyBase.java Fri Nov 25 12:31:19 2016
@@ -49,8 +49,6 @@ public abstract class WSSecDerivedKeyBas
     private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(WSSecDerivedKeyBase.class);
 
-    protected Document document;
-
     /**
      * DerivedKeyToken of this builder
      */
@@ -108,6 +106,11 @@ public abstract class WSSecDerivedKeyBas
         super(securityHeader);
         setKeyIdentifierType(0);
     }
+    
+    public WSSecDerivedKeyBase(Document doc) {
+        super(doc);
+        setKeyIdentifierType(0);
+    }
 
     /**
      * The derived key will change depending on the sig/encr algorithm.
@@ -187,12 +190,9 @@ public abstract class WSSecDerivedKeyBas
      * This method does not add any element to the security header. This must be
      * done explicitly.
      *
-     * @param doc The unsigned SOAP envelope as <code>Document</code>
      * @throws WSSecurityException
      */
-    public void prepare(Document doc) throws WSSecurityException {
-
-        document = doc;
+    public void prepare() throws WSSecurityException {
 
         // Create the derived keys
         // At this point figure out the key length according to the symencAlgo
@@ -218,7 +218,7 @@ public abstract class WSSecDerivedKeyBas
         derivedKeyBytes = algo.createKey(ephemeralKey, seed, offset, length);
 
         // Add the DKTs
-        dkt = new DerivedKeyToken(wscVersion, document);
+        dkt = new DerivedKeyToken(wscVersion, getDocument());
         dktId = getIdAllocator().createId("DK-", dkt);
 
         dkt.setOffset(offset);
@@ -227,7 +227,7 @@ public abstract class WSSecDerivedKeyBas
         dkt.setID(dktId);
 
         if (strElem == null) {
-            SecurityTokenReference secRef = new SecurityTokenReference(document);
+            SecurityTokenReference secRef = new SecurityTokenReference(getDocument());
             String strUri = getIdAllocator().createSecureId("STR-", secRef);
             secRef.setID(strUri);
 
@@ -258,7 +258,7 @@ public abstract class WSSecDerivedKeyBas
                 }
                 break;
             default:
-                Reference ref = new Reference(document);
+                Reference ref = new Reference(getDocument());
 
                 if (tokenIdDirectId) {
                     ref.setURI(tokenIdentifier);

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=1771308&r1=1771307&r2=1771308&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 Fri Nov 25 12:31:19 2016
@@ -111,6 +111,10 @@ public class WSSecEncrypt extends WSSecE
     public WSSecEncrypt(WSSecHeader securityHeader) {
         super(securityHeader);
     }
+    
+    public WSSecEncrypt(Document doc) {
+        super(doc);
+    }
 
     /**
      * Initialize a WSSec Encrypt.
@@ -122,12 +126,10 @@ public class WSSecEncrypt extends WSSecE
      * This method does not add any element to the security header. This must be
      * done explicitly.
      *
-     * @param doc The SOAP envelope as <code>Document</code>
      * @param crypto An instance of the Crypto API to handle keystore and certificates
      * @throws WSSecurityException
      */
-    public void prepare(Document doc, Crypto crypto) throws WSSecurityException {
-        document = doc;
+    public void prepare(Crypto crypto) throws WSSecurityException {
         attachmentEncryptedDataElements = new ArrayList<>();
 
         //
@@ -187,16 +189,15 @@ public class WSSecEncrypt extends WSSecE
      * calls the single function methods in order to perform a <i>one shot
      * encryption</i>. 
      *
-     * @param doc the SOAP envelope as <code>Document</code> with plain text Body
      * @param crypto an instance of the Crypto API to handle keystore and Certificates
      * @return the SOAP envelope with encrypted Body as <code>Document</code>
      * @throws WSSecurityException
      */
-    public Document build(Document doc, Crypto crypto)
+    public Document build(Crypto crypto)
         throws WSSecurityException {
         doDebug = LOG.isDebugEnabled();
 
-        prepare(doc, crypto);
+        prepare(crypto);
 
         if (doDebug) {
             LOG.debug("Beginning Encryption...");
@@ -216,12 +217,12 @@ public class WSSecEncrypt extends WSSecE
 
         clean();
         LOG.debug("Encryption complete.");
-        return doc;
+        return getDocument();
     }
 
     public Element encrypt() throws WSSecurityException {
         if (getParts().isEmpty()) {
-            getParts().add(WSSecurityUtil.getDefaultEncryptionPart(document));
+            getParts().add(WSSecurityUtil.getDefaultEncryptionPart(getDocument()));
         }
 
         return encryptForRef(null, getParts());
@@ -259,7 +260,7 @@ public class WSSecEncrypt extends WSSecE
         SecretKeySpec secretKeySpec = new SecretKeySpec(symmetricKey.getEncoded(), symmetricKey.getAlgorithm());
         List<String> encDataRefs =
             doEncryption(
-                document, getSecurityHeader(), getIdAllocator(), keyInfo, secretKeySpec, getSymmetricEncAlgorithm(), 
+                getDocument(), getSecurityHeader(), getIdAllocator(), keyInfo, secretKeySpec, getSymmetricEncAlgorithm(), 
                 references, callbackLookup, attachmentCallbackHandler, attachmentEncryptedDataElements,
                 storeBytesInAttachment
             );
@@ -269,7 +270,7 @@ public class WSSecEncrypt extends WSSecE
 
         if (dataRef == null) {
             dataRef =
-                document.createElementNS(
+                getDocument().createElementNS(
                     WSConstants.ENC_NS,
                     WSConstants.ENC_PREFIX + ":ReferenceList"
                 );
@@ -283,7 +284,7 @@ public class WSSecEncrypt extends WSSecE
                 );
             }
         }
-        return createDataRefList(document, dataRef, encDataRefs);
+        return createDataRefList(getDocument(), dataRef, encDataRefs);
     }
 
     /**
@@ -762,11 +763,11 @@ public class WSSecEncrypt extends WSSecE
      */
     private KeyInfo createKeyInfo() throws WSSecurityException {
 
-        KeyInfo keyInfo = new KeyInfo(document);
+        KeyInfo keyInfo = new KeyInfo(getDocument());
         if (embedEncryptedKey) {
             keyInfo.addUnknownElement(getEncryptedKeyElement());
         } else if (keyIdentifierType == WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER) {
-            SecurityTokenReference secToken = new SecurityTokenReference(document);
+            SecurityTokenReference secToken = new SecurityTokenReference(getDocument());
             secToken.addWSSENamespace();
             if (customReferenceValue != null) {
                 secToken.setKeyIdentifierEncKeySHA1(customReferenceValue);
@@ -777,19 +778,19 @@ public class WSSecEncrypt extends WSSecE
             secToken.addTokenType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
             keyInfo.addUnknownElement(secToken.getElement());
         } else if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customReferenceValue)) {
-            SecurityTokenReference secToken = new SecurityTokenReference(document);
+            SecurityTokenReference secToken = new SecurityTokenReference(getDocument());
             secToken.addWSSENamespace();
             secToken.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
             secToken.setKeyIdentifier(WSConstants.WSS_SAML_KI_VALUE_TYPE, getId());
             keyInfo.addUnknownElement(secToken.getElement());
         } else if (WSConstants.WSS_SAML2_KI_VALUE_TYPE.equals(customReferenceValue)) {
-            SecurityTokenReference secToken = new SecurityTokenReference(document);
+            SecurityTokenReference secToken = new SecurityTokenReference(getDocument());
             secToken.addWSSENamespace();
             secToken.addTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
             secToken.setKeyIdentifier(WSConstants.WSS_SAML2_KI_VALUE_TYPE, getId());
             keyInfo.addUnknownElement(secToken.getElement());
         } else if (WSConstants.WSS_KRB_KI_VALUE_TYPE.equals(customReferenceValue)) {
-            SecurityTokenReference secToken = new SecurityTokenReference(document);
+            SecurityTokenReference secToken = new SecurityTokenReference(getDocument());
             secToken.addWSSENamespace();
             secToken.addTokenType(WSConstants.WSS_GSS_KRB_V5_AP_REQ);
             secToken.setKeyIdentifier(customReferenceValue, getId(), true);
@@ -801,9 +802,9 @@ public class WSSecEncrypt extends WSSecE
             );
             keyInfo.addUnknownElement(securityTokenReference.getElement());
         } else if (getId() != null) {
-            SecurityTokenReference secToken = new SecurityTokenReference(document);
+            SecurityTokenReference secToken = new SecurityTokenReference(getDocument());
             secToken.addWSSENamespace();
-            Reference ref = new Reference(document);
+            Reference ref = new Reference(getDocument());
             if (encKeyIdDirectId) {
                 ref.setURI(getId());
             } else {
@@ -820,7 +821,7 @@ public class WSSecEncrypt extends WSSecE
             }
             keyInfo.addUnknownElement(secToken.getElement());
         } else if (!encryptSymmKey && keyIdentifierType == WSConstants.ISSUER_SERIAL) {
-            SecurityTokenReference secToken = new SecurityTokenReference(document);
+            SecurityTokenReference secToken = new SecurityTokenReference(getDocument());
             secToken.addWSSENamespace();
             if (customReferenceValue != null) {
                 secToken.setKeyIdentifierEncKeySHA1(customReferenceValue);

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncryptedKey.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncryptedKey.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncryptedKey.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncryptedKey.java Fri Nov 25 12:31:19 2016
@@ -73,8 +73,6 @@ public class WSSecEncryptedKey extends W
     private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(WSSecEncryptedKey.class);
 
-    protected Document document;
-
     /**
      * Encrypted bytes of the ephemeral key
      */
@@ -150,6 +148,10 @@ public class WSSecEncryptedKey extends W
     public WSSecEncryptedKey(WSSecHeader securityHeader) {
         super(securityHeader);
     }
+    
+    public WSSecEncryptedKey(Document doc) {
+        super(doc);
+    }
 
     /**
      * Set the user name to get the encryption certificate.
@@ -186,13 +188,10 @@ public class WSSecEncryptedKey extends W
      * Prepare the ephemeralKey and the tokens required to be added to the
      * security header
      *
-     * @param doc The SOAP envelope as <code>Document</code>
      * @param crypto An instance of the Crypto API to handle keystore and certificates
      * @throws WSSecurityException
      */
-    public void prepare(Document doc, Crypto crypto) throws WSSecurityException {
-
-        document = doc;
+    public void prepare(Crypto crypto) throws WSSecurityException {
 
         //
         // Set up the symmetric key
@@ -323,16 +322,16 @@ public class WSSecEncryptedKey extends W
         // 4) Create the CipherValue element structure and insert the encrypted
         // session key
         //
-        encryptedKeyElement = createEncryptedKey(document, keyEncAlgo);
+        encryptedKeyElement = createEncryptedKey(getDocument(), keyEncAlgo);
         if (encKeyId == null || "".equals(encKeyId)) {
             encKeyId = IDGenerator.generateID("EK-");
         }
         encryptedKeyElement.setAttributeNS(null, "Id", encKeyId);
 
         if (customEKKeyInfoElement != null) {
-            encryptedKeyElement.appendChild(document.adoptNode(customEKKeyInfoElement));
+            encryptedKeyElement.appendChild(getDocument().adoptNode(customEKKeyInfoElement));
         } else {
-            SecurityTokenReference secToken = new SecurityTokenReference(document);
+            SecurityTokenReference secToken = new SecurityTokenReference(getDocument());
 
             switch (keyIdentifierType) {
             case WSConstants.X509_KEY_IDENTIFIER:
@@ -365,9 +364,9 @@ public class WSSecEncryptedKey extends W
                 java.math.BigInteger serialNumber = remoteCert.getSerialNumber();
                 DOMX509IssuerSerial domIssuerSerial =
                     new DOMX509IssuerSerial(
-                        document, issuer, serialNumber
+                        getDocument(), issuer, serialNumber
                     );
-                DOMX509Data domX509Data = new DOMX509Data(document, domIssuerSerial);
+                DOMX509Data domX509Data = new DOMX509Data(getDocument(), domIssuerSerial);
                 secToken.setUnknownElement(domX509Data.getElement());
 
                 if (includeEncryptionToken) {
@@ -376,10 +375,10 @@ public class WSSecEncryptedKey extends W
                 break;
 
             case WSConstants.BST_DIRECT_REFERENCE:
-                Reference ref = new Reference(document);
+                Reference ref = new Reference(getDocument());
                 String certUri = IDGenerator.generateID(null);
                 ref.setURI("#" + certUri);
-                bstToken = new X509Security(document);
+                bstToken = new X509Security(getDocument());
                 ((X509Security) bstToken).setX509Certificate(remoteCert);
                 bstToken.setID(certUri);
                 ref.setValueType(bstToken.getValueType());
@@ -387,7 +386,7 @@ public class WSSecEncryptedKey extends W
                 break;
 
             case WSConstants.CUSTOM_SYMM_SIGNING :
-                Reference refCust = new Reference(document);
+                Reference refCust = new Reference(getDocument());
                 if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customEKTokenValueType)) {
                     secToken.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
                     refCust.setValueType(customEKTokenValueType);
@@ -404,7 +403,7 @@ public class WSSecEncryptedKey extends W
                 break;
 
             case WSConstants.CUSTOM_SYMM_SIGNING_DIRECT :
-                Reference refCustd = new Reference(document);
+                Reference refCustd = new Reference(getDocument());
                 if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customEKTokenValueType)) {
                     secToken.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
                     refCustd.setValueType(customEKTokenValueType);
@@ -437,7 +436,7 @@ public class WSSecEncryptedKey extends W
                 throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "unsupportedKeyId");
             }
             Element keyInfoElement =
-                document.createElementNS(
+                getDocument().createElementNS(
                     WSConstants.SIG_NS, WSConstants.SIG_PREFIX + ":" + WSConstants.KEYINFO_LN
                 );
             keyInfoElement.setAttributeNS(
@@ -447,14 +446,14 @@ public class WSSecEncryptedKey extends W
             encryptedKeyElement.appendChild(keyInfoElement);
         }
 
-        Element xencCipherValue = createCipherValue(document, encryptedKeyElement);
+        Element xencCipherValue = createCipherValue(getDocument(), encryptedKeyElement);
         if (storeBytesInAttachment) {
-            final String attachmentId = getIdAllocator().createId("", document);
-            WSSecurityUtil.storeBytesInAttachment(xencCipherValue, document, attachmentId,
+            final String attachmentId = getIdAllocator().createId("", getDocument());
+            WSSecurityUtil.storeBytesInAttachment(xencCipherValue, getDocument(), attachmentId,
                                                   encryptedEphemeralKey, attachmentCallbackHandler);
         } else {
             Text keyText =
-                WSSecurityUtil.createBase64EncodedTextNode(document, encryptedEphemeralKey);
+                WSSecurityUtil.createBase64EncodedTextNode(getDocument(), encryptedEphemeralKey);
             xencCipherValue.appendChild(keyText);
         }
     }
@@ -474,21 +473,21 @@ public class WSSecEncryptedKey extends W
         // 4) Create the CipherValue element structure and insert the encrypted
         // session key
         //
-        encryptedKeyElement = createEncryptedKey(document, keyEncAlgo);
+        encryptedKeyElement = createEncryptedKey(getDocument(), keyEncAlgo);
         if (encKeyId == null || "".equals(encKeyId)) {
             encKeyId = IDGenerator.generateID("EK-");
         }
         encryptedKeyElement.setAttributeNS(null, "Id", encKeyId);
 
         if (customEKKeyInfoElement != null) {
-            encryptedKeyElement.appendChild(document.adoptNode(customEKKeyInfoElement));
+            encryptedKeyElement.appendChild(getDocument().adoptNode(customEKKeyInfoElement));
         } else {
             SecurityTokenReference secToken = null;
             
             switch (keyIdentifierType) {
             case WSConstants.CUSTOM_SYMM_SIGNING :
-                secToken = new SecurityTokenReference(document);
-                Reference refCust = new Reference(document);
+                secToken = new SecurityTokenReference(getDocument());
+                Reference refCust = new Reference(getDocument());
                 if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customEKTokenValueType)) {
                     secToken.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
                     refCust.setValueType(customEKTokenValueType);
@@ -505,8 +504,8 @@ public class WSSecEncryptedKey extends W
                 break;
 
             case WSConstants.CUSTOM_SYMM_SIGNING_DIRECT :
-                secToken = new SecurityTokenReference(document);
-                Reference refCustd = new Reference(document);
+                secToken = new SecurityTokenReference(getDocument());
+                Reference refCustd = new Reference(getDocument());
                 if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customEKTokenValueType)) {
                     secToken.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
                     refCustd.setValueType(customEKTokenValueType);
@@ -523,7 +522,7 @@ public class WSSecEncryptedKey extends W
                 break;
 
             case WSConstants.CUSTOM_KEY_IDENTIFIER:
-                secToken = new SecurityTokenReference(document);
+                secToken = new SecurityTokenReference(getDocument());
                 secToken.setKeyIdentifier(customEKTokenValueType, customEKTokenId);
                 if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customEKTokenValueType)) {
                     secToken.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
@@ -564,7 +563,7 @@ public class WSSecEncryptedKey extends W
             
             if (secToken != null) {
                 Element keyInfoElement =
-                    document.createElementNS(
+                    getDocument().createElementNS(
                         WSConstants.SIG_NS, WSConstants.SIG_PREFIX + ":" + WSConstants.KEYINFO_LN
                     );
                 keyInfoElement.setAttributeNS(
@@ -575,36 +574,36 @@ public class WSSecEncryptedKey extends W
             }
         }
 
-        Element xencCipherValue = createCipherValue(document, encryptedKeyElement);
+        Element xencCipherValue = createCipherValue(getDocument(), encryptedKeyElement);
         if (storeBytesInAttachment) {
-            final String attachmentId = getIdAllocator().createId("", document);
-            WSSecurityUtil.storeBytesInAttachment(xencCipherValue, document, attachmentId,
+            final String attachmentId = getIdAllocator().createId("", getDocument());
+            WSSecurityUtil.storeBytesInAttachment(xencCipherValue, getDocument(), attachmentId,
                                                   encryptedEphemeralKey, attachmentCallbackHandler);
         } else {
             Text keyText =
-                WSSecurityUtil.createBase64EncodedTextNode(document, encryptedEphemeralKey);
+                WSSecurityUtil.createBase64EncodedTextNode(getDocument(), encryptedEphemeralKey);
             xencCipherValue.appendChild(keyText);
         }
     }
 
     protected void prepareInternal(SecretKey secretKey) throws WSSecurityException {
-        encryptedKeyElement = createEncryptedKey(document, keyEncAlgo);
+        encryptedKeyElement = createEncryptedKey(getDocument(), keyEncAlgo);
         if (encKeyId == null || "".equals(encKeyId)) {
             encKeyId = IDGenerator.generateID("EK-");
         }
         encryptedKeyElement.setAttributeNS(null, "Id", encKeyId);
 
         if (customEKKeyInfoElement != null) {
-            encryptedKeyElement.appendChild(document.adoptNode(customEKKeyInfoElement));
+            encryptedKeyElement.appendChild(getDocument().adoptNode(customEKKeyInfoElement));
         } else if (keyIdentifierType == WSConstants.CUSTOM_SYMM_SIGNING
             || keyIdentifierType == WSConstants.CUSTOM_SYMM_SIGNING_DIRECT
             || keyIdentifierType == WSConstants.CUSTOM_KEY_IDENTIFIER) {
-            SecurityTokenReference secToken = new SecurityTokenReference(document);
+            SecurityTokenReference secToken = new SecurityTokenReference(getDocument());
 
             switch (keyIdentifierType) {
 
                 case WSConstants.CUSTOM_SYMM_SIGNING :
-                    Reference refCust = new Reference(document);
+                    Reference refCust = new Reference(getDocument());
                     if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customEKTokenValueType)) {
                         secToken.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
                         refCust.setValueType(customEKTokenValueType);
@@ -621,7 +620,7 @@ public class WSSecEncryptedKey extends W
                     break;
 
                 case WSConstants.CUSTOM_SYMM_SIGNING_DIRECT :
-                    Reference refCustd = new Reference(document);
+                    Reference refCustd = new Reference(getDocument());
                     if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customEKTokenValueType)) {
                         secToken.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
                         refCustd.setValueType(customEKTokenValueType);
@@ -654,7 +653,7 @@ public class WSSecEncryptedKey extends W
                     throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "unsupportedKeyId");
             }
             Element keyInfoElement =
-                document.createElementNS(
+                getDocument().createElementNS(
                     WSConstants.SIG_NS, WSConstants.SIG_PREFIX + ":" + WSConstants.KEYINFO_LN
                 );
             keyInfoElement.setAttributeNS(
@@ -664,14 +663,14 @@ public class WSSecEncryptedKey extends W
             encryptedKeyElement.appendChild(keyInfoElement);
         }
 
-        Element xencCipherValue = createCipherValue(document, encryptedKeyElement);
+        Element xencCipherValue = createCipherValue(getDocument(), encryptedKeyElement);
         if (storeBytesInAttachment) {
-            final String attachmentId = getIdAllocator().createId("", document);
-            WSSecurityUtil.storeBytesInAttachment(xencCipherValue, document, attachmentId,
+            final String attachmentId = getIdAllocator().createId("", getDocument());
+            WSSecurityUtil.storeBytesInAttachment(xencCipherValue, getDocument(), attachmentId,
                                                   encryptedEphemeralKey, attachmentCallbackHandler);
         } else {
             Text keyText =
-                WSSecurityUtil.createBase64EncodedTextNode(document, encryptedEphemeralKey);
+                WSSecurityUtil.createBase64EncodedTextNode(getDocument(), encryptedEphemeralKey);
             xencCipherValue.appendChild(keyText);
         }
     }
@@ -680,7 +679,7 @@ public class WSSecEncryptedKey extends W
      * Add a BinarySecurityToken
      */
     private void addBST(X509Certificate cert) throws WSSecurityException {
-        bstToken = new X509Security(document);
+        bstToken = new X509Security(getDocument());
         ((X509Security) bstToken).setX509Certificate(cert);
 
         bstAddedToSecurityHeader = false;
@@ -877,13 +876,6 @@ public class WSSecEncryptedKey extends W
     }
 
     /**
-     * @param document The document to set.
-     */
-    public void setDocument(Document document) {
-        this.document = document;
-    }
-
-    /**
      * @param encKeyId The encKeyId to set.
      */
     public void setEncKeyId(String encKeyId) {

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSAMLToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSAMLToken.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSAMLToken.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSAMLToken.java Fri Nov 25 12:31:19 2016
@@ -35,8 +35,6 @@ public class WSSecSAMLToken extends WSSe
     private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(WSSecSAMLToken.class);
 
-    private Document document;
-
     private SamlAssertionWrapper saml;
 
     private Element samlElement;
@@ -44,6 +42,10 @@ public class WSSecSAMLToken extends WSSe
     public WSSecSAMLToken(WSSecHeader securityHeader) {
         super(securityHeader);
     }
+    
+    public WSSecSAMLToken(Document doc) {
+        super(doc);
+    }
 
     /**
      * Creates a SAML token.
@@ -53,12 +55,8 @@ public class WSSecSAMLToken extends WSSe
      * <code>prepare()</code> all parameters such as user, password,
      * passwordType etc. must be set. A complete <code>UsernameToken</code> is
      * constructed.
-     *
-     * @param doc
-     *            The SOAP envelope as W3C document
      */
-    public void prepare(Document doc, SamlAssertionWrapper samlAssertion) {
-        document = doc;
+    public void prepare(SamlAssertionWrapper samlAssertion) {
         saml = samlAssertion;
     }
 
@@ -90,7 +88,7 @@ public class WSSecSAMLToken extends WSSe
         if (saml == null) {
             return null;
         }
-        samlElement = saml.toDOM(document);
+        samlElement = saml.toDOM(getDocument());
         return samlElement;
     }
 
@@ -115,16 +113,15 @@ public class WSSecSAMLToken extends WSSe
      * A complete <code>SAMLAssertion</code> is added to the
      * <code>wsse:Security</code> header.
      *
-     * @param doc      The SOAP envelope as W3C document
      * @param samlAssertion TODO
      * @return Document with UsernameToken added
      */
-    public Document build(Document doc, SamlAssertionWrapper samlAssertion) {
+    public Document build(SamlAssertionWrapper samlAssertion) {
         LOG.debug("Begin add SAMLAssertion token...");
 
-        prepare(doc, samlAssertion);
+        prepare(samlAssertion);
         prependToHeader();
 
-        return doc;
+        return getDocument();
     }
 }

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSecurityContextToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSecurityContextToken.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSecurityContextToken.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSecurityContextToken.java Fri Nov 25 12:31:19 2016
@@ -59,13 +59,25 @@ public class WSSecSecurityContextToken {
     private int wscVersion = ConversationConstants.DEFAULT_VERSION;
     private WSSConfig wssConfig;
     private final WSSecHeader securityHeader;
+    private final Document doc;
 
     public WSSecSecurityContextToken(WSSecHeader securityHeader, WSSConfig config) {
         this.securityHeader = securityHeader;
+        if (securityHeader != null && securityHeader.getSecurityHeaderElement() != null) {
+            doc = securityHeader.getSecurityHeaderElement().getOwnerDocument();
+        } else {
+            doc = null;
+        }
+        wssConfig = config;
+    }
+    
+    public WSSecSecurityContextToken(Document doc, WSSConfig config) {
+        this.securityHeader = null;
+        this.doc = doc;
         wssConfig = config;
     }
 
-    public void prepare(Document doc, Crypto crypto) throws WSSecurityException {
+    public void prepare(Crypto crypto) throws WSSecurityException {
 
         if (sct == null) {
             if (identifier != null) {
@@ -83,7 +95,7 @@ public class WSSecSecurityContextToken {
         sct.setID(sctId);
     }
 
-    public void prependSCTElementToHeader(Document doc)
+    public void prependSCTElementToHeader()
         throws WSSecurityException {
         Element secHeaderElement = securityHeader.getSecurityHeaderElement();
         WSSecurityUtil.prependChildElement(secHeaderElement, sct.getElement());

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignature.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignature.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignature.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignature.java Fri Nov 25 12:31:19 2016
@@ -84,7 +84,6 @@ public class WSSecSignature extends WSSe
     protected CanonicalizationMethod c14nMethod;
     protected XMLSignature sig;
     protected byte[] secretKey;
-    protected Document document;
     protected WSDocInfo wsDocInfo;
     protected String strUri;
     protected Element bstToken;
@@ -111,6 +110,11 @@ public class WSSecSignature extends WSSe
         super(securityHeader);
         init();
     }
+    
+    public WSSecSignature(Document doc) {
+        super(doc);
+        init();
+    }
 
     private void init() {
         // Try to install the Santuario Provider - fall back to the JDK provider if this does
@@ -132,19 +136,17 @@ public class WSSecSignature extends WSSe
      * This method does not add the Signature element to the security header.
      * See <code>prependSignatureElementToHeader()</code> method.
      *
-     * @param doc The SOAP envelope as <code>Document</code>
      * @param cr An instance of the Crypto API to handle keystore and certificates
      * @throws WSSecurityException
      */
-    public void prepare(Document doc, Crypto cr)
+    public void prepare(Crypto cr)
         throws WSSecurityException {
         //
         // Gather some info about the document to process and store it for
         // retrieval
         //
         crypto = cr;
-        document = doc;
-        wsDocInfo = new WSDocInfo(doc);
+        wsDocInfo = new WSDocInfo(getDocument());
         wsDocInfo.setCrypto(cr);
 
         //
@@ -171,7 +173,7 @@ public class WSSecSignature extends WSSe
 
         keyInfoUri = getIdAllocator().createSecureId("KI-", keyInfo);
         if (!useCustomSecRef) {
-            secRef = new SecurityTokenReference(doc);
+            secRef = new SecurityTokenReference(getDocument());
             strUri = getIdAllocator().createSecureId("STR-", secRef);
             secRef.addWSSENamespace();
             secRef.addWSUNamespace();
@@ -186,7 +188,7 @@ public class WSSecSignature extends WSSe
             //
             switch (keyIdentifierType) {
             case WSConstants.BST_DIRECT_REFERENCE:
-                Reference ref = new Reference(document);
+                Reference ref = new Reference(getDocument());
                 ref.setURI("#" + certUri);
 
                 addBST(certs);
@@ -203,8 +205,8 @@ public class WSSecSignature extends WSSe
                 String issuer = certs[0].getIssuerX500Principal().getName();
                 java.math.BigInteger serialNumber = certs[0].getSerialNumber();
                 DOMX509IssuerSerial domIssuerSerial =
-                    new DOMX509IssuerSerial(doc, issuer, serialNumber);
-                DOMX509Data domX509Data = new DOMX509Data(doc, domIssuerSerial);
+                    new DOMX509IssuerSerial(getDocument(), issuer, serialNumber);
+                DOMX509Data domX509Data = new DOMX509Data(getDocument(), domIssuerSerial);
                 secRef.setUnknownElement(domX509Data.getElement());
 
                 if (includeSignatureToken) {
@@ -243,7 +245,7 @@ public class WSSecSignature extends WSSe
                 break;
 
             case WSConstants.CUSTOM_SYMM_SIGNING :
-                Reference refCust = new Reference(document);
+                Reference refCust = new Reference(getDocument());
                 if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customTokenValueType)) {
                     secRef.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
                     refCust.setValueType(customTokenValueType);
@@ -263,7 +265,7 @@ public class WSSecSignature extends WSSe
                 break;
 
             case WSConstants.CUSTOM_SYMM_SIGNING_DIRECT :
-                Reference refCustd = new Reference(document);
+                Reference refCustd = new Reference(getDocument());
                 if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customTokenValueType)) {
                     secRef.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
                     refCustd.setValueType(customTokenValueType);
@@ -342,12 +344,11 @@ public class WSSecSignature extends WSSe
      * creates a Signature and puts it into the Security header. It does so by
      * calling the single functions in order to perform a <i>one shot signature</i>.
      *
-     * @param doc The unsigned SOAP envelope as <code>Document</code>
      * @param cr An instance of the Crypto API to handle keystore and certificates
      * @return A signed SOAP envelope as <code>Document</code>
      * @throws WSSecurityException
      */
-    public Document build(Document doc, Crypto cr)
+    public Document build(Crypto cr)
         throws WSSecurityException {
         doDebug = LOG.isDebugEnabled();
 
@@ -355,9 +356,9 @@ public class WSSecSignature extends WSSe
             LOG.debug("Beginning signing...");
         }
 
-        prepare(doc, cr);
+        prepare(cr);
         if (getParts().isEmpty()) {
-            getParts().add(WSSecurityUtil.getDefaultEncryptionPart(document));
+            getParts().add(WSSecurityUtil.getDefaultEncryptionPart(getDocument()));
         } else {
             for (WSEncryptionPart part : getParts()) {
                 if (part.getId() == null && "STRTransform".equals(part.getName())) {
@@ -378,7 +379,7 @@ public class WSSecSignature extends WSSe
             prependBSTElementToHeader();
         }
 
-        return doc;
+        return getDocument();
     }
 
 
@@ -393,7 +394,7 @@ public class WSSecSignature extends WSSe
     ) throws WSSecurityException {
         return
             addReferencesToSign(
-                document,
+                getDocument(),
                 references,
                 wsDocInfo,
                 signatureFactory,
@@ -421,7 +422,7 @@ public class WSSecSignature extends WSSe
     private void addBST(X509Certificate[] certs) throws WSSecurityException {
         if (storeBytesInAttachment) {
             bstToken =
-                document.createElementNS(WSS4JConstants.WSSE_NS, "wsse:BinarySecurityToken");
+                getDocument().createElementNS(WSS4JConstants.WSSE_NS, "wsse:BinarySecurityToken");
             bstToken.setAttributeNS(null, "EncodingType", WSS4JConstants.BASE64_ENCODING);
             bstToken.setAttributeNS(WSS4JConstants.WSU_NS, WSS4JConstants.WSU_PREFIX + ":Id", certUri);
 
@@ -440,17 +441,17 @@ public class WSSecSignature extends WSSe
                 }
             }
 
-            final String attachmentId = getIdAllocator().createId("", document);
-            WSSecurityUtil.storeBytesInAttachment(bstToken, document, attachmentId,
+            final String attachmentId = getIdAllocator().createId("", getDocument());
+            WSSecurityUtil.storeBytesInAttachment(bstToken, getDocument(), attachmentId,
                                                   certBytes, attachmentCallbackHandler);
             wsDocInfo.addTokenElement(bstToken, false);
         } else {
             BinarySecurity binarySecurity = null;
             if (!useSingleCert) {
-                binarySecurity = new PKIPathSecurity(document);
+                binarySecurity = new PKIPathSecurity(getDocument());
                 ((PKIPathSecurity) binarySecurity).setX509Certificates(certs, crypto);
             } else {
-                binarySecurity = new X509Security(document);
+                binarySecurity = new X509Security(getDocument());
                 ((X509Security) binarySecurity).setX509Certificate(certs[0]);
             }
             binarySecurity.setID(certUri);

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureBase.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureBase.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureBase.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureBase.java Fri Nov 25 12:31:19 2016
@@ -60,6 +60,10 @@ public class WSSecSignatureBase extends
     public WSSecSignatureBase(WSSecHeader securityHeader) {
         super(securityHeader);
     }
+    
+    public WSSecSignatureBase(Document doc) {
+        super(doc);
+    }
 
     /**
      * This method adds references to the Signature.

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureConfirmation.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureConfirmation.java?rev=1771308&r1=1771307&r2=1771308&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureConfirmation.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureConfirmation.java Fri Nov 25 12:31:19 2016
@@ -38,6 +38,10 @@ public class WSSecSignatureConfirmation
     public WSSecSignatureConfirmation(WSSecHeader securityHeader) {
         super(securityHeader);
     }
+    
+    public WSSecSignatureConfirmation(Document doc) {
+        super(doc);
+    }
 
     /**
      * Set the Signature value to store in this SignatureConfirmation.
@@ -55,11 +59,9 @@ public class WSSecSignatureConfirmation
      * The method prepares and initializes a WSSec SignatureConfirmation structure after
      * the relevant information was set. Before calling <code>prepare()</code> the
      * filed <code>signatureValue</code> must be set
-     *
-     * @param doc The SOAP envelope as W3C document
      */
-    public void prepare(Document doc) {
-        sc = new SignatureConfirmation(doc, signatureValue);
+    public void prepare() {
+        sc = new SignatureConfirmation(getDocument(), signatureValue);
         sc.setID(getIdAllocator().createId("SC-", sc));
     }
 
@@ -82,18 +84,17 @@ public class WSSecSignatureConfirmation
      * A complete <code>SignatureConfirmation</code> is constructed and added
      * to the <code>wsse:Security</code> header.
      *
-     * @param doc The SOAP envelope as W3C document
      * @param sigVal the Signature value. This will be the content of the "Value" attribute.
      * @return Document with SignatureConfirmation added
      */
-    public Document build(Document doc, byte[] sigVal) {
+    public Document build(byte[] sigVal) {
         LOG.debug("Begin add signature confirmation...");
 
         signatureValue = sigVal;
-        prepare(doc);
+        prepare();
         prependToHeader();
 
-        return doc;
+        return getDocument();
     }
 
     /**




Mime
View raw message