You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2016/11/25 12:30:37 UTC

svn commit: r1771306 - /webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/

Author: coheigea
Date: Fri Nov 25 12:30:36 2016
New Revision: 1771306

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

Modified:
    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/SamlTokenSVTest.java

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlAlgorithmSuiteTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlAlgorithmSuiteTest.java?rev=1771306&r1=1771305&r2=1771306&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlAlgorithmSuiteTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlAlgorithmSuiteTest.java Fri Nov 25 12:30:36 2016
@@ -75,13 +75,13 @@ public class SamlAlgorithmSuiteTest exte
 
         samlAssertion.signAssertion("16c73ab6-b892-458f-abf5-2f875f74882e", "security", crypto, false);
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
 
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-
-        Document signedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
+        Document signedDoc = wsSign.build(doc, samlAssertion);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -119,13 +119,13 @@ public class SamlAlgorithmSuiteTest exte
 
         samlAssertion.signAssertion("wss40DSA", "security", dsaCrypto, false);
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
 
-        Document signedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        Document signedDoc = wsSign.build(doc, samlAssertion);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -162,13 +162,14 @@ public class SamlAlgorithmSuiteTest exte
             "16c73ab6-b892-458f-abf5-2f875f74882e", "security", crypto, false,
             WSConstants.C14N_EXCL_WITH_COMMENTS, WSConstants.RSA_SHA1);
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
 
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
 
