ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1771303 [1/2] - in /webservices/wss4j/trunk/ws-security-dom/src: main/java/org/apache/wss4j/dom/action/ main/java/org/apache/wss4j/dom/message/ main/java/org/apache/wss4j/dom/processor/ main/java/org/apache/wss4j/dom/saml/ test/java/org/ap...
Date Fri, 25 Nov 2016 12:30:06 GMT
Author: coheigea
Date: Fri Nov 25 12:30:06 2016
New Revision: 1771303

URL: http://svn.apache.org/viewvc?rev=1771303&view=rev
Log:
Refactoring WSSecBase

Modified:
    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/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/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/WSSecHeader.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/processor/EncryptedAssertionProcessor.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/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/handler/SignatureConfirmationTest.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/message/token/BinarySecurityTokenTest.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/validate/ValidatorTest.java

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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -30,13 +30,14 @@ import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.dom.handler.RequestData;
 import org.apache.wss4j.dom.message.WSSecDerivedKeyBase;
 import org.apache.wss4j.dom.message.WSSecEncryptedKey;
+import org.apache.wss4j.dom.message.WSSecHeader;
 import org.apache.wss4j.dom.message.token.SecurityContextToken;
 import org.apache.xml.security.stax.impl.util.IDGenerator;
 
 public abstract class AbstractDerivedAction {
 
     protected Node findEncryptedKeySibling(RequestData reqData) {
-        Element secHeader = reqData.getSecHeader().getSecurityHeader();
+        Element secHeader = reqData.getSecHeader().getSecurityHeaderElement();
         return findSibling(secHeader, WSConstants.ENC_NS, "EncryptedKey");
     }
 
@@ -45,7 +46,7 @@ public abstract class AbstractDerivedAct
         if (!reqData.isUse200512Namespace()) {
             namespace = ConversationConstants.WSC_NS_05_02;
         }
-        Element secHeader = reqData.getSecHeader().getSecurityHeader();
+        Element secHeader = reqData.getSecHeader().getSecurityHeaderElement();
         return findSibling(secHeader, namespace, "SecurityContextToken");
     }
 
@@ -103,6 +104,7 @@ public abstract class AbstractDerivedAct
     }
 
     protected Element setupEKReference(WSSecDerivedKeyBase derivedKeyBase,
+                                       WSSecHeader securityHeader,
                                         WSPasswordCallback passwordCallback,
                                         SignatureEncryptionActionToken actionToken,
                                         SignatureEncryptionActionToken previousActionToken,
@@ -120,7 +122,7 @@ public abstract class AbstractDerivedAct
             derivedKeyBase.setExternalKey(ek, tokenIdentifier);
             return null;
         } else {
-            WSSecEncryptedKey encrKeyBuilder = new WSSecEncryptedKey();
+            WSSecEncryptedKey encrKeyBuilder = new WSSecEncryptedKey(securityHeader);
             encrKeyBuilder.setUserInfo(actionToken.getUser());
             if (actionToken.getDerivedKeyIdentifier() != 0) {
                 encrKeyBuilder.setKeyIdentifierType(actionToken.getDerivedKeyIdentifier());

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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -63,7 +63,7 @@ public class CustomTokenAction implement
             );
         }
 
