ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1043138 [1/2] - in /webservices/wss4j/trunk: ./ keys/ src/main/java/org/apache/ws/security/ src/main/java/org/apache/ws/security/handler/ src/main/java/org/apache/ws/security/message/ src/main/java/org/apache/ws/security/message/token/ src...
Date Tue, 07 Dec 2010 17:41:06 GMT
Author: coheigea
Date: Tue Dec  7 17:41:05 2010
New Revision: 1043138

URL: http://svn.apache.org/viewvc?rev=1043138&view=rev
Log:
[WSS-250] - More test refactoring.

Added:
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/components/crypto/CryptoProviderTest.java
      - copied, changed from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityWSS86.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/CallbackRefTest.java
      - copied, changed from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityWSS245.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/SignatureUTAliasTest.java
      - copied, changed from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityWSS194.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/DerivedKeyTest.java
      - copied, changed from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityNewDK.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/NoSoapPrefixSignatureTest.java
      - copied, changed from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityWSS60.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SecurityContextTokenTest.java
      - copied, changed from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityNewSCT.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureCertTest.java
      - copied, changed from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityWSS40.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UTDerivedKeyTest.java
      - copied, changed from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityUTDK.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UTSignatureTest.java
      - copied, changed from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityUTSignature.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UTWseSignatureTest.java
      - copied, changed from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityNew13.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/token/WCFUsernameTokenTest.java
      - copied, changed from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityWSS199.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlReferenceTest.java
      - copied, changed from r1042732, webservices/wss4j/trunk/wssec/TestWSSecuritySAMLKeyIdentifier.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SamlTokenTest.java
      - copied, changed from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityNewST1.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/saml/SignedSamlTokenTest.java
      - copied, changed from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityNewST2.java
    webservices/wss4j/trunk/src/test/resources/keys/
      - copied from r1043041, webservices/wss4j/trunk/keys/
Removed:
    webservices/wss4j/trunk/keys/
    webservices/wss4j/trunk/wssec/
Modified:
    webservices/wss4j/trunk/build.xml
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSSConfig.java
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSSecurityEngine.java
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/handler/WSHandler.java
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/WSSecBase.java
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/token/SecurityContextToken.java
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/SAMLIssuerImpl.java
    webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UsernameTokenTest.java

Modified: webservices/wss4j/trunk/build.xml
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/build.xml?rev=1043138&r1=1043137&r2=1043138&view=diff
==============================================================================
--- webservices/wss4j/trunk/build.xml (original)
+++ webservices/wss4j/trunk/build.xml Tue Dec  7 17:41:05 2010
@@ -30,7 +30,7 @@ Build Instructions:
         <!--<property name='product.version.level' value='0'/>-->
         <property name='product.version.qualifier' value='-SNAPSHOT'/>
         <property name='product.version' value='${product.version.major}.${product.version.minor}${product.version.qualifier}'/>
-        <property name="year" value="2008"/>
+        <property name="year" value="2010"/>
         <property name="copyright" value="Copyright &#169; ${year} Apache WSS4J Project. All Rights Reserved."/>
 
         <!-- Give user a chance to override without editing this file
@@ -42,9 +42,9 @@ Build Instructions:
         <property name="dir.dist" value="./dist"/>
         <property name="dir.libs" value="./lib"/>
         <property name="dir.endorsed.libs" value="./endorsed"/>
-        <property name="dir.src" value="./src"/>
-        <property name="dir.test" value="./test"/>
-        <property name="dir.keys" value="./keys"/>
+        <property name="dir.src" value="./src/main"/>
+        <property name="dir.test" value="./src/test"/>
+        <property name="dir.keys" value="./src/test/resources/keys"/>
 
         <property name="build.dir" value="./build"/>
         <property name="build.classes" value="${build.dir}/classes"/>
@@ -109,7 +109,8 @@ Build Instructions:
         <path id="classpath.test">
             <!-- classpath for test is librarypath plus junit -->
             <path refid="classpath.library"/>
-<!--            <pathelement path="${java.class.path}"/> -->
+            <pathelement path="${build.classes}/resources"/>
+            <pathelement path="${build.classes}/resources/keys"/>
         </path>
 
         <path id="classpath.test.jar">
@@ -129,10 +130,6 @@ Build Instructions:
             <include name="src/**/*"/>
         </patternset>
 
-        <patternset id="srcUnitTestsFiles">
-            <include name="test/**/*"/>
-        </patternset>
-
         <property name="javadoc.packages"
             value="
 org.apache.ws.security,
@@ -207,7 +204,7 @@ org.apache.ws.security.util
         <mkdir dir="${build.dir}/test-reports"/>
 
         <available property="junit.present" 
-                classname="junit.framework.TestCase">
+                classname="org.junit.Assert">
             <!-- check whether JUnit is available -->
             <classpath refid="classpath.test"/>
         </available>
@@ -323,8 +320,7 @@ org.apache.ws.security.util
             <formatter type="xml"/>
             <batchtest todir="${build.dir}/test-reports">
                 <fileset dir="${build.classes}">