-        Document signedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        Document signedDoc = wsSign.build(doc, samlAssertion);
 
         if (LOG.isDebugEnabled()) {
             String outputString =

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlAuthnTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlAuthnTest.java?rev=1771306&r1=1771305&r2=1771306&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlAuthnTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlAuthnTest.java Fri Nov 25 12:30:36 2016
@@ -164,13 +164,13 @@ public class SamlAuthnTest extends org.j
         SAMLUtil.doSAMLCallback(samlCallbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
+
+        Document unsignedDoc = wsSign.build(doc, samlAssertion);
 
         if (LOG.isDebugEnabled()) {
             String outputString =

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlConditionsTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlConditionsTest.java?rev=1771306&r1=1771305&r2=1771306&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlConditionsTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlConditionsTest.java Fri Nov 25 12:30:36 2016
@@ -154,13 +154,13 @@ public class SamlConditionsTest extends
         issueInstant = issueInstant.plusMinutes(60);
         samlAssertion.getSaml2().setIssueInstant(issueInstant);
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
 
-        Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        Document unsignedDoc = wsSign.build(doc, samlAssertion);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("SAML 2 Authn Assertion (sender vouches):");
@@ -192,13 +192,13 @@ public class SamlConditionsTest extends
         samlAssertion.getSaml2().setIssueInstant(issueInstant);
         samlAssertion.getSaml2().getConditions().setNotOnOrAfter(null);
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
 
-        Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        Document unsignedDoc = wsSign.build(doc, samlAssertion);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("SAML 2 Authn Assertion (sender vouches):");
@@ -233,13 +233,13 @@ public class SamlConditionsTest extends
         issueInstant = issueInstant.minusMinutes(31);
         samlAssertion.getSaml2().setIssueInstant(issueInstant);
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
 
-        Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        Document unsignedDoc = wsSign.build(doc, samlAssertion);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("SAML 2 Authn Assertion (sender vouches):");
@@ -266,13 +266,13 @@ public class SamlConditionsTest extends
         samlAssertion.getSaml1().setIssueInstant(issueInstant);
         samlAssertion.getSaml1().getConditions().setNotOnOrAfter(null);
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
 
-        Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        Document unsignedDoc = wsSign.build(doc, samlAssertion);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("SAML 1 Authn Assertion (sender vouches):");
@@ -347,13 +347,13 @@ public class SamlConditionsTest extends
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
 
-        Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        Document unsignedDoc = wsSign.build(doc, samlAssertion);
 
         String outputString =
             XMLUtils.prettyDocumentToString(unsignedDoc);
@@ -391,13 +391,13 @@ public class SamlConditionsTest extends
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
 
-        Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        Document unsignedDoc = wsSign.build(doc, samlAssertion);
 
         String outputString =
             XMLUtils.prettyDocumentToString(unsignedDoc);
@@ -434,13 +434,13 @@ public class SamlConditionsTest extends
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
 
-        Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        Document unsignedDoc = wsSign.build(doc, samlAssertion);
 
         String outputString =
             XMLUtils.prettyDocumentToString(unsignedDoc);
@@ -474,13 +474,13 @@ public class SamlConditionsTest extends
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
 
-        Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        Document unsignedDoc = wsSign.build(doc, samlAssertion);
 
         String outputString =
             XMLUtils.prettyDocumentToString(unsignedDoc);
@@ -534,13 +534,13 @@ public class SamlConditionsTest extends
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
 
-        Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        Document unsignedDoc = wsSign.build(doc, samlAssertion);
 
         String outputString =
             XMLUtils.prettyDocumentToString(unsignedDoc);
@@ -602,13 +602,13 @@ public class SamlConditionsTest extends
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
 
-        Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        Document unsignedDoc = wsSign.build(doc, samlAssertion);
 
         String outputString =
             XMLUtils.prettyDocumentToString(unsignedDoc);
@@ -647,13 +647,13 @@ public class SamlConditionsTest extends
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
 
-        Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        Document unsignedDoc = wsSign.build(doc, samlAssertion);
 
         String outputString =
             XMLUtils.prettyDocumentToString(unsignedDoc);
@@ -719,13 +719,13 @@ public class SamlConditionsTest extends
         SAMLUtil.doSAMLCallback(samlCallbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
 
-        Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        Document unsignedDoc = wsSign.build(doc, samlAssertion);
 
         if (LOG.isDebugEnabled()) {
             String outputString =

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlNegativeTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlNegativeTest.java?rev=1771306&r1=1771305&r2=1771306&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlNegativeTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlNegativeTest.java Fri Nov 25 12:30:36 2016
@@ -116,16 +116,16 @@ public class SamlNegativeTest extends or
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
-        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
-        wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSignatureSAML wsSign = new WSSecSignatureSAML(secHeader);
+        wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
 
         Document signedDoc =
             wsSign.build(
-                doc, null, samlAssertion, userCrypto, "wss40", "security", secHeader
+                doc, null, samlAssertion, userCrypto, "wss40", "security"
             );
 
         //
@@ -170,13 +170,13 @@ public class SamlNegativeTest extends or
 
         samlAssertion.signAssertion("wss40_server", "security", issuerCrypto, false);
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
 
-        Document signedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        Document signedDoc = wsSign.build(doc, samlAssertion);
 
         //
         // Modify the assertion
@@ -222,13 +222,13 @@ public class SamlNegativeTest extends or
 
         samlAssertion.signAssertion("wss40_server", "security", issuerCrypto, false);
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
 
-        Document signedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        Document signedDoc = wsSign.build(doc, samlAssertion);
         //
         // Modify the assertion
         //
@@ -273,8 +273,8 @@ public class SamlNegativeTest extends or
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
-        Document signedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
+        Document signedDoc = wsSign.build(doc, samlAssertion);
 
         String outputString =
             XMLUtils.prettyDocumentToString(signedDoc);
@@ -316,8 +316,8 @@ public class SamlNegativeTest extends or
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        WSSecSAMLToken wsSign = new WSSecSAMLToken();
-        Document signedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
+        Document signedDoc = wsSign.build(doc, samlAssertion);
 
         String outputString =
             XMLUtils.prettyDocumentToString(signedDoc);
@@ -354,18 +354,18 @@ public class SamlNegativeTest extends or
             CryptoFactory.getInstance("crypto.properties"), false
         );
 
-        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
+        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+        WSSecHeader secHeader = new WSSecHeader(doc);
+        secHeader.insertSecurityHeader();
+        
+        WSSecSignatureSAML wsSign = new WSSecSignatureSAML(secHeader);
         wsSign.setUserInfo("wss40", "security");
         wsSign.setDigestAlgo("http://www.w3.org/2001/04/xmlenc#sha256");
         wsSign.setSignatureAlgorithm("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
         wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
 
-        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();
-
         Document signedDoc =
-            wsSign.build(doc, userCrypto, samlAssertion, null, null, null, secHeader);
+            wsSign.build(doc, userCrypto, samlAssertion, null, null, null);
 
         String outputString =
             XMLUtils.prettyDocumentToString(signedDoc);

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlReferenceTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlReferenceTest.java?rev=1771306&r1=1771305&r2=1771306&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlReferenceTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlReferenceTest.java Fri Nov 25 12:30:36 2016
@@ -116,12 +116,12 @@ public class SamlReferenceTest extends o
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
+        WSSecSignatureSAML wsSign = new WSSecSignatureSAML(secHeader);
         wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         Document signedDoc =
             wsSign.build(
                 doc, null, samlAssertion, crypto, "16c73ab6-b892-458f-abf5-2f875f74882e",
-                "security", secHeader
+                "security"
             );
 
         String outputString =
@@ -179,13 +179,13 @@ public class SamlReferenceTest extends o
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
+        WSSecSignatureSAML wsSign = new WSSecSignatureSAML(secHeader);
         wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         wsSign.setUseDirectReferenceToAssertion(true);
         Document signedDoc =
             wsSign.build(
                 doc, null, samlAssertion, crypto, "16c73ab6-b892-458f-abf5-2f875f74882e",
-                "security", secHeader
+                "security"
             );
 
         String outputString =
@@ -241,17 +241,17 @@ public class SamlReferenceTest extends o
 
         samlAssertion.signAssertion("wss40_server", "security", issuerCrypto, false);
 
-        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
-        wsSign.setUserInfo("wss40", "security");
-        wsSign.setDigestAlgo("http://www.w3.org/2001/04/xmlenc#sha256");
-        wsSign.setSignatureAlgorithm("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
+        WSSecSignatureSAML wsSign = new WSSecSignatureSAML(secHeader);
+        wsSign.setUserInfo("wss40", "security");
+        wsSign.setDigestAlgo("http://www.w3.org/2001/04/xmlenc#sha256");
+        wsSign.setSignatureAlgorithm("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
+
         Document signedDoc =
-            wsSign.build(doc, userCrypto, samlAssertion, null, null, null, secHeader);
+            wsSign.build(doc, userCrypto, samlAssertion, null, null, null);
 
         String outputString =
             XMLUtils.prettyDocumentToString(doc);
@@ -304,19 +304,19 @@ public class SamlReferenceTest extends o
 
         samlAssertion.signAssertion("wss40_server", "security", issuerCrypto, false);
 
-        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
+        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+        WSSecHeader secHeader = new WSSecHeader(doc);
+        secHeader.insertSecurityHeader();
+
+        WSSecSignatureSAML wsSign = new WSSecSignatureSAML(secHeader);
         wsSign.setUserInfo("wss40", "security");
         wsSign.setDigestAlgo("http://www.w3.org/2001/04/xmlenc#sha256");
         wsSign.setSignatureAlgorithm("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
         wsSign.setUseDirectReferenceToAssertion(true);
         wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
 
-        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();
-
         Document signedDoc =
-            wsSign.build(doc, userCrypto, samlAssertion, null, null, null, secHeader);
+            wsSign.build(doc, userCrypto, samlAssertion, null, null, null);
 
         String outputString =
             XMLUtils.prettyDocumentToString(doc);
@@ -373,22 +373,22 @@ public class SamlReferenceTest extends o
 
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
         Crypto crypto = CryptoFactory.getInstance("crypto.properties");
-        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
+        WSSecSignatureSAML wsSign = new WSSecSignatureSAML(secHeader);
         wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         Document samlDoc =
             wsSign.build(doc, null, samlAssertion, crypto,
-                "16c73ab6-b892-458f-abf5-2f875f74882e", "security", secHeader
+                "16c73ab6-b892-458f-abf5-2f875f74882e", "security"
             );
 
-        WSSecEncrypt builder = new WSSecEncrypt();
+        WSSecEncrypt builder = new WSSecEncrypt(secHeader);
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
         builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-        Document encryptedDoc = builder.build(samlDoc, crypto, secHeader);
+        Document encryptedDoc = builder.build(samlDoc, crypto);
 
         //
         // Remove the assertion its place in the security header and then append it
         //
-        Element secHeaderElement = secHeader.getSecurityHeader();
+        Element secHeaderElement = secHeader.getSecurityHeaderElement();
         Node assertionNode =
             secHeaderElement.getElementsByTagNameNS(WSConstants.SAML_NS, "Assertion").item(0);
         secHeaderElement.removeChild(assertionNode);
@@ -432,10 +432,10 @@ public class SamlReferenceTest extends o
         WSSecHeader secHeader = new WSSecHeader(doc);
         Node assertionNode = samlAssertion.toDOM(doc);
         secHeader.insertSecurityHeader();
-        secHeader.getSecurityHeader().appendChild(assertionNode);
+        secHeader.getSecurityHeaderElement().appendChild(assertionNode);
 
         // Encrypt the SOAP body
-        WSSecEncrypt builder = new WSSecEncrypt();
+        WSSecEncrypt builder = new WSSecEncrypt(secHeader);
         builder.setUserInfo("wss40");
         builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
         builder.setKeyIdentifierType(WSConstants.CUSTOM_KEY_IDENTIFIER);
@@ -450,7 +450,7 @@ public class SamlReferenceTest extends o
         builder.getParts().add(encP);
         Element refElement = builder.encrypt();
         builder.addInternalRefElement(refElement);
-        builder.appendToHeader(secHeader);
+        builder.appendToHeader();
 
         String outputString =
             XMLUtils.prettyDocumentToString(doc);
@@ -508,10 +508,10 @@ public class SamlReferenceTest extends o
         WSSecHeader secHeader = new WSSecHeader(doc);
         Node assertionNode = samlAssertion.toDOM(doc);
         secHeader.insertSecurityHeader();
-        secHeader.getSecurityHeader().appendChild(assertionNode);
+        secHeader.getSecurityHeaderElement().appendChild(assertionNode);
 
         // Encrypt the SOAP body
-        WSSecEncrypt builder = new WSSecEncrypt();
+        WSSecEncrypt builder = new WSSecEncrypt(secHeader);
         builder.setUserInfo("wss40");
         builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
         builder.setKeyIdentifierType(WSConstants.CUSTOM_SYMM_SIGNING);
@@ -526,7 +526,7 @@ public class SamlReferenceTest extends o
         builder.getParts().add(encP);
         Element refElement = builder.encrypt();
         builder.addInternalRefElement(refElement);
-        builder.appendToHeader(secHeader);
+        builder.appendToHeader();
 
         String outputString =
             XMLUtils.prettyDocumentToString(doc);
@@ -579,12 +579,12 @@ public class SamlReferenceTest extends o
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
+        WSSecSignatureSAML wsSign = new WSSecSignatureSAML(secHeader);
         wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         Document signedDoc =
             wsSign.build(
                 doc, null, samlAssertion, crypto, "16c73ab6-b892-458f-abf5-2f875f74882e",
-                "security", secHeader
+                "security"
             );
 
         String outputString =
@@ -641,13 +641,13 @@ public class SamlReferenceTest extends o
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
+        WSSecSignatureSAML wsSign = new WSSecSignatureSAML(secHeader);
         wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         wsSign.setUseDirectReferenceToAssertion(true);
         Document signedDoc =
             wsSign.build(
                 doc, null, samlAssertion, crypto, "16c73ab6-b892-458f-abf5-2f875f74882e",
-                "security", secHeader
+                "security"
             );
 
         String outputString =
@@ -702,18 +702,18 @@ public class SamlReferenceTest extends o
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
         samlAssertion.signAssertion("wss40_server", "security", issuerCrypto, false);
+        
+        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+        WSSecHeader secHeader = new WSSecHeader(doc);
+        secHeader.insertSecurityHeader();
 
-        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
+        WSSecSignatureSAML wsSign = new WSSecSignatureSAML(secHeader);
         wsSign.setUserInfo("wss40", "security");
         wsSign.setDigestAlgo("http://www.w3.org/2001/04/xmlenc#sha256");
         wsSign.setSignatureAlgorithm("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
 
-        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();
-
         Document signedDoc =
-            wsSign.build(doc, userCrypto, samlAssertion, null, null, null, secHeader);
+            wsSign.build(doc, userCrypto, samlAssertion, null, null, null);
 
         String outputString =
             XMLUtils.prettyDocumentToString(doc);
@@ -766,19 +766,20 @@ public class SamlReferenceTest extends o
 
         samlAssertion.signAssertion("wss40_server", "security", issuerCrypto, false);
 
-        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
+        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+        WSSecHeader secHeader = new WSSecHeader(doc);
+        secHeader.insertSecurityHeader();
+
+        
+        WSSecSignatureSAML wsSign = new WSSecSignatureSAML(secHeader);
         wsSign.setUserInfo("wss40", "security");
         wsSign.setDigestAlgo("http://www.w3.org/2001/04/xmlenc#sha256");
         wsSign.setSignatureAlgorithm("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
         wsSign.setUseDirectReferenceToAssertion(true);
         wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
 
-        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();
-
         Document signedDoc =
-            wsSign.build(doc, userCrypto, samlAssertion, null, null, null, secHeader);
+            wsSign.build(doc, userCrypto, samlAssertion, null, null, null);
 
         String outputString =
             XMLUtils.prettyDocumentToString(doc);
@@ -835,10 +836,10 @@ public class SamlReferenceTest extends o
         WSSecHeader secHeader = new WSSecHeader(doc);
         Node assertionNode = samlAssertion.toDOM(doc);
         secHeader.insertSecurityHeader();
-        secHeader.getSecurityHeader().appendChild(assertionNode);
+        secHeader.getSecurityHeaderElement().appendChild(assertionNode);
 
         // Encrypt the SOAP body
-        WSSecEncrypt builder = new WSSecEncrypt();
+        WSSecEncrypt builder = new WSSecEncrypt(secHeader);
         builder.setUserInfo("wss40");
         builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
         builder.setKeyIdentifierType(WSConstants.CUSTOM_KEY_IDENTIFIER);
@@ -853,7 +854,7 @@ public class SamlReferenceTest extends o
         builder.getParts().add(encP);
         Element refElement = builder.encrypt();
         builder.addInternalRefElement(refElement);
-        builder.appendToHeader(secHeader);
+        builder.appendToHeader();
 
         String outputString =
             XMLUtils.prettyDocumentToString(doc);
@@ -911,10 +912,10 @@ public class SamlReferenceTest extends o
         WSSecHeader secHeader = new WSSecHeader(doc);
         Node assertionNode = samlAssertion.toDOM(doc);
         secHeader.insertSecurityHeader();
-        secHeader.getSecurityHeader().appendChild(assertionNode);
+        secHeader.getSecurityHeaderElement().appendChild(assertionNode);
 
         // Encrypt the SOAP body
-        WSSecEncrypt builder = new WSSecEncrypt();
+        WSSecEncrypt builder = new WSSecEncrypt(secHeader);
         builder.setUserInfo("wss40");
         builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
         builder.setKeyIdentifierType(WSConstants.CUSTOM_SYMM_SIGNING);
@@ -929,7 +930,7 @@ public class SamlReferenceTest extends o
         builder.getParts().add(encP);
         Element refElement = builder.encrypt();
         builder.addInternalRefElement(refElement);
-        builder.appendToHeader(secHeader);
+        builder.appendToHeader();
 
         String outputString =
             XMLUtils.prettyDocumentToString(doc);

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenCustomSignatureTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenCustomSignatureTest.java?rev=1771306&r1=1771305&r2=1771306&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenCustomSignatureTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenCustomSignatureTest.java Fri Nov 25 12:30:36 2016
@@ -95,7 +95,7 @@ public class SamlTokenCustomSignatureTes
 
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        secHeader.getSecurityHeader().appendChild(assertionElement);
+        secHeader.getSecurityHeaderElement().appendChild(assertionElement);
 
         // Sign
         signAssertion(doc, assertionElement);
@@ -136,7 +136,7 @@ public class SamlTokenCustomSignatureTes
 
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        secHeader.getSecurityHeader().appendChild(assertionElement);
+        secHeader.getSecurityHeaderElement().appendChild(assertionElement);
 
         // Sign
         signAssertion(doc, assertionElement);
@@ -174,9 +174,9 @@ public class SamlTokenCustomSignatureTes
 
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        secHeader.getSecurityHeader().appendChild(assertionElement);
+        secHeader.getSecurityHeaderElement().appendChild(assertionElement);
 
-        WSSecSignature sign = new WSSecSignature();
+        WSSecSignature sign = new WSSecSignature(secHeader);
         sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         sign.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
@@ -188,7 +188,7 @@ public class SamlTokenCustomSignatureTes
         encP.setRequired(false);
         sign.getParts().add(encP);
 
-        Document signedDoc = sign.build(doc, crypto, secHeader);
+        Document signedDoc = sign.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString = XMLUtils.prettyDocumentToString(doc);

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenDerivedTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenDerivedTest.java?rev=1771306&r1=1771305&r2=1771306&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenDerivedTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenDerivedTest.java Fri Nov 25 12:30:36 2016
@@ -99,14 +99,14 @@ public class SamlTokenDerivedTest extend
 
         SecurityTokenReference secRefSaml =
             createSamlSTR(doc, samlAssertion, WSSConfig.getNewInstance());
-        secHeader.getSecurityHeader().appendChild(samlAssertion.toDOM(doc));
-        secHeader.getSecurityHeader().appendChild(secRefSaml.getElement());
+        secHeader.getSecurityHeaderElement().appendChild(samlAssertion.toDOM(doc));
+        secHeader.getSecurityHeaderElement().appendChild(secRefSaml.getElement());
 
         //
         // Create a Derived Key object for signature
         //
-        WSSecDKSign sigBuilder = createDKSign(doc, secRefSaml);
-        Document signedDoc = sigBuilder.build(doc, secHeader);
+        WSSecDKSign sigBuilder = createDKSign(doc, secRefSaml, secHeader);
+        Document signedDoc = sigBuilder.build(doc);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("SAML 1.1 Authn Assertion Derived (sender vouches):");
@@ -168,7 +168,8 @@ public class SamlTokenDerivedTest extend
      */
     private WSSecDKSign createDKSign(
         Document doc,
-        SecurityTokenReference secRefSaml
+        SecurityTokenReference secRefSaml,
+        WSSecHeader secHeader
     ) throws WSSecurityException {
         SecurityTokenReference secToken = new SecurityTokenReference(doc);
         CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
@@ -176,7 +177,7 @@ public class SamlTokenDerivedTest extend
         X509Certificate[] certs = crypto.getX509Certificates(cryptoType);
         secToken.setKeyIdentifierThumb(certs[0]);
 
-        WSSecDKSign sigBuilder = new WSSecDKSign();
+        WSSecDKSign sigBuilder = new WSSecDKSign(secHeader);
         java.security.Key key =
             crypto.getPrivateKey("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         sigBuilder.setExternalKey(key.getEncoded(), secToken.getElement());

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenSVTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenSVTest.java?rev=1771306&r1=1771305&r2=1771306&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenSVTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlTokenSVTest.java Fri Nov 25 12:30:36 2016
@@ -85,17 +85,17 @@ public class SamlTokenSVTest extends org
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
-        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
-        wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSignatureSAML wsSign = new WSSecSignatureSAML(secHeader);
+        wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
 
         Document signedDoc =
             wsSign.build(
                 doc, null, samlAssertion, crypto, "16c73ab6-b892-458f-abf5-2f875f74882e",
-                "security", secHeader
+                "security"
             );
 
         if (LOG.isDebugEnabled()) {
@@ -145,17 +145,17 @@ public class SamlTokenSVTest extends org
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
-        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
-        wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSignatureSAML wsSign = new WSSecSignatureSAML(secHeader);
+        wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
 
         Document signedDoc =
             wsSign.build(
                 doc, null, samlAssertion, crypto, "16c73ab6-b892-458f-abf5-2f875f74882e",
-                "security", secHeader
+                "security"
             );
 
         if (LOG.isDebugEnabled()) {
@@ -205,17 +205,17 @@ public class SamlTokenSVTest extends org
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
-        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
-        wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSignatureSAML wsSign = new WSSecSignatureSAML(secHeader);
+        wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
 
         Document signedDoc =
             wsSign.build(
                 doc, null, samlAssertion, crypto, "16c73ab6-b892-458f-abf5-2f875f74882e",
-                "security", secHeader
+                "security"
             );
 
         if (LOG.isDebugEnabled()) {
@@ -265,17 +265,17 @@ public class SamlTokenSVTest extends org
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
-        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
-        wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSignatureSAML wsSign = new WSSecSignatureSAML(secHeader);
+        wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
 
         Document signedDoc =
             wsSign.build(
                 doc, null, samlAssertion, crypto, "16c73ab6-b892-458f-abf5-2f875f74882e",
-                "security", secHeader
+                "security"
             );
 
         if (LOG.isDebugEnabled()) {
@@ -327,18 +327,17 @@ public class SamlTokenSVTest extends org
         SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
         SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
 
-        WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
-        wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSignatureSAML wsSign = new WSSecSignatureSAML(secHeader);
+        wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
 
         Document signedDoc =
             wsSign.build(
                 doc, null, samlAssertion, crypto, "16c73ab6-b892-458f-abf5-2f875f74882e",
-                "security", secHeader
+                "security"
             );
         //
         // Now verify it but first call Handler#doReceiverAction