-        Element securityHeader = reqData.getSecHeader().getSecurityHeader();
+        Element securityHeader = reqData.getSecHeader().getSecurityHeaderElement();
         securityHeader.appendChild(securityHeader.getOwnerDocument().adoptNode(customToken));
     }
 }

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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -40,7 +40,7 @@ public class EncryptionAction implements
     public void execute(WSHandler handler, SecurityActionToken actionToken,
                         Document doc, RequestData reqData)
             throws WSSecurityException {
-        WSSecEncrypt wsEncrypt = new WSSecEncrypt();
+        WSSecEncrypt wsEncrypt = new WSSecEncrypt(reqData.getSecHeader());
         wsEncrypt.setIdAllocator(reqData.getWssConfig().getIdAllocator());
 
         EncryptionActionToken encryptionToken = null;
@@ -123,7 +123,7 @@ public class EncryptionAction implements
         wsEncrypt.setStoreBytesInAttachment(reqData.isStoreBytesInAttachment());
 
         try {
-            wsEncrypt.build(doc, encryptionToken.getCrypto(), reqData.getSecHeader());
+            wsEncrypt.build(doc, 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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -58,7 +58,7 @@ public class EncryptionDerivedAction ext
 
         WSPasswordCallback passwordCallback =
             handler.getPasswordCB(encryptionToken.getUser(), WSConstants.DKT_ENCR, callbackHandler, reqData);
-        WSSecDKEncrypt wsEncrypt = new WSSecDKEncrypt();
+        WSSecDKEncrypt wsEncrypt = new WSSecDKEncrypt(reqData.getSecHeader());
         wsEncrypt.setIdAllocator(reqData.getWssConfig().getIdAllocator());
 
         if (encryptionToken.getKeyIdentifierId() != 0) {
@@ -107,17 +107,17 @@ public class EncryptionDerivedAction ext
                 nextSibling = findSCTSibling(reqData);
             }
             if (nextSibling == null) {
-                wsEncrypt.prependDKElementToHeader(reqData.getSecHeader());
+                wsEncrypt.prependDKElementToHeader();
             } else {
-                reqData.getSecHeader().getSecurityHeader().insertBefore(
+                reqData.getSecHeader().getSecurityHeaderElement().insertBefore(
                     wsEncrypt.getdktElement(), nextSibling);
             }
 
             // Add the ReferenceList to the security header
-            wsEncrypt.addExternalRefElement(externRefList, reqData.getSecHeader());
+            wsEncrypt.addExternalRefElement(externRefList);
 
             if (tokenElement != null) {
-                WSSecurityUtil.prependChildElement(reqData.getSecHeader().getSecurityHeader(), tokenElement);
+                WSSecurityUtil.prependChildElement(reqData.getSecHeader().getSecurityHeaderElement(), tokenElement);
             }
 
         } catch (WSSecurityException e) {
@@ -137,7 +137,7 @@ public class EncryptionDerivedAction ext
             return setupSCTReference(wsEncrypt, passwordCallback, encryptionToken, reqData.getSignatureToken(),
                                      reqData.isUse200512Namespace(), doc);
         } else {
-            return setupEKReference(wsEncrypt, passwordCallback, encryptionToken, reqData.getSignatureToken(),
+            return setupEKReference(wsEncrypt, reqData.getSecHeader(), passwordCallback, encryptionToken, reqData.getSignatureToken(),
                                      reqData.isUse200512Namespace(), doc, encryptionToken.getKeyTransportAlgorithm(),
                                      encryptionToken.getMgfAlgorithm());
         }

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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -84,7 +84,7 @@ public class SAMLTokenSignedAction imple
                 samlCallback.getSignatureDigestAlgorithm()
             );
         }
-        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
+        WSSecSignatureSAML wsSign = new WSSecSignatureSAML(reqData.getSecHeader());
         wsSign.setIdAllocator(reqData.getWssConfig().getIdAllocator());
         wsSign.setAddInclusivePrefixes(reqData.isAddInclusivePrefixes());
 
@@ -126,8 +126,7 @@ public class SAMLTokenSignedAction imple
                     samlAssertion,
                     samlCallback.getIssuerCrypto(),
                     samlCallback.getIssuerKeyName(),
-                    samlCallback.getIssuerKeyPassword(),
-                    reqData.getSecHeader());
+                    samlCallback.getIssuerKeyPassword());
             reqData.getSignatureValues().add(wsSign.getSignatureValue());
         } catch (WSSecurityException e) {
             throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e, "empty",

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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -37,7 +37,7 @@ public class SAMLTokenUnsignedAction imp
     public void execute(WSHandler handler, SecurityActionToken actionToken,
                         Document doc, RequestData reqData)
             throws WSSecurityException {
-        WSSecSAMLToken builder = new WSSecSAMLToken();
+        WSSecSAMLToken builder = new WSSecSAMLToken(reqData.getSecHeader());
         builder.setIdAllocator(reqData.getWssConfig().getIdAllocator());
 
         CallbackHandler samlCallbackHandler =
@@ -68,6 +68,6 @@ public class SAMLTokenUnsignedAction imp
         }
 
         // add the SAMLAssertion Token to the SOAP Envelope
-        builder.build(doc, samlAssertion, reqData.getSecHeader());
+        builder.build(doc, 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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -57,7 +57,7 @@ public class SignatureAction implements
 
         WSPasswordCallback passwordCallback =
             handler.getPasswordCB(signatureToken.getUser(), WSConstants.SIGN, callbackHandler, reqData);
-        WSSecSignature wsSign = new WSSecSignature();
+        WSSecSignature wsSign = new WSSecSignature(reqData.getSecHeader());
         wsSign.setIdAllocator(reqData.getWssConfig().getIdAllocator());
         wsSign.setAddInclusivePrefixes(reqData.isAddInclusivePrefixes());
 
@@ -101,7 +101,7 @@ public class SignatureAction implements
         wsSign.setStoreBytesInAttachment(reqData.isStoreBytesInAttachment());
 
         try {
-            wsSign.prepare(doc, signatureToken.getCrypto(), reqData.getSecHeader());
+            wsSign.prepare(doc, signatureToken.getCrypto());
 
             Element siblingElementToPrepend = null;
             boolean signBST = false;
@@ -115,7 +115,7 @@ public class SignatureAction implements
                         reqData.getOriginalSignatureActionPosition();
                     // Need to figure out where to put the Signature Element in the header
                     if (originalSignatureActionIndex > 0) {
-                        Element secHeader = reqData.getSecHeader().getSecurityHeader();
+                        Element secHeader = reqData.getSecHeader().getSecurityHeaderElement();
                         Node lastChild = secHeader.getLastChild();
                         int count = 0;
                         while (lastChild != null && count < originalSignatureActionIndex) {
@@ -135,7 +135,7 @@ public class SignatureAction implements
             }
 
             if (signBST) {
-                wsSign.prependBSTElementToHeader(reqData.getSecHeader());
+                wsSign.prependBSTElementToHeader();
             }
 
             List<WSEncryptionPart> parts = signatureToken.getParts();
@@ -144,8 +144,7 @@ public class SignatureAction implements
                 parts.add(WSSecurityUtil.getDefaultEncryptionPart(doc));
             }
 
-            List<javax.xml.crypto.dsig.Reference> referenceList =
-                wsSign.addReferencesToSign(parts, reqData.getSecHeader());
+            List<javax.xml.crypto.dsig.Reference> referenceList = wsSign.addReferencesToSign(parts);
 
             if (signBST 
                 || reqData.isAppendSignatureAfterTimestamp() && siblingElementToPrepend == null) {
@@ -155,7 +154,7 @@ public class SignatureAction implements
             }
 
             if (!signBST) {
-                wsSign.prependBSTElementToHeader(reqData.getSecHeader());
+                wsSign.prependBSTElementToHeader();
             }
             reqData.getSignatureValues().add(wsSign.getSignatureValue());
         } catch (WSSecurityException e) {

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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -57,7 +57,7 @@ public class SignatureConfirmationAction
         //
         // prepare a SignatureConfirmation token
         //
-        WSSecSignatureConfirmation wsc = new WSSecSignatureConfirmation();
+        WSSecSignatureConfirmation wsc = new WSSecSignatureConfirmation(reqData.getSecHeader());
         wsc.setIdAllocator(reqData.getWssConfig().getIdAllocator());
         SignatureActionToken signatureToken = (SignatureActionToken)actionToken;
         if (signatureToken == null) {
@@ -81,7 +81,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, reqData.getSecHeader());
+                    wsc.build(doc, sigVal);
                     signatureParts.add(new WSEncryptionPart(wsc.getId()));
                     signatureAdded = true;
                 }
@@ -89,7 +89,7 @@ public class SignatureConfirmationAction
         }
 
         if (!signatureAdded) {
-            wsc.build(doc, null, reqData.getSecHeader());
+            wsc.build(doc, 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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -59,7 +59,7 @@ public class SignatureDerivedAction exte
 
         WSPasswordCallback passwordCallback =
             handler.getPasswordCB(signatureToken.getUser(), WSConstants.DKT_SIGN, callbackHandler, reqData);
-        WSSecDKSign wsSign = new WSSecDKSign();
+        WSSecDKSign wsSign = new WSSecDKSign(reqData.getSecHeader());
         wsSign.setIdAllocator(reqData.getWssConfig().getIdAllocator());
         wsSign.setAddInclusivePrefixes(reqData.isAddInclusivePrefixes());
 
@@ -97,10 +97,9 @@ public class SignatureDerivedAction exte
                 wsSign.getParts().add(WSSecurityUtil.getDefaultEncryptionPart(doc));
             }
 
-            wsSign.prepare(doc, reqData.getSecHeader());
+            wsSign.prepare(doc);
 
-            List<javax.xml.crypto.dsig.Reference> referenceList =
-                wsSign.addReferencesToSign(parts, reqData.getSecHeader());
+            List<javax.xml.crypto.dsig.Reference> referenceList = wsSign.addReferencesToSign(parts);
 
             // Put the DerivedKeyToken Element in the right place in the security header
             Node nextSibling = null;
@@ -119,14 +118,14 @@ public class SignatureDerivedAction exte
             }
 
             if (nextSibling == null) {
-                wsSign.prependDKElementToHeader(reqData.getSecHeader());
+                wsSign.prependDKElementToHeader();
             } else {
-                reqData.getSecHeader().getSecurityHeader().insertBefore(
+                reqData.getSecHeader().getSecurityHeaderElement().insertBefore(
                     wsSign.getdktElement(), wsSign.getSignatureElement());
             }
 
             if (tokenElement != null) {
-                WSSecurityUtil.prependChildElement(reqData.getSecHeader().getSecurityHeader(), tokenElement);
+                WSSecurityUtil.prependChildElement(reqData.getSecHeader().getSecurityHeaderElement(), tokenElement);
             }
 
             reqData.getSignatureValues().add(wsSign.getSignatureValue());
@@ -144,7 +143,7 @@ public class SignatureDerivedAction exte
         String derivedKeyTokenReference = signatureToken.getDerivedKeyTokenReference();
 
         if ("EncryptedKey".equals(derivedKeyTokenReference)) {
-            return setupEKReference(wsSign, passwordCallback, signatureToken, reqData.getEncryptionToken(),
+            return setupEKReference(wsSign, reqData.getSecHeader(), passwordCallback, signatureToken, reqData.getEncryptionToken(),
                                      reqData.isUse200512Namespace(), doc, null, null);
         } else if ("SecurityContextToken".equals(derivedKeyTokenReference)) {
             return setupSCTReference(wsSign, passwordCallback, signatureToken, reqData.getEncryptionToken(),

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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -34,11 +34,11 @@ public class TimestampAction implements
         //
         // add the Timestamp to the SOAP Envelope
         //
-        WSSecTimestamp timeStampBuilder = new WSSecTimestamp();
+        WSSecTimestamp timeStampBuilder = new WSSecTimestamp(reqData.getSecHeader());
         timeStampBuilder.setIdAllocator(reqData.getWssConfig().getIdAllocator());
         timeStampBuilder.setPrecisionInMilliSeconds(reqData.isPrecisionInMilliSeconds());
         timeStampBuilder.setTimeToLive(reqData.getTimeStampTTL());
         timeStampBuilder.setWsTimeSource(reqData.getWssConfig().getCurrentTime());
-        timeStampBuilder.build(doc, reqData.getSecHeader());
+        timeStampBuilder.build(doc);
     }
 }

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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -50,7 +50,7 @@ public class UsernameTokenAction impleme
             throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noUser");
         }
 
-        WSSecUsernameToken builder = new WSSecUsernameToken();
+        WSSecUsernameToken builder = new WSSecUsernameToken(reqData.getSecHeader());
         builder.setIdAllocator(reqData.getWssConfig().getIdAllocator());
         builder.setPrecisionInMilliSeconds(reqData.isPrecisionInMilliSeconds());
         builder.setWsTimeSource(reqData.getWssConfig().getCurrentTime());
@@ -66,6 +66,6 @@ public class UsernameTokenAction impleme
             builder.addCreated();
         }
 
-        builder.build(doc, reqData.getSecHeader());
+        builder.build(doc);
     }
 }

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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -59,7 +59,7 @@ public class UsernameTokenSignedAction i
             throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noUser");
         }
 
