ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1771303 [2/2] - in /webservices/wss4j/trunk/ws-security-dom/src: main/java/org/apache/wss4j/dom/action/ main/java/org/apache/wss4j/dom/message/ main/java/org/apache/wss4j/dom/processor/ main/java/org/apache/wss4j/dom/saml/ test/java/org/ap...
Date Fri, 25 Nov 2016 12:30:06 GMT
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CertificateStoreTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CertificateStoreTest.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CertificateStoreTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CertificateStoreTest.java Fri Nov 25 12:30:06 2016
@@ -76,15 +76,15 @@ public class CertificateStoreTest extend
      */
     @Test
     public void testSignatureDirectReference() throws Exception {
-        WSSecSignature sign = new WSSecSignature();
-        sign.setUserInfo("wss40", "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, senderCrypto, secHeader);
+        
+        WSSecSignature sign = new WSSecSignature(secHeader);
+        sign.setUserInfo("wss40", "security");
+        sign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
+
+        Document signedDoc = sign.build(doc, senderCrypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -108,15 +108,15 @@ public class CertificateStoreTest extend
      */
     @Test
     public void testSignatureX509() throws Exception {
-        WSSecSignature sign = new WSSecSignature();
-        sign.setUserInfo("wss40", "security");
-        sign.setKeyIdentifierType(WSConstants.X509_KEY_IDENTIFIER);
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document signedDoc = sign.build(doc, senderCrypto, secHeader);
+        
+        WSSecSignature sign = new WSSecSignature(secHeader);
+        sign.setUserInfo("wss40", "security");
+        sign.setKeyIdentifierType(WSConstants.X509_KEY_IDENTIFIER);
+
+        Document signedDoc = sign.build(doc, senderCrypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -146,15 +146,15 @@ public class CertificateStoreTest extend
      */
     @Test
     public void testSignatureIssuerSerial() throws Exception {
-        WSSecSignature sign = new WSSecSignature();
-        sign.setUserInfo("wss40", "security");
-        sign.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document signedDoc = sign.build(doc, senderCrypto, secHeader);
+        
+        WSSecSignature sign = new WSSecSignature(secHeader);
+        sign.setUserInfo("wss40", "security");
+        sign.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
+
+        Document signedDoc = sign.build(doc, senderCrypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -180,15 +180,15 @@ public class CertificateStoreTest extend
      */
     @Test
     public void testSignatureThumbprint() throws Exception {
-        WSSecSignature sign = new WSSecSignature();
-        sign.setUserInfo("wss40", "security");
-        sign.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document signedDoc = sign.build(doc, senderCrypto, secHeader);
+        
+        WSSecSignature sign = new WSSecSignature(secHeader);
+        sign.setUserInfo("wss40", "security");
+        sign.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
+
+        Document signedDoc = sign.build(doc, senderCrypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -214,15 +214,15 @@ public class CertificateStoreTest extend
      */
     @Test
     public void testSignatureSKI() throws Exception {
-        WSSecSignature sign = new WSSecSignature();
-        sign.setUserInfo("wss40", "security");
-        sign.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER);
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document signedDoc = sign.build(doc, senderCrypto, secHeader);
+        
+        WSSecSignature sign = new WSSecSignature(secHeader);
+        sign.setUserInfo("wss40", "security");
+        sign.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER);
+
+        Document signedDoc = sign.build(doc, senderCrypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -249,15 +249,15 @@ public class CertificateStoreTest extend
      */
     @Test
     public void testSignatureDirectReferenceUntrusted() 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.insertSecurityHeader();
-        Document signedDoc = sign.build(doc, CryptoFactory.getInstance(), 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, CryptoFactory.getInstance());
 
         if (LOG.isDebugEnabled()) {
             String outputString =

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CryptoProviderTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CryptoProviderTest.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CryptoProviderTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CryptoProviderTest.java Fri Nov 25 12:30:06 2016
@@ -81,13 +81,14 @@ public class CryptoProviderTest extends
     @Test
     public void testSignatureOID() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        WSSecSignature sign = new WSSecSignature();
+        WSSecHeader secHeader = new WSSecHeader(doc);
+        secHeader.insertSecurityHeader();
+        
+        WSSecSignature sign = new WSSecSignature(secHeader);
         sign.setUserInfo("wss86", "security");
         sign.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
-        WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();
-        Document signedDoc = sign.build(doc, crypto, secHeader);
+        Document signedDoc = sign.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -104,13 +105,14 @@ public class CryptoProviderTest extends
     @Test
     public void testSignatureEmailAddress() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        WSSecSignature sign = new WSSecSignature();
+        WSSecHeader secHeader = new WSSecHeader(doc);
+        secHeader.insertSecurityHeader();
+        
+        WSSecSignature sign = new WSSecSignature(secHeader);
         sign.setUserInfo("wss86", "security");
         sign.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
-        WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();
-        Document signedDoc = sign.build(doc, crypto, secHeader);
+        Document signedDoc = sign.build(doc, crypto);
 
         String outputString = XMLUtils.prettyDocumentToString(signedDoc);
         outputString =
@@ -131,13 +133,14 @@ public class CryptoProviderTest extends
     @Test
     public void testSignatureOtherEmailAddress() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        WSSecSignature sign = new WSSecSignature();
+        WSSecHeader secHeader = new WSSecHeader(doc);
+        secHeader.insertSecurityHeader();
+        
+        WSSecSignature sign = new WSSecSignature(secHeader);
         sign.setUserInfo("wss86", "security");
         sign.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
-        WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();
-        Document signedDoc = sign.build(doc, crypto, secHeader);
+        Document signedDoc = sign.build(doc, crypto);
 
         String outputString = XMLUtils.prettyDocumentToString(signedDoc);
         outputString =
@@ -192,12 +195,13 @@ public class CryptoProviderTest extends
                     new ByteArrayInputStream(certBytes)
                 );
 
-            WSSecEncrypt encrypt = new WSSecEncrypt();
-            encrypt.setUseThisCert(cert);
             Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
             WSSecHeader secHeader = new WSSecHeader(doc);
             secHeader.insertSecurityHeader();
-            Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
+            
+            WSSecEncrypt encrypt = new WSSecEncrypt(secHeader);
+            encrypt.setUseThisCert(cert);
+            Document encryptedDoc = encrypt.build(doc, crypto);
 
             if (LOG.isDebugEnabled()) {
                 String outputString =
@@ -247,12 +251,13 @@ public class CryptoProviderTest extends
                     new ByteArrayInputStream(certBytes)
                 );
 
-            WSSecEncrypt encrypt = new WSSecEncrypt();
-            encrypt.setUseThisCert(cert);
             Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
             WSSecHeader secHeader = new WSSecHeader(doc);
             secHeader.insertSecurityHeader();
-            Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
+            
+            WSSecEncrypt encrypt = new WSSecEncrypt(secHeader);
+            encrypt.setUseThisCert(cert);
+            Document encryptedDoc = encrypt.build(doc, crypto);
 
             if (LOG.isDebugEnabled()) {
                 String outputString =

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CryptoTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CryptoTest.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CryptoTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/components/crypto/CryptoTest.java Fri Nov 25 12:30:06 2016
@@ -95,13 +95,13 @@ public class CryptoTest extends org.juni
      */
     @Test
     public void testDynamicCrypto() 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);
 
         // Load the keystore
         Crypto crypto = new Merlin();
@@ -111,7 +111,7 @@ public class CryptoTest extends org.juni
         keyStore.load(input, "security".toCharArray());
         input.close();
         ((Merlin)crypto).setKeyStore(keyStore);
-        Document signedDoc = builder.build(doc, crypto, secHeader);
+        Document signedDoc = builder.build(doc, crypto);
 
         // Load the truststore
         Crypto processCrypto = new Merlin();

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/CustomActionProcessorTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/CustomActionProcessorTest.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/CustomActionProcessorTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/CustomActionProcessorTest.java Fri Nov 25 12:30:06 2016
@@ -67,14 +67,15 @@ public class CustomActionProcessorTest e
     @Test
     public void
     testCustomUserProcessor() throws Exception {
-        WSSecSignature builder = new WSSecSignature();
-        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
-        builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
-        LOG.info("Before Signing IS....");
         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);
+        LOG.info("Before Signing IS....");
+        Document signedDoc = builder.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed message with IssuerSerial key identifier:");
@@ -112,14 +113,15 @@ public class CustomActionProcessorTest e
     @Test
     public void
     testCustomUserProcessorObject() throws Exception {
-        WSSecSignature builder = new WSSecSignature();
-        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
-        builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
-        LOG.info("Before Signing IS....");
         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);
+        LOG.info("Before Signing IS....");
+        Document signedDoc = builder.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Signed message with IssuerSerial key identifier:");

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/CustomTokenTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/CustomTokenTest.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/CustomTokenTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/CustomTokenTest.java Fri Nov 25 12:30:06 2016
@@ -64,7 +64,7 @@ public class CustomTokenTest extends org
         dbf.setNamespaceAware(true);
         Document timestampDoc = dbf.newDocumentBuilder().newDocument();
 
-        WSSecTimestamp timestamp = new WSSecTimestamp();
+        WSSecTimestamp timestamp = new WSSecTimestamp(null);
         timestamp.setTimeToLive(300);
         timestamp.prepare(timestampDoc);
         Element timestampElement = timestamp.getElement();

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java Fri Nov 25 12:30:06 2016
@@ -286,7 +286,7 @@ public class SignatureConfirmationTest e
         byte[] randomBytes = WSSecurityUtil.generateNonce(20);
         SignatureConfirmation sigConf = new SignatureConfirmation(doc, randomBytes);
         Element sigConfElement = sigConf.getElement();
-        secHeader.getSecurityHeader().appendChild(sigConfElement);
+        secHeader.getSecurityHeaderElement().appendChild(sigConfElement);
 
         if (LOG.isDebugEnabled()) {
             String outputString =

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/UsernameTokenTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/UsernameTokenTest.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/UsernameTokenTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/UsernameTokenTest.java Fri Nov 25 12:30:06 2016
@@ -126,13 +126,14 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testUsernameTokenDigest() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setUserInfo("wernerd", "verySecret");
-        LOG.info("Before adding UsernameToken PW Digest....");
         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");
+        LOG.info("Before adding UsernameToken PW Digest....");
+        Document signedDoc = builder.build(doc);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Message with UserNameToken PW Digest:");
@@ -176,15 +177,16 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testUsernameTokenWithEncodedPassword() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
+        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+        WSSecHeader secHeader = new WSSecHeader(doc);
+        secHeader.insertSecurityHeader();
+        
+        WSSecUsernameToken builder = new WSSecUsernameToken(secHeader);
         builder.setPasswordsAreEncoded(true);
         builder.setUserInfo("wernerd", 
                             Base64.getMimeEncoder().encodeToString(MessageDigest.getInstance("SHA-1").digest("verySecret".getBytes(StandardCharsets.UTF_8))));
         LOG.info("Before adding UsernameToken PW Digest....");
-        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();
-        Document signedDoc = builder.build(doc, secHeader);
+        Document signedDoc = builder.build(doc);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Message with UserNameToken PW Digest:");
@@ -207,13 +209,14 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testUsernameTokenBadUsername() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setUserInfo("badusername", "verySecret");
-        LOG.info("Before adding UsernameToken PW Digest....");
         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("badusername", "verySecret");
+        LOG.info("Before adding UsernameToken PW Digest....");
+        Document signedDoc = builder.build(doc);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Message with UserNameToken PW Digest:");
@@ -238,13 +241,14 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testUsernameTokenBadDigest() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setUserInfo("wernerd", "verySecre");
-        LOG.info("Before adding UsernameToken PW Digest....");
         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", "verySecre");
+        LOG.info("Before adding UsernameToken PW Digest....");
+        Document signedDoc = builder.build(doc);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Message with UserNameToken PW Digest:");
@@ -268,12 +272,13 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testOldUsernameToken() 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 =
@@ -335,7 +340,7 @@ public class UsernameTokenTest extends o
         elementCreated.appendChild(doc.createTextNode(zulu.format(createdDate)));
         usernameTokenElement.appendChild(elementCreated);
 
-        secHeader.getSecurityHeader().appendChild(usernameTokenElement);
+        secHeader.getSecurityHeaderElement().appendChild(usernameTokenElement);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -400,7 +405,7 @@ public class UsernameTokenTest extends o
         elementCreated.appendChild(doc.createTextNode(zulu.format(createdDate)));
         usernameTokenElement.appendChild(elementCreated);
 
-        secHeader.getSecurityHeader().appendChild(usernameTokenElement);
+        secHeader.getSecurityHeaderElement().appendChild(usernameTokenElement);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -422,14 +427,15 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testUsernameTokenText() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setPasswordType(WSConstants.PASSWORD_TEXT);
-        builder.setUserInfo("wernerd", "verySecret");
-        LOG.info("Before adding UsernameToken PW Text....");
         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");
+        LOG.info("Before adding UsernameToken PW Text....");
+        Document signedDoc = builder.build(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Message with UserNameToken PW Text:");
             String outputString =
@@ -457,7 +463,11 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testUsernameTokenDigestText() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
+        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+        WSSecHeader secHeader = new WSSecHeader(doc);
+        secHeader.insertSecurityHeader();
+        
+        WSSecUsernameToken builder = new WSSecUsernameToken(secHeader);
         builder.setPasswordType(WSConstants.PASSWORD_TEXT);
         byte[] password = "verySecret".getBytes();
         MessageDigest sha = MessageDigest.getInstance("MD5");
@@ -467,10 +477,7 @@ public class UsernameTokenTest extends o
 
         builder.setUserInfo("wernerd", passwdDigest);
         LOG.info("Before adding UsernameToken PW Text....");
-        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();
-        Document signedDoc = builder.build(doc, secHeader);
+        Document signedDoc = builder.build(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Message with UserNameToken PW Text:");
             String outputString =
@@ -484,14 +491,15 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testUsernameTokenBadText() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setPasswordType(WSConstants.PASSWORD_TEXT);
-        builder.setUserInfo("wernerd", "verySecre");
-        LOG.info("Before adding UsernameToken PW Text....");
         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", "verySecre");
+        LOG.info("Before adding UsernameToken PW Text....");
+        Document signedDoc = builder.build(doc);
         if (LOG.isDebugEnabled()) {
             LOG.debug("Message with UserNameToken PW Text:");
             String outputString =
@@ -565,14 +573,15 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testUsernameTokenNoPassword() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setPasswordType(null);
-        builder.setUserInfo("nopassuser", null);
-        LOG.info("Before adding UsernameToken with no password....");
         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(null);
+        builder.setUserInfo("nopassuser", null);
+        LOG.info("Before adding UsernameToken with no password....");
+        Document signedDoc = builder.build(doc);
         if (LOG.isDebugEnabled()) {
             String outputString =
                 XMLUtils.prettyDocumentToString(signedDoc);
@@ -592,14 +601,15 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testUsernameTokenEmptyPassword() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setPasswordType(WSConstants.PASSWORD_TEXT);
-        builder.setUserInfo("emptyuser", "");
-        LOG.info("Before adding UsernameToken with an empty password....");
         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("emptyuser", "");
+        LOG.info("Before adding UsernameToken with an empty password....");
+        Document signedDoc = builder.build(doc);
         if (LOG.isDebugEnabled()) {
             String outputString =
                 XMLUtils.prettyDocumentToString(signedDoc);
@@ -632,14 +642,15 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testUsernameTokenCustomFail() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setPasswordType("RandomType");
-        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("RandomType");
+        builder.setUserInfo("wernerd", "verySecret");
+
+        Document signedDoc = builder.build(doc);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Message with UserNameToken PW Text:");
@@ -663,14 +674,15 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testUsernameTokenCustomPass() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setPasswordType("RandomType");
-        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("RandomType");
+        builder.setUserInfo("wernerd", "verySecret");
+
+        Document signedDoc = builder.build(doc);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Message with UserNameToken PW custom type:");
@@ -699,14 +711,15 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testNullNonce() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setPasswordType(WSConstants.PASSWORD_DIGEST);
-        builder.setUserInfo("wernerd", "BAD_PASSWORD");
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document utDoc = builder.build(doc, secHeader);
+        
+        WSSecUsernameToken builder = new WSSecUsernameToken(secHeader);
+        builder.setPasswordType(WSConstants.PASSWORD_DIGEST);
+        builder.setUserInfo("wernerd", "BAD_PASSWORD");
+
+        Document utDoc = builder.build(doc);
 
         //
         // Manually find the Nonce node and set the content to null
@@ -742,15 +755,15 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testNullCreated() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setPasswordType(WSConstants.PASSWORD_DIGEST);
-        builder.setUserInfo("wernerd", "BAD_PASSWORD");
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document utDoc = builder.build(doc, secHeader);
+        
+        WSSecUsernameToken builder = new WSSecUsernameToken(secHeader);
+        builder.setPasswordType(WSConstants.PASSWORD_DIGEST);
+        builder.setUserInfo("wernerd", "BAD_PASSWORD");
 
+        Document utDoc = builder.build(doc);
         //
         // Manually find the Created node and set the content to null
         //
@@ -783,13 +796,14 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testUsernameTokenNonceEncodingType() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setUserInfo("wernerd", "verySecret");
-        LOG.info("Before adding UsernameToken PW Digest....");
         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");
+        LOG.info("Before adding UsernameToken PW Digest....");
+        Document signedDoc = builder.build(doc);
         String outputString =
             XMLUtils.prettyDocumentToString(signedDoc);
         assertTrue(outputString.contains("EncodingType"));
@@ -892,14 +906,15 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testMultipleNonce() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setPasswordType(WSConstants.PASSWORD_DIGEST);
-        builder.setUserInfo("wernerd", "verySecret");
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document utDoc = builder.build(doc, secHeader);
+        
+        WSSecUsernameToken builder = new WSSecUsernameToken(secHeader);
+        builder.setPasswordType(WSConstants.PASSWORD_DIGEST);
+        builder.setUserInfo("wernerd", "verySecret");
+
+        Document utDoc = builder.build(doc);
 
         //
         // Manually find the Nonce node and duplicate it
@@ -935,14 +950,15 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testMultipleCreated() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setPasswordType(WSConstants.PASSWORD_DIGEST);
-        builder.setUserInfo("wernerd", "verySecret");
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document utDoc = builder.build(doc, secHeader);
+        
+        WSSecUsernameToken builder = new WSSecUsernameToken(secHeader);
+        builder.setPasswordType(WSConstants.PASSWORD_DIGEST);
+        builder.setUserInfo("wernerd", "verySecret");
+
+        Document utDoc = builder.build(doc);
 
         //
         // Manually find the Created node and duplicate it
@@ -978,14 +994,15 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testMultiplePassword() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setPasswordType(WSConstants.PASSWORD_DIGEST);
-        builder.setUserInfo("wernerd", "verySecret");
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document utDoc = builder.build(doc, secHeader);
+        
+        WSSecUsernameToken builder = new WSSecUsernameToken(secHeader);
+        builder.setPasswordType(WSConstants.PASSWORD_DIGEST);
+        builder.setUserInfo("wernerd", "verySecret");
+
+        Document utDoc = builder.build(doc);
 
         //
         // Manually find the Nonce node and duplicate it
@@ -1021,14 +1038,15 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testNonceBadEncodingType() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setPasswordType(WSConstants.PASSWORD_DIGEST);
-        builder.setUserInfo("wernerd", "verySecret");
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document utDoc = builder.build(doc, secHeader);
+        
+        WSSecUsernameToken builder = new WSSecUsernameToken(secHeader);
+        builder.setPasswordType(WSConstants.PASSWORD_DIGEST);
+        builder.setUserInfo("wernerd", "verySecret");
+
+        Document utDoc = builder.build(doc);
 
         //
         // Manually find the Nonce node and duplicate it
@@ -1095,11 +1113,12 @@ public class UsernameTokenTest extends o
      */
     @Test
     public void testSpoofedUsernameToken() 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();
+        
+        WSSecUsernameToken builder = new WSSecUsernameToken(secHeader);
+        builder.setUserInfo("wernerd", "verySecret");
 
         WSTimeSource spoofedTimeSource = new WSTimeSource() {
 
@@ -1112,7 +1131,7 @@ public class UsernameTokenTest extends o
         };
 
         builder.setWsTimeSource(spoofedTimeSource);
-        Document signedDoc = builder.build(doc, secHeader);
+        Document signedDoc = builder.build(doc);
 
         if (LOG.isDebugEnabled()) {
             String outputString =

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/XOPAttachmentTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/XOPAttachmentTest.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/XOPAttachmentTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/XOPAttachmentTest.java Fri Nov 25 12:30:06 2016
@@ -103,12 +103,12 @@ public class XOPAttachmentTest extends o
     @Test
     public void testManualEncryptedSOAPBody() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        WSSecEncrypt encrypt = new WSSecEncrypt();
-        encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
-        encrypt.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
-
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecEncrypt encrypt = new WSSecEncrypt(secHeader);
+        encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        encrypt.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
         encrypt.getParts().add(new WSEncryptionPart("Body", "http://schemas.xmlsoap.org/soap/envelope/", "Content"));
         encrypt.getParts().add(new WSEncryptionPart("cid:Attachments", "Content"));
@@ -123,7 +123,7 @@ public class XOPAttachmentTest extends o
         encrypt.setAttachmentCallbackHandler(attachmentCallbackHandler);
         List<Attachment> encryptedAttachments = attachmentCallbackHandler.getResponseAttachments();
 
-        Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
+        Document encryptedDoc = encrypt.build(doc, crypto);
 
         // Find the SOAP Body + replace with a xop:Include to the attachment!
         Element soapBody = WSSecurityUtil.findBodyElement(encryptedDoc);
@@ -190,12 +190,12 @@ public class XOPAttachmentTest extends o
     @Test
     public void testEncryptedSOAPBody() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        WSSecEncrypt encrypt = new WSSecEncrypt();
-        encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
-        encrypt.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
-
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecEncrypt encrypt = new WSSecEncrypt(secHeader);
+        encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        encrypt.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
         AttachmentCallbackHandler outboundAttachmentCallback = new AttachmentCallbackHandler();
         encrypt.setAttachmentCallbackHandler(outboundAttachmentCallback);
@@ -203,7 +203,7 @@ public class XOPAttachmentTest extends o
 
         encrypt.getParts().add(new WSEncryptionPart("Body", "http://schemas.xmlsoap.org/soap/envelope/", "Content"));
 
-        Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
+        Document encryptedDoc = encrypt.build(doc, crypto);
 
         List<Attachment> encryptedAttachments = outboundAttachmentCallback.getResponseAttachments();
         assertNotNull(encryptedAttachments);
@@ -227,19 +227,19 @@ public class XOPAttachmentTest extends o
     // Here we are storing the BinarySecurityToken bytes in an attachment
     @Test
     public void testSignedSOAPBody() throws Exception {
-        WSSecSignature builder = new WSSecSignature();
-        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "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("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
 
         AttachmentCallbackHandler outboundAttachmentCallback = new AttachmentCallbackHandler();
         builder.setAttachmentCallbackHandler(outboundAttachmentCallback);
         builder.setStoreBytesInAttachment(true);
 
-        Document signedDoc = builder.build(doc, crypto, secHeader);
+        Document signedDoc = builder.build(doc, crypto);
 
         List<Attachment> signedAttachments = outboundAttachmentCallback.getResponseAttachments();
         assertNotNull(signedAttachments);
@@ -259,20 +259,20 @@ public class XOPAttachmentTest extends o
 
     @Test
     public void testSignedSOAPBodyAndBinarySecurityToken() throws Exception {
-        WSSecSignature builder = new WSSecSignature();
-        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
-        builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
-        builder.setIncludeSignatureToken(true);
-
         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");
+        builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
+        builder.setIncludeSignatureToken(true);
 
         AttachmentCallbackHandler outboundAttachmentCallback = new AttachmentCallbackHandler();
         builder.setAttachmentCallbackHandler(outboundAttachmentCallback);
         builder.setStoreBytesInAttachment(true);
 
-        Document signedDoc = builder.build(doc, crypto, secHeader);
+        Document signedDoc = builder.build(doc, crypto);
 
         List<Attachment> signedAttachments = outboundAttachmentCallback.getResponseAttachments();
         assertNotNull(signedAttachments);
@@ -293,12 +293,12 @@ public class XOPAttachmentTest extends o
     @Test
     public void testEncryptedHeaderAsEncryptedData() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAP_HEADER_MSG);
-        WSSecEncrypt encrypt = new WSSecEncrypt();
-        encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
-        encrypt.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
-
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecEncrypt encrypt = new WSSecEncrypt(secHeader);
+        encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        encrypt.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
         AttachmentCallbackHandler outboundAttachmentCallback = new AttachmentCallbackHandler();
         encrypt.setAttachmentCallbackHandler(outboundAttachmentCallback);
@@ -310,7 +310,7 @@ public class XOPAttachmentTest extends o
         encrypt.getParts().add(new WSEncryptionPart("Body", "http://schemas.xmlsoap.org/soap/envelope/", "Content"));
         encrypt.getParts().add(encP);
 
-        Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
+        Document encryptedDoc = encrypt.build(doc, crypto);
 
         List<Attachment> encryptedAttachments = outboundAttachmentCallback.getResponseAttachments();
         assertNotNull(encryptedAttachments);
@@ -331,12 +331,12 @@ public class XOPAttachmentTest extends o
     @Test
     public void testEncryptedHeaderasEncryptedHeader() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAP_HEADER_MSG);
-        WSSecEncrypt encrypt = new WSSecEncrypt();
-        encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
-        encrypt.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
-
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecEncrypt encrypt = new WSSecEncrypt(secHeader);
+        encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        encrypt.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
         AttachmentCallbackHandler outboundAttachmentCallback = new AttachmentCallbackHandler();
         encrypt.setAttachmentCallbackHandler(outboundAttachmentCallback);
@@ -348,7 +348,7 @@ public class XOPAttachmentTest extends o
         encrypt.getParts().add(new WSEncryptionPart("Body", "http://schemas.xmlsoap.org/soap/envelope/", "Content"));
         encrypt.getParts().add(encP);
 
-        Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
+        Document encryptedDoc = encrypt.build(doc, crypto);
 
         List<Attachment> encryptedAttachments = outboundAttachmentCallback.getResponseAttachments();
         assertNotNull(encryptedAttachments);
@@ -374,7 +374,7 @@ public class XOPAttachmentTest extends o
         AttachmentCallbackHandler outboundAttachmentCallback = new AttachmentCallbackHandler();
 
         //EncryptedKey
-        WSSecEncryptedKey encrKeyBuilder = new WSSecEncryptedKey();
+        WSSecEncryptedKey encrKeyBuilder = new WSSecEncryptedKey(secHeader);
         encrKeyBuilder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
         encrKeyBuilder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
         encrKeyBuilder.setAttachmentCallbackHandler(outboundAttachmentCallback);
@@ -386,15 +386,15 @@ public class XOPAttachmentTest extends o
         String tokenIdentifier = encrKeyBuilder.getId();
 
         //Derived key encryption
-        WSSecDKEncrypt encrBuilder = new WSSecDKEncrypt();
+        WSSecDKEncrypt encrBuilder = new WSSecDKEncrypt(secHeader);
         encrBuilder.setSymmetricEncAlgorithm(WSConstants.AES_128);
         encrBuilder.setExternalKey(ek, tokenIdentifier);
         encrBuilder.setAttachmentCallbackHandler(outboundAttachmentCallback);
         encrBuilder.setStoreBytesInAttachment(true);
-        Document encryptedDoc = encrBuilder.build(doc, secHeader);
+        Document encryptedDoc = encrBuilder.build(doc);
 
-        encrKeyBuilder.prependToHeader(secHeader);
-        encrKeyBuilder.prependBSTElementToHeader(secHeader);
+        encrKeyBuilder.prependToHeader();
+        encrKeyBuilder.prependBSTElementToHeader();
 
         List<Attachment> encryptedAttachments = outboundAttachmentCallback.getResponseAttachments();
         assertNotNull(encryptedAttachments);
@@ -424,7 +424,7 @@ public class XOPAttachmentTest extends o
         AttachmentCallbackHandler outboundAttachmentCallback = new AttachmentCallbackHandler();
 
         //EncryptedKey
-        WSSecEncryptedKey encrKeyBuilder = new WSSecEncryptedKey();
+        WSSecEncryptedKey encrKeyBuilder = new WSSecEncryptedKey(secHeader);
         encrKeyBuilder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
         encrKeyBuilder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
         encrKeyBuilder.setAttachmentCallbackHandler(outboundAttachmentCallback);
@@ -436,15 +436,15 @@ public class XOPAttachmentTest extends o
         String tokenIdentifier = encrKeyBuilder.getId();
 
         //Derived key encryption
-        WSSecDKSign sigBuilder = new WSSecDKSign();
+        WSSecDKSign sigBuilder = new WSSecDKSign(secHeader);
         sigBuilder.setExternalKey(ek, tokenIdentifier);
         sigBuilder.setSignatureAlgorithm(WSConstants.HMAC_SHA1);
         sigBuilder.setAttachmentCallbackHandler(outboundAttachmentCallback);
         sigBuilder.setStoreBytesInAttachment(true);
-        Document signedDoc = sigBuilder.build(doc, secHeader);
+        Document signedDoc = sigBuilder.build(doc);
 
-        encrKeyBuilder.prependToHeader(secHeader);
-        encrKeyBuilder.prependBSTElementToHeader(secHeader);
+        encrKeyBuilder.prependToHeader();
+        encrKeyBuilder.prependBSTElementToHeader();
 
         List<Attachment> signedAttachments = outboundAttachmentCallback.getResponseAttachments();
         assertNotNull(signedAttachments);
@@ -471,16 +471,16 @@ public class XOPAttachmentTest extends o
 
         AttachmentCallbackHandler outboundAttachmentCallback = new AttachmentCallbackHandler();
 
-        WSSecSignature builder = new WSSecSignature();
+        WSSecSignature builder = new WSSecSignature(secHeader);
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
 
         builder.setAttachmentCallbackHandler(outboundAttachmentCallback);
         builder.setStoreBytesInAttachment(true);
         builder.getParts().add(new WSEncryptionPart("Body", "http://schemas.xmlsoap.org/soap/envelope/", "Content"));
-        builder.build(doc, crypto, secHeader);
+        builder.build(doc, crypto);
 
-        WSSecEncrypt encrypt = new WSSecEncrypt();
+        WSSecEncrypt encrypt = new WSSecEncrypt(secHeader);
         encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         encrypt.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
@@ -488,7 +488,7 @@ public class XOPAttachmentTest extends o
         encrypt.setStoreBytesInAttachment(true);
         encrypt.getParts().add(new WSEncryptionPart("Body", "http://schemas.xmlsoap.org/soap/envelope/", "Content"));
 
-        Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
+        Document encryptedDoc = encrypt.build(doc, crypto);
 
         List<Attachment> encryptedAttachments = outboundAttachmentCallback.getResponseAttachments();
         assertNotNull(encryptedAttachments);

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/token/BSTKerberosTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/token/BSTKerberosTest.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/token/BSTKerberosTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/token/BSTKerberosTest.java Fri Nov 25 12:30:06 2016
@@ -90,7 +90,7 @@ public class BSTKerberosTest extends org
         bst.setValueType(AP_REQ);
         bst.setEncodingType(BASE64_NS);
         bst.setToken("12345678".getBytes());
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
+        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -119,9 +119,9 @@ public class BSTKerberosTest extends org
         bst.setEncodingType(BASE64_NS);
         bst.setToken("12345678".getBytes());
         bst.setID("Id-" + bst.hashCode());
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
+        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
-        WSSecSignature sign = new WSSecSignature();
+        WSSecSignature sign = new WSSecSignature(secHeader);
         sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         sign.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
@@ -129,7 +129,7 @@ public class BSTKerberosTest extends org
             new WSEncryptionPart(bst.getID());
         sign.getParts().add(encP);
 
-        Document signedDoc = sign.build(doc, crypto, secHeader);
+        Document signedDoc = sign.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -155,20 +155,20 @@ public class BSTKerberosTest extends org
         bst.setEncodingType(BASE64_NS);
         bst.setToken("12345678".getBytes());
         bst.setID("Id-" + bst.hashCode());
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
+        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
-        WSSecTimestamp timestamp = new WSSecTimestamp();
+        WSSecTimestamp timestamp = new WSSecTimestamp(secHeader);
         timestamp.setTimeToLive(600);
-        timestamp.build(doc, secHeader);
+        timestamp.build(doc);
 
-        WSSecSignature sign = new WSSecSignature();
+        WSSecSignature sign = new WSSecSignature(secHeader);
         sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         sign.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
         sign.getParts().add(new WSEncryptionPart(bst.getID()));
         sign.getParts().add(new WSEncryptionPart(timestamp.getId()));
 
-        Document signedDoc = sign.build(doc, crypto, secHeader);
+        Document signedDoc = sign.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -193,7 +193,7 @@ public class BSTKerberosTest extends org
         bst.setValueType(AP_REQ);
         bst.setEncodingType(BASE64_NS);
         bst.setToken("12345678".getBytes());
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
+        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -227,7 +227,7 @@ public class BSTKerberosTest extends org
         bst.setValueType(AP_REQ);
         bst.setEncodingType(BASE64_NS);
         bst.setToken("12345678".getBytes());
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
+        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -271,16 +271,16 @@ public class BSTKerberosTest extends org
 
         bst.setToken(keyData);
         bst.setID("Id-" + bst.hashCode());
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
+        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
-        WSSecSignature sign = new WSSecSignature();
+        WSSecSignature sign = new WSSecSignature(secHeader);
         sign.setSignatureAlgorithm(SignatureMethod.HMAC_SHA1);
         sign.setKeyIdentifierType(WSConstants.CUSTOM_SYMM_SIGNING);
         sign.setCustomTokenValueType(AP_REQ);
         sign.setCustomTokenId(bst.getID());
         sign.setSecretKey(keyData);
 
-        Document signedDoc = sign.build(doc, crypto, secHeader);
+        Document signedDoc = sign.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -310,9 +310,9 @@ public class BSTKerberosTest extends org
 
         bst.setToken(keyData);
         bst.setID("Id-" + bst.hashCode());
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
+        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
-        WSSecSignature sign = new WSSecSignature();
+        WSSecSignature sign = new WSSecSignature(secHeader);
         sign.setSignatureAlgorithm(SignatureMethod.HMAC_SHA1);
         sign.setKeyIdentifierType(WSConstants.CUSTOM_KEY_IDENTIFIER);
         sign.setCustomTokenValueType(WSConstants.WSS_KRB_KI_VALUE_TYPE);
@@ -321,7 +321,7 @@ public class BSTKerberosTest extends org
         sign.setCustomTokenId(Base64.getMimeEncoder().encodeToString(digestBytes));
         sign.setSecretKey(keyData);
 
-        Document signedDoc = sign.build(doc, crypto, secHeader);
+        Document signedDoc = sign.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -351,15 +351,15 @@ public class BSTKerberosTest extends org
 
         bst.setToken(keyData);
         bst.setID("Id-" + bst.hashCode());
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
+        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
-        WSSecEncrypt builder = new WSSecEncrypt();
+        WSSecEncrypt builder = new WSSecEncrypt(secHeader);
         builder.setSymmetricEncAlgorithm(WSConstants.AES_128);
         builder.setSymmetricKey(key);
         builder.setEncryptSymmKey(false);
         builder.setCustomReferenceValue(AP_REQ);
         builder.setEncKeyId(bst.getID());
-        Document encryptedDoc = builder.build(doc, crypto, secHeader);
+        Document encryptedDoc = builder.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -389,9 +389,9 @@ public class BSTKerberosTest extends org
 
         bst.setToken(keyData);
         bst.setID("Id-" + bst.hashCode());
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
+        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
-        WSSecEncrypt builder = new WSSecEncrypt();
+        WSSecEncrypt builder = new WSSecEncrypt(secHeader);
         builder.setSymmetricEncAlgorithm(WSConstants.AES_128);
         builder.setSymmetricKey(key);
         builder.setEncryptSymmKey(false);
@@ -400,7 +400,7 @@ public class BSTKerberosTest extends org
         byte[] digestBytes = KeyUtils.generateDigest(keyData);
         builder.setEncKeyId(Base64.getMimeEncoder().encodeToString(digestBytes));
 
-        Document encryptedDoc = builder.build(doc, crypto, secHeader);
+        Document encryptedDoc = builder.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/token/BinarySecurityTokenTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/token/BinarySecurityTokenTest.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/token/BinarySecurityTokenTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/token/BinarySecurityTokenTest.java Fri Nov 25 12:30:06 2016
@@ -75,7 +75,7 @@ public class BinarySecurityTokenTest ext
         X509Certificate[] certs = crypto.getX509Certificates(cryptoType);
         bst.setX509Certificate(certs[0]);
 
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
+        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("BST output");
@@ -116,7 +116,7 @@ public class BinarySecurityTokenTest ext
         X509Certificate[] certs = crypto.getX509Certificates(cryptoType);
         bst.setX509Certificates(certs, crypto);
 
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
+        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("PKIPath output");
@@ -150,7 +150,7 @@ public class BinarySecurityTokenTest ext
         BinarySecurity bst = new BinarySecurity(doc);
         bst.setToken("12435677".getBytes());
 
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
+        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Custom Token output");
@@ -175,7 +175,7 @@ public class BinarySecurityTokenTest ext
         bst.setValueType("http://custom_value_Type");
         secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
+        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
         WSHandlerResult results =
             secEngine.processSecurityHeader(doc, null, null, crypto);

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/FaultCodeTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/FaultCodeTest.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/FaultCodeTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/FaultCodeTest.java Fri Nov 25 12:30:06 2016
@@ -70,13 +70,14 @@ public class FaultCodeTest extends org.j
      */
     @Test
     public void testFailedCheck() throws Exception {
-        WSSecEncrypt builder = new WSSecEncrypt();
-        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 encryptedDoc = builder.build(doc, crypto, secHeader);
+        
+        WSSecEncrypt builder = new WSSecEncrypt(secHeader);
+        builder.setUserInfo("wss40", "security");
+        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
+        Document encryptedDoc = builder.build(doc, crypto);
 
         try {
             verify(encryptedDoc);
@@ -113,13 +114,14 @@ public class FaultCodeTest extends org.j
      */
     @Test
     public void testMessageExpired() throws Exception {
-        WSSecTimestamp builder = new WSSecTimestamp();
-        builder.setTimeToLive(-1);
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
-        Document timestampedDoc = builder.build(doc, secHeader);
+        
+        WSSecTimestamp builder = new WSSecTimestamp(secHeader);
+        builder.setTimeToLive(-1);
+
+        Document timestampedDoc = builder.build(doc);
 
         try {
             verify(timestampedDoc);
@@ -138,15 +140,16 @@ public class FaultCodeTest extends org.j
      */
     @Test
     public void testFailedAuthentication() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
+        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+        WSSecHeader secHeader = new WSSecHeader(doc);
+        secHeader.insertSecurityHeader();
+        
+        WSSecUsernameToken builder = new WSSecUsernameToken(secHeader);
         builder.addCreated();
         builder.addNonce();
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
 
-        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();
-        Document timestampedDoc = builder.build(doc, secHeader);
+        Document timestampedDoc = builder.build(doc);
 
         try {
             verify(timestampedDoc);
@@ -165,15 +168,16 @@ public class FaultCodeTest extends org.j
      */
     @Test
     public void testInvalidSecurityToken() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
+        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+        WSSecHeader secHeader = new WSSecHeader(doc);
+        secHeader.insertSecurityHeader();
+        
+        WSSecUsernameToken builder = new WSSecUsernameToken(secHeader);
         builder.addCreated();
         builder.addNonce();
         builder.setUserInfo(null, "security");
 
-        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();
-        builder.build(doc, secHeader);
+        builder.build(doc);
 
         try {
             new UsernameToken(doc.getDocumentElement(), false, new BSPEnforcer());

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/PrincipalTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/PrincipalTest.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/PrincipalTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/PrincipalTest.java Fri Nov 25 12:30:06 2016
@@ -77,12 +77,13 @@ public class PrincipalTest extends org.j
      */
     @Test
     public void testUsernameToken() 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 =
@@ -109,12 +110,13 @@ public class PrincipalTest extends org.j
      */
     @Test
     public void testTransformedUsernameToken() 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 =
@@ -143,14 +145,14 @@ public class PrincipalTest extends org.j
         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 =
@@ -187,13 +189,13 @@ public class PrincipalTest extends org.j
         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);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -231,13 +233,13 @@ public class PrincipalTest extends org.j
         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);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -280,7 +282,7 @@ public class PrincipalTest extends org.j
         X509Certificate[] certs = crypto.getX509Certificates(cryptoType);
         bst.setX509Certificate(certs[0]);
 
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
+        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
         if (LOG.isDebugEnabled()) {
             String outputString =

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/processor/EncryptedKeyDataRefTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/processor/EncryptedKeyDataRefTest.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/processor/EncryptedKeyDataRefTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/processor/EncryptedKeyDataRefTest.java Fri Nov 25 12:30:06 2016
@@ -81,12 +81,13 @@ public class EncryptedKeyDataRefTest ext
     @Test
     public void testDataRefEncryptedKeyProcessor() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        WSSecEncrypt builder = new WSSecEncrypt();
+        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);
-        WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();
         LOG.info("Before Encryption Triple DES....");
 
         /*
@@ -120,9 +121,9 @@ public class EncryptedKeyDataRefTest ext
          * now add (prepend) the EncryptedKey element, then a
          * BinarySecurityToken if one was setup during prepare
          */
-        builder.prependToHeader(secHeader);
+        builder.prependToHeader();
 
-        builder.prependBSTElementToHeader(secHeader);
+        builder.prependBSTElementToHeader();
 
         Document encryptedDoc = doc;
         LOG.info("After Encryption Triple DES....");

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/processor/ReferenceListDataRefTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/processor/ReferenceListDataRefTest.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/processor/ReferenceListDataRefTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/processor/ReferenceListDataRefTest.java Fri Nov 25 12:30:06 2016
@@ -81,12 +81,13 @@ public class ReferenceListDataRefTest ex
     @Test
     public void testDataRefReferenceListProcessor() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-        WSSecEncrypt builder = new WSSecEncrypt();
+        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);
-        WSSecHeader secHeader = new WSSecHeader(doc);
-        secHeader.insertSecurityHeader();
         LOG.info("Before Encryption Triple DES....");
 
         /*
@@ -110,15 +111,15 @@ public class ReferenceListDataRefTest ex
          * EncryptedKey element in the Security header (strict layout)
          */
         Element refs = builder.encrypt();
-        builder.addExternalRefElement(refs, secHeader);
+        builder.addExternalRefElement(refs);
 
         /*
          * now add (prepend) the EncryptedKey element, then a
          * BinarySecurityToken if one was setup during prepare
          */
-        builder.prependToHeader(secHeader);
+        builder.prependToHeader();
 
-        builder.prependBSTElementToHeader(secHeader);
+        builder.prependBSTElementToHeader();
 
         Document encryptedDoc = doc;
         LOG.info("After Encryption Triple DES....");

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/validate/ValidatorTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/validate/ValidatorTest.java?rev=1771303&r1=1771302&r2=1771303&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/validate/ValidatorTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/validate/ValidatorTest.java Fri Nov 25 12:30:06 2016
@@ -78,9 +78,9 @@ public class ValidatorTest extends org.j
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
 
-        WSSecTimestamp timestamp = new WSSecTimestamp();
+        WSSecTimestamp timestamp = new WSSecTimestamp(secHeader);
         timestamp.setTimeToLive(-1);
-        Document createdDoc = timestamp.build(doc, secHeader);
+        Document createdDoc = timestamp.build(doc);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -107,16 +107,16 @@ public class ValidatorTest extends org.j
      */
     @Test
     public void testUntrustedSignature() throws Exception {
-        WSSecSignature sign = new WSSecSignature();
-        sign.setUserInfo("wss40", "security");
-        sign.setKeyIdentifierType(WSConstants.X509_KEY_IDENTIFIER);
-
         Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
-
         WSSecHeader secHeader = new WSSecHeader(doc);
         secHeader.insertSecurityHeader();
+        
+        WSSecSignature sign = new WSSecSignature(secHeader);
+        sign.setUserInfo("wss40", "security");
+        sign.setKeyIdentifierType(WSConstants.X509_KEY_IDENTIFIER);
+
         Crypto crypto = CryptoFactory.getInstance("wss40.properties");
-        Document signedDoc = sign.build(doc, crypto, secHeader);
+        Document signedDoc = sign.build(doc, crypto);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -151,14 +151,15 @@ public class ValidatorTest extends org.j
      */
     @Test
     public void testUsernameTokenBadText() throws Exception {
-        WSSecUsernameToken builder = new WSSecUsernameToken();
-        builder.setPasswordType(WSConstants.PASSWORD_TEXT);
-        builder.setUserInfo("wernerd", "verySecre");
-
         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", "verySecre");
+
+        Document signedDoc = builder.build(doc);
 
         if (LOG.isDebugEnabled()) {
             String outputString =
@@ -198,7 +199,7 @@ public class ValidatorTest extends org.j
         X509Certificate[] certs = crypto.getX509Certificates(cryptoType);
         bst.setX509Certificate(certs[0]);
 
-        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
+        WSSecurityUtil.prependChildElement(secHeader.getSecurityHeaderElement(), bst.getElement());
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("BST output");
@@ -235,13 +236,14 @@ public class ValidatorTest extends org.j
      */
     @Test
     public void testValidatedBSTSignature() throws Exception {
-        WSSecSignature builder = new WSSecSignature();
-        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "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, CryptoFactory.getInstance(), secHeader);
+        
+        WSSecSignature builder = new WSSecSignature(secHeader);
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
+        Document signedDoc = builder.build(doc, CryptoFactory.getInstance());
 
         if (LOG.isDebugEnabled()) {
             String outputString =



Mime
View raw message