ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1042732 [1/2] - in /webservices/wss4j/trunk: src/test/java/org/apache/ws/security/common/ src/test/java/org/apache/ws/security/components/crypto/ src/test/java/org/apache/ws/security/handler/ src/test/java/org/apache/ws/security/message/ s...
Date Mon, 06 Dec 2010 17:22:40 GMT
Author: coheigea
Date: Mon Dec  6 17:22:39 2010
New Revision: 1042732

URL: http://svn.apache.org/viewvc?rev=1042732&view=rev
Log:
[WSS-250] - Lots more test reshuffling.

Added:
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/components/crypto/CryptoTest.java
      - copied, changed from r1042661, webservices/wss4j/trunk/src/test/java/org/apache/ws/security/components/crypto/MerlinTest.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/CustomActionProcessorTest.java
      - copied, changed from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityUserProcessor.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/ResultsOrderTest.java
      - copied, changed from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityResultsOrder.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/WSHandlerGetPasswordTest.java
      - copied, changed from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityGetPassword.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/EncryptionPartsTest.java
      - copied, changed from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityEncryptionParts.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/EncryptionTest.java
      - copied, changed from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew2.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SKISignatureTest.java
      - copied, changed from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew12.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/STRSignatureTest.java
      - copied, changed from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew11.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureEncryptionTest.java
      - copied, changed from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew6.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignaturePartsTest.java
      - copied, changed from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecuritySignatureParts.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureTest.java
      - copied, changed from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SymmetricSignatureTest.java
      - copied, changed from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew17.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/TimestampTest.java
      - copied, changed from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityTimestamp.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UsernameTokenTest.java
      - copied, changed from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew5.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/token/BSTKerberosTest.java
      - copied, changed from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityKerberosTokenProfile.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/misc/
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/misc/FaultCodeTest.java
      - copied, changed from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityFaultCodes.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/processor/
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/processor/EncryptedKeyDataRefTest.java
      - copied, changed from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityDataRef1.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/processor/ReferenceListDataRefTest.java
      - copied, changed from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityDataRef.java
    webservices/wss4j/trunk/wssec/
      - copied from r1042661, webservices/wss4j/trunk/src/test/java/wssec/
Removed:
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/components/crypto/MerlinTest.java
    webservices/wss4j/trunk/src/test/java/wssec/
    webservices/wss4j/trunk/wssec/TestWSSecurityDataRef.java
    webservices/wss4j/trunk/wssec/TestWSSecurityDataRef1.java
    webservices/wss4j/trunk/wssec/TestWSSecurityEncryptionParts.java
    webservices/wss4j/trunk/wssec/TestWSSecurityFaultCodes.java
    webservices/wss4j/trunk/wssec/TestWSSecurityGetPassword.java
    webservices/wss4j/trunk/wssec/TestWSSecurityKerberosTokenProfile.java
    webservices/wss4j/trunk/wssec/TestWSSecurityNew.java
    webservices/wss4j/trunk/wssec/TestWSSecurityNew10.java
    webservices/wss4j/trunk/wssec/TestWSSecurityNew11.java
    webservices/wss4j/trunk/wssec/TestWSSecurityNew12.java
    webservices/wss4j/trunk/wssec/TestWSSecurityNew14.java
    webservices/wss4j/trunk/wssec/TestWSSecurityNew15.java
    webservices/wss4j/trunk/wssec/TestWSSecurityNew16.java
    webservices/wss4j/trunk/wssec/TestWSSecurityNew17.java
    webservices/wss4j/trunk/wssec/TestWSSecurityNew18.java
    webservices/wss4j/trunk/wssec/TestWSSecurityNew2.java
    webservices/wss4j/trunk/wssec/TestWSSecurityNew3.java
    webservices/wss4j/trunk/wssec/TestWSSecurityNew5.java
    webservices/wss4j/trunk/wssec/TestWSSecurityNew6.java
    webservices/wss4j/trunk/wssec/TestWSSecurityNew7.java
    webservices/wss4j/trunk/wssec/TestWSSecurityNew8.java
    webservices/wss4j/trunk/wssec/TestWSSecurityNew9.java
    webservices/wss4j/trunk/wssec/TestWSSecurityNewSOAP12.java
    webservices/wss4j/trunk/wssec/TestWSSecurityResultsOrder.java
    webservices/wss4j/trunk/wssec/TestWSSecuritySignatureParts.java
    webservices/wss4j/trunk/wssec/TestWSSecurityTimestamp.java
    webservices/wss4j/trunk/wssec/TestWSSecurityUserProcessor.java
    webservices/wss4j/trunk/wssec/TestWSSecurityWSS234.java
