ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1771304 [2/2] - /webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/
Date Fri, 25 Nov 2016 12:30:21 GMT
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ModifiedRequestTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ModifiedRequestTest.java?rev=1771304&r1=1771303&r2=1771304&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ModifiedRequestTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ModifiedRequestTest.java Fri Nov 25 12:30:21 2016
@@ -95,12 +95,13 @@ public class ModifiedRequestTest extends
      */
     @Test
     public void testMovedElement() throws Exception {
-        WSSecSignature builder = new WSSecSignature();
-        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
-        LOG.info("Before Signing....");
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSignature builder = new WSSecSignature(secHeader);
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        LOG.info("Before Signing....");
 
         WSEncryptionPart encP =
             new WSEncryptionPart(
@@ -109,13 +110,13 @@ public class ModifiedRequestTest extends
                 "");
         builder.getParts().add(encP);
 
-        Document signedDoc = builder.build(doc, crypto, secHeader);
+        Document signedDoc = builder.build(doc, crypto);
 
         //
         // Replace the signed element with a modified element, and move the original
         // signed element into the SOAP header
         //
-        Element secHeaderElement = secHeader.getSecurityHeader();
+        Element secHeaderElement = secHeader.getSecurityHeaderElement();
         Element envelopeElement = signedDoc.getDocumentElement();
         Node valueNode =
             envelopeElement.getElementsByTagNameNS("http://blah.com", "value").item(0);
@@ -149,12 +150,13 @@ public class ModifiedRequestTest extends
      */
     @Test
     public void testMovedElementChangedId() throws Exception {
-        WSSecSignature builder = new WSSecSignature();
-        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
-        LOG.info("Before Signing....");
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSignature builder = new WSSecSignature(secHeader);
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        LOG.info("Before Signing....");
 
         WSEncryptionPart encP =
             new WSEncryptionPart(
@@ -163,13 +165,13 @@ public class ModifiedRequestTest extends
                 "");
         builder.getParts().add(encP);
 
-        Document signedDoc = builder.build(doc, crypto, secHeader);
+        Document signedDoc = builder.build(doc, crypto);
 
         //
         // Replace the signed element with a modified element, and move the original
         // signed element into the SOAP header
         //
-        Element secHeaderElement = secHeader.getSecurityHeader();
+        Element secHeaderElement = secHeader.getSecurityHeaderElement();
         Element envelopeElement = signedDoc.getDocumentElement();
         Node valueNode =
             envelopeElement.getElementsByTagNameNS("http://blah.com", "value").item(0);
@@ -228,22 +230,22 @@ public class ModifiedRequestTest extends
         SAMLCallback samlCallback = new SAMLCallback();
         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"
             );
         Element assertionElement = (Element) samlAssertion.getElement().cloneNode(true);
         assertionElement.removeChild(assertionElement.getFirstChild());
-        secHeader.getSecurityHeader().appendChild(assertionElement);
+        secHeader.getSecurityHeaderElement().appendChild(assertionElement);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("SAML 1.1 Authn Assertion (sender vouches):");
@@ -271,11 +273,11 @@ public class ModifiedRequestTest extends
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        WSSecUsernameToken usernameToken = new WSSecUsernameToken();
+        WSSecUsernameToken usernameToken = new WSSecUsernameToken(secHeader);
         usernameToken.setUserInfo("wss86", "security");
-        Document createdDoc = usernameToken.build(doc, secHeader);
+        Document createdDoc = usernameToken.build(doc);
 
-        WSSecSignature builder = new WSSecSignature();
+        WSSecSignature builder = new WSSecSignature(secHeader);
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
 
         WSEncryptionPart encP =
@@ -285,14 +287,14 @@ public class ModifiedRequestTest extends
                 "");
         builder.getParts().add(encP);
 
-        builder.prepare(createdDoc, crypto, secHeader);
+        builder.prepare(createdDoc, crypto);
 
         List<javax.xml.crypto.dsig.Reference> referenceList =
-            builder.addReferencesToSign(builder.getParts(), secHeader);
+            builder.addReferencesToSign(builder.getParts());
 
         builder.computeSignature(referenceList, false, null);
 