-                    <include name="**/wssec/PackageTests.class"/>
-                    <include name="**/components/PackageTests.class"/>
+                    <include name="**/*Test.class"/>
                 </fileset>
             </batchtest>
         </junit>

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSSConfig.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSSConfig.java?rev=1043138&r1=1043137&r2=1043138&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSSConfig.java (original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSSConfig.java Tue Dec  7 17:41:05 2010
@@ -169,8 +169,6 @@ public class WSSConfig {
         DEFAULT_PROCESSORS = java.util.Collections.unmodifiableMap(tmp);
     }
 
-    protected static WSSConfig defaultConfig = null;
-
     protected boolean wsiBSPCompliant = false;
 
     /**
@@ -336,17 +334,6 @@ public class WSSConfig {
     }
 
     /**
-     * returns a static WSConfig instance that is configured with the latest
-     * OASIS WS-Security settings.
-     */
-    public static WSSConfig getDefaultWSConfig() {
-        if (defaultConfig == null) {
-            defaultConfig = getNewInstance();
-        }
-        return defaultConfig;
-    }
-    
-    /**
      * Checks if we are in WS-I Basic Security Profile compliance mode
      * 
      * @return whether we are in WS-I Basic Security Profile compliance mode

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSSecurityEngine.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSSecurityEngine.java?rev=1043138&r1=1043137&r2=1043138&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSSecurityEngine.java (original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSSecurityEngine.java Tue Dec  7 17:41:05 2010
@@ -46,11 +46,7 @@ import java.util.List;
 public class WSSecurityEngine {
     public static final String VALUE_TYPE = "ValueType";
     private static Log log = LogFactory.getLog(WSSecurityEngine.class.getName());
-    private static Log tlog =
-            LogFactory.getLog("org.apache.ws.security.TIME");
 
-    private static WSSecurityEngine engine = new WSSecurityEngine();
-    
     /**
      * The WSSConfig instance used by this SecurityEngine to
      * find Processors for processing security headers
@@ -132,23 +128,14 @@ public class WSSecurityEngine {
         new QName(ConversationConstants.WSC_NS_05_12, ConversationConstants.SECURITY_CONTEXT_TOKEN_LN);
     
     /**
-     * Get a singleton instance of security engine.
-     * <p/>
-     *
-     * @return ws-security engine.
-     */
-    public static WSSecurityEngine getInstance() {
-        return engine;
-    }
-    
-    /**
-     * @return      the WSSConfig object set on this instance, or
-     *              the statically defined one, if the instance-level
-     *              config object is null.
+     * @return      the WSSConfig object set on this instance
      */
     public final WSSConfig
     getWssConfig() {
-        return (wssConfig == null) ? WSSConfig.getDefaultWSConfig() : wssConfig;
+        if (wssConfig == null) {
+            wssConfig = WSSConfig.getNewInstance();
+        }
+        return wssConfig;
     }
     
     /**
@@ -286,11 +273,6 @@ public class WSSecurityEngine {
         Crypto sigCrypto,
         Crypto decCrypto
     ) throws WSSecurityException {
-
-        long t0 = 0, t1 = 0, t2 = 0;
-        if (tlog.isDebugEnabled()) {
-            t0 = System.currentTimeMillis();
-        }
         //
         // Gather some info about the document to process and store
         // it for retrieval. Store the implementation of signature crypto
@@ -299,9 +281,6 @@ public class WSSecurityEngine {
         WSDocInfo wsDocInfo = new WSDocInfo(securityHeader.getOwnerDocument());
         wsDocInfo.setCrypto(sigCrypto);
 
-        if (tlog.isDebugEnabled()) {
-            t1 = System.currentTimeMillis();
-        }
         List<WSSecurityEngineResult> returnResults = new ArrayList<WSSecurityEngineResult>();
         final WSSConfig cfg = getWssConfig();
         Node node = securityHeader.getFirstChild();
@@ -332,13 +311,6 @@ public class WSSecurityEngine {
             }
             node = node.getNextSibling();
         }
-        if (tlog.isDebugEnabled()) {
-            t2 = System.currentTimeMillis();
-            tlog.debug(
-                "processHeader: total " + (t2 - t0) + ", prepare " + (t1 - t0) 
-                + ", handle " + (t2 - t1)
-            );
-        }
         return returnResults;
     }
 }

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/handler/WSHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/handler/WSHandler.java?rev=1043138&r1=1043137&r2=1043138&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/handler/WSHandler.java (original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/handler/WSHandler.java Tue Dec  7 17:41:05 2010
@@ -62,7 +62,7 @@ import java.util.concurrent.ConcurrentHa
  */
 public abstract class WSHandler {
     private static Log log = LogFactory.getLog(WSHandler.class.getName());
-    protected WSSecurityEngine secEngine = WSSecurityEngine.getInstance();
+    protected WSSecurityEngine secEngine = new WSSecurityEngine();
     protected Map<String, Crypto> cryptos = new ConcurrentHashMap<String, Crypto>();
 
     private boolean doDebug = log.isDebugEnabled();

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/WSSecBase.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/WSSecBase.java?rev=1043138&r1=1043137&r2=1043138&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/WSSecBase.java (original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/WSSecBase.java Tue Dec  7 17:41:05 2010
@@ -46,7 +46,7 @@ public class WSSecBase {
 
     protected boolean doDebug = false;
 
-    protected WSSConfig wssConfig = WSSConfig.getDefaultWSConfig();
+    protected WSSConfig wssConfig = WSSConfig.getNewInstance();
     
     /**
      * Set which parts of the message to encrypt/sign. <p/>

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/token/SecurityContextToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/token/SecurityContextToken.java?rev=1043138&r1=1043137&r2=1043138&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/token/SecurityContextToken.java (original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/message/token/SecurityContextToken.java Tue Dec  7 17:41:05 2010
@@ -50,6 +50,8 @@ public class SecurityContextToken {
      */
     protected Element elementIdentifier = null;
     
+    private WSSConfig wssConfig = WSSConfig.getNewInstance();
+    
     /**
      * Constructor to create the SCT
      *
@@ -91,7 +93,7 @@ public class SecurityContextToken {
         
         elementIdentifier.appendChild(doc.createTextNode(uuid));
         
-        setID(WSSConfig.getDefaultWSConfig().getIdAllocator().createSecureId("sctId-", element));
+        setID(wssConfig.getIdAllocator().createSecureId("sctId-", element));
     }
 
     /**

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/SAMLIssuerImpl.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/SAMLIssuerImpl.java?rev=1043138&r1=1043137&r2=1043138&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/SAMLIssuerImpl.java (original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/saml/SAMLIssuerImpl.java Tue Dec  7 17:41:05 2010
@@ -77,7 +77,7 @@ public class SAMLIssuerImpl implements S
     private Crypto userCrypto = null;
     private String username = null;
     
-    private WSSConfig wssConfig = WSSConfig.getDefaultWSConfig();
+    private WSSConfig wssConfig = WSSConfig.getNewInstance();
     
     private KeyInfoFactory keyInfoFactory = KeyInfoFactory.getInstance("DOM");
     

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/components/crypto/CryptoProviderTest.java (from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityWSS86.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/components/crypto/CryptoProviderTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/components/crypto/CryptoProviderTest.java&p1=webservices/wss4j/trunk/wssec/TestWSSecurityWSS86.java&r1=1042732&r2=1043138&rev=1043138&view=diff
==============================================================================
--- webservices/wss4j/trunk/wssec/TestWSSecurityWSS86.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/components/crypto/CryptoProviderTest.java Tue Dec  7 17:41:05 2010
@@ -17,21 +17,17 @@
  * under the License.
  */
 
-package wssec;
+package org.apache.ws.security.components.crypto;
 
-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.WSSecurityEngine;
 import org.apache.ws.security.WSConstants;
-import org.apache.ws.security.components.crypto.Crypto;
-import org.apache.ws.security.components.crypto.CryptoFactory;
+import org.apache.ws.security.common.SOAPUtil;
 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.message.WSSecSignature;
 import org.w3c.dom.Document;
 
 import javax.security.auth.callback.Callback;
@@ -54,8 +50,8 @@ import java.security.cert.X509Certificat
  * -dname "1.2.840.113549.1.9.1=#16125765726e6572406578616d706c652e636f6d,CN=Werner,
  * OU=WSS4J,O=Apache,L=Munich,ST=Bayern,C=DE"
  */
-public class TestWSSecurityWSS86 extends TestCase implements CallbackHandler {
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityWSS86.class);
+public class CryptoProviderTest extends org.junit.Assert implements CallbackHandler {
+    private static final Log LOG = LogFactory.getLog(CryptoProviderTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -71,32 +67,15 @@ public class TestWSSecurityWSS86 extends
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto;
 
-    /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityWSS86(String name) {
-        super(name);
+    public CryptoProviderTest() {
         secEngine.getWssConfig(); //make sure BC gets registered
         crypto = CryptoFactory.getInstance("wss86.properties");
     }
 
     /**
-     * JUnit suite
-     * <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityWSS86.class);
-    }
-
-    
-    /**
      * A unit test...
      */
+    @org.junit.Test
     public void testGetAliasWithReversedDN() throws Exception {
         String issuer = "C=DE,ST=Bayern,L=Munich,O=Apache,OU=WSS4J,CN=Werner,E=Werner@example.com";
         
@@ -110,6 +89,7 @@ public class TestWSSecurityWSS86 extends
     /**
      * Test signing a SOAP message using a cert with an OID
      */
+    @org.junit.Test
     public void testSignatureOID() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecSignature sign = new WSSecSignature();
@@ -132,6 +112,7 @@ public class TestWSSecurityWSS86 extends
      * Test loading a certificate using BouncyCastle, and using it to encrypt a message, but
      * decrypt the message using the Java Keystore provider
      */
+    @org.junit.Test
     public void testInterop() throws Exception {
         // 
         // This cert corresponds to the cert in wss86.keystore
@@ -182,6 +163,7 @@ public class TestWSSecurityWSS86 extends
      * decrypt the message using the Java Keystore provider. In this case though the cert doesn't
      * correspond with the cert in wss86.keystore.
      */
+    @org.junit.Test
     public void testBadInterop() throws Exception {
         byte[] certBytes = 
             org.apache.ws.security.util.Base64.decode(

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/CallbackRefTest.java (from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityWSS245.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/CallbackRefTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/CallbackRefTest.java&p1=webservices/wss4j/trunk/wssec/TestWSSecurityWSS245.java&r1=1042732&r2=1043138&rev=1043138&view=diff
==============================================================================
--- webservices/wss4j/trunk/wssec/TestWSSecurityWSS245.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/CallbackRefTest.java Tue Dec  7 17:41:05 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;
@@ -44,8 +40,8 @@ import javax.security.auth.callback.Unsu
  *
  * https://issues.apache.org/jira/browse/WSS-245
  */
-public class TestWSSecurityWSS245 extends TestCase {
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityWSS245.class);
+public class CallbackRefTest extends org.junit.Assert {
+    private static final Log LOG = LogFactory.getLog(CallbackRefTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -60,30 +56,11 @@ public class TestWSSecurityWSS245 extend
         + "</SOAP-ENV:Envelope>";
 
     /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityWSS245(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityWSS245.class);
-    }
-
-    /**
      * A test for {@link WSHandler#getPassword(String, int, String, String, RequestData)},
      * where the password is obtained from a Callback Handler, which is placed on the 
      * Message Context using a reference.
      */
+    @org.junit.Test
     public void
     testMessageContextRef() throws Exception {
         
@@ -102,7 +79,7 @@ public class TestWSSecurityWSS245 extend
         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, 
@@ -125,6 +102,7 @@ public class TestWSSecurityWSS245 extend
      * where the password is obtained from a Callback Handler, which is obtained from the
      * handler options using a ref.
      */
+    @org.junit.Test
     public void
     testHandlerOptionRef() throws Exception {
         
@@ -138,7 +116,7 @@ public class TestWSSecurityWSS245 extend
         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.setOption(WSHandlerConstants.PW_CALLBACK_REF, new MyCallbackHandler());
         handler.send(
             WSConstants.UT, 

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/SignatureUTAliasTest.java (from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityWSS194.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/SignatureUTAliasTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/SignatureUTAliasTest.java&p1=webservices/wss4j/trunk/wssec/TestWSSecurityWSS194.java&r1=1042732&r2=1043138&rev=1043138&view=diff
==============================================================================
--- webservices/wss4j/trunk/wssec/TestWSSecurityWSS194.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/handler/SignatureUTAliasTest.java Tue Dec  7 17:41:05 2010
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package wssec;
+package org.apache.ws.security.handler;
 
 import java.io.IOException;
 import java.util.List;
@@ -26,10 +26,6 @@ import javax.security.auth.callback.Call
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.callback.UnsupportedCallbackException;
 
-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;
@@ -37,6 +33,8 @@ import org.apache.ws.security.WSPassword
 import org.apache.ws.security.WSSConfig;
 import org.apache.ws.security.WSSecurityEngine;
 import org.apache.ws.security.WSSecurityEngineResult;
+import org.apache.ws.security.common.CustomHandler;
+import org.apache.ws.security.common.SOAPUtil;
 import org.apache.ws.security.components.crypto.CryptoFactory;
 import org.apache.ws.security.handler.RequestData;
 import org.apache.ws.security.handler.WSHandlerConstants;
@@ -47,9 +45,8 @@ import org.w3c.dom.Document;
  * This is a test for WSS-194 - "Support overriding KeyStore alias for signature so that it can
  * be different than user name used for UsernameToken".
  */
-public class TestWSSecurityWSS194 extends TestCase implements CallbackHandler {
-    
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityWSS194.class);
+public class SignatureUTAliasTest extends org.junit.Assert implements CallbackHandler {
+    private static final Log LOG = LogFactory.getLog(SignatureUTAliasTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -65,30 +62,11 @@ public class TestWSSecurityWSS194 extend
     private WSSecurityEngine secEngine = new WSSecurityEngine();
 
     /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityWSS194(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityWSS194.class);
-    }
-    
-    /**
      * Test involving adding a Username Token to a SOAP message and signing it, where the
      * private key for signature is extracted from the KeyStore using a different username/alias
      * to the UsernameToken. 
      */
+    @org.junit.Test
     public void 
     testUsernameTokenSignatureHandler() throws Exception {
         final WSSConfig cfg = WSSConfig.getNewInstance();
@@ -114,7 +92,7 @@ public class TestWSSecurityWSS194 extend
         actions.add(new Integer(WSConstants.UT));
         actions.add(new Integer(WSConstants.SIGN));
         final Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         handler.send(
             WSConstants.UT | WSConstants.SIGN, 
             doc, 

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/DerivedKeyTest.java (from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityNewDK.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/DerivedKeyTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/DerivedKeyTest.java&p1=webservices/wss4j/trunk/wssec/TestWSSecurityNewDK.java&r1=1042732&r2=1043138&rev=1043138&view=diff
==============================================================================
--- webservices/wss4j/trunk/wssec/TestWSSecurityNewDK.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/DerivedKeyTest.java Tue Dec  7 17:41:05 2010
@@ -17,20 +17,16 @@
  * under the License.
  */
 
-package wssec;
-
+package org.apache.ws.security.message;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSPasswordCallback;
 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.WSSecDKEncrypt;
-import org.apache.ws.security.message.WSSecDKSign;
-import org.apache.ws.security.message.WSSecEncryptedKey;
-import org.apache.ws.security.message.WSSecHeader;
 import org.apache.ws.security.message.token.SecurityTokenReference;
 import org.w3c.dom.Document;
 
@@ -41,12 +37,11 @@ import javax.security.auth.callback.Unsu
 import java.io.IOException;
 import java.security.cert.X509Certificate;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class TestWSSecurityNewDK extends TestCase implements CallbackHandler {
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityNewDK.class);
+/**
+ * A set of tests for using a derived key for encryption/signature.
+ */
+public class DerivedKeyTest extends org.junit.Assert implements CallbackHandler {
+    private static final Log LOG = LogFactory.getLog(DerivedKeyTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -62,31 +57,11 @@ public class TestWSSecurityNewDK extends
     private Crypto crypto = CryptoFactory.getInstance("wss40.properties");
 
     /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityNewDK(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityNewDK.class);
-    }
-
-
-    /**
      * Test encryption using a DerivedKeyToken using TRIPLEDES
      * @throws Exception Thrown when there is any problem in signing or 
      * verification
      */
+    @org.junit.Test
     public void testEncryptionDecryptionTRIPLEDES() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
@@ -124,139 +99,143 @@ public class TestWSSecurityNewDK extends
      * Test encryption using a DerivedKeyToken using AES128 
      * @throws Exception Thrown when there is any problem in signing or verification
      */
-     public void testEncryptionDecryptionAES128() throws Exception {
-         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
-         WSSecHeader secHeader = new WSSecHeader();
-         secHeader.insertSecurityHeader(doc);
-
-         //EncryptedKey
-         WSSecEncryptedKey encrKeyBuilder = new WSSecEncryptedKey();
-         encrKeyBuilder.setUserInfo("wss40");
-         encrKeyBuilder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
-         encrKeyBuilder.prepare(doc, crypto);
-
-         //Key information from the EncryptedKey
-         byte[] ek = encrKeyBuilder.getEphemeralKey();
-         String tokenIdentifier = encrKeyBuilder.getId();  
-         
-         //Derived key encryption
-         WSSecDKEncrypt encrBuilder = new WSSecDKEncrypt();
-         encrBuilder.setSymmetricEncAlgorithm(WSConstants.AES_128);
-         encrBuilder.setExternalKey(ek, tokenIdentifier);
-         Document encryptedDoc = encrBuilder.build(doc, secHeader);
-         
-         encrKeyBuilder.prependToHeader(secHeader);
-         encrKeyBuilder.prependBSTElementToHeader(secHeader);
-         
-         if (LOG.isDebugEnabled()) {
-             LOG.debug("Encrypted message: 3DES  + DerivedKeys");
-             String outputString = 
-                 org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedDoc);
-             LOG.debug(outputString);
-         }
+    @org.junit.Test
+    public void testEncryptionDecryptionAES128() throws Exception {
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+
+        //EncryptedKey
+        WSSecEncryptedKey encrKeyBuilder = new WSSecEncryptedKey();
+        encrKeyBuilder.setUserInfo("wss40");
+        encrKeyBuilder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
+        encrKeyBuilder.prepare(doc, crypto);
+
+        //Key information from the EncryptedKey
+        byte[] ek = encrKeyBuilder.getEphemeralKey();
+        String tokenIdentifier = encrKeyBuilder.getId();  
+
+        //Derived key encryption
+        WSSecDKEncrypt encrBuilder = new WSSecDKEncrypt();
+        encrBuilder.setSymmetricEncAlgorithm(WSConstants.AES_128);
+        encrBuilder.setExternalKey(ek, tokenIdentifier);
+        Document encryptedDoc = encrBuilder.build(doc, secHeader);
+
+        encrKeyBuilder.prependToHeader(secHeader);
+        encrKeyBuilder.prependBSTElementToHeader(secHeader);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Encrypted message: 3DES  + DerivedKeys");
+            String outputString = 
+                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedDoc);
+            LOG.debug(outputString);
+        }
         verify(doc);
      }
      
-     public void testSignature() throws Exception {
-         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
-         WSSecHeader secHeader = new WSSecHeader();
-         secHeader.insertSecurityHeader(doc);
-
-         //EncryptedKey
-         WSSecEncryptedKey encrKeyBuilder = new WSSecEncryptedKey();
-         encrKeyBuilder.setUserInfo("wss40");
-         encrKeyBuilder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
-         encrKeyBuilder.prepare(doc, crypto);
-
-         //Key information from the EncryptedKey
-         byte[] ek = encrKeyBuilder.getEphemeralKey();
-         String tokenIdentifier = encrKeyBuilder.getId();         
-         
-         //Derived key encryption
-         WSSecDKSign sigBuilder = new WSSecDKSign();
-         sigBuilder.setExternalKey(ek, tokenIdentifier);
-         sigBuilder.setSignatureAlgorithm(WSConstants.HMAC_SHA1);
-         /* Document signedDoc = */ sigBuilder.build(doc, secHeader);
-         
-         encrKeyBuilder.prependToHeader(secHeader);
-         encrKeyBuilder.prependBSTElementToHeader(secHeader);
-         
-         if (LOG.isDebugEnabled()) {
-             LOG.debug("Encrypted message: 3DES  + DerivedKeys");
-             String outputString = 
-                 org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
-             LOG.debug(outputString);
-         }
-         verify(doc);
-     }
-     
-     
-     /**
-      * A test for WSS-211 - "WSS4J does not support ThumbprintSHA1 in DerivedKeyTokens".
-      * Here we're signing the SOAP body, where the signature refers to a DerivedKeyToken
-      * which uses a Thumbprint-SHA1 reference to the encoded certificate (which is in the
-      * keystore)
-      */
-     public void testSignatureThumbprintSHA1() throws Exception {
-         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
-         WSSecHeader secHeader = new WSSecHeader();
-         secHeader.insertSecurityHeader(doc);
-
-         SecurityTokenReference secToken = new SecurityTokenReference(doc);
-         X509Certificate[] certs = crypto.getCertificates("wss40");
-         secToken.setKeyIdentifierThumb(certs[0]);
-         
-         WSSecDKSign sigBuilder = new WSSecDKSign();
-         java.security.Key key = crypto.getPrivateKey("wss40", "security");
-         sigBuilder.setExternalKey(key.getEncoded(), secToken.getElement());
-         sigBuilder.setSignatureAlgorithm(WSConstants.HMAC_SHA1);
-         sigBuilder.build(doc, secHeader);
-         
-         sigBuilder.prependDKElementToHeader(secHeader);
-         
-         if (LOG.isDebugEnabled()) {
-             LOG.debug("Encrypted message: ThumbprintSHA1 + DerivedKeys");
-             String outputString = 
-                 org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
-             LOG.debug(outputString);
-         }
-         verify(doc);
-     }
-     
-     
-     /**
-      * Here we're signing the SOAP body, where the signature refers to a DerivedKeyToken
-      * which uses an SKI reference to the encoded certificate (which is in the
-      * keystore)
-      */
-     public void testSignatureSKI() throws Exception {
-         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
-         WSSecHeader secHeader = new WSSecHeader();
-         secHeader.insertSecurityHeader(doc);
-
-         SecurityTokenReference secToken = new SecurityTokenReference(doc);
-         X509Certificate[] certs = crypto.getCertificates("wss40");
-         secToken.setKeyIdentifierSKI(certs[0], crypto);
-         
-         WSSecDKSign sigBuilder = new WSSecDKSign();
-         java.security.Key key = crypto.getPrivateKey("wss40", "security");
-         sigBuilder.setExternalKey(key.getEncoded(), secToken.getElement());
-         sigBuilder.setSignatureAlgorithm(WSConstants.HMAC_SHA1);
-         sigBuilder.build(doc, secHeader);
-         
-         sigBuilder.prependDKElementToHeader(secHeader);
-         
-         if (LOG.isDebugEnabled()) {
-             LOG.debug("Encrypted message: SKI + DerivedKeys");
-             String outputString = 
-                 org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
-             LOG.debug(outputString);
-         }
-         verify(doc);
-     }
-     
-     
-     public void testSignatureEncrypt() throws Exception {
+    @org.junit.Test
+    public void testSignature() throws Exception {
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+
+        //EncryptedKey
+        WSSecEncryptedKey encrKeyBuilder = new WSSecEncryptedKey();
+        encrKeyBuilder.setUserInfo("wss40");
+        encrKeyBuilder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
+        encrKeyBuilder.prepare(doc, crypto);
+
+        //Key information from the EncryptedKey
+        byte[] ek = encrKeyBuilder.getEphemeralKey();
+        String tokenIdentifier = encrKeyBuilder.getId();         
+
+        //Derived key encryption
+        WSSecDKSign sigBuilder = new WSSecDKSign();
+        sigBuilder.setExternalKey(ek, tokenIdentifier);
+        sigBuilder.setSignatureAlgorithm(WSConstants.HMAC_SHA1);
+        /* Document signedDoc = */ sigBuilder.build(doc, secHeader);
+
+        encrKeyBuilder.prependToHeader(secHeader);
+        encrKeyBuilder.prependBSTElementToHeader(secHeader);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Encrypted message: 3DES  + DerivedKeys");
+            String outputString = 
+                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
+            LOG.debug(outputString);
+        }
+        verify(doc);
+    }
+
+
+    /**
+     * A test for WSS-211 - "WSS4J does not support ThumbprintSHA1 in DerivedKeyTokens".
+     * Here we're signing the SOAP body, where the signature refers to a DerivedKeyToken
+     * which uses a Thumbprint-SHA1 reference to the encoded certificate (which is in the
+     * keystore)
+     */
+    @org.junit.Test
+    public void testSignatureThumbprintSHA1() throws Exception {
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+
+        SecurityTokenReference secToken = new SecurityTokenReference(doc);
+        X509Certificate[] certs = crypto.getCertificates("wss40");
+        secToken.setKeyIdentifierThumb(certs[0]);
+
+        WSSecDKSign sigBuilder = new WSSecDKSign();
+        java.security.Key key = crypto.getPrivateKey("wss40", "security");
+        sigBuilder.setExternalKey(key.getEncoded(), secToken.getElement());
+        sigBuilder.setSignatureAlgorithm(WSConstants.HMAC_SHA1);
+        sigBuilder.build(doc, secHeader);
+
+        sigBuilder.prependDKElementToHeader(secHeader);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Encrypted message: ThumbprintSHA1 + DerivedKeys");
+            String outputString = 
+                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
+            LOG.debug(outputString);
+        }
+        verify(doc);
+    }
+
+
+    /**
+     * Here we're signing the SOAP body, where the signature refers to a DerivedKeyToken
+     * which uses an SKI reference to the encoded certificate (which is in the
+     * keystore)
+     */
+    @org.junit.Test
+    public void testSignatureSKI() throws Exception {
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+
+        SecurityTokenReference secToken = new SecurityTokenReference(doc);
+        X509Certificate[] certs = crypto.getCertificates("wss40");
+        secToken.setKeyIdentifierSKI(certs[0], crypto);
+
+        WSSecDKSign sigBuilder = new WSSecDKSign();
+        java.security.Key key = crypto.getPrivateKey("wss40", "security");
+        sigBuilder.setExternalKey(key.getEncoded(), secToken.getElement());
+        sigBuilder.setSignatureAlgorithm(WSConstants.HMAC_SHA1);
+        sigBuilder.build(doc, secHeader);
+
+        sigBuilder.prependDKElementToHeader(secHeader);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Encrypted message: SKI + DerivedKeys");
+            String outputString = 
+                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
+            LOG.debug(outputString);
+        }
+        verify(doc);
+    }
+
+    @org.junit.Test
+    public void testSignatureEncrypt() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
@@ -295,48 +274,49 @@ public class TestWSSecurityNewDK extends
         }
         verify(signedEncryptedDoc);
     }
-     
-     public void testEncryptSignature() throws Exception {
-         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
-         WSSecHeader secHeader = new WSSecHeader();
-         secHeader.insertSecurityHeader(doc);
-
-         //EncryptedKey
-         WSSecEncryptedKey encrKeyBuilder = new WSSecEncryptedKey();
-         encrKeyBuilder.setUserInfo("wss40");
-         encrKeyBuilder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
-         encrKeyBuilder.prepare(doc, crypto);
-         
-         //Key information from the EncryptedKey
-         byte[] ek = encrKeyBuilder.getEphemeralKey();
-         String tokenIdentifier = encrKeyBuilder.getId();
-         
-         //Derived key encryption
-         WSSecDKEncrypt encrBuilder = new WSSecDKEncrypt();
-         encrBuilder.setSymmetricEncAlgorithm(WSConstants.AES_128);
-         encrBuilder.setExternalKey(ek, tokenIdentifier);
-         encrBuilder.build(doc, secHeader);
-         
-         //Derived key signature
-         WSSecDKSign sigBuilder = new WSSecDKSign();
-         sigBuilder.setExternalKey(ek, tokenIdentifier);
-         sigBuilder.setSignatureAlgorithm(WSConstants.HMAC_SHA1);
-         LOG.info("Before HMAC-SHA1 signature");
-         Document encryptedSignedDoc = sigBuilder.build(doc, secHeader);
-         
-         encrKeyBuilder.prependToHeader(secHeader);
-         encrKeyBuilder.prependBSTElementToHeader(secHeader);
-         
-         if (LOG.isDebugEnabled()) {
-             LOG.debug("Encrypted message: 3DES  + DerivedKeys");
-             String outputString = 
-                 org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedSignedDoc);
-             LOG.debug(outputString);
-         }
 
-         verify(encryptedSignedDoc);
-     }
-    
+    @org.junit.Test
+    public void testEncryptSignature() throws Exception {
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        WSSecHeader secHeader = new WSSecHeader();
+        secHeader.insertSecurityHeader(doc);
+
+        //EncryptedKey
+        WSSecEncryptedKey encrKeyBuilder = new WSSecEncryptedKey();
+        encrKeyBuilder.setUserInfo("wss40");
+        encrKeyBuilder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
+        encrKeyBuilder.prepare(doc, crypto);
+
+        //Key information from the EncryptedKey
+        byte[] ek = encrKeyBuilder.getEphemeralKey();
+        String tokenIdentifier = encrKeyBuilder.getId();
+
+        //Derived key encryption
+        WSSecDKEncrypt encrBuilder = new WSSecDKEncrypt();
+        encrBuilder.setSymmetricEncAlgorithm(WSConstants.AES_128);
+        encrBuilder.setExternalKey(ek, tokenIdentifier);
+        encrBuilder.build(doc, secHeader);
+
+        //Derived key signature
+        WSSecDKSign sigBuilder = new WSSecDKSign();
+        sigBuilder.setExternalKey(ek, tokenIdentifier);
+        sigBuilder.setSignatureAlgorithm(WSConstants.HMAC_SHA1);
+        LOG.info("Before HMAC-SHA1 signature");
+        Document encryptedSignedDoc = sigBuilder.build(doc, secHeader);
+
+        encrKeyBuilder.prependToHeader(secHeader);
+        encrKeyBuilder.prependBSTElementToHeader(secHeader);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Encrypted message: 3DES  + DerivedKeys");
+            String outputString = 
+                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedSignedDoc);
+            LOG.debug(outputString);
+        }
+
+        verify(encryptedSignedDoc);
+    }
+
     /**
      * Verifies the soap envelope
      * <p/>
@@ -365,7 +345,7 @@ public class TestWSSecurityNewDK extends
                 pc.setPassword("security");
             } else {
                 throw new UnsupportedCallbackException(callbacks[i],
-                        "Unrecognized Callback");
+                "Unrecognized Callback");
             }
         }
     }

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/NoSoapPrefixSignatureTest.java (from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityWSS60.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/NoSoapPrefixSignatureTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/NoSoapPrefixSignatureTest.java&p1=webservices/wss4j/trunk/wssec/TestWSSecurityWSS60.java&r1=1042732&r2=1043138&rev=1043138&view=diff
==============================================================================
--- webservices/wss4j/trunk/wssec/TestWSSecurityWSS60.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/NoSoapPrefixSignatureTest.java Tue Dec  7 17:41:05 2010
@@ -17,16 +17,14 @@
  * 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.WSPasswordCallback;
 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;
@@ -42,8 +40,8 @@ import java.io.IOException;
  * This is a test for WSS-60 - "Problems when SOAP envelope namespace prefix is null"
  * http://issues.apache.org/jira/browse/WSS-60
  */
-public class TestWSSecurityWSS60 extends TestCase implements CallbackHandler {
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityWSS60.class);
+public class NoSoapPrefixSignatureTest extends org.junit.Assert implements CallbackHandler {
+    private static final Log LOG = LogFactory.getLog(NoSoapPrefixSignatureTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<Envelope "
@@ -61,29 +59,9 @@ public class TestWSSecurityWSS60 extends
     private Crypto crypto = CryptoFactory.getInstance();
 
     /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityWSS60(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityWSS60.class);
-    }
-
-
-    /**
      * Test signing a SOAP message that has no SOAP namespace prefix
      */
+    @org.junit.Test
     public void testNoSOAPNamespacePrefix() throws Exception {
         WSSecSignature sign = new WSSecSignature();
         sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SecurityContextTokenTest.java (from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityNewSCT.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SecurityContextTokenTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SecurityContextTokenTest.java&p1=webservices/wss4j/trunk/wssec/TestWSSecurityNewSCT.java&r1=1042732&r2=1043138&rev=1043138&view=diff
==============================================================================
--- webservices/wss4j/trunk/wssec/TestWSSecurityNewSCT.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SecurityContextTokenTest.java Tue Dec  7 17:41:05 2010
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package wssec;
+package org.apache.ws.security.message;
 
 import java.io.IOException;
 import java.security.SecureRandom;
@@ -29,32 +29,24 @@ import javax.security.auth.callback.Call
 import javax.security.auth.callback.UnsupportedCallbackException;
 import javax.xml.crypto.dsig.SignatureMethod;
 
-import junit.framework.TestCase;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSPasswordCallback;
 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.conversation.ConversationConstants;
-import org.apache.ws.security.message.WSSecDKEncrypt;
-import org.apache.ws.security.message.WSSecDKSign;
-import org.apache.ws.security.message.WSSecHeader;
-import org.apache.ws.security.message.WSSecSecurityContextToken;
-import org.apache.ws.security.message.WSSecSignature;
 import org.w3c.dom.Document;
 
 /**
- * Testcase to test WSSecSecurityContextToken
- * 
- * @see org.apache.ws.security.message.WSSecSecurityContextToken
+ * A set of tests for SecurityContextTokens.
  * 
  * @author Ruchith Fernando (ruchith.fernando@gmail.com)
  */
-public class TestWSSecurityNewSCT extends TestCase implements CallbackHandler {
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityNewSCT.class);
+public class SecurityContextTokenTest extends org.junit.Assert implements CallbackHandler {
+    private static final Log LOG = LogFactory.getLog(SecurityContextTokenTest.class);
 
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
@@ -75,14 +67,8 @@ public class TestWSSecurityNewSCT extend
      */
     private Map<String, byte[]> secrets = new HashMap<String, byte[]>();
 
-    /**
-     * @param arg0
-     */
-    public TestWSSecurityNewSCT(String arg0) {
-        super(arg0);
-    }
-
 
+    @org.junit.Test
     public void testBuild() {
         try {
             Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
@@ -120,6 +106,7 @@ public class TestWSSecurityNewSCT extend
      * Test encryption using a derived key which is based on a secret associated
      * with a security context token
      */
+    @org.junit.Test
     public void testSCTDKTEncrypt() {
         try {
             Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
@@ -158,6 +145,7 @@ public class TestWSSecurityNewSCT extend
         }
     }
 
+    @org.junit.Test
     public void testSCTKDKTSign() {
         try {
             Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
@@ -200,6 +188,7 @@ public class TestWSSecurityNewSCT extend
      * Test for WSS-217:
      * "Add ability to specify a reference to an absolute URI in the derived key functionality".
      */
+    @org.junit.Test
     public void testSCTKDKTSignAbsolute() {
         try {
             Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
@@ -239,7 +228,7 @@ public class TestWSSecurityNewSCT extend
         }
     }
 
-    
+    @org.junit.Test
     public void testSCTKDKTSignEncrypt() {
         try {
             Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
@@ -284,6 +273,7 @@ public class TestWSSecurityNewSCT extend
         }
     }
 
+    @org.junit.Test
     public void testSCTKDKTEncryptSign() {
         try {
             Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
@@ -333,6 +323,7 @@ public class TestWSSecurityNewSCT extend
      * rather than using a DerivedKeyToken to point to a SecurityContextToken.
      * See WSS-216 - https://issues.apache.org/jira/browse/WSS-216
      */
+    @org.junit.Test
     public void testSCTSign() {
         try {
             Document doc = SOAPUtil.toSOAPPart(SOAPMSG);

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureCertTest.java (from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityWSS40.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureCertTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureCertTest.java&p1=webservices/wss4j/trunk/wssec/TestWSSecurityWSS40.java&r1=1042732&r2=1043138&rev=1043138&view=diff
==============================================================================
--- webservices/wss4j/trunk/wssec/TestWSSecurityWSS40.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/SignatureCertTest.java Tue Dec  7 17:41:05 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.WSPasswordCallback;
@@ -30,12 +27,12 @@ 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.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.handler.RequestData;
 import org.apache.ws.security.handler.WSHandlerConstants;
-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;
 
@@ -75,8 +72,8 @@ import java.util.List;
  * keytool -import -file wss40.crt -alias wss40 -keystore wss40.jks
  * 
  */
-public class TestWSSecurityWSS40 extends TestCase implements CallbackHandler {
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityWSS40.class);
+public class SignatureCertTest extends org.junit.Assert implements CallbackHandler {
+    private static final Log LOG = LogFactory.getLog(SignatureCertTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -94,26 +91,9 @@ public class TestWSSecurityWSS40 extends
     private Crypto cryptoCA = CryptoFactory.getInstance("wss40CA.properties");
 
     /**
-     * TestWSSecurity constructor
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityWSS40(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityWSS40.class);
-    }
-
-    /**
      * Test signing a SOAP message using a BST.
      */
+    @org.junit.Test
     public void testSignatureDirectReference() throws Exception {
         WSSecSignature sign = new WSSecSignature();
         sign.setUserInfo("wss40", "security");
@@ -141,6 +121,7 @@ public class TestWSSecurityWSS40 extends
         assertTrue (cert != null);
     }
     
+    @org.junit.Test
     public void testBSTCertChain() throws Exception {
         Crypto clientCrypto = CryptoFactory.getInstance("wss40_client.properties");
         WSSecSignature sign = new WSSecSignature();
@@ -179,6 +160,7 @@ public class TestWSSecurityWSS40 extends
      * Test signing a SOAP message using a BST, sending the CA cert as well in the
      * message.
      */
+    @org.junit.Test
     public void testSignatureDirectReferenceCACert() throws Exception {
         WSSecSignature sign = new WSSecSignature();
         sign.setUserInfo("wss40", "security");
@@ -217,6 +199,7 @@ public class TestWSSecurityWSS40 extends
      * trust-store does not contain the cert corresponding to wss40, only the CA cert
      * wss40CA.
      */
+    @org.junit.Test
     public void testSignatureIssuerSerial() throws Exception {
         WSSecSignature sign = new WSSecSignature();
         sign.setUserInfo("wss40", "security");
@@ -248,6 +231,7 @@ public class TestWSSecurityWSS40 extends
      * Test signing a SOAP message using a BST. The signature verification passes, but the trust
      * verification will fail as the CA cert is out of date.
      */
+    @org.junit.Test
     public void testSignatureBadCACert() throws Exception {
         WSSecSignature sign = new WSSecSignature();
         sign.setUserInfo("wss4jcertdsa", "security");
@@ -279,6 +263,7 @@ public class TestWSSecurityWSS40 extends
     /**
      * A test for "SignatureAction does not set DigestAlgorithm on WSSecSignature instance"
      */
+    @org.junit.Test
     public void testMultipleCertsWSHandler() throws Exception {
         final WSSConfig cfg = WSSConfig.getNewInstance();
         final int action = WSConstants.SIGN;
@@ -295,7 +280,7 @@ public class TestWSSecurityWSS40 extends
         final java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
         actions.add(new Integer(action));
         final Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         handler.send(
             action, 
             doc, 

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UTDerivedKeyTest.java (from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityUTDK.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UTDerivedKeyTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UTDerivedKeyTest.java&p1=webservices/wss4j/trunk/wssec/TestWSSecurityUTDK.java&r1=1042732&r2=1043138&rev=1043138&view=diff
==============================================================================
--- webservices/wss4j/trunk/wssec/TestWSSecurityUTDK.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UTDerivedKeyTest.java Tue Dec  7 17:41:05 2010
@@ -16,11 +16,9 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package wssec;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+package org.apache.ws.security.message;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSConstants;
@@ -28,12 +26,10 @@ import org.apache.ws.security.WSSecurity
 import org.apache.ws.security.WSSecurityException;
 import org.apache.ws.security.WSPasswordCallback;
 import org.apache.ws.security.WSSecurityEngine;
+import org.apache.ws.security.common.EncodedPasswordCallbackHandler;
+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.WSSecDKEncrypt;
-import org.apache.ws.security.message.WSSecDKSign;
-import org.apache.ws.security.message.WSSecHeader;
-import org.apache.ws.security.message.WSSecUsernameToken;
 import org.apache.ws.security.message.token.UsernameToken;
 import org.apache.ws.security.util.Base64;
 import org.apache.ws.security.util.WSSecurityUtil;
@@ -54,8 +50,8 @@ import java.util.List;
  * UsernameTokenProfile 1.1 specification. The derived keys are used to encrypt
  * and sign, as per wsc:DerivedKeyToken.
  */
-public class TestWSSecurityUTDK extends TestCase implements CallbackHandler {
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityUTDK.class);
+public class UTDerivedKeyTest extends org.junit.Assert implements CallbackHandler {
+    private static final Log LOG = LogFactory.getLog(UTDerivedKeyTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -73,29 +69,9 @@ public class TestWSSecurityUTDK extends 
     private Crypto crypto = CryptoFactory.getInstance();
 
     /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityUTDK(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityUTDK.class);
-    }
-
-
-    /**
      * Unit test for the UsernameToken derived key functionality 
      */
+    @org.junit.Test
     public void testUsernameTokenUnit() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
@@ -138,6 +114,7 @@ public class TestWSSecurityUTDK extends 
     /**
      * Test for encoded passwords.
      */
+    @org.junit.Test
     public void testDerivedKeyWithEncodedPasswordBaseline() throws Exception {
         String password = "password";
         // The SHA-1 of the password is known as a password equivalent in the UsernameToken specification.
@@ -153,6 +130,7 @@ public class TestWSSecurityUTDK extends 
     /**
      * Test using a UsernameToken derived key for encrypting a SOAP body
      */
+    @org.junit.Test
     public void testDerivedKeyEncryption() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
@@ -195,6 +173,7 @@ public class TestWSSecurityUTDK extends 
     /**
      * Test using a UsernameToken derived key for encrypting a SOAP body
      */
+    @org.junit.Test
     public void testDerivedKeyEncryptionWithEncodedPassword() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
@@ -208,7 +187,6 @@ public class TestWSSecurityUTDK extends 
         
         byte[] derivedKey = builder.getDerivedKey();
         assertTrue(derivedKey.length == 20);
-        
         String tokenIdentifier = builder.getId();
         
         //
@@ -232,19 +210,18 @@ public class TestWSSecurityUTDK extends 
             LOG.debug(outputString);
         }
         
-        boolean passwordsAreEnabledOrig = WSSecurityEngine.getInstance().getWssConfig().getPasswordsAreEncoded();
-        try {
-            WSSecurityEngine.getInstance().getWssConfig().setPasswordsAreEncoded(true);
-            verify(encryptedDoc);
-        } finally {
-            WSSecurityEngine.getInstance().getWssConfig().setPasswordsAreEncoded(passwordsAreEnabledOrig);
-        }
+        WSSecurityEngine newEngine = new WSSecurityEngine();
+        newEngine.getWssConfig().setPasswordsAreEncoded(true);
+        newEngine.processSecurityHeader(
+            encryptedDoc, null, new EncodedPasswordCallbackHandler(), null
+        );
     }
     
     /**
      * Test using a UsernameToken derived key for encrypting a SOAP body. In this test the
      * derived key is modified before encryption, and so decryption should fail.
      */
+    @org.junit.Test
     public void testDerivedKeyChangedEncryption() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
@@ -295,6 +272,7 @@ public class TestWSSecurityUTDK extends 
      * Test using a UsernameToken derived key for encrypting a SOAP body. In this test the
      * user is "alice" rather than "bob", and so decryption should fail.
      */
+    @org.junit.Test
     public void testDerivedKeyBadUserEncryption() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
@@ -343,6 +321,7 @@ public class TestWSSecurityUTDK extends 
     /**
      * Test using a UsernameToken derived key for signing a SOAP body
      */
+    @org.junit.Test
     public void testDerivedKeySignature() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
@@ -390,6 +369,7 @@ public class TestWSSecurityUTDK extends 
     /**
      * Test using a UsernameToken derived key for signing a SOAP body
      */
+    @org.junit.Test
     public void testDerivedKeySignatureWithEncodedPassword() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
@@ -426,19 +406,17 @@ public class TestWSSecurityUTDK extends 
             LOG.debug(outputString);
         }
         
-        boolean passwordsAreEnabledOrig = WSSecurityEngine.getInstance().getWssConfig().getPasswordsAreEncoded();
-        try {
-            WSSecurityEngine.getInstance().getWssConfig().setPasswordsAreEncoded(true);
-            List<WSSecurityEngineResult> results = verify(signedDoc);
-            WSSecurityEngineResult actionResult =
-                WSSecurityUtil.fetchActionResult(results, WSConstants.SIGN);
-            java.security.Principal principal = 
-                (java.security.Principal) actionResult.get(WSSecurityEngineResult.TAG_PRINCIPAL);
-            // System.out.println(principal.getName());
-            assertTrue(principal.getName().indexOf("DK") != -1);
-        } finally {
-            WSSecurityEngine.getInstance().getWssConfig().setPasswordsAreEncoded(passwordsAreEnabledOrig);
-        }
+        WSSecurityEngine newEngine = new WSSecurityEngine();
+        newEngine.getWssConfig().setPasswordsAreEncoded(true);
+        List<WSSecurityEngineResult> results =  newEngine.processSecurityHeader(
+            signedDoc, null, new EncodedPasswordCallbackHandler(), null
+        );
+        WSSecurityEngineResult actionResult =
+            WSSecurityUtil.fetchActionResult(results, WSConstants.SIGN);
+        java.security.Principal principal = 
+            (java.security.Principal) actionResult.get(WSSecurityEngineResult.TAG_PRINCIPAL);
+        // System.out.println(principal.getName());
+        assertTrue(principal.getName().indexOf("DK") != -1);
     }
     
     /**
@@ -446,6 +424,7 @@ public class TestWSSecurityUTDK extends 
      * derived key is modified before signature, and so signature verification should
      * fail.
      */
+    @org.junit.Test
     public void testDerivedKeyChangedSignature() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
@@ -491,6 +470,7 @@ public class TestWSSecurityUTDK extends 
      * Test using a UsernameToken derived key for signing a SOAP body. In this test the
      * user is "alice" rather than "bob", and so signature verification should fail.
      */
+    @org.junit.Test
     public void testDerivedKeyBadUserSignature() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
@@ -549,12 +529,7 @@ public class TestWSSecurityUTDK extends 
                 WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
                 if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN
                     && "bob".equals(pc.getIdentifier())) {
-                    if (WSSecurityEngine.getInstance().getWssConfig().getPasswordsAreEncoded()) {
-                        // "jux7xGGAjguKKHg9C+waOiLrCCE=" is the Base64 encoded SHA-1 hash of "security".
-                        pc.setPassword("jux7xGGAjguKKHg9C+waOiLrCCE=");
-                    } else {
-                        pc.setPassword("security");
-                    }
+                    pc.setPassword("security");
                 } else {
                     throw new IOException("Authentication failed");
                 }

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UTSignatureTest.java (from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityUTSignature.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UTSignatureTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UTSignatureTest.java&p1=webservices/wss4j/trunk/wssec/TestWSSecurityUTSignature.java&r1=1042732&r2=1043138&rev=1043138&view=diff
==============================================================================
--- webservices/wss4j/trunk/wssec/TestWSSecurityUTSignature.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UTSignatureTest.java Tue Dec  7 17:41:05 2010
@@ -16,11 +16,9 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package wssec;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+package org.apache.ws.security.message;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSConstants;
@@ -29,13 +27,12 @@ import org.apache.ws.security.WSSecurity
 import org.apache.ws.security.WSSecurityException;
 import org.apache.ws.security.WSPasswordCallback;
 import org.apache.ws.security.WSSecurityEngine;
+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.handler.RequestData;
 import org.apache.ws.security.handler.WSHandlerConstants;
-import org.apache.ws.security.message.WSSecHeader;
-import org.apache.ws.security.message.WSSecSignature;
-import org.apache.ws.security.message.WSSecUsernameToken;
 import org.apache.ws.security.util.WSSecurityUtil;
 import org.w3c.dom.Document;
 
@@ -50,13 +47,13 @@ import java.util.List;
 /**
  * WS-Security Test Case for UsernameToken Key Derivation, as defined in the 
  * UsernameTokenProfile 1.1 specification. The derived keys are used for signature.
- * Note that this functionality is different to the TestWSSecurityUTDK test case,
+ * Note that this functionality is different to the UTDerivedKeyTest test case,
  * which uses the derived key in conjunction with wsc:DerivedKeyToken. It's also
- * different to TestWSSecurityNew13, which derives a key for signature using a 
+ * different to UTWseSignatureTest, which derives a key for signature using a 
  * non-standard implementation.
  */
-public class TestWSSecurityUTSignature extends TestCase implements CallbackHandler {
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityUTSignature.class);
+public class UTSignatureTest extends org.junit.Assert implements CallbackHandler {
+    private static final Log LOG = LogFactory.getLog(UTSignatureTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -74,29 +71,9 @@ public class TestWSSecurityUTSignature e
     private Crypto crypto = CryptoFactory.getInstance();
 
     /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityUTSignature(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityUTSignature.class);
-    }
-
-
-    /**
      * Test using a UsernameToken derived key for signing a SOAP body
      */
+    @org.junit.Test
     public void testSignature() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
@@ -140,6 +117,7 @@ public class TestWSSecurityUTSignature e
      * Test using a UsernameToken derived key for signing a SOAP body. In this test the
      * user is "alice" rather than "bob", and so signature verification should fail.
      */
+    @org.junit.Test
     public void testBadUserSignature() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
@@ -178,6 +156,7 @@ public class TestWSSecurityUTSignature e
     /**
      * Test using a UsernameToken derived key for signing a SOAP body via WSHandler
      */
+    @org.junit.Test
     public void testHandlerSignature() throws Exception {
         
         final WSSConfig cfg = WSSConfig.getNewInstance();
@@ -193,7 +172,7 @@ public class TestWSSecurityUTSignature e
         actions.add(new Integer(WSConstants.UT_SIGN));
         
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         handler.send(
             WSConstants.UT_SIGN, 
             doc, 
@@ -223,6 +202,7 @@ public class TestWSSecurityUTSignature e
     /**
      * Test using a UsernameToken derived key for signing a SOAP body via WSHandler
      */
+    @org.junit.Test
     public void testHandlerSignatureIterations() throws Exception {
         
         final WSSConfig cfg = WSSConfig.getNewInstance();
@@ -239,7 +219,7 @@ public class TestWSSecurityUTSignature e
         actions.add(new Integer(WSConstants.UT_SIGN));
         
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         handler.send(
             WSConstants.UT_SIGN, 
             doc, 

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UTWseSignatureTest.java (from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityNew13.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UTWseSignatureTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UTWseSignatureTest.java&p1=webservices/wss4j/trunk/wssec/TestWSSecurityNew13.java&r1=1042732&r2=1043138&rev=1043138&view=diff
==============================================================================
--- webservices/wss4j/trunk/wssec/TestWSSecurityNew13.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UTWseSignatureTest.java Tue Dec  7 17:41:05 2010
@@ -17,22 +17,18 @@
  * 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.WSPasswordCallback;
 import org.apache.ws.security.WSSConfig;
 import org.apache.ws.security.WSSecurityEngine;
 import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.common.CustomHandler;
+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.WSSecSignature;
-import org.apache.ws.security.message.WSSecHeader;
 
 import org.w3c.dom.Document;
 
@@ -43,13 +39,12 @@ import java.io.IOException;
 
 
 /**
- * WS-Security Test Case
- * <p/>
+ * This a test for deriving a key from a Username Token using a non-standard (WSE) implementation.
  * 
  * @author Werner Dittmann (Wern.erDittmann@siemens.com)
  */
-public class TestWSSecurityNew13 extends TestCase implements CallbackHandler {
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityNew13.class);
+public class UTWseSignatureTest extends org.junit.Assert implements CallbackHandler {
+    private static final Log LOG = LogFactory.getLog(UTWseSignatureTest.class);
     private static final String SOAPMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope "
@@ -66,31 +61,12 @@ public class TestWSSecurityNew13 extends
     private WSSecurityEngine secEngine = new WSSecurityEngine();
 
     /**
-     * TestWSSecurity constructor
-     * <p/>
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityNew13(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * <p/>
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityNew13.class);
-    }
-
-    /**
      * Test the specific signing method that use UsernameToken values
      * <p/>
      * 
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
+    @org.junit.Test
     public void testUsernameTokenSigning() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
 
@@ -130,6 +106,7 @@ public class TestWSSecurityNew13 extends
      * Test the specific signing method that use UsernameToken values
      * Test that uses a 32 byte key length for the secret key, instead of the default 16 bytes.
      */
+    @org.junit.Test
     public void testWSS226() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
 
@@ -184,8 +161,9 @@ public class TestWSSecurityNew13 extends
      * Test that uses a 32 byte key length for the secret key, instead of the default 16 bytes.
      * This test configures the key length via WSHandler.
      */
+    @org.junit.Test
     public void testWSS226Handler() throws Exception {
-        MyHandler handler = new MyHandler();
+        CustomHandler handler = new CustomHandler();
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         
         RequestData reqData = new RequestData();
@@ -233,6 +211,7 @@ public class TestWSSecurityNew13 extends
      * 
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
+    @org.junit.Test
     public void testUsernameTokenSigningDigest() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
 

Modified: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UsernameTokenTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UsernameTokenTest.java?rev=1043138&r1=1043137&r2=1043138&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UsernameTokenTest.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/UsernameTokenTest.java Tue Dec  7 17:41:05 2010
@@ -27,6 +27,7 @@ import org.apache.ws.security.WSSecurity
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSSConfig;
 import org.apache.ws.security.common.CustomHandler;
+import org.apache.ws.security.common.EncodedPasswordCallbackHandler;
 import org.apache.ws.security.common.SOAPUtil;
 import org.apache.ws.security.handler.RequestData;
 import org.apache.ws.security.handler.WSHandlerConstants;
@@ -174,13 +175,9 @@ public class UsernameTokenTest extends o
         }
         LOG.info("After adding UsernameToken PW Digest....");
 
-        boolean passwordsAreEnabledOrig = WSSecurityEngine.getInstance().getWssConfig().getPasswordsAreEncoded();
-        try {
-            WSSecurityEngine.getInstance().getWssConfig().setPasswordsAreEncoded(true);
-            verify(signedDoc);
-        } finally {
-            WSSecurityEngine.getInstance().getWssConfig().setPasswordsAreEncoded(passwordsAreEnabledOrig);
-        }
+        WSSecurityEngine newEngine = new WSSecurityEngine();
+        newEngine.getWssConfig().setPasswordsAreEncoded(true);
+        newEngine.processSecurityHeader(signedDoc, null, new EncodedPasswordCallbackHandler(), null);
     }
     
     /**
@@ -696,21 +693,15 @@ public class UsernameTokenTest extends o
         secEngine.processSecurityHeader(doc, null, this, null);
         LOG.info("After verifying UsernameToken....");
     }
-
+    
     public void handle(Callback[] callbacks)
         throws IOException, UnsupportedCallbackException {
         for (int i = 0; i < callbacks.length; i++) {
             if (callbacks[i] instanceof WSPasswordCallback) {
                 WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
-                boolean passwordsAreEncoded = WSSecurityEngine.getInstance().getWssConfig().getPasswordsAreEncoded();
                 if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN
                     && "wernerd".equals(pc.getIdentifier())) {
-                    if (passwordsAreEncoded) {
-                        // "hGqoUreBgahTJblQ3DbJIkE6uNs=" is the Base64 encoded SHA-1 hash of "verySecret".
-                        pc.setPassword("hGqoUreBgahTJblQ3DbJIkE6uNs=");
-                    } else {
-                        pc.setPassword("verySecret");
-                    }
+                    pc.setPassword("verySecret");
                 } else if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN
                     && "emptyuser".equals(pc.getIdentifier())) {
                     pc.setPassword("");

Copied: webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/token/WCFUsernameTokenTest.java (from r1042732, webservices/wss4j/trunk/wssec/TestWSSecurityWSS199.java)
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/token/WCFUsernameTokenTest.java?p2=webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/token/WCFUsernameTokenTest.java&p1=webservices/wss4j/trunk/wssec/TestWSSecurityWSS199.java&r1=1042732&r2=1043138&rev=1043138&view=diff
==============================================================================
--- webservices/wss4j/trunk/wssec/TestWSSecurityWSS199.java (original)
+++ webservices/wss4j/trunk/src/test/java/org/apache/ws/security/message/token/WCFUsernameTokenTest.java Tue Dec  7 17:41:05 2010
@@ -17,11 +17,8 @@
  * under the License.
  */
 
-package wssec;
+package org.apache.ws.security.message.token;
 
-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.WSSecurityException;
@@ -29,6 +26,7 @@ import org.apache.ws.security.WSPassword
 import org.apache.ws.security.WSSecurityEngine;
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSSConfig;
+import org.apache.ws.security.common.SOAPUtil;
 import org.w3c.dom.Document;
 
 import javax.security.auth.callback.Callback;
@@ -43,8 +41,8 @@ import java.io.IOException;
  * The issue is that WCF generated Username Tokens where the password type is namespace
  * qualified (incorrectly). WSS-199 added the ability to process these Username Tokens.
  */
-public class TestWSSecurityWSS199 extends TestCase implements CallbackHandler {
-    private static final Log LOG = LogFactory.getLog(TestWSSecurityWSS199.class);
+public class WCFUsernameTokenTest extends org.junit.Assert implements CallbackHandler {
+    private static final Log LOG = LogFactory.getLog(WCFUsernameTokenTest.class);
     private static final String SOAPUTMSG = 
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 
         + "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" "
@@ -66,28 +64,10 @@ public class TestWSSecurityWSS199 extend
     private WSSecurityEngine secEngine = new WSSecurityEngine();
 
     /**
-     * TestWSSecurity constructor
-     * 
-     * @param name name of the test
-     */
-    public TestWSSecurityWSS199(String name) {
-        super(name);
-    }
-
-    /**
-     * JUnit suite
-     * 
-     * @return a junit test suite
-     */
-    public static Test suite() {
-        return new TestSuite(TestWSSecurityWSS199.class);
-    }
-
-
-    /**
      * Test that adds a UserNameToken with a namespace qualified type. This should fail
      * as WSS4J rejects these tokens by default.
      */
+    @org.junit.Test
     public void testNamespaceQualifiedTypeRejected() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPUTMSG);
 
@@ -110,6 +90,7 @@ public class TestWSSecurityWSS199 extend
      * Test that adds a UserNameToken with a namespace qualified type. This should pass
      * as WSS4J has been configured to accept these tokens.
      */
+    @org.junit.Test
     public void testNamespaceQualifiedTypeAccepted() throws Exception {
         Document doc = SOAPUtil.toSOAPPart(SOAPUTMSG);
 



Mime
View raw message