Modified:
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomCrypto.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/SignatureConfirmationTest.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/CertErrorTest.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/ModifiedRequestTest.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/PasswordTypeTest.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureKeyValueTest.java

Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomCrypto.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomCrypto.java?rev=1042732&r1=1042731&r2=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomCrypto.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/common/CustomCrypto.java Mon Dec  6 17:22:39 2010
@@ -23,7 +23,7 @@ import org.apache.ws.security.components
 
 public class CustomCrypto extends CryptoBase {
     
-    java.util.Map<String, Object> config = null;
+    private java.util.Map<String, Object> config = null;
     
     public
     CustomCrypto(
@@ -33,22 +33,16 @@ public class CustomCrypto extends Crypto
         this.config = config;
     }
 
-    //
-    // org.apache.ws.security.components.crypto.Crypto implementation
-    //
-
     public String 
     getDefaultX509Alias() {
         return null;
     }
 
-    //
-    // org.apache.ws.security.components.crypto.AbstractCryptoBase
-    // implementation
-    //
-
-    protected String
-    getCryptoProvider() {
+    public String getCryptoProvider() {
         return null;
     }
+    
+    public java.util.Map<String, Object> getConfig() {
+        return config;
+    }
 }

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/components/crypto/CryptoTest.java (from r1042661, webservices/wss4j/trunk/src/test/java/org/apache/ws/security/components/crypto/MerlinTest.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/components/crypto/CryptoTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/components/crypto/CryptoTest.java&p1=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/components/crypto/MerlinTest.java&r1=1042661&r2=1042732&rev=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/components/crypto/MerlinTest.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/components/crypto/CryptoTest.java Mon Dec  6 17:22:39 2010
@@ -19,6 +19,8 @@
 
 package org.apache.ws.security.components.crypto;
 
+import org.apache.ws.security.common.CustomCrypto;
+
 /**
  * Created by IntelliJ IDEA.
  * User: srida01
@@ -26,7 +28,7 @@ package org.apache.ws.security.component
  * Time: 10:50:05 AM
  * To change this template use File | Settings | File Templates.
  */
-public class MerlinTest extends org.junit.Assert {
+public class CryptoTest extends org.junit.Assert {
     
     @org.junit.Test
     public void testCrypto() {
@@ -42,6 +44,34 @@ public class MerlinTest extends org.juni
     }
     
     /**
+     * Ensure that we can load a custom crypto implementation using a Map
+     */
+    @org.junit.Test
+    public void testCustomCrypto() {
+        java.util.Map<String, Object> tmp = new java.util.TreeMap<String, Object>();
+        Crypto crypto = CryptoFactory.getInstance(
+            "org.apache.ws.security.common.CustomCrypto",
+            tmp
+        );
+        assertNotNull(crypto);
+        assertTrue(crypto instanceof CustomCrypto);
+        CustomCrypto custom = (CustomCrypto)crypto;
+        assertSame(tmp, custom.getConfig());
+    }
+    
+    /**
+     * Test for WSS-149 - "AbstractCrypto requires org.apache.ws.security.crypto.merlin.file
+     * to be set and point to an existing file"
+     */
+    @org.junit.Test
+    public void testNoKeyStoreFile() {
+        Crypto crypto = CryptoFactory.getInstance(
+            "nofile.properties"
+        );
+        assertNotNull(crypto);
+    }
+    
+    /**
      * WSS-102 -- ensure AbstractCrypto will null properties
      * can be instantiated
      */

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/CustomActionProcessorTest.java (from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityUserProcessor.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/CustomActionProcessorTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/CustomActionProcessorTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityUserProcessor.java&r1=1042661&r2=1042732&rev=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityUserProcessor.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/CustomActionProcessorTest.java Mon Dec  6 17:22:39 2010
@@ -17,11 +17,8 @@
  * under the License.
  */
 
-package wssec;
+package org.apache.ws.security.handler;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSSecurityEngine;
@@ -29,6 +26,10 @@ import org.apache.ws.security.WSConstant
 import org.apache.ws.security.WSSConfig;
 import org.apache.ws.security.WSSecurityEngineResult;
 import org.apache.ws.security.WSSecurityException;
+import org.apache.ws.security.common.CustomAction;
+import org.apache.ws.security.common.CustomHandler;
+import org.apache.ws.security.common.CustomProcessor;
+import org.apache.ws.security.common.SOAPUtil;
 import org.apache.ws.security.components.crypto.Crypto;
 import org.apache.ws.security.components.crypto.CryptoFactory;
 import org.apache.ws.security.handler.RequestData;
@@ -43,11 +44,10 @@ import java.util.ArrayList;
 
 
 /**
- * WS-Security Test Case
- * <p/>
+ * A test for adding custom actions/processors etc.
  */
-public class TestWSSecurityUserProcessor extends TestCase {
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityUserProcessor.class);
+public class CustomActionProcessorTest extends org.junit.Assert {
+    private static final Log LOG = LogFactory.getLog(CustomActionProcessorTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -64,30 +64,10 @@ public class TestWSSecurityUserProcessor
     private Crypto crypto = CryptoFactory.getInstance();
 
     /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityUserProcessor(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityUserProcessor.class);
-    }
-
-
-    /**
      * Test to see that a custom processor configured through a 
      * WSSConfig instance is called
      */
+    @org.junit.Test
     public void 
     testCustomUserProcessor() throws Exception {
         WSSecSignature builder = new WSSecSignature();
@@ -110,7 +90,7 @@ public class TestWSSecurityUserProcessor
         // Check to make sure we can install/replace and use our own processor
         //
         WSSConfig cfg = WSSConfig.getNewInstance();
-        String p = "wssec.MyProcessor";
+        String p = "org.apache.ws.security.common.CustomProcessor";
         cfg.setProcessor(
             WSSecurityEngine.SIGNATURE,
             p
@@ -128,13 +108,14 @@ public class TestWSSecurityUserProcessor
                 }
             }
         }
-        assertTrue("Unable to find result from MyProcessor", found);
+        assertTrue("Unable to find result from CustomProcessor", found);
     }
     
     /**
      * Test to see that a custom processor (object) configured through a 
      * WSSConfig instance is called
      */
+    @org.junit.Test
     public void 
     testCustomUserProcessorObject() throws Exception {
         WSSecSignature builder = new WSSecSignature();
@@ -159,7 +140,7 @@ public class TestWSSecurityUserProcessor
         WSSConfig cfg = WSSConfig.getNewInstance();
         cfg.setProcessor(
             WSSecurityEngine.SIGNATURE,
-            new wssec.MyProcessor()
+            new CustomProcessor()
         );
         final WSSecurityEngine engine = new WSSecurityEngine();
         engine.setWssConfig(cfg);
@@ -169,31 +150,32 @@ public class TestWSSecurityUserProcessor
         for (WSSecurityEngineResult result : results) {
             Object obj = result.get("foo");
             if (obj != null) {
-                if (obj.getClass().getName().equals(wssec.MyProcessor.class.getName())) {
+                if (obj.getClass().getName().equals(CustomProcessor.class.getName())) {
                     found = true;
                 }
             }
         }
-        assertTrue("Unable to find result from MyProcessor", found);
+        assertTrue("Unable to find result from CustomProcessor", found);
     }
     
     /**
      * Test to see that a custom action configured through a
      * WSSConfig instance is called
      */
+    @org.junit.Test
     public void
     testCustomAction() throws Exception {
         
         final WSSConfig cfg = WSSConfig.getNewInstance();
         final int action = 0xDEADF000;
-        cfg.setAction(action, "wssec.MyAction");
+        cfg.setAction(action, "org.apache.ws.security.common.CustomAction");
         final RequestData reqData = new RequestData();
         reqData.setWssConfig(cfg);
         
         final List<Integer> actions = new ArrayList<Integer>();
         actions.add(new Integer(action));
         final Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         reqData.setMsgContext("bread");
         assertEquals(reqData.getMsgContext(), "bread");
         handler.send(
@@ -210,19 +192,20 @@ public class TestWSSecurityUserProcessor
      * Test to see that a custom action object configured through a
      * WSSConfig instance is called
      */
+    @org.junit.Test
     public void
     testCustomActionObject() throws Exception {
         
         final WSSConfig cfg = WSSConfig.getNewInstance();
         final int action = 0xDEADF000;
-        cfg.setAction(action, new wssec.MyAction());
+        cfg.setAction(action, new CustomAction());
         final RequestData reqData = new RequestData();
         reqData.setWssConfig(cfg);
         
         final List<Integer> actions = new ArrayList<Integer>();
         actions.add(new Integer(action));
         final Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         reqData.setMsgContext("bread");
         assertEquals(reqData.getMsgContext(), "bread");
         handler.send(
@@ -239,6 +222,7 @@ public class TestWSSecurityUserProcessor
      * Test to see that a custom action can be configured via WSSecurityUtil.decodeAction.
      * A standard Timestamp action is also configured.
      */
+    @org.junit.Test
     public void
     testDecodeCustomAction() throws Exception {
         
@@ -286,14 +270,14 @@ public class TestWSSecurityUserProcessor
         //
         // This parsing should pass as WSSConfig has been configured with the custom action
         //
-        cfg.setAction(customAction, "wssec.MyAction");
+        cfg.setAction(customAction, "org.apache.ws.security.common.CustomAction");
         int actions = WSSecurityUtil.decodeAction(actionString, actionList, cfg);
         
         final RequestData reqData = new RequestData();
         reqData.setWssConfig(cfg);
         
         final Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         reqData.setMsgContext("bread");
         assertEquals(reqData.getMsgContext(), "bread");
         handler.send(

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/ResultsOrderTest.java (from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityResultsOrder.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/ResultsOrderTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/ResultsOrderTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityResultsOrder.java&r1=1042661&r2=1042732&rev=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityResultsOrder.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/ResultsOrderTest.java Mon Dec  6 17:22:39 2010
@@ -17,46 +17,26 @@
  * under the License.
  */
 
-package wssec;
+package org.apache.ws.security.handler;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSSecurityEngineResult;
 
+import org.apache.ws.security.common.CustomHandler;
+
 
 /**
  * This is a test for WSS-147. A "checkReceiverResultsAnyOrder" method is added to WSHandler
  * which applications can use if they want.
  */
-public class TestWSSecurityResultsOrder extends TestCase {
-
-    /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityResultsOrder(String name) {
-        super(name);
-    }
+public class ResultsOrderTest extends org.junit.Assert {
 
     /**
-     * JUnit suite
-     * <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityResultsOrder.class);
-    }
-    
-    /**
      */
+    @org.junit.Test
     public void 
     testOrder() throws Exception {
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         
         java.util.List<WSSecurityEngineResult> results = new java.util.ArrayList<WSSecurityEngineResult>();
         results.add(
@@ -83,9 +63,10 @@ public class TestWSSecurityResultsOrder 
 
     /**
      */
+    @org.junit.Test
     public void 
     testReverseOrder() throws Exception {
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         
         java.util.List<WSSecurityEngineResult> results = new java.util.ArrayList<WSSecurityEngineResult>();
         results.add(
@@ -113,9 +94,10 @@ public class TestWSSecurityResultsOrder 
     
     /**
      */
+    @org.junit.Test
     public void 
     testMixedOrder() throws Exception {
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         
         java.util.List<WSSecurityEngineResult> results = 
             new java.util.ArrayList<WSSecurityEngineResult>();
@@ -144,9 +126,10 @@ public class TestWSSecurityResultsOrder 
     
     /**
      */
+    @org.junit.Test
     public void 
     testMixedOrder2() throws Exception {
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         
         java.util.List<WSSecurityEngineResult> results = 
             new java.util.ArrayList<WSSecurityEngineResult>();
@@ -174,9 +157,10 @@ public class TestWSSecurityResultsOrder 
     
     /**
      */
+    @org.junit.Test
     public void 
     testMissingResult() throws Exception {
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         
         java.util.List<WSSecurityEngineResult> results = 
             new java.util.ArrayList<WSSecurityEngineResult>();
@@ -201,9 +185,10 @@ public class TestWSSecurityResultsOrder 
     
     /**
      */
+    @org.junit.Test
     public void 
     testMissingAction() throws Exception {
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         
         java.util.List<WSSecurityEngineResult> results = 
             new java.util.ArrayList<WSSecurityEngineResult>();
@@ -230,9 +215,10 @@ public class TestWSSecurityResultsOrder 
     
     /**
      */
+    @org.junit.Test
     public void 
     testNoResult() throws Exception {
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         
         java.util.List<WSSecurityEngineResult> results = 
             new java.util.ArrayList<WSSecurityEngineResult>();
@@ -246,9 +232,10 @@ public class TestWSSecurityResultsOrder 
     
     /**
      */
+    @org.junit.Test
     public void 
     testNoAction() throws Exception {
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         
         java.util.List<WSSecurityEngineResult> results = 
             new java.util.ArrayList<WSSecurityEngineResult>();
@@ -264,9 +251,10 @@ public class TestWSSecurityResultsOrder 
     
     /**
      */
+    @org.junit.Test
     public void 
     testMultipleIdenticalResults() throws Exception {
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         
         java.util.List<WSSecurityEngineResult> results = 
             new java.util.ArrayList<WSSecurityEngineResult>();

Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/SignatureConfirmationTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/SignatureConfirmationTest.java?rev=1042732&r1=1042731&r2=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/SignatureConfirmationTest.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/SignatureConfirmationTest.java Mon Dec  6 17:22:39 2010
@@ -29,9 +29,6 @@ import org.apache.ws.security.common.Cus
 import org.apache.ws.security.common.SOAPUtil;
 import org.apache.ws.security.components.crypto.Crypto;
 import org.apache.ws.security.components.crypto.CryptoFactory;
-import org.apache.ws.security.handler.RequestData;
-import org.apache.ws.security.handler.WSHandlerConstants;
-import org.apache.ws.security.handler.WSHandlerResult;
 import org.apache.ws.security.util.Base64;
 import org.apache.ws.security.util.WSSecurityUtil;
 import org.w3c.dom.Document;

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/WSHandlerGetPasswordTest.java (from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityGetPassword.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/WSHandlerGetPasswordTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/WSHandlerGetPasswordTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityGetPassword.java&r1=1042661&r2=1042732&rev=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityGetPassword.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/WSHandlerGetPasswordTest.java Mon Dec  6 17:22:39 2010
@@ -17,19 +17,15 @@
  * under the License.
  */
 
-package wssec;
+package org.apache.ws.security.handler;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSPasswordCallback;
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSSConfig;
-import org.apache.ws.security.handler.WSHandler;
-import org.apache.ws.security.handler.RequestData;
-import org.apache.ws.security.handler.WSHandlerConstants;
+import org.apache.ws.security.common.CustomHandler;
+import org.apache.ws.security.common.SOAPUtil;
 import org.w3c.dom.Document;
 
 import java.io.IOException;
@@ -38,13 +34,12 @@ import javax.security.auth.callback.Call
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.callback.UnsupportedCallbackException;
 
-
 /**
  * WS-Security Test Case for the getPassword method in WSHandler.
  * <p/>
  */
-public class TestWSSecurityGetPassword extends TestCase {
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityGetPassword.class);
+public class WSHandlerGetPasswordTest extends org.junit.Assert {
+    private static final Log LOG = LogFactory.getLog(WSHandlerGetPasswordTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -59,30 +54,10 @@ public class TestWSSecurityGetPassword e
         + "</SOAP-ENV:Envelope>";
 
     /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityGetPassword(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityGetPassword.class);
-    }
-
-
-    /**
      * A unit test for {@link WSHandler#getPassword(String, int, String, String, RequestData)},
      * where the password is obtained from the Message Context.
      */
+    @org.junit.Test
     public void
     testGetPasswordRequestContextUnit() throws Exception {
         
@@ -93,7 +68,7 @@ public class TestWSSecurityGetPassword e
         messageContext.put("password", "securityPassword");
         reqData.setMsgContext(messageContext);
         
-        WSHandler handler = new MyHandler();
+        WSHandler handler = new CustomHandler();
         WSPasswordCallback callback = 
             handler.getPassword(
                 "bob", 
@@ -111,6 +86,7 @@ public class TestWSSecurityGetPassword e
      * A WSHandler test for {@link WSHandler#getPassword(String, int, String, String, RequestData)},
      * where the password is obtained from the Message Context.
      */
+    @org.junit.Test
     public void
     testGetPasswordRequestContext() throws Exception {
         
@@ -126,7 +102,7 @@ public class TestWSSecurityGetPassword e
         final java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
         actions.add(new Integer(WSConstants.UT));
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         handler.send(
             WSConstants.UT, 
             doc, 
@@ -149,6 +125,7 @@ public class TestWSSecurityGetPassword e
      * where the password is obtained from a Callback Handler, which is placed on the 
      * Message Context using a reference.
      */
+    @org.junit.Test
     public void
     testGetPasswordCallbackHandlerRef() throws Exception {
         
@@ -167,7 +144,7 @@ public class TestWSSecurityGetPassword e
         final java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
         actions.add(new Integer(WSConstants.UT));
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         handler.send(
             WSConstants.UT, 
             doc, 
@@ -186,7 +163,6 @@ public class TestWSSecurityGetPassword e
     }
     
 
-    
     public static class MyCallbackHandler implements CallbackHandler {
         public void handle(Callback[] callbacks)
             throws IOException, UnsupportedCallbackException {

Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/CertErrorTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/CertErrorTest.java?rev=1042732&r1=1042731&r2=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/CertErrorTest.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/CertErrorTest.java Mon Dec  6 17:22:39 2010
@@ -22,9 +22,6 @@ package org.apache.ws.security.message;
 import org.apache.ws.security.WSSecurityException;
 import org.apache.ws.security.common.SOAPUtil;
 import org.apache.ws.security.components.crypto.CryptoFactory;
-import org.apache.ws.security.message.WSSecEncrypt;
-import org.apache.ws.security.message.WSSecSignature;
-import org.apache.ws.security.message.WSSecHeader;
 import org.w3c.dom.Document;
 
 

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/EncryptionPartsTest.java (from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityEncryptionParts.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/EncryptionPartsTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/EncryptionPartsTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityEncryptionParts.java&r1=1042661&r2=1042732&rev=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityEncryptionParts.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/EncryptionPartsTest.java Mon Dec  6 17:22:39 2010
@@ -17,11 +17,8 @@
  * under the License.
  */
 
-package wssec;
+package org.apache.ws.security.message;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.SOAPConstants;
@@ -32,10 +29,9 @@ import org.apache.ws.security.WSSecurity
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSSecurityEngineResult;
 import org.apache.ws.security.WSSecurityException;
+import org.apache.ws.security.common.SOAPUtil;
 import org.apache.ws.security.components.crypto.Crypto;
 import org.apache.ws.security.components.crypto.CryptoFactory;
-import org.apache.ws.security.message.WSSecEncrypt;
-import org.apache.ws.security.message.WSSecHeader;
 import org.apache.ws.security.util.WSSecurityUtil;
 import org.w3c.dom.Document;
 
@@ -52,8 +48,8 @@ import java.util.ArrayList;
  * This is some unit tests for encryption using encryption using parts. Note that the "soapMsg" below
  * has a custom header added.
  */
-public class TestWSSecurityEncryptionParts extends TestCase implements CallbackHandler {
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityEncryptionParts.class);
+public class EncryptionPartsTest extends org.junit.Assert implements CallbackHandler {
+    private static final Log LOG = LogFactory.getLog(EncryptionPartsTest.class);
     private static final String SOAPMSG = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
             "<soapenv:Envelope xmlns:foo=\"urn:foo.bar\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
             "   <soapenv:Header>" +
@@ -68,30 +64,10 @@ public class TestWSSecurityEncryptionPar
     private Crypto crypto = CryptoFactory.getInstance();
 
     /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityEncryptionParts(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityEncryptionParts.class);
-    }
-
-
-    /**
      * Test encrypting a custom SOAP header
      */
     @SuppressWarnings("unchecked")
+    @org.junit.Test
     public void testSOAPHeader() throws Exception {
         WSSecEncrypt encrypt = new WSSecEncrypt();
         encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
@@ -158,6 +134,7 @@ public class TestWSSecurityEncryptionPar
      * Test encrypting a custom SOAP header using wsse11:EncryptedHeader
      */
     @SuppressWarnings("unchecked")
+    @org.junit.Test
     public void testSOAPEncryptedHeader() throws Exception {
         WSSecEncrypt encrypt = new WSSecEncrypt();
         encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
@@ -206,6 +183,7 @@ public class TestWSSecurityEncryptionPar
     /**
      * Test encrypting a custom SOAP header with a bad localname
      */
+    @org.junit.Test
     public void testBadLocalname() throws Exception {
         WSSecEncrypt encrypt = new WSSecEncrypt();
         encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
@@ -237,6 +215,7 @@ public class TestWSSecurityEncryptionPar
     /**
      * Test encrypting a custom SOAP header with a bad namespace
      */
+    @org.junit.Test
     public void testBadNamespace() throws Exception {
         WSSecEncrypt encrypt = new WSSecEncrypt();
         encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
@@ -268,6 +247,7 @@ public class TestWSSecurityEncryptionPar
     /**
      * Test signing a custom SOAP header and the SOAP body
      */
+    @org.junit.Test
     public void testSOAPHeaderAndBody() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         SOAPConstants soapConstants = 

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/EncryptionTest.java (from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew2.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/EncryptionTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/EncryptionTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew2.java&r1=1042661&r2=1042732&rev=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew2.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/EncryptionTest.java Mon Dec  6 17:22:39 2010
@@ -17,25 +17,30 @@
  * under the License.
  */
 
-package wssec;
+package org.apache.ws.security.message;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.ws.security.SOAPConstants;
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSPasswordCallback;
+import org.apache.ws.security.WSSConfig;
 import org.apache.ws.security.WSSecurityEngine;
 import org.apache.ws.security.WSEncryptionPart;
 import org.apache.ws.security.WSSecurityEngineResult;
 import org.apache.ws.security.WSDataRef;
+import org.apache.ws.security.common.CustomHandler;
+import org.apache.ws.security.common.SOAPUtil;
 import org.apache.ws.security.components.crypto.Crypto;
 import org.apache.ws.security.components.crypto.CryptoFactory;
-import org.apache.ws.security.message.WSSecEncrypt;
-import org.apache.ws.security.message.WSSecHeader;
+import org.apache.ws.security.handler.RequestData;
+import org.apache.ws.security.handler.WSHandlerConstants;
+import org.apache.ws.security.util.WSSecurityUtil;
 import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 
+import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKey;
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.callback.UnsupportedCallbackException;
@@ -44,13 +49,13 @@ import java.io.IOException;
 import java.util.ArrayList;
 
 /**
- * WS-Security Test Case
- * <p/>
- * 
+ * A set of test-cases for encrypting and decrypting SOAP requests.
+ *
  * @author Davanum Srinivas (dims@yahoo.com)
+ * @author Werner Dittmann (werner@apache.org)
  */
-public class TestWSSecurityNew2 extends TestCase implements CallbackHandler {
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityNew2.class);
+public class EncryptionTest extends org.junit.Assert implements CallbackHandler {
+    private static final Log LOG = LogFactory.getLog(EncryptionTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -69,25 +74,20 @@ public class TestWSSecurityNew2 extends 
 
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = CryptoFactory.getInstance("wss40.properties");
-
-    /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityNew2(String name) {
-        super(name);
-    }
-
+    private byte[] keyData;
+    private SecretKey key;
+    
     /**
-     * JUnit suite
-     * <p/>
+     * Setup method
      * 
-     * @return a junit test suite
+     * @throws java.lang.Exception Thrown when there is a problem in setup
      */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityNew2.class);
+    @org.junit.Before
+    public void setUp() throws Exception {
+        KeyGenerator keyGen = KeyGenerator.getInstance("AES");
+        keyGen.init(128);
+        key = keyGen.generateKey();
+        keyData = key.getEncoded();
     }
 
     /**
@@ -98,6 +98,7 @@ public class TestWSSecurityNew2 extends 
      * 
      * @throws Exception Thrown when there is any problem in signing or verification
      */
+    @org.junit.Test
     public void testEncryptionDecryptionRSA15() throws Exception {
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("wss40");
@@ -162,7 +163,8 @@ public class TestWSSecurityNew2 extends 
      * 
      * @throws Exception Thrown when there is any problem in signing or verification
      */
-     public void testEncryptionDecryptionOAEP() throws Exception {
+    @org.junit.Test
+    public void testEncryptionDecryptionOAEP() throws Exception {
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("wss40");
         builder.setKeyIdentifierType(WSConstants.X509_KEY_IDENTIFIER);
@@ -186,6 +188,304 @@ public class TestWSSecurityNew2 extends 
     }
     
     /**
+     * Test that encrypt and then again encrypts (Super encryption) WS-Security
+     * envelope and then verifies it <p/>
+     * 
+     * @throws Exception
+     *             Thrown when there is any problem in encryption or
+     *             verification
+     */
+    @org.junit.Test
+    public void testEncryptionEncryption() throws Exception {
+        Crypto encCrypto = CryptoFactory.getInstance();
+        WSSecEncrypt encrypt = new WSSecEncrypt();
+        encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
+        LOG.info("Before Encryption....");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+
+        Document encryptedDoc = encrypt.build(doc, encCrypto, secHeader);
+        
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("After the first encryption:");
+            String outputString = 
+                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedDoc);
+            LOG.debug(outputString);
+        }
+        
+        Document encryptedEncryptedDoc = encrypt.build(encryptedDoc, encCrypto, secHeader);
+        
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("After the second encryption:");
+            String outputString = 
+                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedEncryptedDoc);
+            LOG.debug(outputString);
+        }
+
+        LOG.info("After Encryption....");
+        verify(encryptedEncryptedDoc, encCrypto);
+    }
+    
+    /**
+     * Test that encrypts and decrypts a WS-Security envelope.
+     * The test uses the ThumbprintSHA1 key identifier type. 
+     * <p/>
+     * 
+     * @throws java.lang.Exception Thrown when there is any problem in encryption or decryption
+     */
+    @org.junit.Test
+    public void testX509EncryptionThumb() throws Exception {
+        Crypto encCrypto = CryptoFactory.getInstance();
+        WSSecEncrypt builder = new WSSecEncrypt();
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        builder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
+        
+        LOG.info("Before Encrypting ThumbprintSHA1....");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);        
+        Document encryptedDoc = builder.build(doc, encCrypto, secHeader);
+        
+        String outputString = 
+            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedDoc);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Encrypted message with THUMBPRINT_IDENTIFIER:");
+            LOG.debug(outputString);
+        }
+        assertTrue(outputString.indexOf("#ThumbprintSHA1") != -1);
+    
+        LOG.info("After Encrypting ThumbprintSHA1....");
+        verify(encryptedDoc, encCrypto);
+    }
+    
+    /**
+     * Test that encrypts and decrypts a WS-Security envelope.
+     * The test uses the EncryptedKeySHA1 key identifier type. 
+     * <p/>
+     * 
+     * @throws java.lang.Exception Thrown when there is any problem in encryption or decryption
+     */
+    @org.junit.Test
+    public void testX509EncryptionSHA1() throws Exception {
+        Crypto encCrypto = CryptoFactory.getInstance();
+        WSSecEncrypt builder = new WSSecEncrypt();
+        builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        builder.setKeyIdentifierType(WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER);
+     
+        LOG.info("Before Encrypting EncryptedKeySHA1....");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);        
+        Document encryptedDoc = builder.build(doc, encCrypto, secHeader);
+     
+        String outputString = 
+            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedDoc);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Encrypted message with ENCRYPTED_KEY_SHA1_IDENTIFIER:");
+            LOG.debug(outputString);
+        }
+        assertTrue(outputString.indexOf("#EncryptedKeySHA1") != -1);
+     
+        LOG.info("After Encrypting EncryptedKeySHA1....");
+        verify(encryptedDoc, encCrypto);
+    }
+    
+    /**
+     * Test that encrypts using EncryptedKeySHA1, where it uses a symmetric key, rather than a 
+     * generated session key which is then encrypted using a public key.
+     * 
+     * @throws java.lang.Exception Thrown when there is any problem in encryption or decryption
+     */
+    @org.junit.Test
+    public void testEncryptionSHA1Symmetric() throws Exception {
+        WSSecEncrypt builder = new WSSecEncrypt();
+        builder.setKeyIdentifierType(WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER);
+        builder.setSymmetricKey(key);
+        builder.setEncryptSymmKey(false);
+        
+        LOG.info("Before Encrypting EncryptedKeySHA1....");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);        
+        Document encryptedDoc = builder.build(doc, crypto, secHeader);
+     
+        String outputString = 
+            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedDoc);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Encrypted message with ENCRYPTED_KEY_SHA1_IDENTIFIER:");
+            LOG.debug(outputString);
+        }
+        assertTrue(outputString.indexOf("#EncryptedKeySHA1") != -1);
+     
+        LOG.info("After Encrypting EncryptedKeySHA1....");
+        verify(encryptedDoc, (Crypto)null);
+    }
+    
+    /**
+     * Test that encrypts using EncryptedKeySHA1, where it uses a symmetric key (bytes), 
+     * rather than a generated session key which is then encrypted using a public key.
+     * 
+     * @throws java.lang.Exception Thrown when there is any problem in encryption or decryption
+     */
+    @org.junit.Test
+    public void testEncryptionSHA1SymmetricBytes() throws Exception {
+        WSSecEncrypt builder = new WSSecEncrypt();
+        builder.setKeyIdentifierType(WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER);
+        builder.setEphemeralKey(keyData);
+        builder.setEncryptSymmKey(false);
+        
+        LOG.info("Before Encrypting EncryptedKeySHA1....");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);        
+        Document encryptedDoc = builder.build(doc, crypto, secHeader);
+     
+        String outputString = 
+            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedDoc);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Encrypted message with ENCRYPTED_KEY_SHA1_IDENTIFIER:");
+            LOG.debug(outputString);
+        }
+        assertTrue(outputString.indexOf("#EncryptedKeySHA1") != -1);
+     
+        LOG.info("After Encrypting EncryptedKeySHA1....");
+        verify(encryptedDoc, crypto);
+    }
+    
+    
+    /**
+     * Test that encrypts using EncryptedKeySHA1, where it uses a symmetric key, rather than a 
+     * generated session key which is then encrypted using a public key. The request is generated
+     * using WSHandler, instead of coding it.
+     * 
+     * @throws java.lang.Exception Thrown when there is any problem in encryption or decryption
+     */
+    @org.junit.Test
+    public void testEncryptionSHA1SymmetricBytesHandler() throws Exception {
+        final WSSConfig cfg = WSSConfig.getNewInstance();
+        final RequestData reqData = new RequestData();
+        reqData.setWssConfig(cfg);
+        java.util.Map<String, Object> messageContext = new java.util.TreeMap<String, Object>();
+        messageContext.put(WSHandlerConstants.ENC_SYM_ENC_KEY, "false");
+        messageContext.put(WSHandlerConstants.ENC_KEY_ID, "EncryptedKeySHA1");
+        messageContext.put(WSHandlerConstants.PW_CALLBACK_REF, this);
+        reqData.setMsgContext(messageContext);
+        reqData.setUsername("");
+        
+        final java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
+        actions.add(new Integer(WSConstants.ENCR));
+        final Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        CustomHandler handler = new CustomHandler();
+        handler.send(
+            WSConstants.ENCR, 
+            doc, 
+            reqData, 
+            actions,
+            true
+        );
+        
+        String outputString = 
+            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(outputString);
+        }
+        
+        verify(doc, (Crypto)null);
+    }
+    
+    /**
+     * Test that encrypt and decrypt a WS-Security envelope.
+     * 
+     * This test uses the RSA_15 algorithm to transport (wrap) the symmetric key.
+     * The test case creates a ReferenceList element that references EncryptedData
+     * elements. The ReferencesList element is put into the Security header, not
+     * as child of the EncryptedKey. The EncryptedData elements contain a KeyInfo
+     * that references the EncryptedKey via a STR/Reference structure.
+     * 
+     * Refer to OASIS WS Security spec 1.1, chap 7.7
+     */
+    @org.junit.Test
+    public void testEncryptionDecryptionRSA15STR() throws Exception {
+        WSSecEncrypt builder = new WSSecEncrypt();
+        builder.setUserInfo("wss40");
+        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
+        builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        LOG.info("Before Encryption Triple DES....");
+
+        /*
+         * Prepare the Encrypt object with the token, setup data structure
+         */
+        builder.prepare(doc, crypto);
+
+        /*
+         * Set up the parts structure to encrypt the body
+         */
+        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc
+                .getDocumentElement());
+        java.util.List<WSEncryptionPart> parts = new ArrayList<WSEncryptionPart>();
+        WSEncryptionPart encP = new WSEncryptionPart(soapConstants
+                .getBodyQName().getLocalPart(), soapConstants.getEnvelopeURI(),
+                "Content");
+        parts.add(encP);
+
+        /*
+         * Encrypt the parts (Body), create EncryptedData elements that reference
+         * the EncryptedKey, and get a ReferenceList that can be put into the
+         * Security header. Be sure that the ReferenceList is after the
+         * EncryptedKey element in the Security header (strict layout)
+         */
+        Element refs = builder.encryptForRef(null, parts);
+        builder.addExternalRefElement(refs, secHeader);
+
+        /*
+         * now add (prepend) the EncryptedKey element, then a
+         * BinarySecurityToken if one was setup during prepare
+         */
+        builder.prependToHeader(secHeader);
+
+        builder.prependBSTElementToHeader(secHeader);
+
+        Document encryptedDoc = doc;
+        LOG.info("After Encryption Triple DES....");
+
+        String outputString = 
+            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedDoc);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Encrypted message, RSA-15 keytransport, 3DES:");
+            LOG.debug(outputString);
+        }
+        assertTrue(outputString.indexOf("LogTestService2") == -1 ? true
+                : false);
+        verify(encryptedDoc, crypto);
+        
+        outputString = 
+            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedDoc);
+        assertTrue(outputString.indexOf("LogTestService2") > 0 ? true
+                : false);
+    }
+
+    
+    /**
+     * Verifies the soap envelope <p/>
+     * 
+     * @param envelope
+     * @throws Exception
+     *             Thrown when there is a problem in verification
+     */
+    private void verify(Document doc, Crypto decCrypto) throws Exception {
+        secEngine.processSecurityHeader(doc, null, this, decCrypto);
+        if (LOG.isDebugEnabled()) {
+            String outputString = 
+                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
+            LOG.debug(outputString);
+        }
+    }
+    
+    /**
      * Verifies the soap envelope
      * <p/>
      * 
@@ -256,6 +556,7 @@ public class TestWSSecurityNew2 extends 
                  * for Testing we supply a fixed name here.
                  */
                 pc.setPassword("security");
+                pc.setKey(keyData);
             } else {
                 throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
             }

Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/ModifiedRequestTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/ModifiedRequestTest.java?rev=1042732&r1=1042731&r2=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/ModifiedRequestTest.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/ModifiedRequestTest.java Mon Dec  6 17:22:39 2010
@@ -29,8 +29,6 @@ import org.apache.ws.security.WSSecurity
 import org.apache.ws.security.common.SOAPUtil;
 import org.apache.ws.security.components.crypto.Crypto;
 import org.apache.ws.security.components.crypto.CryptoFactory;
-import org.apache.ws.security.message.WSSecSignature;
-import org.apache.ws.security.message.WSSecHeader;
 import org.apache.ws.security.util.WSSecurityUtil;
 import org.w3c.dom.Document;
 

Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/PasswordTypeTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/PasswordTypeTest.java?rev=1042732&r1=1042731&r2=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/PasswordTypeTest.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/PasswordTypeTest.java Mon Dec  6 17:22:39 2010
@@ -30,8 +30,6 @@ import org.apache.ws.security.common.Cus
 import org.apache.ws.security.common.SOAPUtil;
 import org.apache.ws.security.handler.RequestData;
 import org.apache.ws.security.handler.WSHandlerConstants;
-import org.apache.ws.security.message.WSSecUsernameToken;
-import org.apache.ws.security.message.WSSecHeader;
 import org.w3c.dom.Document;
 
 import javax.security.auth.callback.Callback;

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SKISignatureTest.java (from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew12.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SKISignatureTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SKISignatureTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew12.java&r1=1042661&r2=1042732&rev=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew12.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SKISignatureTest.java Mon Dec  6 17:22:39 2010
@@ -17,15 +17,13 @@
  * under the License.
  */
 
-package wssec;
+package org.apache.ws.security.message;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSSecurityEngine;
 import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.common.SOAPUtil;
 import org.apache.ws.security.components.crypto.Crypto;
 import org.apache.ws.security.components.crypto.CryptoFactory;
 import org.apache.ws.security.message.WSSecSignature;
@@ -38,8 +36,8 @@ import org.w3c.dom.Document;
  * @author Davanum Srinivas (dims@yahoo.com)
  * @author Werner Dittmann (Werner.Dittmann@siemens.com)
  */
-public class TestWSSecurityNew12 extends TestCase {
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityNew12.class);
+public class SKISignatureTest extends org.junit.Assert {
+    private static final Log LOG = LogFactory.getLog(SKISignatureTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -57,27 +55,6 @@ public class TestWSSecurityNew12 extends
     private Crypto crypto = CryptoFactory.getInstance("wss40.properties");
 
     /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityNew12(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityNew12.class);
-    }
-
-
-    /**
      * Test that signs and verifies a WS-Security envelope using SubjectKeyIdentifier.
      * This test uses the SubjectKeyIdentifier to identify the certificate. It
      * uses the Direct version, that is it embeds the certificate in the message.
@@ -85,6 +62,7 @@ public class TestWSSecurityNew12 extends
      * 
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
+    @org.junit.Test
     public void testX509SignatureDSA_SKI() throws Exception {
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("wss40DSA", "security");
@@ -119,6 +97,7 @@ public class TestWSSecurityNew12 extends
      * 
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
+    @org.junit.Test
     public void testX509SignatureDSA_Autodetect() throws Exception {
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("wss40DSA", "security");
@@ -152,6 +131,7 @@ public class TestWSSecurityNew12 extends
      * 
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
+    @org.junit.Test
     public void testX509SignatureRSA_Autodetect() throws Exception {
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("wss40", "security");

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/STRSignatureTest.java (from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew11.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/STRSignatureTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/STRSignatureTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew11.java&r1=1042661&r2=1042732&rev=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew11.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/STRSignatureTest.java Mon Dec  6 17:22:39 2010
@@ -17,11 +17,8 @@
  * under the License.
  */
 
-package wssec;
+package org.apache.ws.security.message;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.SOAPConstants;
@@ -29,24 +26,22 @@ import org.apache.ws.security.WSEncrypti
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.util.WSSecurityUtil;
 import org.apache.ws.security.WSSecurityEngine;
+import org.apache.ws.security.common.SOAPUtil;
 import org.apache.ws.security.components.crypto.Crypto;
 import org.apache.ws.security.components.crypto.CryptoFactory;
-import org.apache.ws.security.message.WSSecSignature;
-import org.apache.ws.security.message.WSSecHeader;
-import org.apache.ws.security.message.WSSecTimestamp;
 import org.w3c.dom.Document;
 
 import java.util.List;
 import java.util.ArrayList;
 
 /**
- * WS-Security Test Case
- * <p/>
+ * WS-Security Test Case for signature creation/validation using the
+ * SecurityTokenReference transform.
  * 
  * @author Davanum Srinivas (dims@yahoo.com)
  */
-public class TestWSSecurityNew11 extends TestCase {
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityNew11.class);
+public class STRSignatureTest extends org.junit.Assert {
+    private static final Log LOG = LogFactory.getLog(STRSignatureTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -64,27 +59,6 @@ public class TestWSSecurityNew11 extends
     private Crypto crypto = CryptoFactory.getInstance("wss40.properties");
 
     /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityNew11(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityNew11.class);
-    }
-
-
-    /**
      * Test that signs and verifies a WS-Security envelope.
      * This test uses the direct reference key identifier (certificate included
      * as a BinarySecurityToken (BST) in the message). The test signs the message
@@ -93,6 +67,7 @@ public class TestWSSecurityNew11 extends
      * 
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
+    @org.junit.Test
     public void testX509SignatureDirectSTR() throws Exception {
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("wss40", "security");
@@ -142,6 +117,7 @@ public class TestWSSecurityNew11 extends
      * "Error when making a signature when containing a WSSecTimestamp"
      * A timestamp is added to the document and signed.
      */
+    @org.junit.Test
     public void testWSS96() throws Exception {
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("wss40", "security");
@@ -200,6 +176,7 @@ public class TestWSSecurityNew11 extends
      * 
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
+    @org.junit.Test
     public void testX509SignatureISSTR() throws Exception {
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("wss40", "security");
@@ -254,6 +231,7 @@ public class TestWSSecurityNew11 extends
      * 
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
+    @org.junit.Test
     public void testX509SignatureSKISTR() throws Exception {
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("wss40", "security");

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureEncryptionTest.java (from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew6.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureEncryptionTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureEncryptionTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew6.java&r1=1042661&r2=1042732&rev=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/TestWSSecurityNew6.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureEncryptionTest.java Mon Dec  6 17:22:39 2010
@@ -17,11 +17,8 @@
  * under the License.
  */
 
-package wssec;
+package org.apache.ws.security.message;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSConstants;
@@ -30,28 +27,28 @@ import org.apache.ws.security.WSEncrypti
 import org.apache.ws.security.WSPasswordCallback;
 import org.apache.ws.security.WSSecurityEngine;
 import org.apache.ws.security.WSSecurityEngineResult;
+import org.apache.ws.security.common.SOAPUtil;
 import org.apache.ws.security.components.crypto.Crypto;
 import org.apache.ws.security.components.crypto.CryptoFactory;
-import org.apache.ws.security.message.WSSecEncrypt;
-import org.apache.ws.security.message.WSSecSignature;
-import org.apache.ws.security.message.WSSecHeader;
 import org.apache.ws.security.util.WSSecurityUtil;
 import org.w3c.dom.Document;
 
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.xml.crypto.dsig.SignatureMethod;
+
 import java.io.IOException;
 import java.util.List;
 import java.util.ArrayList;
 
 /**
- * WS-Security Test Case <p/>
+ * A set of tests for combined signature/encryption, verification/decryption.
  * 
  * @author Davanum Srinivas (dims@yahoo.com)
  */
-public class TestWSSecurityNew6 extends TestCase implements CallbackHandler {
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityNew6.class);
+public class SignatureEncryptionTest extends org.junit.Assert implements CallbackHandler {
+    private static final Log LOG = LogFactory.getLog(SignatureEncryptionTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -67,26 +64,21 @@ public class TestWSSecurityNew6 extends 
 
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = CryptoFactory.getInstance();
-
-    /**
-     * TestWSSecurity constructor <p/>
-     * 
-     * @param name
-     *            name of the test
-     */
-    public TestWSSecurityNew6(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityNew6.class);
-    }
-
+    
+    private static final byte[] key = {
+        (byte)0x31, (byte)0xfd,
+        (byte)0xcb, (byte)0xda,
+        (byte)0xfb, (byte)0xcd,
+        (byte)0x6b, (byte)0xa8,
+        (byte)0xe6, (byte)0x19,
+        (byte)0xa7, (byte)0xbf,
+        (byte)0x51, (byte)0xf7,
+        (byte)0xc7, (byte)0x3e,
+        (byte)0x80, (byte)0xae,
+        (byte)0x98, (byte)0x51,
+        (byte)0xc8, (byte)0x51,
+        (byte)0x34, (byte)0x04,
+    };
 
     /**
      * Test that encrypts and then signs a WS-Security envelope, then performs
@@ -96,6 +88,7 @@ public class TestWSSecurityNew6 extends 
      *             Thrown when there is any problem in signing, encryption,
      *             decryption, or verification
      */
+    @org.junit.Test
     public void testEncryptionSigning() throws Exception {
         WSSecEncrypt encrypt = new WSSecEncrypt();
         WSSecSignature sign = new WSSecSignature();
@@ -137,6 +130,7 @@ public class TestWSSecurityNew6 extends 
      *             decryption, or verification
      */
     @SuppressWarnings("unchecked")
+    @org.junit.Test
     public void testEncryptionElementSigning() throws Exception {
         WSSecEncrypt encrypt = new WSSecEncrypt();
         WSSecSignature sign = new WSSecSignature();
@@ -224,6 +218,7 @@ public class TestWSSecurityNew6 extends 
      *             Thrown when there is any problem in signing, encryption,
      *             decryption, or verification
      */
+    @org.junit.Test
     public void testSigningEncryption() throws Exception {
         WSSecEncrypt encrypt = new WSSecEncrypt();
         WSSecSignature sign = new WSSecSignature();
@@ -247,6 +242,7 @@ public class TestWSSecurityNew6 extends 
      * As the encryption adds a wsu:Id to the encrypted element, this test checks that
      * verification still works ok.
      */
+    @org.junit.Test
     public void testWSS198() throws Exception {
         WSSecEncrypt encrypt = new WSSecEncrypt();
         WSSecSignature sign = new WSSecSignature();
@@ -278,6 +274,129 @@ public class TestWSSecurityNew6 extends 
         verify(encryptedSignedDoc);
     }
     
+    /**
+     * Test that first signs, then encrypts a WS-Security envelope.
+     * The test uses the IssuerSerial key identifier to get the keys for
+     * signature and encryption. Encryption uses 3DES.
+     * <p/>
+     * 
+     * @throws Exception Thrown when there is any problem in signing, encryption,
+     *                   decryption, or verification
+     */
+    @org.junit.Test
+    public void testSigningEncryptionIS3DES() throws Exception {
+        WSSecEncrypt encrypt = new WSSecEncrypt();
+        encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
+        encrypt.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
+        encrypt.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
+
+        WSSecSignature sign = new WSSecSignature();
+        sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        sign.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
+
+        LOG.info("Before Sign/Encryption....");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+        
+        Document signedDoc = sign.build(doc, crypto, secHeader);
+        Document encryptedSignedDoc = encrypt.build(signedDoc, crypto, secHeader);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Signed and encrypted message with IssuerSerial key identifier (both), 3DES:");
+            String outputString = 
+                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedSignedDoc);
+            LOG.debug(outputString);
+        }
+        
+        LOG.info("After Sign/Encryption....");
+        verify(encryptedSignedDoc);
+    }
+    
+    /**
+     * Test that encrypts and signs a WS-Security envelope, then performs
+     * verification and decryption.
+     * <p/>
+     * 
+     * @throws Exception Thrown when there is any problem in signing, encryption,
+     *                   decryption, or verification
+     */
+    @org.junit.Test
+    public void testSigningEncryptionEmbedded() throws Exception {
+        WSSecEncrypt encrypt = new WSSecEncrypt();
+        WSSecSignature sign = new WSSecSignature();
+        
+        encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
+        encrypt.setKeyIdentifierType(WSConstants.EMBEDDED_KEYNAME);
+        encrypt.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);        
+        encrypt.setKey(key);
+
+        sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        LOG.info("Before Encryption....");
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        encrypt.setDocument(doc);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);                
+        Document signedDoc = sign.build(doc, crypto, secHeader);
+        Document encryptedSignedDoc = encrypt.build(signedDoc, crypto, secHeader);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Encrypted message, RSA-OAEP keytransport, 3DES:");
+            String outputString = 
+                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedSignedDoc);
+            LOG.debug(outputString);
+        }
+        LOG.info("After Encryption....");
+        verify(encryptedSignedDoc);
+    }
+    
+    /**
+     * Test signature created using an encrypted key
+     * SOAP Body is signed and encrypted. In the encryption, The ReferenceList element is 
+     * put into the Encrypted Key, as a child of the EncryptedKey. Signature is created 
+     * using the encrypted key. 
+     */
+    @org.junit.Test
+    public void testEncryptedKeySignature() throws Exception {
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        LOG.info("Before Sign/Encryption....");
+
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+
+        WSSecEncryptedKey encrKey = new WSSecEncryptedKey();
+        encrKey.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
+        encrKey.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
+        encrKey.setKeySize(192);
+        encrKey.prepare(doc, crypto);   
+
+        WSSecEncrypt encrypt = new WSSecEncrypt();
+        encrypt.setEncKeyId(encrKey.getId());
+        encrypt.setEphemeralKey(encrKey.getEphemeralKey());
+        encrypt.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
+        encrypt.setEncryptSymmKey(false);
+        encrypt.setEncryptedKeyElement(encrKey.getEncryptedKeyElement());
+
+        WSSecSignature sign = new WSSecSignature();
+        sign.setKeyIdentifierType(WSConstants.CUSTOM_SYMM_SIGNING);
+        sign.setCustomTokenId(encrKey.getId());
+        sign.setSecretKey(encrKey.getEphemeralKey());
+        sign.setSignatureAlgorithm(SignatureMethod.HMAC_SHA1);
+
+        Document signedDoc = sign.build(doc, crypto, secHeader);
+        Document encryptedSignedDoc = encrypt.build(signedDoc, crypto, secHeader);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Signed and encrypted message with IssuerSerial key identifier (both), 3DES:");
+            String outputString = 
+                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedSignedDoc);
+            LOG.debug(outputString);
+        }
+
+        LOG.info("After Sign/Encryption....");
+        verify(encryptedSignedDoc);
+    }
+
 
     /**
      * Verifies the soap envelope <p/>
@@ -306,13 +425,11 @@ public class TestWSSecurityNew6 extends 
         for (int i = 0; i < callbacks.length; i++) {
             if (callbacks[i] instanceof WSPasswordCallback) {
                 WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
-                /*
-                 * here call a function/method to lookup the password for the
-                 * given identifier (e.g. a user name or keystore alias) e.g.:
-                 * pc.setPassword(passStore.getPassword(pc.getIdentfifier)) for
-                 * Testing we supply a fixed name here.
-                 */
-                pc.setPassword("security");
+                if (pc.getUsage() == WSPasswordCallback.KEY_NAME) {
+                    pc.setKey(key);
+                } else {
+                    pc.setPassword("security");
+                }
             } else {
                 throw new UnsupportedCallbackException(callbacks[i],
                         "Unrecognized Callback");

Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureKeyValueTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureKeyValueTest.java?rev=1042732&r1=1042731&r2=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureKeyValueTest.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureKeyValueTest.java Mon Dec  6 17:22:39 2010
@@ -29,8 +29,6 @@ import org.apache.ws.security.WSSecurity
 import org.apache.ws.security.common.SOAPUtil;
 import org.apache.ws.security.components.crypto.Crypto;
 import org.apache.ws.security.components.crypto.CryptoFactory;
-import org.apache.ws.security.message.WSSecSignature;
-import org.apache.ws.security.message.WSSecHeader;
 import org.apache.ws.security.util.WSSecurityUtil;
 import org.w3c.dom.Document;
 

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignaturePartsTest.java (from r1042661, webservices/wss4j/trunk/src/test/java/wssec/TestWSSecuritySignatureParts.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignaturePartsTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignaturePartsTest.java&p1=webservices/wss4j/trunk/src/test/java/wssec/TestWSSecuritySignatureParts.java&r1=1042661&r2=1042732&rev=1042732&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/wssec/TestWSSecuritySignatureParts.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignaturePartsTest.java Mon Dec  6 17:22:39 2010
@@ -17,11 +17,8 @@
  * under the License.
  */
 
-package wssec;
+package org.apache.ws.security.message;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.SOAPConstants;
@@ -32,6 +29,7 @@ import org.apache.ws.security.WSSecurity
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSSecurityEngineResult;
 import org.apache.ws.security.WSSecurityException;
+import org.apache.ws.security.common.SOAPUtil;
 import org.apache.ws.security.components.crypto.Crypto;
 import org.apache.ws.security.components.crypto.CryptoFactory;
 import org.apache.ws.security.message.WSSecSignature;
@@ -55,8 +53,8 @@ import javax.xml.namespace.QName;
  * This is some unit tests for signing using signature parts. Note that the "soapMsg" below
  * has a custom header added.
  */
-public class TestWSSecuritySignatureParts extends TestCase implements CallbackHandler {
-    private static final Log LOG = LogFactory.getLog(TestWSSecuritySignatureParts.class);
+public class SignaturePartsTest extends org.junit.Assert implements CallbackHandler {
+    private static final Log LOG = LogFactory.getLog(SignaturePartsTest.class);
     private static final String SOAPMSG = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
             "<soapenv:Envelope xmlns:foo=\"urn:foo.bar\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
             "   <soapenv:Header>" +
@@ -71,29 +69,10 @@ public class TestWSSecuritySignaturePart
     private Crypto crypto = CryptoFactory.getInstance();
 
     /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecuritySignatureParts(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecuritySignatureParts.class);
-    }
-
-    /**
      * Test signing a custom SOAP header
      */
     @SuppressWarnings("unchecked")
+    @org.junit.Test
     public void testSOAPHeader() throws Exception {
         WSSecSignature sign = new WSSecSignature();
         sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
@@ -166,6 +145,7 @@ public class TestWSSecuritySignaturePart
      * Test signing of a header through a STR Dereference Transform
      */
     @SuppressWarnings("unchecked")
+    @org.junit.Test
     public void testSOAPHeaderSTRTransform() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         
@@ -227,6 +207,7 @@ public class TestWSSecuritySignaturePart
     /**
      * Test signing a custom SOAP header with a bad localname
      */
+    @org.junit.Test
     public void testBadLocalname() throws Exception {
         WSSecSignature sign = new WSSecSignature();
         sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
@@ -257,6 +238,7 @@ public class TestWSSecuritySignaturePart
     /**
      * Test signing a custom SOAP header with a bad namespace
      */
+    @org.junit.Test
     public void testBadNamespace() throws Exception {
         WSSecSignature sign = new WSSecSignature();
         sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
@@ -287,6 +269,7 @@ public class TestWSSecuritySignaturePart
     /**
      * Test signing a custom SOAP header and the SOAP body
      */
+    @org.junit.Test
     public void testSOAPHeaderAndBody() throws Exception {
         WSSecSignature sign = new WSSecSignature();
         sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");



Mime
View raw message