-        secHeader.getSecurityHeader().appendChild(
+        secHeader.getSecurityHeaderElement().appendChild(
             usernameToken.getUsernameTokenElement().cloneNode(true)
         );
 
@@ -318,15 +320,17 @@ public class ModifiedRequestTest extends
      */
     @Test
     public void testModifiedEncryptedDataStructure() throws Exception {
-        WSSecEncrypt builder = new WSSecEncrypt();
-        builder.setUserInfo("wss40");
-        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-        builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecEncrypt builder = new WSSecEncrypt(secHeader);
+        builder.setUserInfo("wss40");
+        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
+        builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
+
         Crypto wssCrypto = CryptoFactory.getInstance("wss40.properties");
-        Document encryptedDoc = builder.build(doc, wssCrypto, secHeader);
+        Document encryptedDoc = builder.build(doc, wssCrypto);
 
         Element body = WSSecurityUtil.findBodyElement(doc);
         Element encryptionMethod =
@@ -353,15 +357,17 @@ public class ModifiedRequestTest extends
      */
     @Test
     public void testModifiedEncryptedDataCipherValue() throws Exception {
-        WSSecEncrypt builder = new WSSecEncrypt();
-        builder.setUserInfo("wss40");
-        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-        builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecEncrypt builder = new WSSecEncrypt(secHeader);
+        builder.setUserInfo("wss40");
+        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
+        builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
+
         Crypto wssCrypto = CryptoFactory.getInstance("wss40.properties");
-        Document encryptedDoc = builder.build(doc, wssCrypto, secHeader);
+        Document encryptedDoc = builder.build(doc, wssCrypto);
 
         Element body = WSSecurityUtil.findBodyElement(doc);
         Element cipherValue =
@@ -400,19 +406,20 @@ public class ModifiedRequestTest extends
      */
     @Test
     public void testModifiedSecurityHeaderEncryptedDataCipherValue() throws Exception {
-        WSSecEncrypt builder = new WSSecEncrypt();
+        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+        WSSecHeader secHeader = new WSSecHeader(doc);
+        secHeader.insertSecurityHeader();
+        
+        WSSecEncrypt builder = new WSSecEncrypt(secHeader);
         builder.setUserInfo("wss40");
         builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
 
-        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();
         Crypto wssCrypto = CryptoFactory.getInstance("wss40.properties");
 
-        WSSecTimestamp timestamp = new WSSecTimestamp();
+        WSSecTimestamp timestamp = new WSSecTimestamp(secHeader);
         timestamp.setTimeToLive(300);
-        timestamp.build(doc, secHeader);
+        timestamp.build(doc);
 
         WSEncryptionPart encP =
             new WSEncryptionPart(
@@ -421,7 +428,7 @@ public class ModifiedRequestTest extends
                 "");
         builder.getParts().add(encP);
 
-        Document encryptedDoc = builder.build(doc, wssCrypto, secHeader);
+        Document encryptedDoc = builder.build(doc, wssCrypto);
 
         Element securityHeader =
             WSSecurityUtil.getSecurityHeader(encryptedDoc, "");
@@ -462,15 +469,17 @@ public class ModifiedRequestTest extends
      */
     @Test
     public void testModifiedEncryptedKeyCipherValue() throws Exception {
-        WSSecEncrypt builder = new WSSecEncrypt();
-        builder.setUserInfo("wss40");
-        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-        builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecEncrypt builder = new WSSecEncrypt(secHeader);
+        builder.setUserInfo("wss40");
+        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
+        builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
+
         Crypto wssCrypto = CryptoFactory.getInstance("wss40.properties");
-        Document encryptedDoc = builder.build(doc, wssCrypto, secHeader);
+        Document encryptedDoc = builder.build(doc, wssCrypto);
 
         Element encryptedKey =
             XMLUtils.findElement(doc.getDocumentElement(), "EncryptedKey", WSConstants.ENC_NS);
@@ -511,15 +520,16 @@ public class ModifiedRequestTest extends
      */
     @Test
     public void testModifiedSignatureReference() throws Exception {
-        WSSecSignature builder = new WSSecSignature();
-        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSignature builder = new WSSecSignature(secHeader);
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
 
-        WSSecTimestamp timestamp = new WSSecTimestamp();
+        WSSecTimestamp timestamp = new WSSecTimestamp(secHeader);
         timestamp.setTimeToLive(300);
-        Document createdDoc = timestamp.build(doc, secHeader);
+        Document createdDoc = timestamp.build(doc);
 
         WSEncryptionPart encP =
             new WSEncryptionPart(
@@ -528,7 +538,7 @@ public class ModifiedRequestTest extends
                 "");
         builder.getParts().add(encP);
 
-        Document signedDoc = builder.build(createdDoc, crypto, secHeader);
+        Document signedDoc = builder.build(createdDoc, crypto);
 
         // Modify the Created text of the Timestamp element
         Element timestampElement = timestamp.getElement();
@@ -563,14 +573,15 @@ public class ModifiedRequestTest extends
      */
     @Test
     public void testUntrustedSignature() throws Exception {
-        WSSecSignature builder = new WSSecSignature();
-        builder.setUserInfo("wss40", "security");
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSignature builder = new WSSecSignature(secHeader);
+        builder.setUserInfo("wss40", "security");
 
         Crypto wss40Crypto = CryptoFactory.getInstance("wss40.properties");
-        Document signedDoc = builder.build(doc, wss40Crypto, secHeader);
+        Document signedDoc = builder.build(doc, wss40Crypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -591,13 +602,14 @@ public class ModifiedRequestTest extends
      */
     @Test
     public void testModifiedSignature() throws Exception {
-        WSSecSignature builder = new WSSecSignature();
-        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSignature builder = new WSSecSignature(secHeader);
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
 
-        Document signedDoc = builder.build(doc, crypto, secHeader);
+        Document signedDoc = builder.build(doc, crypto);
 
         // Modify the Signature element
         Element signatureElement = builder.getSignatureElement();

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/NoSoapPrefixSignatureTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/NoSoapPrefixSignatureTest.java?rev=1771304&r1=1771303&r2=1771304&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/NoSoapPrefixSignatureTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/NoSoapPrefixSignatureTest.java Fri Nov 25 12:30:21 2016
@@ -55,16 +55,16 @@ public class NoSoapPrefixSignatureTest e
      */
     @Test
     public void testNoSOAPNamespacePrefix() throws Exception {
-        WSSecSignature sign = new WSSecSignature();
-        sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
-        sign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.setActor("bob");
         secHeader.insertSecurityHeader();
-        Document signedDoc = sign.build(doc, crypto, secHeader);
+        
+        WSSecSignature sign = new WSSecSignature(secHeader);
+        sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        sign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
+
+        Document signedDoc = sign.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/PasswordEncryptorTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/PasswordEncryptorTest.java?rev=1771304&r1=1771303&r2=1771304&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/PasswordEncryptorTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/PasswordEncryptorTest.java Fri Nov 25 12:30:21 2016
@@ -84,14 +84,15 @@ public class PasswordEncryptorTest exten
 
     @Test
     public void testSignature() throws Exception {
-        WSSecSignature builder = new WSSecSignature();
-        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
-        builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document signedDoc = builder.build(doc, crypto, secHeader);
+        
+        WSSecSignature builder = new WSSecSignature(secHeader);
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
+
+        Document signedDoc = builder.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -133,15 +134,16 @@ public class PasswordEncryptorTest exten
 
     @Test
     public void testDecryption() throws Exception {
-        WSSecEncrypt builder = new WSSecEncrypt();
+        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+        WSSecHeader secHeader = new WSSecHeader(doc);
+        secHeader.insertSecurityHeader();
+        
+        WSSecEncrypt builder = new WSSecEncrypt(secHeader);
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
         builder.setKeyEncAlgo(WSConstants.KEYTRANSPORT_RSAOAEP);
 
-        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();
-        Document encryptedDoc = builder.build(doc, crypto, secHeader);
+        Document encryptedDoc = builder.build(doc, crypto);
 
         String outputString =
             XMLUtils.prettyDocumentToString(encryptedDoc);

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/PasswordTypeTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/PasswordTypeTest.java?rev=1771304&r1=1771303&r2=1771304&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/PasswordTypeTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/PasswordTypeTest.java Fri Nov 25 12:30:21 2016
@@ -56,12 +56,13 @@ public class PasswordTypeTest extends or
      */
     @Test
     public void testPasswordDigest() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setUserInfo("wernerd", "verySecret");
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document signedDoc = builder.build(doc, secHeader);
+        
+        WSSecUsernameToken builder = new WSSecUsernameToken(secHeader);
+        builder.setUserInfo("wernerd", "verySecret");
+        Document signedDoc = builder.build(doc);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Message with UserNameToken PW Digest:");
@@ -107,13 +108,14 @@ public class PasswordTypeTest extends or
      */
     @Test
     public void testUsernameTokenText() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setPasswordType(WSConstants.PASSWORD_TEXT);
-        builder.setUserInfo("wernerd", "verySecret");
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document signedDoc = builder.build(doc, secHeader);
+        
+        WSSecUsernameToken builder = new WSSecUsernameToken(secHeader);
+        builder.setPasswordType(WSConstants.PASSWORD_TEXT);
+        builder.setUserInfo("wernerd", "verySecret");
+        Document signedDoc = builder.build(doc);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Message with UserNameToken PW Text:");

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ReplayTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ReplayTest.java?rev=1771304&r1=1771303&r2=1771304&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ReplayTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/ReplayTest.java Fri Nov 25 12:30:21 2016
@@ -77,11 +77,11 @@ public class ReplayTest extends org.juni
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        WSSecTimestamp timestamp = new WSSecTimestamp();
+        WSSecTimestamp timestamp = new WSSecTimestamp(secHeader);
         timestamp.setTimeToLive(300);
-        Document createdDoc = timestamp.build(doc, secHeader);
+        Document createdDoc = timestamp.build(doc);
 
-        WSSecSignature builder = new WSSecSignature();
+        WSSecSignature builder = new WSSecSignature(secHeader);
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
@@ -90,10 +90,10 @@ public class ReplayTest extends org.juni
                 "Timestamp", WSConstants.WSU_NS, "");
         builder.getParts().add(encP);
 
-        builder.prepare(createdDoc, crypto, secHeader);
+        builder.prepare(createdDoc, crypto);
 
         List<javax.xml.crypto.dsig.Reference> referenceList =
-            builder.addReferencesToSign(builder.getParts(), secHeader);
+            builder.addReferencesToSign(builder.getParts());
 
         builder.computeSignature(referenceList, false, null);
 
@@ -128,11 +128,11 @@ public class ReplayTest extends org.juni
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        WSSecTimestamp timestamp = new WSSecTimestamp();
+        WSSecTimestamp timestamp = new WSSecTimestamp(secHeader);
         timestamp.setTimeToLive(300);
-        Document createdDoc = timestamp.build(doc, secHeader);
+        Document createdDoc = timestamp.build(doc);
 
-        WSSecSignature builder = new WSSecSignature();
+        WSSecSignature builder = new WSSecSignature(secHeader);
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
@@ -141,10 +141,10 @@ public class ReplayTest extends org.juni
                 "Timestamp", WSConstants.WSU_NS, "");
         builder.getParts().add(encP);
 
-        builder.prepare(createdDoc, crypto, secHeader);
+        builder.prepare(createdDoc, crypto);
 
         List<javax.xml.crypto.dsig.Reference> referenceList =
-            builder.addReferencesToSign(builder.getParts(), secHeader);
+            builder.addReferencesToSign(builder.getParts());
 
         builder.computeSignature(referenceList, false, null);
 
@@ -182,11 +182,11 @@ public class ReplayTest extends org.juni
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        WSSecTimestamp timestamp = new WSSecTimestamp();
+        WSSecTimestamp timestamp = new WSSecTimestamp(secHeader);
         timestamp.setTimeToLive(300);
-        Document createdDoc = timestamp.build(doc, secHeader);
+        Document createdDoc = timestamp.build(doc);
 
-        WSSecSignature builder = new WSSecSignature();
+        WSSecSignature builder = new WSSecSignature(secHeader);
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
@@ -195,7 +195,7 @@ public class ReplayTest extends org.juni
                 "Timestamp", WSConstants.WSU_NS, "");
         builder.getParts().add(encP);
 
-        builder.build(createdDoc, crypto, secHeader);
+        builder.build(createdDoc, crypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -228,11 +228,11 @@ public class ReplayTest extends org.juni
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        WSSecTimestamp timestamp = new WSSecTimestamp();
+        WSSecTimestamp timestamp = new WSSecTimestamp(secHeader);
         timestamp.setTimeToLive(300);
-        Document createdDoc = timestamp.build(doc, secHeader);
+        Document createdDoc = timestamp.build(doc);
 
-        WSSecSignature builder = new WSSecSignature();
+        WSSecSignature builder = new WSSecSignature(secHeader);
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
@@ -241,7 +241,7 @@ public class ReplayTest extends org.juni
                 "Timestamp", WSConstants.WSU_NS, "");
         builder.getParts().add(encP);
 
-        builder.build(createdDoc, crypto, secHeader);
+        builder.build(createdDoc, crypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -277,11 +277,11 @@ public class ReplayTest extends org.juni
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        WSSecTimestamp timestamp = new WSSecTimestamp();
+        WSSecTimestamp timestamp = new WSSecTimestamp(secHeader);
         timestamp.setTimeToLive(0);
-        Document createdDoc = timestamp.build(doc, secHeader);
+        Document createdDoc = timestamp.build(doc);
 
-        WSSecSignature builder = new WSSecSignature();
+        WSSecSignature builder = new WSSecSignature(secHeader);
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
@@ -290,10 +290,10 @@ public class ReplayTest extends org.juni
                 "Timestamp", WSConstants.WSU_NS, "");
         builder.getParts().add(encP);
 
-        builder.prepare(createdDoc, crypto, secHeader);
+        builder.prepare(createdDoc, crypto);
 
         List<javax.xml.crypto.dsig.Reference> referenceList =
-            builder.addReferencesToSign(builder.getParts(), secHeader);
+            builder.addReferencesToSign(builder.getParts());
 
         builder.computeSignature(referenceList, false, null);
 
@@ -328,11 +328,11 @@ public class ReplayTest extends org.juni
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        WSSecTimestamp timestamp = new WSSecTimestamp();
+        WSSecTimestamp timestamp = new WSSecTimestamp(secHeader);
         timestamp.setTimeToLive(0);
-        Document createdDoc = timestamp.build(doc, secHeader);
+        Document createdDoc = timestamp.build(doc);
 
-        WSSecSignature builder = new WSSecSignature();
+        WSSecSignature builder = new WSSecSignature(secHeader);
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
@@ -341,10 +341,10 @@ public class ReplayTest extends org.juni
                 "Timestamp", WSConstants.WSU_NS, "");
         builder.getParts().add(encP);
 
-        builder.prepare(createdDoc, crypto, secHeader);
+        builder.prepare(createdDoc, crypto);
 
         List<javax.xml.crypto.dsig.Reference> referenceList =
-            builder.addReferencesToSign(builder.getParts(), secHeader);
+            builder.addReferencesToSign(builder.getParts());
 
         builder.computeSignature(referenceList, false, null);
 
@@ -377,13 +377,14 @@ public class ReplayTest extends org.juni
 
     @Test
     public void testReplayedUsernameToken() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setUserInfo("wernerd", "verySecret");
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document signedDoc = builder.build(doc, secHeader);
+        
+        WSSecUsernameToken builder = new WSSecUsernameToken(secHeader);
+        builder.setUserInfo("wernerd", "verySecret");
+
+        Document signedDoc = builder.build(doc);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -411,13 +412,14 @@ public class ReplayTest extends org.juni
 
     @Test
     public void testEhCacheReplayedUsernameToken() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setUserInfo("wernerd", "verySecret");
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document signedDoc = builder.build(doc, secHeader);
+        
+        WSSecUsernameToken builder = new WSSecUsernameToken(secHeader);
+        builder.setUserInfo("wernerd", "verySecret");
+
+        Document signedDoc = builder.build(doc);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -467,14 +469,14 @@ public class ReplayTest extends org.juni
         SAMLCallback samlCallback = new SAMLCallback();
         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();
 
-        Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
+
+        Document unsignedDoc = wsSign.build(doc, samlAssertion);
 
         if (LOG.isDebugEnabled()) {
             String outputString = XMLUtils.prettyDocumentToString(unsignedDoc);
@@ -522,14 +524,14 @@ public class ReplayTest extends org.juni
         SAMLCallback samlCallback = new SAMLCallback();
         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();
 
-        Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
+        WSSecSAMLToken wsSign = new WSSecSAMLToken(secHeader);
+
+        Document unsignedDoc = wsSign.build(doc, samlAssertion);
 
         String outputString =
             XMLUtils.prettyDocumentToString(unsignedDoc);

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/RequireSignedEncryptedDataElementsTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/RequireSignedEncryptedDataElementsTest.java?rev=1771304&r1=1771303&r2=1771304&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/RequireSignedEncryptedDataElementsTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/RequireSignedEncryptedDataElementsTest.java Fri Nov 25 12:30:21 2016
@@ -287,17 +287,17 @@ public class RequireSignedEncryptedDataE
     }
 
     private Document getRequestDocument() throws Exception {
-        WSSecEncrypt encrypt = new WSSecEncrypt();
-        WSSecSignature sign = new WSSecSignature();
-        encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
-        sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
-        LOG.info("Before Encryption....");
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
-
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecEncrypt encrypt = new WSSecEncrypt(secHeader);
+        WSSecSignature sign = new WSSecSignature(secHeader);
+        encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
+        sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        LOG.info("Before Encryption....");
 
-        Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
+        Document encryptedDoc = encrypt.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("After Encryption....");
@@ -306,7 +306,7 @@ public class RequireSignedEncryptedDataE
             LOG.debug(outputString);
         }
 
-        Document encryptedSignedDoc = sign.build(encryptedDoc, crypto, secHeader);
+        Document encryptedSignedDoc = sign.build(encryptedDoc, crypto);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("After Signing....");
@@ -318,17 +318,17 @@ public class RequireSignedEncryptedDataE
     }
 
     private Document getRequestDocumentEncryptionFirst() throws Exception {
-        WSSecEncrypt encrypt = new WSSecEncrypt();
-        WSSecSignature sign = new WSSecSignature();
-        encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
-        sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
-        LOG.info("Before Encryption....");
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
-
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecEncrypt encrypt = new WSSecEncrypt(secHeader);
+        WSSecSignature sign = new WSSecSignature(secHeader);
+        encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
+        sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        LOG.info("Before Encryption....");
 
-        Document signedDoc = sign.build(doc, crypto, secHeader);
+        Document signedDoc = sign.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("After Signing....");
@@ -337,7 +337,7 @@ public class RequireSignedEncryptedDataE
             LOG.debug(outputString);
         }
 
-        Document encryptedDoc = encrypt.build(signedDoc, crypto, secHeader);
+        Document encryptedDoc = encrypt.build(signedDoc, crypto);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("After Encryption....");

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SecurityContextTokenTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SecurityContextTokenTest.java?rev=1771304&r1=1771303&r2=1771304&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SecurityContextTokenTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SecurityContextTokenTest.java Fri Nov 25 12:30:21 2016
@@ -63,10 +63,10 @@ public class SecurityContextTokenTest ex
             WSSecHeader secHeader = new WSSecHeader(doc);
             secHeader.insertSecurityHeader();
 
-            WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken();
+            WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken(secHeader, null);
             sctBuilder.prepare(doc, crypto);
 
-            sctBuilder.prependSCTElementToHeader(doc, secHeader);
+            sctBuilder.prependSCTElementToHeader(doc);
 
             String out =
                 XMLUtils.prettyDocumentToString(doc);
@@ -101,7 +101,7 @@ public class SecurityContextTokenTest ex
             WSSecHeader secHeader = new WSSecHeader(doc);
             secHeader.insertSecurityHeader();
 
-            WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken();
+            WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken(secHeader, null);
             sctBuilder.prepare(doc, crypto);
 
             byte[] tempSecret = WSSecurityUtil.generateNonce(16);
@@ -112,12 +112,12 @@ public class SecurityContextTokenTest ex
             String tokenId = sctBuilder.getSctId();
 
             // Derived key encryption
-            WSSecDKEncrypt encrBuilder = new WSSecDKEncrypt();
+            WSSecDKEncrypt encrBuilder = new WSSecDKEncrypt(secHeader);
             encrBuilder.setSymmetricEncAlgorithm(WSConstants.AES_128);
             encrBuilder.setExternalKey(tempSecret, tokenId);
-            encrBuilder.build(doc, secHeader);
+            encrBuilder.build(doc);
 
-            sctBuilder.prependSCTElementToHeader(doc, secHeader);
+            sctBuilder.prependSCTElementToHeader(doc);
 
             if (LOG.isDebugEnabled()) {
                 String out = XMLUtils.prettyDocumentToString(doc);
@@ -150,7 +150,7 @@ public class SecurityContextTokenTest ex
             WSSecHeader secHeader = new WSSecHeader(doc);
             secHeader.insertSecurityHeader();
 
-            WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken();
+            WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken(secHeader, null);
             sctBuilder.setWscVersion(ConversationConstants.VERSION_05_12);
             sctBuilder.prepare(doc, crypto);
 
@@ -162,12 +162,12 @@ public class SecurityContextTokenTest ex
             String tokenId = sctBuilder.getSctId();
 
             // Derived key signature
-            WSSecDKSign sigBuilder = new WSSecDKSign();
+            WSSecDKSign sigBuilder = new WSSecDKSign(secHeader);
             sigBuilder.setExternalKey(tempSecret, tokenId);
             sigBuilder.setSignatureAlgorithm(WSConstants.HMAC_SHA1);
-            sigBuilder.build(doc, secHeader);
+            sigBuilder.build(doc);
 
-            sctBuilder.prependSCTElementToHeader(doc, secHeader);
+            sctBuilder.prependSCTElementToHeader(doc);
 
             if (LOG.isDebugEnabled()) {
                 String out = XMLUtils.prettyDocumentToString(doc);
@@ -200,7 +200,7 @@ public class SecurityContextTokenTest ex
             WSSecHeader secHeader = new WSSecHeader(doc);
             secHeader.insertSecurityHeader();
 
-            WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken();
+            WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken(secHeader, null);
             sctBuilder.prepare(doc, crypto);
 
             byte[] tempSecret = WSSecurityUtil.generateNonce(16);
@@ -209,13 +209,13 @@ public class SecurityContextTokenTest ex
             callbackHandler.addSecretKey(sctBuilder.getIdentifier(), tempSecret);
 
             // Derived key signature
-            WSSecDKSign sigBuilder = new WSSecDKSign();
+            WSSecDKSign sigBuilder = new WSSecDKSign(secHeader);
             sigBuilder.setExternalKey(tempSecret, sctBuilder.getIdentifier());
             sigBuilder.setTokenIdDirectId(true);
             sigBuilder.setSignatureAlgorithm(WSConstants.HMAC_SHA1);
-            sigBuilder.build(doc, secHeader);
+            sigBuilder.build(doc);
 
-            sctBuilder.prependSCTElementToHeader(doc, secHeader);
+            sctBuilder.prependSCTElementToHeader(doc);
 
             if (LOG.isDebugEnabled()) {
                 LOG.debug("DKT Absolute");
@@ -238,7 +238,7 @@ public class SecurityContextTokenTest ex
             WSSecHeader secHeader = new WSSecHeader(doc);
             secHeader.insertSecurityHeader();
 
-            WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken();
+            WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken(secHeader, null);
             sctBuilder.prepare(doc, crypto);
 
             byte[] tempSecret = WSSecurityUtil.generateNonce(16);
@@ -249,18 +249,18 @@ public class SecurityContextTokenTest ex
             String tokenId = sctBuilder.getSctId();
 
             // Derived key signature
-            WSSecDKSign sigBuilder = new WSSecDKSign();
+            WSSecDKSign sigBuilder = new WSSecDKSign(secHeader);
             sigBuilder.setExternalKey(tempSecret, tokenId);
             sigBuilder.setSignatureAlgorithm(WSConstants.HMAC_SHA1);
-            sigBuilder.build(doc, secHeader);
+            sigBuilder.build(doc);
 
             // Derived key encryption
-            WSSecDKEncrypt encrBuilder = new WSSecDKEncrypt();
+            WSSecDKEncrypt encrBuilder = new WSSecDKEncrypt(secHeader);
             encrBuilder.setSymmetricEncAlgorithm(WSConstants.AES_128);
             encrBuilder.setExternalKey(tempSecret, tokenId);
-            encrBuilder.build(doc, secHeader);
+            encrBuilder.build(doc);
 
-            sctBuilder.prependSCTElementToHeader(doc, secHeader);
+            sctBuilder.prependSCTElementToHeader(doc);
 
             if (LOG.isDebugEnabled()) {
                 String out = XMLUtils.prettyDocumentToString(doc);
@@ -281,7 +281,7 @@ public class SecurityContextTokenTest ex
             WSSecHeader secHeader = new WSSecHeader(doc);
             secHeader.insertSecurityHeader();
 
-            WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken();
+            WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken(secHeader, null);
             sctBuilder.prepare(doc, crypto);
 
             byte[] tempSecret = WSSecurityUtil.generateNonce(16);
@@ -292,18 +292,18 @@ public class SecurityContextTokenTest ex
             String tokenId = sctBuilder.getSctId();
 
             // Derived key encryption
-            WSSecDKEncrypt encrBuilder = new WSSecDKEncrypt();
+            WSSecDKEncrypt encrBuilder = new WSSecDKEncrypt(secHeader);
             encrBuilder.setSymmetricEncAlgorithm(WSConstants.AES_128);
             encrBuilder.setExternalKey(tempSecret, tokenId);
-            encrBuilder.build(doc, secHeader);
+            encrBuilder.build(doc);
 
             // Derived key signature
-            WSSecDKSign sigBuilder = new WSSecDKSign();
+            WSSecDKSign sigBuilder = new WSSecDKSign(secHeader);
             sigBuilder.setExternalKey(tempSecret, tokenId);
             sigBuilder.setSignatureAlgorithm(WSConstants.HMAC_SHA1);
-            sigBuilder.build(doc, secHeader);
+            sigBuilder.build(doc);
 
-            sctBuilder.prependSCTElementToHeader(doc, secHeader);
+            sctBuilder.prependSCTElementToHeader(doc);
 
             if (LOG.isDebugEnabled()) {
                 String out = XMLUtils.prettyDocumentToString(doc);
@@ -329,7 +329,7 @@ public class SecurityContextTokenTest ex
             WSSecHeader secHeader = new WSSecHeader(doc);
             secHeader.insertSecurityHeader();
 
-            WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken();
+            WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken(secHeader, null);
             sctBuilder.prepare(doc, crypto);
 
             byte[] tempSecret = WSSecurityUtil.generateNonce(16);
@@ -339,15 +339,15 @@ public class SecurityContextTokenTest ex
 
             String tokenId = sctBuilder.getSctId();
 
-            WSSecSignature builder = new WSSecSignature();
+            WSSecSignature builder = new WSSecSignature(secHeader);
             builder.setSecretKey(tempSecret);
             builder.setKeyIdentifierType(WSConstants.CUSTOM_SYMM_SIGNING);
             builder.setCustomTokenValueType(WSConstants.WSC_SCT);
             builder.setCustomTokenId(tokenId);
             builder.setSignatureAlgorithm(SignatureMethod.HMAC_SHA1);
-            builder.build(doc, crypto, secHeader);
+            builder.build(doc, crypto);
 
-            sctBuilder.prependSCTElementToHeader(doc, secHeader);
+            sctBuilder.prependSCTElementToHeader(doc);
 
             if (LOG.isDebugEnabled()) {
                 LOG.debug("SCT sign");

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureAKITest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureAKITest.java?rev=1771304&r1=1771303&r2=1771304&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureAKITest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureAKITest.java Fri Nov 25 12:30:21 2016
@@ -59,14 +59,15 @@ public class SignatureAKITest extends or
 
     @Test
     public void testSignatureAKI() throws Exception {
-        WSSecSignature builder = new WSSecSignature();
-        builder.setUserInfo("wss40", "security");
-        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSignature builder = new WSSecSignature(secHeader);
+        builder.setUserInfo("wss40", "security");
+        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         Crypto signingCrypto = CryptoFactory.getInstance("wss40.properties");
-        Document signedDoc = builder.build(doc, signingCrypto, secHeader);
+        Document signedDoc = builder.build(doc, signingCrypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -85,14 +86,15 @@ public class SignatureAKITest extends or
     // Here, the CA keystore contains two keys with the same Distinguished Name
     @Test
     public void testSignatureAKIDuplicate() throws Exception {
-        WSSecSignature builder = new WSSecSignature();
-        builder.setUserInfo("wss40", "security");
-        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSignature builder = new WSSecSignature(secHeader);
+        builder.setUserInfo("wss40", "security");
+        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         Crypto signingCrypto = CryptoFactory.getInstance("wss40.properties");
-        Document signedDoc = builder.build(doc, signingCrypto, secHeader);
+        Document signedDoc = builder.build(doc, signingCrypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureCRLTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureCRLTest.java?rev=1771304&r1=1771303&r2=1771304&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureCRLTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureCRLTest.java Fri Nov 25 12:30:21 2016
@@ -89,15 +89,15 @@ public class SignatureCRLTest extends or
     @Test
     @org.junit.Ignore
     public void testSignatureDirectReference() throws Exception {
-        WSSecSignature sign = new WSSecSignature();
-        sign.setUserInfo("wss40rev", "security");
-        sign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document signedDoc = sign.build(doc, crypto, secHeader);
+        
+        WSSecSignature sign = new WSSecSignature(secHeader);
+        sign.setUserInfo("wss40rev", "security");
+        sign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
+
+        Document signedDoc = sign.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -123,15 +123,15 @@ public class SignatureCRLTest extends or
     @Test
     @org.junit.Ignore
     public void testSignatureDirectReferenceRevocation() throws Exception {
-        WSSecSignature sign = new WSSecSignature();
-        sign.setUserInfo("wss40rev", "security");
-        sign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document signedDoc = sign.build(doc, crypto, secHeader);
+        
+        WSSecSignature sign = new WSSecSignature(secHeader);
+        sign.setUserInfo("wss40rev", "security");
+        sign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
+
+        Document signedDoc = sign.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -161,15 +161,15 @@ public class SignatureCRLTest extends or
     @Test
     @org.junit.Ignore
     public void testSignatureDirectReferenceRevocationKeyStore() throws Exception {
-        WSSecSignature sign = new WSSecSignature();
-        sign.setUserInfo("wss40rev", "security");
-        sign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document signedDoc = sign.build(doc, crypto, secHeader);
+        
+        WSSecSignature sign = new WSSecSignature(secHeader);
+        sign.setUserInfo("wss40rev", "security");
+        sign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
+
+        Document signedDoc = sign.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureCertConstraintsTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureCertConstraintsTest.java?rev=1771304&r1=1771303&r2=1771304&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureCertConstraintsTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureCertConstraintsTest.java Fri Nov 25 12:30:21 2016
@@ -65,14 +65,15 @@ public class SignatureCertConstraintsTes
      */
     @Test
     public void testBSTSignature() throws Exception {
-        WSSecSignature builder = new WSSecSignature();
-        builder.setUserInfo("wss40", "security");
-        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document signedDoc = builder.build(doc, crypto, secHeader);
+        
+        WSSecSignature builder = new WSSecSignature(secHeader);
+        builder.setUserInfo("wss40", "security");
+        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
+
+        Document signedDoc = builder.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed message with BST key identifier:");
@@ -99,15 +100,16 @@ public class SignatureCertConstraintsTes
      */
     @Test
     public void testBSTSignaturePKIPath() throws Exception {
-        WSSecSignature builder = new WSSecSignature();
+        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+        WSSecHeader secHeader = new WSSecHeader(doc);
+        secHeader.insertSecurityHeader();
+        
+        WSSecSignature builder = new WSSecSignature(secHeader);
         builder.setUserInfo("wss40", "security");
         builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         builder.setUseSingleCertificate(false);
 
-        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();
-        Document signedDoc = builder.build(doc, crypto, secHeader);
+        Document signedDoc = builder.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed message with BST key identifier:");

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureKeyValueTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureKeyValueTest.java?rev=1771304&r1=1771303&r2=1771304&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureKeyValueTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureKeyValueTest.java Fri Nov 25 12:30:21 2016
@@ -63,13 +63,14 @@ public class SignatureKeyValueTest exten
      */
     @Test
     public void testRSAKeyValue() throws Exception {
-        WSSecSignature builder = new WSSecSignature();
-        builder.setUserInfo("wss40", "security");
-        builder.setKeyIdentifierType(WSConstants.KEY_VALUE);
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document signedDoc = builder.build(doc, crypto, secHeader);
+        
+        WSSecSignature builder = new WSSecSignature(secHeader);
+        builder.setUserInfo("wss40", "security");
+        builder.setKeyIdentifierType(WSConstants.KEY_VALUE);
+        Document signedDoc = builder.build(doc, crypto);
 
         String outputString =
             XMLUtils.prettyDocumentToString(signedDoc);
@@ -105,14 +106,15 @@ public class SignatureKeyValueTest exten
      */
     @Test
     public void testBadRSAKeyValue() throws Exception {
-        WSSecSignature builder = new WSSecSignature();
-        builder.setUserInfo("wss86", "security");
-        builder.setKeyIdentifierType(WSConstants.KEY_VALUE);
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSignature builder = new WSSecSignature(secHeader);
+        builder.setUserInfo("wss86", "security");
+        builder.setKeyIdentifierType(WSConstants.KEY_VALUE);
         Document signedDoc =
-            builder.build(doc, CryptoFactory.getInstance("wss86.properties"), secHeader);
+            builder.build(doc, CryptoFactory.getInstance("wss86.properties"));
 
         String outputString =
             XMLUtils.prettyDocumentToString(signedDoc);
@@ -140,13 +142,14 @@ public class SignatureKeyValueTest exten
      */
     @Test
     public void testDSAKeyValue() throws Exception {
-        WSSecSignature builder = new WSSecSignature();
-        builder.setUserInfo("wss40DSA", "security");
-        builder.setKeyIdentifierType(WSConstants.KEY_VALUE);
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document signedDoc = builder.build(doc, crypto, secHeader);
+        
+        WSSecSignature builder = new WSSecSignature(secHeader);
+        builder.setUserInfo("wss40DSA", "security");
+        builder.setKeyIdentifierType(WSConstants.KEY_VALUE);
+        Document signedDoc = builder.build(doc, crypto);
 
         String outputString =
             XMLUtils.prettyDocumentToString(signedDoc);

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignedBSTTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignedBSTTest.java?rev=1771304&r1=1771303&r2=1771304&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignedBSTTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignedBSTTest.java Fri Nov 25 12:30:21 2016
@@ -81,10 +81,10 @@ public class SignedBSTTest extends org.j
         String certUri = WSSConfig.getNewInstance().getIdAllocator().createSecureId("X509-", certs[0]);
         bst.setX509Certificate(certs[0]);
         bst.setID(certUri);
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
+        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
         // Add the signature
-        WSSecSignature sign = new WSSecSignature();
+        WSSecSignature sign = new WSSecSignature(secHeader);
         sign.setUserInfo("wss40", "security");
         sign.setSignatureAlgorithm(WSConstants.RSA);
         sign.setKeyIdentifierType(WSConstants.CUSTOM_SYMM_SIGNING);
@@ -107,10 +107,10 @@ public class SignedBSTTest extends org.j
 
         sign.setCustomTokenId(bst.getID());
         sign.setCustomTokenValueType(bst.getValueType());
-        sign.prepare(doc, crypto, secHeader);
+        sign.prepare(doc, crypto);
 
         List<javax.xml.crypto.dsig.Reference> referenceList =
-            sign.addReferencesToSign(sign.getParts(), secHeader);
+            sign.addReferencesToSign(sign.getParts());
         sign.computeSignature(referenceList, false, null);
 
         if (LOG.isDebugEnabled()) {

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SymmetricSignatureTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SymmetricSignatureTest.java?rev=1771304&r1=1771303&r2=1771304&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SymmetricSignatureTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SymmetricSignatureTest.java Fri Nov 25 12:30:21 2016
@@ -99,12 +99,12 @@ public class SymmetricSignatureTest exte
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        WSSecSignature sign = new WSSecSignature();
+        WSSecSignature sign = new WSSecSignature(secHeader);
         sign.setKeyIdentifierType(WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER);
         sign.setSecretKey(keyData);
         sign.setSignatureAlgorithm(SignatureMethod.HMAC_SHA1);
 
-        Document signedDoc = sign.build(doc, crypto, secHeader);
+        Document signedDoc = sign.build(doc, crypto);
 
         byte[] encodedBytes = KeyUtils.generateDigest(keyData);
         String identifier = Base64.getMimeEncoder().encodeToString(encodedBytes);
@@ -132,21 +132,21 @@ public class SymmetricSignatureTest exte
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        WSSecEncryptedKey encrKey = new WSSecEncryptedKey();
+        WSSecEncryptedKey encrKey = new WSSecEncryptedKey(secHeader);
         encrKey.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
         encrKey.setUserInfo("wss40", "security");
         encrKey.setSymmetricEncAlgorithm(WSConstants.AES_192);
         encrKey.prepare(doc, crypto);
 
-        WSSecSignature sign = new WSSecSignature();
+        WSSecSignature sign = new WSSecSignature(secHeader);
         sign.setKeyIdentifierType(WSConstants.CUSTOM_SYMM_SIGNING);
         sign.setCustomTokenId(encrKey.getId());
         sign.setSecretKey(encrKey.getEphemeralKey());
         sign.setSignatureAlgorithm(SignatureMethod.HMAC_SHA1);
         sign.setCustomTokenValueType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
 
-        Document signedDoc = sign.build(doc, crypto, secHeader);
-        encrKey.prependToHeader(secHeader);
+        Document signedDoc = sign.build(doc, crypto);
+        encrKey.prependToHeader();
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed symmetric message DR:");
@@ -173,28 +173,28 @@ public class SymmetricSignatureTest exte
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        WSSecEncryptedKey encrKey = new WSSecEncryptedKey();
+        WSSecEncryptedKey encrKey = new WSSecEncryptedKey(secHeader);
         encrKey.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
         encrKey.setUserInfo("wss40", "security");
         encrKey.setSymmetricEncAlgorithm(WSConstants.AES_192);
         encrKey.prepare(doc, crypto);
 
-        WSSecEncrypt encrypt = new WSSecEncrypt();
+        WSSecEncrypt encrypt = new WSSecEncrypt(secHeader);
         encrypt.setEncKeyId(encrKey.getId());
         encrypt.setEphemeralKey(encrKey.getEphemeralKey());
         encrypt.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
         encrypt.setEncryptSymmKey(false);
         encrypt.setEncryptedKeyElement(encrKey.getEncryptedKeyElement());
 
-        WSSecSignature sign = new WSSecSignature();
+        WSSecSignature sign = new WSSecSignature(secHeader);
         sign.setKeyIdentifierType(WSConstants.CUSTOM_SYMM_SIGNING);
         sign.setCustomTokenId(encrKey.getId());
         sign.setCustomTokenValueType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
         sign.setSecretKey(encrKey.getEphemeralKey());
         sign.setSignatureAlgorithm(SignatureMethod.HMAC_SHA1);
 
-        Document signedDoc = sign.build(doc, crypto, secHeader);
-        Document encryptedSignedDoc = encrypt.build(signedDoc, crypto, secHeader);
+        Document signedDoc = sign.build(doc, crypto);
+        Document encryptedSignedDoc = encrypt.build(signedDoc, crypto);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed and encrypted message with IssuerSerial key identifier (both), 3DES:");

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/UTSignatureTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/UTSignatureTest.java?rev=1771304&r1=1771303&r2=1771304&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/UTSignatureTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/UTSignatureTest.java Fri Nov 25 12:30:21 2016
@@ -74,20 +74,20 @@ public class UTSignatureTest extends org
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        WSSecUsernameToken builder = new WSSecUsernameToken();
+        WSSecUsernameToken builder = new WSSecUsernameToken(secHeader);
         builder.setUserInfo("bob", "security");
         builder.addDerivedKey(true, null, 1000);
         builder.prepare(doc);
 
-        WSSecSignature sign = new WSSecSignature();
+        WSSecSignature sign = new WSSecSignature(secHeader);
         sign.setCustomTokenValueType(WSConstants.USERNAMETOKEN_NS + "#UsernameToken");
         sign.setCustomTokenId(builder.getId());
         sign.setSecretKey(builder.getDerivedKey());
         sign.setKeyIdentifierType(WSConstants.CUSTOM_SYMM_SIGNING);
         sign.setSignatureAlgorithm(WSConstants.HMAC_SHA1);
 
-        Document signedDoc = sign.build(doc, null, secHeader);
-        builder.prependToHeader(secHeader);
+        Document signedDoc = sign.build(doc, null);
+        builder.prependToHeader();
 
         String outputString =
             XMLUtils.prettyDocumentToString(signedDoc);
@@ -125,20 +125,20 @@ public class UTSignatureTest extends org
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        WSSecUsernameToken builder = new WSSecUsernameToken();
+        WSSecUsernameToken builder = new WSSecUsernameToken(secHeader);
         builder.setUserInfo("colm", "security");
         builder.addDerivedKey(true, null, 1000);
         builder.prepare(doc);
 
-        WSSecSignature sign = new WSSecSignature();
+        WSSecSignature sign = new WSSecSignature(secHeader);
         sign.setCustomTokenValueType(WSConstants.USERNAMETOKEN_NS + "#UsernameToken");
         sign.setCustomTokenId(builder.getId());
         sign.setSecretKey(builder.getDerivedKey());
         sign.setKeyIdentifierType(WSConstants.CUSTOM_SYMM_SIGNING);
         sign.setSignatureAlgorithm(WSConstants.HMAC_SHA1);
 
-        Document signedDoc = sign.build(doc, null, secHeader);
-        builder.prependToHeader(secHeader);
+        Document signedDoc = sign.build(doc, null);
+        builder.prependToHeader();
 
         String outputString =
             XMLUtils.prettyDocumentToString(signedDoc);



Mime
View raw message