-        WSSecUsernameToken builder = new WSSecUsernameToken();
+        WSSecUsernameToken builder = new WSSecUsernameToken(reqData.getSecHeader());
         builder.setIdAllocator(reqData.getWssConfig().getIdAllocator());
         builder.setPrecisionInMilliSeconds(reqData.isPrecisionInMilliSeconds());
         builder.setWsTimeSource(reqData.getWssConfig().getCurrentTime());
@@ -97,7 +97,7 @@ public class UsernameTokenSignedAction i
             signatureToken = reqData.getSignatureToken();
         }
 
-        WSSecSignature sign = new WSSecSignature();
+        WSSecSignature sign = new WSSecSignature(reqData.getSecHeader());
         sign.setIdAllocator(reqData.getWssConfig().getIdAllocator());
         sign.setAddInclusivePrefixes(reqData.isAddInclusivePrefixes());
 
@@ -115,7 +115,7 @@ public class UsernameTokenSignedAction i
             sign.setSignatureAlgorithm(WSConstants.HMAC_SHA1);
         }
 
-        sign.prepare(doc, null, reqData.getSecHeader());
+        sign.prepare(doc, null);
 
         // prepend in this order: first the Signature Element and then the
         // UsernameToken Element. This way the server gets the UsernameToken
@@ -130,8 +130,7 @@ public class UsernameTokenSignedAction i
             parts = new ArrayList<>(1);
             parts.add(WSSecurityUtil.getDefaultEncryptionPart(doc));
         }
-        List<javax.xml.crypto.dsig.Reference> referenceList =
-            sign.addReferencesToSign(parts, reqData.getSecHeader());
+        List<javax.xml.crypto.dsig.Reference> referenceList = sign.addReferencesToSign(parts);
 
         try {
             sign.computeSignature(referenceList);
@@ -141,6 +140,6 @@ public class UsernameTokenSignedAction i
                     "empty", new Object[] {"WSHandler: Error during UsernameTokenSignature"}
             );
         }
-        builder.prependToHeader(reqData.getSecHeader());
+        builder.prependToHeader();
     }
 }

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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -50,9 +50,14 @@ public class WSSecBase {
 
     private WsuIdAllocator idAllocator;
     private final List<WSEncryptionPart> parts = new ArrayList<>();
+    private final WSSecHeader securityHeader;
 
-
-    public WSSecBase() {
+    public WSSecBase(WSSecHeader securityHeader) {
+        this.securityHeader = securityHeader;
+    }
+    
+    public WSSecHeader getSecurityHeader() {
+        return securityHeader;
     }
 
     /**

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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -51,8 +51,8 @@ public class WSSecDKEncrypt extends WSSe
     
     private Serializer encryptionSerializer;
     
-    public WSSecDKEncrypt() {
-        super();
+    public WSSecDKEncrypt(WSSecHeader securityHeader) {
+        super(securityHeader);
     }
 
     @Override
@@ -62,7 +62,7 @@ public class WSSecDKEncrypt extends WSSe
         attachmentEncryptedDataElements = new ArrayList<>();
     }
 
-    public Document build(Document doc, WSSecHeader secHeader) throws WSSecurityException {
+    public Document build(Document doc) throws WSSecurityException {
 
         //
         // Setup the encrypted key
@@ -71,44 +71,35 @@ public class WSSecDKEncrypt extends WSSe
         //
         // prepend elements in the right order to the security header
         //
-        prependDKElementToHeader(secHeader);
+        prependDKElementToHeader();
 
-        Element externRefList = encrypt(secHeader);
+        Element externRefList = encrypt();
 
-        addAttachmentEncryptedDataElements(secHeader);
+        addAttachmentEncryptedDataElements();
 
-        addExternalRefElement(externRefList, secHeader);
+        addExternalRefElement(externRefList);
 
         return doc;
     }
 
-    public void addAttachmentEncryptedDataElements(WSSecHeader secHeader) {
+    public void addAttachmentEncryptedDataElements() {
         if (attachmentEncryptedDataElements != null) {
             for (int i = 0; i < attachmentEncryptedDataElements.size(); i++) {
                 Element encryptedData = attachmentEncryptedDataElements.get(i);
-                WSSecurityUtil.prependChildElement(
-                        secHeader.getSecurityHeader(), encryptedData
-                );
+                Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
+                WSSecurityUtil.prependChildElement(securityHeaderElement, encryptedData);
             }
         }
     }
 
     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(), secHeader);
+        return encryptForExternalRef(null, getParts());
     }
     
-    public Element encryptForExternalRef(Element dataRef, List<WSEncryptionPart> references) throws WSSecurityException {
-        return encryptForExternalRef(dataRef, references, null);
-    }
-
     /**
      * Encrypt one or more parts or elements of the message (external).
      *
@@ -127,11 +118,10 @@ 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, WSSecHeader secHeader)
+    public Element encryptForExternalRef(Element dataRef, List<WSEncryptionPart> references)
         throws WSSecurityException {
 
         KeyInfo keyInfo = createKeyInfo();
@@ -140,7 +130,7 @@ public class WSSecDKEncrypt extends WSSe
 
         List<String> encDataRefs =
             WSSecEncrypt.doEncryption(
-                document, secHeader, getIdAllocator(), keyInfo, key, symEncAlgo, references, callbackLookup,
+                document, getSecurityHeader(), getIdAllocator(), keyInfo, key, symEncAlgo, references, callbackLookup,
                 attachmentCallbackHandler, attachmentEncryptedDataElements, storeBytesInAttachment,
                 encryptionSerializer
             );
@@ -186,17 +176,17 @@ public class WSSecDKEncrypt extends WSSe
      * reference element in the SecurityHeader.
      *
      * @param referenceList The external <code>enc:Reference</code> element
-     * @param secHeader The security header.
      */
-    public void addExternalRefElement(Element referenceList, WSSecHeader secHeader) {
+    public void addExternalRefElement(Element referenceList) {
         if (referenceList != null) {
             Node node = getdktElement().getNextSibling();
+            Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
             if (node != null && Node.ELEMENT_NODE == node.getNodeType()) {
-                secHeader.getSecurityHeader().insertBefore(referenceList, node);
+                securityHeaderElement.insertBefore(referenceList, node);
             } else {
                 // If (at this moment) DerivedKeyToken is the LAST element of
                 // the security header
-                secHeader.getSecurityHeader().appendChild(referenceList);
+                securityHeaderElement.appendChild(referenceList);
             }
         }
     }

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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -73,12 +73,11 @@ public class WSSecDKSign extends WSSecDe
     private XMLSignature sig;
     private KeyInfo keyInfo;
     private CanonicalizationMethod c14nMethod;
-    private Element securityHeader;
     private int derivedKeyLength = -1;
     private boolean addInclusivePrefixes = true;
 
-    public WSSecDKSign() {
-        super();
+    public WSSecDKSign(WSSecHeader securityHeader) {
+        super(securityHeader);
         init();
     }
 
@@ -92,9 +91,9 @@ public class WSSecDKSign extends WSSecDe
         }
     }
 
-    public Document build(Document doc, WSSecHeader secHeader) throws WSSecurityException {
+    public Document build(Document doc) throws WSSecurityException {
 
-        prepare(doc, secHeader);
+        prepare(doc);
         if (getParts().isEmpty()) {
             getParts().add(WSSecurityUtil.getDefaultEncryptionPart(document));
         } else {
@@ -105,29 +104,28 @@ public class WSSecDKSign extends WSSecDe
             }
         }
 
-        List<javax.xml.crypto.dsig.Reference> referenceList =
-            addReferencesToSign(getParts(), secHeader);
+        List<javax.xml.crypto.dsig.Reference> referenceList = addReferencesToSign(getParts());
         computeSignature(referenceList);
 
         //
         // prepend elements in the right order to the security header
         //
-        prependDKElementToHeader(secHeader);
+        prependDKElementToHeader();
 
         return doc;
     }
 
-    public void prepare(Document doc, WSSecHeader secHeader) throws WSSecurityException {
+    public void prepare(Document doc) throws WSSecurityException {
         super.prepare(doc);
         wsDocInfo = new WSDocInfo(doc);
-        securityHeader = secHeader.getSecurityHeader();
         sig = null;
 
         try {
             C14NMethodParameterSpec c14nSpec = null;
             if (addInclusivePrefixes && canonAlgo.equals(WSConstants.C14N_EXCL_OMIT_COMMENTS)) {
+                Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
                 List<String> prefixes =
-                    getInclusivePrefixes(secHeader.getSecurityHeader(), false);
+                    getInclusivePrefixes(securityHeaderElement, false);
                 c14nSpec = new ExcC14NParameterSpec(prefixes);
             }
 
@@ -169,9 +167,10 @@ public class WSSecDKSign extends WSSecDe
      * @return The DOM Element of the signature.
      */
     public Element getSignatureElement() {
+        Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
         return
             XMLUtils.getDirectChildElement(
-                securityHeader, WSConstants.SIG_LN, WSConstants.SIG_NS
+                securityHeaderElement, WSConstants.SIG_LN, WSConstants.SIG_NS
             );
     }
 
@@ -179,12 +178,10 @@ public class WSSecDKSign extends WSSecDe
      * This method adds references to the Signature.
      *
      * @param references The list of references to sign
-     * @param secHeader The Security Header
      * @throws WSSecurityException
      */
     public List<javax.xml.crypto.dsig.Reference> addReferencesToSign(
-        List<WSEncryptionPart> references,
-        WSSecHeader secHeader
+        List<WSEncryptionPart> references
     ) throws WSSecurityException {
         return
             addReferencesToSign(
@@ -192,7 +189,6 @@ public class WSSecDKSign extends WSSecDe
                 references,
                 wsDocInfo,
                 signatureFactory,
-                secHeader,
                 addInclusivePrefixes,
                 digestAlgo
             );
@@ -245,17 +241,18 @@ public class WSSecDKSign extends WSSecDe
             // Figure out where to insert the signature element
             //
             XMLSignContext signContext = null;
+            Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
             if (prepend) {
                 if (siblingElement == null) {
-                    siblingElement = (Element)securityHeader.getFirstChild();
+                    siblingElement = (Element)securityHeaderElement.getFirstChild();
                 }
                 if (siblingElement == null) {
-                    signContext = new DOMSignContext(key, securityHeader);
+                    signContext = new DOMSignContext(key, securityHeaderElement);
                 } else {
-                    signContext = new DOMSignContext(key, securityHeader, siblingElement);
+                    signContext = new DOMSignContext(key, securityHeaderElement, siblingElement);
                 }
             } else {
-                signContext = new DOMSignContext(key, securityHeader);
+                signContext = new DOMSignContext(key, securityHeaderElement);
             }
 
             signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);

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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -104,8 +104,8 @@ public abstract class WSSecDerivedKeyBas
     private X509Certificate useThisCert;
     private Crypto crypto;
 
-    public WSSecDerivedKeyBase() {
-        super();
+    public WSSecDerivedKeyBase(WSSecHeader securityHeader) {
+        super(securityHeader);
         setKeyIdentifierType(0);
     }
 
@@ -303,18 +303,15 @@ public abstract class WSSecDerivedKeyBas
      * The method can be called any time after <code>prepare()</code>. This
      * allows to insert the DerivedKey element at any position in the Security
      * header.
-     *
-     * @param secHeader The security header that holds the Signature element.
      */
-    public void prependDKElementToHeader(WSSecHeader secHeader) {
-        WSSecurityUtil.prependChildElement(
-            secHeader.getSecurityHeader(), dkt.getElement()
-        );
+    public void prependDKElementToHeader() {
+        Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
+        WSSecurityUtil.prependChildElement(securityHeaderElement, dkt.getElement());
     }
 
-    public void appendDKElementToHeader(WSSecHeader secHeader) {
-        Element secHeaderElement = secHeader.getSecurityHeader();
-        secHeaderElement.appendChild(dkt.getElement());
+    public void appendDKElementToHeader() {
+        Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
+        securityHeaderElement.appendChild(dkt.getElement());
     }
 
     /**

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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -108,8 +108,8 @@ public class WSSecEncrypt extends WSSecE
     
     private Serializer encryptionSerializer;
     
-    public WSSecEncrypt() {
-        super();
+    public WSSecEncrypt(WSSecHeader securityHeader) {
+        super(securityHeader);
     }
 
     /**
@@ -185,17 +185,14 @@ public class WSSecEncrypt extends WSSecE
      *
      * This is a convenience method and for backward compatibility. The method
      * calls the single function methods in order to perform a <i>one shot
-     * encryption</i>. This method is compatible with the build method of the
-     * previous version with the exception of the additional WSSecHeader
-     * parameter.
+     * 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
-     * @param secHeader the security header element to hold the encrypted key element.
      * @return the SOAP envelope with encrypted Body as <code>Document</code>
      * @throws WSSecurityException
      */
-    public Document build(Document doc, Crypto crypto, WSSecHeader secHeader)
+    public Document build(Document doc, Crypto crypto)
         throws WSSecurityException {
         doDebug = LOG.isDebugEnabled();
 
@@ -205,17 +202,17 @@ public class WSSecEncrypt extends WSSecE
             LOG.debug("Beginning Encryption...");
         }
 
-        Element refs = encrypt(secHeader);
+        Element refs = encrypt();
 
-        addAttachmentEncryptedDataElements(secHeader);
+        addAttachmentEncryptedDataElements();
         if (getEncryptedKeyElement() != null) {
             addInternalRefElement(refs);
-            prependToHeader(secHeader);
+            prependToHeader();
         } else {
-            addExternalRefElement(refs, secHeader);
+            addExternalRefElement(refs);
         }
 
-        prependBSTElementToHeader(secHeader);
+        prependBSTElementToHeader();
 
         clean();
         LOG.debug("Encryption complete.");
@@ -223,24 +220,13 @@ 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(), secHeader);
+        return encryptForRef(null, getParts());
     }
     
-    public Element encryptForRef(
-        Element dataRef,
-        List<WSEncryptionPart> references
-    ) throws WSSecurityException {
-        return encryptForRef(dataRef, references, null);
-    }
-
     /**
      * Encrypt one or more parts or elements of the message.
      *
@@ -259,14 +245,12 @@ 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,
-        WSSecHeader secHeader
+        List<WSEncryptionPart> references
     ) throws WSSecurityException {
         KeyInfo keyInfo = createKeyInfo();
         //the sun/oracle jce provider doesn't like a foreign SecretKey impl.
@@ -275,9 +259,9 @@ public class WSSecEncrypt extends WSSecE
         SecretKeySpec secretKeySpec = new SecretKeySpec(symmetricKey.getEncoded(), symmetricKey.getAlgorithm());
         List<String> encDataRefs =
             doEncryption(
-                document, secHeader, getIdAllocator(), keyInfo, secretKeySpec, getSymmetricEncAlgorithm(), references,
-                    callbackLookup, attachmentCallbackHandler, attachmentEncryptedDataElements,
-                    storeBytesInAttachment
+                document, getSecurityHeader(), getIdAllocator(), keyInfo, secretKeySpec, getSymmetricEncAlgorithm(), 
+                references, callbackLookup, attachmentCallbackHandler, attachmentEncryptedDataElements,
+                storeBytesInAttachment
             );
         if (encDataRefs.isEmpty()) {
             return null;
@@ -325,21 +309,20 @@ public class WSSecEncrypt extends WSSecE
      * reference element in the SecurityHeader.
      *
      * @param dataRef The external <code>enc:Reference</code> element
-     * @param secHeader The security header.
      */
-    public void addExternalRefElement(Element dataRef, WSSecHeader secHeader) {
+    public void addExternalRefElement(Element dataRef) {
         if (dataRef != null) {
-            WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), dataRef);
+            Element secHeaderElement = getSecurityHeader().getSecurityHeaderElement();
+            WSSecurityUtil.prependChildElement(secHeaderElement, dataRef);
         }
     }
 
-    public void addAttachmentEncryptedDataElements(WSSecHeader secHeader) {
+    public void addAttachmentEncryptedDataElements() {
         if (attachmentEncryptedDataElements != null) {
             for (int i = 0; i < attachmentEncryptedDataElements.size(); i++) {
                 Element encryptedData = attachmentEncryptedDataElements.get(i);
-                WSSecurityUtil.prependChildElement(
-                        secHeader.getSecurityHeader(), encryptedData
-                );
+                Element secHeaderElement = getSecurityHeader().getSecurityHeaderElement();
+                WSSecurityUtil.prependChildElement(secHeaderElement, encryptedData);
             }
         }
     }
@@ -754,7 +737,7 @@ public class WSSecEncrypt extends WSSecE
         elem.appendChild(elementToEncrypt);
 
         if (securityHeader != null) {
-            NamedNodeMap map = securityHeader.getSecurityHeader().getAttributes();
+            NamedNodeMap map = securityHeader.getSecurityHeaderElement().getAttributes();
             for (int i = 0; i < map.getLength(); i++) {
                 Attr attr = (Attr)map.item(i);
                 if (WSConstants.URI_SOAP11_ENV.equals(attr.getNamespaceURI())

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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -147,8 +147,8 @@ public class WSSecEncryptedKey extends W
     private boolean includeEncryptionToken;
     private Element customEKKeyInfoElement;
 
-    public WSSecEncryptedKey() {
-        super();
+    public WSSecEncryptedKey(WSSecHeader securityHeader) {
+        super(securityHeader);
     }
 
     /**
@@ -737,11 +737,10 @@ public class WSSecEncryptedKey extends W
      * The method can be called any time after <code>prepare()</code>. This
      * allows to insert the EncryptedKey element at any position in the Security
      * header.
-     *
-     * @param secHeader The security header that holds the Signature element.
      */
-    public void prependToHeader(WSSecHeader secHeader) {
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), encryptedKeyElement);
+    public void prependToHeader() {
+        Element secHeaderElement = getSecurityHeader().getSecurityHeaderElement();
+        WSSecurityUtil.prependChildElement(secHeaderElement, encryptedKeyElement);
     }
 
     /**
@@ -751,11 +750,9 @@ public class WSSecEncryptedKey extends W
      * The method can be called any time after <code>prepare()</code>. This
      * allows to insert the EncryptedKey element at any position in the Security
      * header.
-     *
-     * @param secHeader The security header that holds the Signature element.
      */
-    public void appendToHeader(WSSecHeader secHeader) {
-        Element secHeaderElement = secHeader.getSecurityHeader();
+    public void appendToHeader() {
+        Element secHeaderElement = getSecurityHeader().getSecurityHeaderElement();
         secHeaderElement.appendChild(encryptedKeyElement);
     }
 
@@ -765,14 +762,11 @@ public class WSSecEncryptedKey extends W
      *
      * The method can be called any time after <code>prepare()</code>. This
      * allows to insert the BST element at any position in the Security header.
-     *
-     * @param secHeader The security header that holds the BST element.
      */
-    public void prependBSTElementToHeader(WSSecHeader secHeader) {
+    public void prependBSTElementToHeader() {
         if (bstToken != null && !bstAddedToSecurityHeader) {
-            WSSecurityUtil.prependChildElement(
-                secHeader.getSecurityHeader(), bstToken.getElement()
-            );
+            Element secHeaderElement = getSecurityHeader().getSecurityHeaderElement();
+            WSSecurityUtil.prependChildElement(secHeaderElement, bstToken.getElement());
             bstAddedToSecurityHeader = true;
         }
     }
@@ -783,12 +777,10 @@ public class WSSecEncryptedKey extends W
      *
      * The method can be called any time after <code>prepare()</code>. This
      * allows to insert the BST element at any position in the Security header.
-     *
-     * @param secHeader The security header that holds the BST element.
      */
-    public void appendBSTElementToHeader(WSSecHeader secHeader) {
+    public void appendBSTElementToHeader() {
         if (bstToken != null && !bstAddedToSecurityHeader) {
-            Element secHeaderElement = secHeader.getSecurityHeader();
+            Element secHeaderElement = getSecurityHeader().getSecurityHeaderElement();
             secHeaderElement.appendChild(bstToken.getElement());
             bstAddedToSecurityHeader = true;
         }

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecHeader.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecHeader.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecHeader.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecHeader.java Fri Nov 25 12:30:06 2016
@@ -98,7 +98,7 @@ public class WSSecHeader {
      *
      * @return The security header element.
      */
-    public Element getSecurityHeader() {
+    public Element getSecurityHeaderElement() {
         return securityHeader;
     }
 

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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -41,8 +41,8 @@ public class WSSecSAMLToken extends WSSe
 
     private Element samlElement;
 
-    public WSSecSAMLToken() {
-        super();
+    public WSSecSAMLToken(WSSecHeader securityHeader) {
+        super(securityHeader);
     }
 
     /**
@@ -70,14 +70,13 @@ public class WSSecSAMLToken extends WSSe
      * This allows to insert the SAML assertion at any position in the
      * Security header.
      *
-     * @param secHeader
-     *            The security header that holds the Signature element.
      */
-    public void prependToHeader(WSSecHeader secHeader) {
+    public void prependToHeader() {
         try {
             Element element = getElement();
             if (element != null) {
-                WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), element);
+                Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
+                WSSecurityUtil.prependChildElement(securityHeaderElement, element);
             }
         } catch (WSSecurityException ex) {
             throw new RuntimeException(ex.toString(), ex);
@@ -120,11 +119,11 @@ public class WSSecSAMLToken extends WSSe
      * @param samlAssertion TODO
      * @return Document with UsernameToken added
      */
-    public Document build(Document doc, SamlAssertionWrapper samlAssertion, WSSecHeader secHeader) {
+    public Document build(Document doc, SamlAssertionWrapper samlAssertion) {
         LOG.debug("Begin add SAMLAssertion token...");
 
         prepare(doc, samlAssertion);
-        prependToHeader(secHeader);
+        prependToHeader();
 
         return doc;
     }

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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -26,6 +26,7 @@ import org.apache.wss4j.dom.engine.WSSCo
 import org.apache.wss4j.dom.message.token.SecurityContextToken;
 import org.apache.wss4j.dom.util.WSSecurityUtil;
 import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 
 /**
  * Builder class to add a <code>wsc:SecurityContextToken</code> into the
@@ -57,11 +58,10 @@ public class WSSecSecurityContextToken {
 
     private int wscVersion = ConversationConstants.DEFAULT_VERSION;
     private WSSConfig wssConfig;
+    private final WSSecHeader securityHeader;
 
-    public WSSecSecurityContextToken() {
-    }
-
-    public WSSecSecurityContextToken(WSSConfig config) {
+    public WSSecSecurityContextToken(WSSecHeader securityHeader, WSSConfig config) {
+        this.securityHeader = securityHeader;
         wssConfig = config;
     }
 
@@ -83,9 +83,10 @@ public class WSSecSecurityContextToken {
         sct.setID(sctId);
     }
 
-    public void prependSCTElementToHeader(Document doc, WSSecHeader secHeader)
+    public void prependSCTElementToHeader(Document doc)
         throws WSSecurityException {
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), sct.getElement());
+        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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -102,14 +102,13 @@ public class WSSecSignature extends WSSe
     private Crypto crypto;
     private String digestAlgo = WSConstants.SHA1;
     private X509Certificate useThisCert;
-    private Element securityHeader;
     private boolean useCustomSecRef;
     private boolean bstAddedToSecurityHeader;
     private boolean includeSignatureToken;
     private boolean addInclusivePrefixes = true;
 
-    public WSSecSignature() {
-        super();
+    public WSSecSignature(WSSecHeader securityHeader) {
+        super(securityHeader);
         init();
     }
 
@@ -135,11 +134,9 @@ public class WSSecSignature extends WSSe
      *
      * @param doc The SOAP envelope as <code>Document</code>
      * @param cr An instance of the Crypto API to handle keystore and certificates
-     * @param secHeader The security header that will hold the Signature. This is used
-     *                   to construct namespace prefixes for Signature. This method
      * @throws WSSecurityException
      */
-    public void prepare(Document doc, Crypto cr, WSSecHeader secHeader)
+    public void prepare(Document doc, Crypto cr)
         throws WSSecurityException {
         //
         // Gather some info about the document to process and store it for
@@ -149,7 +146,6 @@ public class WSSecSignature extends WSSe
         document = doc;
         wsDocInfo = new WSDocInfo(doc);
         wsDocInfo.setCrypto(cr);
-        securityHeader = secHeader.getSecurityHeader();
 
         //
         // At first get the security token (certificate) according to the parameters.
@@ -159,8 +155,9 @@ public class WSSecSignature extends WSSe
         try {
             C14NMethodParameterSpec c14nSpec = null;
             if (addInclusivePrefixes && canonAlgo.equals(WSConstants.C14N_EXCL_OMIT_COMMENTS)) {
+                Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
                 List<String> prefixes =
-                    getInclusivePrefixes(secHeader.getSecurityHeader(), false);
+                    getInclusivePrefixes(securityHeaderElement, false);
                 c14nSpec = new ExcC14NParameterSpec(prefixes);
             }
 
@@ -344,16 +341,13 @@ public class WSSecSignature extends WSSe
      * This is a convenience method and for backward compatibility. The method
      * 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>.
-     * This method is compatible with the build method of the previous version
-     * with the exception of the additional WSSecHeader parameter.
      *
      * @param doc The unsigned SOAP envelope as <code>Document</code>
      * @param cr An instance of the Crypto API to handle keystore and certificates
-     * @param secHeader the security header element to hold the encrypted key element.
      * @return A signed SOAP envelope as <code>Document</code>
      * @throws WSSecurityException
      */
-    public Document build(Document doc, Crypto cr, WSSecHeader secHeader)
+    public Document build(Document doc, Crypto cr)
         throws WSSecurityException {
         doDebug = LOG.isDebugEnabled();
 
@@ -361,7 +355,7 @@ public class WSSecSignature extends WSSe
             LOG.debug("Beginning signing...");
         }
 
-        prepare(doc, cr, secHeader);
+        prepare(doc, cr);
         if (getParts().isEmpty()) {
             getParts().add(WSSecurityUtil.getDefaultEncryptionPart(document));
         } else {
@@ -372,8 +366,7 @@ public class WSSecSignature extends WSSe
             }
         }
 
-        List<javax.xml.crypto.dsig.Reference> referenceList =
-            addReferencesToSign(getParts(), secHeader);
+        List<javax.xml.crypto.dsig.Reference> referenceList = addReferencesToSign(getParts());
 
         computeSignature(referenceList);
 
@@ -382,7 +375,7 @@ public class WSSecSignature extends WSSe
         // strict layout rules.
         //
         if (bstToken != null) {
-            prependBSTElementToHeader(secHeader);
+            prependBSTElementToHeader();
         }
 
         return doc;
@@ -393,12 +386,10 @@ public class WSSecSignature extends WSSe
      * This method adds references to the Signature.
      *
      * @param references The list of references to sign
-     * @param secHeader The Security Header
      * @throws WSSecurityException
      */
     public List<javax.xml.crypto.dsig.Reference> addReferencesToSign(
-        List<WSEncryptionPart> references,
-        WSSecHeader secHeader
+        List<WSEncryptionPart> references
     ) throws WSSecurityException {
         return
             addReferencesToSign(
@@ -406,7 +397,6 @@ public class WSSecSignature extends WSSe
                 references,
                 wsDocInfo,
                 signatureFactory,
-                secHeader,
                 addInclusivePrefixes,
                 digestAlgo
             );
@@ -418,9 +408,10 @@ public class WSSecSignature extends WSSe
      * @return The DOM Element of the signature.
      */
     public Element getSignatureElement() {
+        Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
         return
             XMLUtils.getDirectChildElement(
-                securityHeader, WSConstants.SIG_LN, WSConstants.SIG_NS
+                securityHeaderElement, WSConstants.SIG_LN, WSConstants.SIG_NS
             );
     }
 
@@ -477,24 +468,22 @@ public class WSSecSignature extends WSSe
      * The method can be called any time after <code>prepare()</code>.
      * This allows to insert the BST element at any position in the Security
      * header.
-     *
-     * @param secHeader The security header
      */
-    public void prependBSTElementToHeader(WSSecHeader secHeader) {
+    public void prependBSTElementToHeader() {
         if (bstToken != null && !bstAddedToSecurityHeader) {
-            WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bstToken);
+            Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
+            WSSecurityUtil.prependChildElement(securityHeaderElement, bstToken);
             bstAddedToSecurityHeader = true;
         }
     }
 
     /**
      * Append the BinarySecurityToken to the security header.
-     * @param secHeader The security header
      */
-    public void appendBSTElementToHeader(WSSecHeader secHeader) {
+    public void appendBSTElementToHeader() {
         if (bstToken != null && !bstAddedToSecurityHeader) {
-            Element secHeaderElement = secHeader.getSecurityHeader();
-            secHeaderElement.appendChild(bstToken);
+            Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
+            securityHeaderElement.appendChild(bstToken);
             bstAddedToSecurityHeader = true;
         }
     }
@@ -556,21 +545,22 @@ public class WSSecSignature extends WSSe
             // Figure out where to insert the signature element
             //
             XMLSignContext signContext = null;
+            Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
             if (prepend) {
                 if (siblingElement == null) {
-                    Node child = securityHeader.getFirstChild();
+                    Node child = securityHeaderElement.getFirstChild();
                     while (child != null && child.getNodeType() != Node.ELEMENT_NODE) {
                         child = child.getNextSibling();
                     }
                     siblingElement = (Element)child;
                 }
                 if (siblingElement == null) {
-                    signContext = new DOMSignContext(key, securityHeader);
+                    signContext = new DOMSignContext(key, securityHeaderElement);
                 } else {
-                    signContext = new DOMSignContext(key, securityHeader, siblingElement);
+                    signContext = new DOMSignContext(key, securityHeaderElement, siblingElement);
                 }
             } else {
-                signContext = new DOMSignContext(key, securityHeader);
+                signContext = new DOMSignContext(key, securityHeaderElement);
             }
 
             signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
@@ -780,7 +770,7 @@ public class WSSecSignature extends WSSe
 
     /**
      * @return the URI associated with the SecurityTokenReference
-     * (must be called after {@link #prepare(Document, Crypto, WSSecHeader)}
+     * (must be called after {@link #prepare(Document, Crypto)}
      */
     public String getSecurityTokenReferenceURI() {
         return strUri;

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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -57,8 +57,8 @@ public class WSSecSignatureBase extends
     private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(WSSecSignatureBase.class);
 
-    public WSSecSignatureBase() {
-        super();
+    public WSSecSignatureBase(WSSecHeader securityHeader) {
+        super(securityHeader);
     }
 
     /**
@@ -68,7 +68,6 @@ public class WSSecSignatureBase extends
      * @param references The list of references to sign
      * @param wsDocInfo The WSDocInfo object to store protection elements in
      * @param signatureFactory The XMLSignature object
-     * @param secHeader The Security Header
      * @param addInclusivePrefixes Whether to add inclusive prefixes or not
      * @param digestAlgo The digest algorithm to use
      * @throws WSSecurityException
@@ -78,7 +77,6 @@ public class WSSecSignatureBase extends
         List<WSEncryptionPart> references,
         WSDocInfo wsDocInfo,
         XMLSignatureFactory signatureFactory,
-        WSSecHeader secHeader,
         boolean addInclusivePrefixes,
         String digestAlgo
     ) throws WSSecurityException {

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=1771303&r1=1771302&r2=1771303&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:30:06 2016
@@ -35,8 +35,8 @@ public class WSSecSignatureConfirmation
 
     private byte[] signatureValue;
 
-    public WSSecSignatureConfirmation() {
-        super();
+    public WSSecSignatureConfirmation(WSSecHeader securityHeader) {
+        super(securityHeader);
     }
 
     /**
@@ -70,11 +70,10 @@ public class WSSecSignatureConfirmation
      * The method can be called any time after <code>prepare()</code>.
      * This allows to insert the SignatureConfirmation element at any position in the
      * Security header.
-     *
-     * @param secHeader The security header that holds the Signature element.
      */
-    public void prependToHeader(WSSecHeader secHeader) {
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), sc.getElement());
+    public void prependToHeader() {
+        Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
+        WSSecurityUtil.prependChildElement(securityHeaderElement, sc.getElement());
     }
 
     /**
@@ -85,15 +84,14 @@ public class WSSecSignatureConfirmation
      *
      * @param doc The SOAP envelope as W3C document
      * @param sigVal the Signature value. This will be the content of the "Value" attribute.
-     * @param secHeader The security header that holds the Signature element.
      * @return Document with SignatureConfirmation added
      */
-    public Document build(Document doc, byte[] sigVal, WSSecHeader secHeader) {
+    public Document build(Document doc, byte[] sigVal) {
         LOG.debug("Begin add signature confirmation...");
 
         signatureValue = sigVal;
         prepare(doc);
-        prependToHeader(secHeader);
+        prependToHeader();
 
         return doc;
     }

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecTimestamp.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecTimestamp.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecTimestamp.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecTimestamp.java Fri Nov 25 12:30:06 2016
@@ -42,8 +42,8 @@ public class WSSecTimestamp extends WSSe
     private boolean precisionInMilliSeconds = true;
     private WSTimeSource wsTimeSource = new WSCurrentTimeSource();
 
-    public WSSecTimestamp() {
-        super();
+    public WSSecTimestamp(WSSecHeader securityHeader) {
+        super(securityHeader);
     }
 
     /**
@@ -80,11 +80,10 @@ public class WSSecTimestamp extends WSSe
      * The method can be called any time after <code>prepare()</code>. This
      * allows to insert the Timestamp element at any position in the Security
      * header.
-     *
-     * @param secHeader The security header that holds the Signature element.
      */
-    public void prependToHeader(WSSecHeader secHeader) {
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), ts.getElement());
+    public void prependToHeader() {
+        Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
+        WSSecurityUtil.prependChildElement(securityHeaderElement, ts.getElement());
     }
 
     /**
@@ -94,15 +93,14 @@ public class WSSecTimestamp extends WSSe
      * <code>wsse:Security</code> header.
      *
      * @param doc The SOAP envelope as W3C document
-     * @param secHeader The security header that hold this Timestamp
      * @return Document with Timestamp added
      * @throws Exception
      */
-    public Document build(Document doc, WSSecHeader secHeader) {
+    public Document build(Document doc) {
         LOG.debug("Begin add timestamp...");
 
         prepare(doc);
-        prependToHeader(secHeader);
+        prependToHeader();
 
         return doc;
     }

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecUsernameToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecUsernameToken.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecUsernameToken.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecUsernameToken.java Fri Nov 25 12:30:06 2016
@@ -53,8 +53,8 @@ public class WSSecUsernameToken extends
     private boolean precisionInMilliSeconds = true;
     private WSTimeSource wsTimeSource = new WSCurrentTimeSource();
 
-    public WSSecUsernameToken() {
-        super();
+    public WSSecUsernameToken(WSSecHeader securityHeader) {
+        super(securityHeader);
     }
 
     /**
@@ -189,11 +189,10 @@ public class WSSecUsernameToken extends
      * The method can be called any time after <code>prepare()</code>.
      * This allows to insert the UsernameToken element at any position in the
      * Security header.
-     *
-     * @param secHeader The security header that holds the Signature element.
      */
-    public void prependToHeader(WSSecHeader secHeader) {
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), ut.getElement());
+    public void prependToHeader() {
+        Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
+        WSSecurityUtil.prependChildElement(securityHeaderElement, ut.getElement());
     }
 
     /**
@@ -203,12 +202,10 @@ public class WSSecUsernameToken extends
      * The method can be called any time after <code>prepare()</code>.
      * This allows to insert the UsernameToken element at any position in the
      * Security header.
-     *
-     * @param secHeader The security header that holds the Signature element.
      */
-    public void appendToHeader(WSSecHeader secHeader) {
-        Element secHeaderElement = secHeader.getSecurityHeader();
-        secHeaderElement.appendChild(ut.getElement());
+    public void appendToHeader() {
+        Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
+        securityHeaderElement.appendChild(ut.getElement());
     }
 
     /**
@@ -220,14 +217,13 @@ public class WSSecUsernameToken extends
      * <code>wsse:Security</code> header.
      *
      * @param doc The SOAP envelope as W3C document
-     * @param secHeader The security header inside the SOAP envelope
      * @return Document with UsernameToken added
      */
-    public Document build(Document doc, WSSecHeader secHeader) {
+    public Document build(Document doc) {
         LOG.debug("Begin add username token...");
 
         prepare(doc);
-        prependToHeader(secHeader);
+        prependToHeader();
 
         return doc;
     }

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/EncryptedAssertionProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/EncryptedAssertionProcessor.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/EncryptedAssertionProcessor.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/EncryptedAssertionProcessor.java Fri Nov 25 12:30:06 2016
@@ -83,6 +83,7 @@ public class EncryptedAssertionProcessor
         // at this point. Process it accordingly.
         if (!completeResults.isEmpty()) {
             for (WSSecurityEngineResult r : completeResults) {
+                @SuppressWarnings("unchecked")
                 List<WSDataRef> dataRefs =
                     (List<WSDataRef>)r.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
                 if (dataRefs != null) {

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/saml/WSSecSignatureSAML.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/saml/WSSecSignatureSAML.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/saml/WSSecSignatureSAML.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/saml/WSSecSignatureSAML.java Fri Nov 25 12:30:06 2016
@@ -76,8 +76,8 @@ public class WSSecSignatureSAML extends
     /**
      * Constructor.
      */
-    public WSSecSignatureSAML() {
-        super();
+    public WSSecSignatureSAML(WSSecHeader securityHeader) {
+        super(securityHeader);
         doDebug = LOG.isDebugEnabled();
     }
 
@@ -101,17 +101,15 @@ public class WSSecSignatureSAML extends
      *            Private key to use in case of "sender-Vouches"
      * @param iKeyPW
      *            Password for issuer private key
-     * @param secHeader
-     *            The Security header
      * @return A signed SOAP envelope as <code>Document</code>
      * @throws WSSecurityException
      */
     public Document build(
         Document doc, Crypto uCrypto, SamlAssertionWrapper samlAssertion,
-        Crypto iCrypto, String iKeyName, String iKeyPW, WSSecHeader secHeader
+        Crypto iCrypto, String iKeyName, String iKeyPW
     ) throws WSSecurityException {
 
-        prepare(doc, uCrypto, samlAssertion, iCrypto, iKeyName, iKeyPW, secHeader);
+        prepare(doc, uCrypto, samlAssertion, iCrypto, iKeyName, iKeyPW);
 
         if (getParts().isEmpty()) {
             getParts().add(WSSecurityUtil.getDefaultEncryptionPart(doc));
@@ -136,15 +134,14 @@ public class WSSecSignatureSAML extends
             getParts().add(encP);
         }
 
-        List<javax.xml.crypto.dsig.Reference> referenceList =
-            addReferencesToSign(getParts(), secHeader);
+        List<javax.xml.crypto.dsig.Reference> referenceList = addReferencesToSign(getParts());
 
-        prependSAMLElementsToHeader(secHeader);
+        prependSAMLElementsToHeader();
 
         if (senderVouches) {
-            computeSignature(referenceList, secHeader, secRefSaml.getElement());
+            computeSignature(referenceList, secRefSaml.getElement());
         } else {
-            computeSignature(referenceList, secHeader, samlToken);
+            computeSignature(referenceList, samlToken);
         }
 
         //
@@ -152,7 +149,7 @@ public class WSSecSignatureSAML extends
         // strict layout rules.
         //
         if (bstToken != null) {
-            prependBSTElementToHeader(secHeader);
+            prependBSTElementToHeader();
         }
 
         return doc;
@@ -182,13 +179,11 @@ public class WSSecSignatureSAML extends
      *            Private key to use in case of "sender-Vouches"
      * @param iKeyPW
      *            Password for issuer private key
-     * @param secHeader
-     *            The Security header
      * @throws WSSecurityException
      */
     public void prepare(
         Document doc, Crypto uCrypto, SamlAssertionWrapper samlAssertion, Crypto iCrypto,
-        String iKeyName, String iKeyPW, WSSecHeader secHeader
+        String iKeyName, String iKeyPW
     ) throws WSSecurityException {
 
         if (doDebug) {
@@ -301,8 +296,8 @@ public class WSSecSignatureSAML extends
         try {
             C14NMethodParameterSpec c14nSpec = null;
             if (isAddInclusivePrefixes() && getSigCanonicalization().equals(WSConstants.C14N_EXCL_OMIT_COMMENTS)) {
-                List<String> prefixes =
-                    getInclusivePrefixes(secHeader.getSecurityHeader(), false);
+                Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
+                List<String> prefixes = getInclusivePrefixes(securityHeaderElement, false);
                 c14nSpec = new ExcC14NParameterSpec(prefixes);
             }
 
@@ -471,18 +466,14 @@ public class WSSecSignatureSAML extends
      *
      * This methods first prepends the SAML security reference if mode is
      * <code>senderVouches</code>, then the SAML token itself,
-     *
-     * @param secHeader
-     *            The security header that holds the BST element.
      */
-    public void prependSAMLElementsToHeader(WSSecHeader secHeader) {
+    public void prependSAMLElementsToHeader() {
+        Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
         if (senderVouches) {
-            WSSecurityUtil.prependChildElement(
-                secHeader.getSecurityHeader(), secRefSaml.getElement()
-            );
+            WSSecurityUtil.prependChildElement(securityHeaderElement, secRefSaml.getElement());
         }
 
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), samlToken);
+        WSSecurityUtil.prependChildElement(securityHeaderElement, samlToken);
     }
 
 
@@ -497,7 +488,6 @@ public class WSSecSignatureSAML extends
      */
     public void computeSignature(
         List<javax.xml.crypto.dsig.Reference> referenceList,
-        WSSecHeader secHeader,
         Element siblingElement
     ) throws WSSecurityException {
         try {
@@ -521,7 +511,7 @@ public class WSSecSignatureSAML extends
                     getIdAllocator().createId("SIG-", null),
                     null);
 
-            Element securityHeaderElement = secHeader.getSecurityHeader();
+            Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement();
             //
             // Prepend the signature element to the security header (after the assertion)
             //

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/AbstractSAMLCallbackHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/AbstractSAMLCallbackHandler.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/AbstractSAMLCallbackHandler.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/AbstractSAMLCallbackHandler.java Fri Nov 25 12:30:06 2016
@@ -212,7 +212,7 @@ public abstract class AbstractSAMLCallba
             Document doc = docBuilder.newDocument();
 
             // Create an Encrypted Key
-            WSSecEncryptedKey encrKey = new WSSecEncryptedKey();
+            WSSecEncryptedKey encrKey = new WSSecEncryptedKey(null);
             encrKey.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
             encrKey.setUseThisCert(certs[0]);
             encrKey.prepare(doc, null);



Mime
View raw message