cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1477617 - in /cxf/branches/wss4j2.0-port/rt/ws/security/src: main/java/org/apache/cxf/ws/security/wss4j/ test/java/org/apache/cxf/ws/security/wss4j/ test/java/org/apache/cxf/ws/security/wss4j/saml/
Date Tue, 30 Apr 2013 13:20:50 GMT
Author: coheigea
Date: Tue Apr 30 13:20:50 2013
New Revision: 1477617

URL: http://svn.apache.org/r1477617
Log:
Some more WSS4J 2.0 unit tests

Modified:
    cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JStaxInInterceptor.java
    cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxRoundTripTest.java
    cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxToDOMRoundTripTest.java
    cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/StaxToDOMSamlTest.java

Modified: cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JStaxInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JStaxInInterceptor.java?rev=1477617&r1=1477616&r2=1477617&view=diff
==============================================================================
--- cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JStaxInInterceptor.java (original)
+++ cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JStaxInInterceptor.java Tue Apr 30 13:20:50 2013
@@ -147,20 +147,24 @@ public class WSS4JStaxInInterceptor exte
             WSS4JUtils.getReplayCache(
                 msg, SecurityConstants.ENABLE_NONCE_CACHE, SecurityConstants.NONCE_CACHE_INSTANCE
             );
-        if (securityProperties != null) {
-            securityProperties.setNonceReplayCache(nonceCache);
-        } else {
-            config.put(ConfigurationConstants.NONCE_CACHE_INSTANCE, nonceCache);
+        if (nonceCache != null) {
+            if (securityProperties != null) {
+                securityProperties.setNonceReplayCache(nonceCache);
+            } else {
+                config.put(ConfigurationConstants.NONCE_CACHE_INSTANCE, nonceCache);
+            }
         }
         
         ReplayCache timestampCache = 
             WSS4JUtils.getReplayCache(
                 msg, SecurityConstants.ENABLE_TIMESTAMP_CACHE, SecurityConstants.TIMESTAMP_CACHE_INSTANCE
             );
-        if (securityProperties != null) {
-            securityProperties.setTimestampReplayCache(timestampCache);
-        } else {
-            config.put(ConfigurationConstants.TIMESTAMP_CACHE_INSTANCE, timestampCache);
+        if (timestampCache != null) {
+            if (securityProperties != null) {
+                securityProperties.setTimestampReplayCache(timestampCache);
+            } else {
+                config.put(ConfigurationConstants.TIMESTAMP_CACHE_INSTANCE, timestampCache);
+            }
         }
         
         boolean enableRevocation = 

Modified: cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxRoundTripTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxRoundTripTest.java?rev=1477617&r1=1477616&r2=1477617&view=diff
==============================================================================
--- cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxRoundTripTest.java (original)
+++ cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxRoundTripTest.java Tue Apr 30 13:20:50 2013
@@ -18,6 +18,8 @@
  */
 package org.apache.cxf.ws.security.wss4j;
 
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Properties;
 
 import javax.xml.namespace.QName;
@@ -31,6 +33,7 @@ import org.apache.cxf.jaxws.JaxWsProxyFa
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.transport.local.LocalTransportFactory;
+import org.apache.wss4j.common.ConfigurationConstants;
 import org.apache.wss4j.common.crypto.CryptoFactory;
 import org.apache.wss4j.stax.ext.WSSConstants;
 import org.apache.wss4j.stax.ext.WSSSecurityProperties;
@@ -76,6 +79,38 @@ public class StaxRoundTripTest extends A
     }
     
     @Test
+    public void testUsernameTokenTextConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inConfig = new HashMap<String, Object>();
+        inConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inConfig);
+        WSS4JPrincipalInterceptor principalInterceptor = new WSS4JPrincipalInterceptor();
+        principalInterceptor.setPrincipalName("username");
+        service.getInInterceptors().add(inhandler);
+        service.getInInterceptors().add(principalInterceptor);
+
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.USERNAME_TOKEN);
+        outConfig.put(ConfigurationConstants.PASSWORD_TYPE, "PasswordText");
+        outConfig.put(ConfigurationConstants.USER, "username");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testUsernameTokenDigest() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -107,6 +142,38 @@ public class StaxRoundTripTest extends A
     }
     
     @Test
+    public void testUsernameTokenDigestConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inConfig = new HashMap<String, Object>();
+        inConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inConfig);
+        WSS4JPrincipalInterceptor principalInterceptor = new WSS4JPrincipalInterceptor();
+        principalInterceptor.setPrincipalName("username");
+        service.getInInterceptors().add(inhandler);
+        service.getInInterceptors().add(principalInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.USERNAME_TOKEN);
+        outConfig.put(ConfigurationConstants.PASSWORD_TYPE, "PasswordDigest");
+        outConfig.put(ConfigurationConstants.USER, "username");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testEncrypt() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -141,6 +208,36 @@ public class StaxRoundTripTest extends A
     }
     
     @Test
+    public void testEncryptConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inConfig = new HashMap<String, Object>();
+        inConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        inConfig.put(ConfigurationConstants.DEC_PROP_FILE, "insecurity.properties");
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inConfig);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.ENCRYPT);
+        outConfig.put(ConfigurationConstants.ENCRYPTION_USER, "myalias");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        outConfig.put(ConfigurationConstants.ENC_PROP_FILE, "outsecurity.properties");
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testEncryptUsernameToken() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -181,6 +278,44 @@ public class StaxRoundTripTest extends A
     }
     
     @Test
+    public void testEncryptUsernameTokenConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inConfig = new HashMap<String, Object>();
+        inConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        inConfig.put(ConfigurationConstants.DEC_PROP_FILE, "insecurity.properties");
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inConfig);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(
+            ConfigurationConstants.ACTION, 
+            ConfigurationConstants.USERNAME_TOKEN + " " + ConfigurationConstants.ENCRYPT
+        );
+        outConfig.put(
+            ConfigurationConstants.ENCRYPTION_PARTS, 
+            "{Element}{" + WSSConstants.NS_WSSE10 + "}UsernameToken"
+        );
+        outConfig.put(ConfigurationConstants.USER, "username");
+        outConfig.put(ConfigurationConstants.ENCRYPTION_USER, "myalias");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        outConfig.put(ConfigurationConstants.ENC_PROP_FILE, "outsecurity.properties");
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testSignature() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -218,6 +353,40 @@ public class StaxRoundTripTest extends A
     }
     
     @Test
+    public void testSignatureConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inConfig = new HashMap<String, Object>();
+        inConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        inConfig.put(ConfigurationConstants.SIG_VER_PROP_FILE, "insecurity.properties");
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inConfig);
+        
+        WSS4JPrincipalInterceptor principalInterceptor = new WSS4JPrincipalInterceptor();
+        principalInterceptor.setPrincipalName("CN=myAlias");
+        service.getInInterceptors().add(inhandler);
+        service.getInInterceptors().add(principalInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.SIGNATURE);
+        outConfig.put(ConfigurationConstants.SIGNATURE_USER, "myalias");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        outConfig.put(ConfigurationConstants.SIG_PROP_FILE, "outsecurity.properties");
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testSignedUsernameToken() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -265,6 +434,48 @@ public class StaxRoundTripTest extends A
     }
     
     @Test
+    public void testSignedUsernameTokenConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inConfig = new HashMap<String, Object>();
+        inConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        inConfig.put(ConfigurationConstants.SIG_VER_PROP_FILE, "insecurity.properties");
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inConfig);
+        //WSS4JPrincipalInterceptor principalInterceptor = new WSS4JPrincipalInterceptor();
+        //principalInterceptor.setPrincipalName("username");
+        service.getInInterceptors().add(inhandler);
+        //service.getInInterceptors().add(principalInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(
+            ConfigurationConstants.ACTION, 
+            ConfigurationConstants.USERNAME_TOKEN + " " + ConfigurationConstants.SIGNATURE
+        );
+        outConfig.put(
+            ConfigurationConstants.SIGNATURE_PARTS, 
+            "{Element}{" + WSSConstants.NS_WSSE10 + "}UsernameToken;"
+            + "{Element}{" + WSSConstants.NS_SOAP11 + "}Body"
+        );
+        outConfig.put(ConfigurationConstants.USER, "username");
+        outConfig.put(ConfigurationConstants.SIGNATURE_USER, "myalias");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        outConfig.put(ConfigurationConstants.SIG_PROP_FILE, "outsecurity.properties");
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testTimestamp() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -290,6 +501,31 @@ public class StaxRoundTripTest extends A
     }
     
     @Test
+    public void testTimestampConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inConfig = new HashMap<String, Object>();
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inConfig);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.TIMESTAMP);
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testSignatureTimestamp() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -332,6 +568,44 @@ public class StaxRoundTripTest extends A
     }
     
     @Test
+    public void testSignatureTimestampConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inConfig = new HashMap<String, Object>();
+        inConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        inConfig.put(ConfigurationConstants.SIG_VER_PROP_FILE, "insecurity.properties");
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inConfig);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(
+            ConfigurationConstants.ACTION, 
+            ConfigurationConstants.TIMESTAMP + " " + ConfigurationConstants.SIGNATURE
+        );
+        outConfig.put(
+            ConfigurationConstants.SIGNATURE_PARTS, 
+            "{Element}{" + WSSConstants.NS_WSU10 + "}Timestamp;"
+            + "{Element}{" + WSSConstants.NS_SOAP11 + "}Body"
+        );
+        outConfig.put(ConfigurationConstants.SIGNATURE_USER, "myalias");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        outConfig.put(ConfigurationConstants.SIG_PROP_FILE, "outsecurity.properties");
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testSignaturePKI() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -376,6 +650,41 @@ public class StaxRoundTripTest extends A
     }
     
     @Test
+    public void testSignaturePKIConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inConfig = new HashMap<String, Object>();
+        inConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        inConfig.put(ConfigurationConstants.SIG_VER_PROP_FILE, "cxfca.properties");
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inConfig);
+        WSS4JPrincipalInterceptor principalInterceptor = new WSS4JPrincipalInterceptor();
+        principalInterceptor.setPrincipalName("CN=alice,OU=eng,O=apache.org");
+        service.getInInterceptors().add(inhandler);
+        service.getInInterceptors().add(principalInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.SIGNATURE);
+        outConfig.put(ConfigurationConstants.SIGNATURE_USER, "alice");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new KeystorePasswordCallback());
+        outConfig.put(ConfigurationConstants.SIG_PROP_FILE, "alice.properties");
+        outConfig.put(ConfigurationConstants.USE_SINGLE_CERTIFICATE, "true");
+        outConfig.put(ConfigurationConstants.SIG_KEY_ID, "DirectReference");
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testEncryptSignature() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -415,6 +724,42 @@ public class StaxRoundTripTest extends A
     }
     
     @Test
+    public void testEncryptSignatureConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inConfig = new HashMap<String, Object>();
+        inConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        inConfig.put(ConfigurationConstants.SIG_VER_PROP_FILE, "insecurity.properties");
+        inConfig.put(ConfigurationConstants.DEC_PROP_FILE, "insecurity.properties");
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inConfig);
+        service.getInInterceptors().add(inhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(
+            ConfigurationConstants.ACTION, 
+            ConfigurationConstants.ENCRYPT + " " + ConfigurationConstants.SIGNATURE
+        );
+        outConfig.put(ConfigurationConstants.SIGNATURE_USER, "myalias");
+        outConfig.put(ConfigurationConstants.ENCRYPTION_USER, "myalias");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        outConfig.put(ConfigurationConstants.SIG_PROP_FILE, "outsecurity.properties");
+        outConfig.put(ConfigurationConstants.ENC_PROP_FILE, "outsecurity.properties");
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+        
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testSignatureConfirmation() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -469,6 +814,57 @@ public class StaxRoundTripTest extends A
         assertEquals("test", echo.echo("test"));
     }
     
+    @Test
+    public void testSignatureConfirmationConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inConfig = new HashMap<String, Object>();
+        inConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        inConfig.put(ConfigurationConstants.SIG_VER_PROP_FILE, "insecurity.properties");
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inConfig);
+        service.getInInterceptors().add(inhandler);
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(
+            ConfigurationConstants.ACTION, ConfigurationConstants.SIGNATURE
+        );
+        outConfig.put(ConfigurationConstants.SIGNATURE_USER, "myalias");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        outConfig.put(ConfigurationConstants.ENABLE_SIGNATURE_CONFIRMATION, "true");
+        outConfig.put(ConfigurationConstants.SIG_PROP_FILE, "outsecurity.properties");
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        service.getOutInterceptors().add(ohandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> clientOutConfig = new HashMap<String, Object>();
+        clientOutConfig.put(
+            ConfigurationConstants.ACTION, ConfigurationConstants.SIGNATURE
+        );
+        clientOutConfig.put(ConfigurationConstants.SIGNATURE_USER, "myalias");
+        clientOutConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        clientOutConfig.put(ConfigurationConstants.SIG_PROP_FILE, "outsecurity.properties");
+        WSS4JStaxOutInterceptor clientOhandler = new WSS4JStaxOutInterceptor(clientOutConfig);
+        
+        client.getOutInterceptors().add(clientOhandler);
+        
+        Map<String, Object> clientInConfig = new HashMap<String, Object>();
+        clientInConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        clientInConfig.put(ConfigurationConstants.ENABLE_SIGNATURE_CONFIRMATION, "true");
+        clientInConfig.put(ConfigurationConstants.SIG_VER_PROP_FILE, "insecurity.properties");
+        WSS4JStaxInInterceptor clientInHandler = new WSS4JStaxInInterceptor(clientInConfig);
+        client.getInInterceptors().add(clientInHandler);
+        
+        assertEquals("test", echo.echo("test"));
+    }
+    
     private Service createService() {
         // Create the Service
         JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();

Modified: cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxToDOMRoundTripTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxToDOMRoundTripTest.java?rev=1477617&r1=1477616&r2=1477617&view=diff
==============================================================================
--- cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxToDOMRoundTripTest.java (original)
+++ cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/StaxToDOMRoundTripTest.java Tue Apr 30 13:20:50 2013
@@ -33,6 +33,7 @@ import org.apache.cxf.jaxws.JaxWsProxyFa
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.transport.local.LocalTransportFactory;
+import org.apache.wss4j.common.ConfigurationConstants;
 import org.apache.wss4j.common.crypto.CryptoFactory;
 import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.dom.handler.WSHandlerConstants;
@@ -94,6 +95,53 @@ public class StaxToDOMRoundTripTest exte
         }
     }
     
+    
+    @Test
+    public void testUsernameTokenTextConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inProperties = new HashMap<String, Object>();
+        inProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
+        inProperties.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
+        inProperties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.USERNAME_TOKEN);
+        outConfig.put(ConfigurationConstants.PASSWORD_TYPE, "PasswordText");
+        outConfig.put(ConfigurationConstants.USER, "username");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+        
+        // Negative test for wrong password type
+        service.getInInterceptors().remove(inInterceptor);
+        inProperties.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
+        inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        try {
+            echo.echo("test");
+            fail("Failure expected on the wrong password type");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            // expected
+            String error = "The security token could not be authenticated or authorized";
+            assertTrue(ex.getMessage().contains(error));
+        }
+    }
+    
     @Test
     public void testUsernameTokenDigest() throws Exception {
         // Create + configure service
@@ -140,6 +188,52 @@ public class StaxToDOMRoundTripTest exte
     }
     
     @Test
+    public void testUsernameTokenDigestConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inProperties = new HashMap<String, Object>();
+        inProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
+        inProperties.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
+        inProperties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.USERNAME_TOKEN);
+        outConfig.put(ConfigurationConstants.PASSWORD_TYPE, "PasswordDigest");
+        outConfig.put(ConfigurationConstants.USER, "username");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+        
+        // Negative test for wrong password type
+        service.getInInterceptors().remove(inInterceptor);
+        inProperties.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
+        inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        try {
+            echo.echo("test");
+            fail("Failure expected on the wrong password type");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            // expected
+            String error = "The security token could not be authenticated or authorized";
+            assertTrue(ex.getMessage().contains(error));
+        }
+    }
+    
+    @Test
     public void testEncrypt() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -173,6 +267,37 @@ public class StaxToDOMRoundTripTest exte
     }
     
     @Test
+    public void testEncryptConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inProperties = new HashMap<String, Object>();
+        inProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.ENCRYPT);
+        inProperties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        inProperties.put(WSHandlerConstants.DEC_PROP_FILE, "insecurity.properties");
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.ENCRYPT);
+        outConfig.put(ConfigurationConstants.ENCRYPTION_USER, "myalias");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        outConfig.put(ConfigurationConstants.ENC_PROP_FILE, "outsecurity.properties");
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testEncryptionAlgorithms() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -216,6 +341,53 @@ public class StaxToDOMRoundTripTest exte
     }
     
     @Test
+    public void testEncryptionAlgorithmsConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inProperties = new HashMap<String, Object>();
+        inProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.ENCRYPT);
+        inProperties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        inProperties.put(WSHandlerConstants.DEC_PROP_FILE, "insecurity.properties");
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.ENCRYPT);
+        outConfig.put(ConfigurationConstants.ENCRYPTION_USER, "myalias");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        outConfig.put(
+            ConfigurationConstants.ENC_KEY_TRANSPORT, 
+            "http://www.w3.org/2001/04/xmlenc#rsa-1_5"
+        );
+        outConfig.put(
+             ConfigurationConstants.ENC_SYM_ALGO, 
+             "http://www.w3.org/2001/04/xmlenc#tripledes-cbc"
+        );
+        outConfig.put(ConfigurationConstants.ENC_PROP_FILE, "outsecurity.properties");
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+        
+        try {
+            echo.echo("test");
+            fail("Failure expected as RSA v1.5 is not allowed by default");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            // expected
+        }
+        
+        inProperties.put(WSHandlerConstants.ALLOW_RSA15_KEY_TRANSPORT_ALGORITHM, "true");
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testEncryptUsernameToken() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -258,6 +430,48 @@ public class StaxToDOMRoundTripTest exte
     }
     
     @Test
+    public void testEncryptUsernameTokenConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inProperties = new HashMap<String, Object>();
+        inProperties.put(
+            WSHandlerConstants.ACTION, 
+            WSHandlerConstants.USERNAME_TOKEN + " " + WSHandlerConstants.ENCRYPT
+        );
+        inProperties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        inProperties.put(WSHandlerConstants.DEC_PROP_FILE, "insecurity.properties");
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(
+            ConfigurationConstants.ACTION, 
+            ConfigurationConstants.USERNAME_TOKEN + " " + ConfigurationConstants.ENCRYPT
+        );
+        outConfig.put(
+            ConfigurationConstants.ENCRYPTION_PARTS, 
+            "{Element}{" + WSSConstants.NS_WSSE10 + "}UsernameToken"
+        );
+        outConfig.put(ConfigurationConstants.USER, "username");
+        outConfig.put(ConfigurationConstants.ENCRYPTION_USER, "myalias");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        outConfig.put(ConfigurationConstants.ENC_PROP_FILE, "outsecurity.properties");
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testSignature() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -291,6 +505,37 @@ public class StaxToDOMRoundTripTest exte
     }
     
     @Test
+    public void testSignatureConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inProperties = new HashMap<String, Object>();
+        inProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
+        inProperties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE, "insecurity.properties");
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.SIGNATURE);
+        outConfig.put(ConfigurationConstants.SIGNATURE_USER, "myalias");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        outConfig.put(ConfigurationConstants.SIG_PROP_FILE, "outsecurity.properties");
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testSignedUsernameToken() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -337,6 +582,49 @@ public class StaxToDOMRoundTripTest exte
     }
     
     @Test
+    public void testSignedUsernameTokenConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inProperties = new HashMap<String, Object>();
+        inProperties.put(
+            WSHandlerConstants.ACTION, 
+            WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.USERNAME_TOKEN
+        );
+        inProperties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE, "insecurity.properties");
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(
+            ConfigurationConstants.ACTION, 
+            ConfigurationConstants.USERNAME_TOKEN + " " + ConfigurationConstants.SIGNATURE
+        );
+        outConfig.put(
+            ConfigurationConstants.SIGNATURE_PARTS, 
+            "{Element}{" + WSSConstants.NS_WSSE10 + "}UsernameToken;"
+            + "{Element}{" + WSSConstants.NS_SOAP11 + "}Body"
+        );
+        outConfig.put(ConfigurationConstants.USER, "username");
+        outConfig.put(ConfigurationConstants.SIGNATURE_USER, "myalias");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        outConfig.put(ConfigurationConstants.SIG_PROP_FILE, "outsecurity.properties");
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testTimestamp() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -378,6 +666,47 @@ public class StaxToDOMRoundTripTest exte
     }
     
     @Test
+    public void testTimestampConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inProperties = new HashMap<String, Object>();
+        inProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP);
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.TIMESTAMP);
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+        
+        // Negative test for no Timestamp
+        service.getInInterceptors().remove(inInterceptor);
+        inProperties.put(WSHandlerConstants.ACTION, "");
+        inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        try {
+            echo.echo("test");
+            fail("Failure expected on no Timestamp");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            // expected
+            String error = "An error was discovered";
+            assertTrue(ex.getMessage().contains(error));
+        }
+    }
+    
+    @Test
     public void testSignatureTimestamp() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -422,6 +751,48 @@ public class StaxToDOMRoundTripTest exte
     }
     
     @Test
+    public void testSignatureTimestampConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inProperties = new HashMap<String, Object>();
+        inProperties.put(
+            WSHandlerConstants.ACTION, 
+            WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.TIMESTAMP
+        );
+        inProperties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE, "insecurity.properties");
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(
+            ConfigurationConstants.ACTION, 
+            ConfigurationConstants.TIMESTAMP + " " + ConfigurationConstants.SIGNATURE
+        );
+        outConfig.put(
+            ConfigurationConstants.SIGNATURE_PARTS, 
+            "{Element}{" + WSSConstants.NS_WSU10 + "}Timestamp;"
+            + "{Element}{" + WSSConstants.NS_SOAP11 + "}Body"
+        );
+        outConfig.put(ConfigurationConstants.SIGNATURE_USER, "myalias");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        outConfig.put(ConfigurationConstants.SIG_PROP_FILE, "outsecurity.properties");
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testSignatureTimestampWrongNamespace() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -511,6 +882,39 @@ public class StaxToDOMRoundTripTest exte
     }
     
     @Test
+    public void testSignaturePKIConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inProperties = new HashMap<String, Object>();
+        inProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
+        inProperties.put(WSHandlerConstants.PW_CALLBACK_REF, new KeystorePasswordCallback());
+        inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE, "cxfca.properties");
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.SIGNATURE);
+        outConfig.put(ConfigurationConstants.SIGNATURE_USER, "alice");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new KeystorePasswordCallback());
+        outConfig.put(ConfigurationConstants.SIG_PROP_FILE, "alice.properties");
+        outConfig.put(ConfigurationConstants.USE_SINGLE_CERTIFICATE, "true");
+        outConfig.put(ConfigurationConstants.SIG_KEY_ID, "DirectReference");
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testEncryptSignature() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -552,6 +956,46 @@ public class StaxToDOMRoundTripTest exte
     }
     
     @Test
+    public void testEncryptSignatureConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inProperties = new HashMap<String, Object>();
+        inProperties.put(
+            WSHandlerConstants.ACTION, 
+            WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT
+        );
+        inProperties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE, "insecurity.properties");
+        inProperties.put(WSHandlerConstants.DEC_PROP_FILE, "insecurity.properties");
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(
+            ConfigurationConstants.ACTION, 
+            ConfigurationConstants.ENCRYPT + " " + ConfigurationConstants.SIGNATURE
+        );
+        outConfig.put(ConfigurationConstants.SIGNATURE_USER, "myalias");
+        outConfig.put(ConfigurationConstants.ENCRYPTION_USER, "myalias");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        outConfig.put(ConfigurationConstants.SIG_PROP_FILE, "outsecurity.properties");
+        outConfig.put(ConfigurationConstants.ENC_PROP_FILE, "outsecurity.properties");
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testSignatureConfirmation() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -603,6 +1047,57 @@ public class StaxToDOMRoundTripTest exte
         assertEquals("test", echo.echo("test"));
     }
     
+    @Test
+    public void testSignatureConfirmationConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inProperties = new HashMap<String, Object>();
+        inProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
+        inProperties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE, "insecurity.properties");
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        Map<String, Object> outProperties = new HashMap<String, Object>();
+        outProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
+        outProperties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        outProperties.put(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties");
+        outProperties.put(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION, "true");
+        outProperties.put(WSHandlerConstants.USER, "myalias");
+        
+        WSS4JOutInterceptor domOhandler = new WSS4JOutInterceptor(outProperties);
+        service.getOutInterceptors().add(domOhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> clientOutConfig = new HashMap<String, Object>();
+        clientOutConfig.put(
+            ConfigurationConstants.ACTION, ConfigurationConstants.SIGNATURE
+        );
+        clientOutConfig.put(ConfigurationConstants.SIGNATURE_USER, "myalias");
+        clientOutConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        clientOutConfig.put(ConfigurationConstants.SIG_PROP_FILE, "outsecurity.properties");
+        WSS4JStaxOutInterceptor clientOhandler = new WSS4JStaxOutInterceptor(clientOutConfig);
+        
+        client.getOutInterceptors().add(clientOhandler);
+        
+        Map<String, Object> clientInConfig = new HashMap<String, Object>();
+        clientInConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        clientInConfig.put(ConfigurationConstants.ENABLE_SIGNATURE_CONFIRMATION, "true");
+        clientInConfig.put(ConfigurationConstants.SIG_VER_PROP_FILE, "insecurity.properties");
+        WSS4JStaxInInterceptor clientInHandler = new WSS4JStaxInInterceptor(clientInConfig);
+        
+        client.getInInterceptors().add(clientInHandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
     private Service createService() {
         // Create the Service
         JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();

Modified: cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/StaxToDOMSamlTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/StaxToDOMSamlTest.java?rev=1477617&r1=1477616&r2=1477617&view=diff
==============================================================================
--- cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/StaxToDOMSamlTest.java (original)
+++ cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/saml/StaxToDOMSamlTest.java Tue Apr 30 13:20:50 2013
@@ -39,6 +39,7 @@ import org.apache.cxf.ws.security.wss4j.
 import org.apache.cxf.ws.security.wss4j.EchoImpl;
 import org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor;
 import org.apache.cxf.ws.security.wss4j.WSS4JStaxOutInterceptor;
+import org.apache.wss4j.common.ConfigurationConstants;
 import org.apache.wss4j.common.crypto.CryptoFactory;
 import org.apache.wss4j.common.saml.builder.SAML1Constants;
 import org.apache.wss4j.common.saml.builder.SAML2Constants;
@@ -92,6 +93,41 @@ public class StaxToDOMSamlTest extends A
     }
     
     @Test
+    public void testSaml1Config() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inProperties = new HashMap<String, Object>();
+        inProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.SAML_TOKEN_UNSIGNED);
+        final Map<QName, Object> customMap = new HashMap<QName, Object>();
+        CustomSamlValidator validator = new CustomSamlValidator();
+        customMap.put(WSSecurityEngine.SAML_TOKEN, validator);
+        customMap.put(WSSecurityEngine.SAML2_TOKEN, validator);
+        inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP, customMap);
+        inProperties.put(SecurityConstants.VALIDATE_SAML_SUBJECT_CONFIRMATION, "false");
+        
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        service.put(SecurityConstants.VALIDATE_SAML_SUBJECT_CONFIRMATION, "false");
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.SAML_TOKEN_UNSIGNED);
+        outConfig.put(ConfigurationConstants.SAML_CALLBACK_REF, new SAML1CallbackHandler());
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testSaml1SignedSenderVouches() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -139,6 +175,47 @@ public class StaxToDOMSamlTest extends A
     }
     
     @Test
+    public void testSaml1SignedSenderVouchesConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inProperties = new HashMap<String, Object>();
+        inProperties.put(
+            WSHandlerConstants.ACTION, 
+            WSHandlerConstants.SAML_TOKEN_UNSIGNED + " " + WSHandlerConstants.SIGNATURE
+        );
+        inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE, "insecurity.properties");
+        final Map<QName, Object> customMap = new HashMap<QName, Object>();
+        CustomSamlValidator validator = new CustomSamlValidator();
+        customMap.put(WSSecurityEngine.SAML_TOKEN, validator);
+        customMap.put(WSSecurityEngine.SAML2_TOKEN, validator);
+        inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP, customMap);
+        
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.SAML_TOKEN_SIGNED);
+        outConfig.put(ConfigurationConstants.SAML_CALLBACK_REF, new SAML1CallbackHandler());
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new PasswordCallbackHandler());
+        outConfig.put(ConfigurationConstants.SIGNATURE_USER, "alice");
+        outConfig.put(ConfigurationConstants.SIG_PROP_FILE, "alice.properties");
+        outConfig.put(ConfigurationConstants.SIG_KEY_ID, "DirectReference");
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testSaml2() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -175,6 +252,42 @@ public class StaxToDOMSamlTest extends A
     }
     
     @Test
+    public void testSaml2Config() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inProperties = new HashMap<String, Object>();
+        inProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.SAML_TOKEN_UNSIGNED);
+        final Map<QName, Object> customMap = new HashMap<QName, Object>();
+        CustomSamlValidator validator = new CustomSamlValidator();
+        validator.setRequireSAML1Assertion(false);
+        customMap.put(WSSecurityEngine.SAML_TOKEN, validator);
+        customMap.put(WSSecurityEngine.SAML2_TOKEN, validator);
+        inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP, customMap);
+        inProperties.put(SecurityConstants.VALIDATE_SAML_SUBJECT_CONFIRMATION, "false");
+        
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        service.put(SecurityConstants.VALIDATE_SAML_SUBJECT_CONFIRMATION, "false");
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.SAML_TOKEN_UNSIGNED);
+        outConfig.put(ConfigurationConstants.SAML_CALLBACK_REF, new SAML2CallbackHandler());
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testSaml2SignedSenderVouches() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -223,6 +336,48 @@ public class StaxToDOMSamlTest extends A
     }
     
     @Test
+    public void testSaml2SignedSenderVouchesConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inProperties = new HashMap<String, Object>();
+        inProperties.put(
+            WSHandlerConstants.ACTION, 
+            WSHandlerConstants.SAML_TOKEN_UNSIGNED + " " + WSHandlerConstants.SIGNATURE
+        );
+        inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE, "insecurity.properties");
+        final Map<QName, Object> customMap = new HashMap<QName, Object>();
+        CustomSamlValidator validator = new CustomSamlValidator();
+        validator.setRequireSAML1Assertion(false);
+        customMap.put(WSSecurityEngine.SAML_TOKEN, validator);
+        customMap.put(WSSecurityEngine.SAML2_TOKEN, validator);
+        inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP, customMap);
+        
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.SAML_TOKEN_SIGNED);
+        outConfig.put(ConfigurationConstants.SAML_CALLBACK_REF, new SAML2CallbackHandler());
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new PasswordCallbackHandler());
+        outConfig.put(ConfigurationConstants.SIGNATURE_USER, "alice");
+        outConfig.put(ConfigurationConstants.SIG_PROP_FILE, "alice.properties");
+        outConfig.put(ConfigurationConstants.SIG_KEY_ID, "DirectReference");
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+
+        client.getOutInterceptors().add(ohandler);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testSaml1TokenHOK() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -281,6 +436,59 @@ public class StaxToDOMSamlTest extends A
     }
     
     @Test
+    public void testSaml1TokenHOKConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inProperties = new HashMap<String, Object>();
+        inProperties.put(
+            WSHandlerConstants.ACTION, 
+            WSHandlerConstants.SAML_TOKEN_SIGNED + " " + WSHandlerConstants.SIGNATURE
+        );
+        inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE, "insecurity.properties");
+        final Map<QName, Object> customMap = new HashMap<QName, Object>();
+        CustomSamlValidator validator = new CustomSamlValidator();
+        customMap.put(WSSecurityEngine.SAML_TOKEN, validator);
+        customMap.put(WSSecurityEngine.SAML2_TOKEN, validator);
+        inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP, customMap);
+        
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.SAML_TOKEN_SIGNED);
+        SAML1CallbackHandler callbackHandler = new SAML1CallbackHandler();
+        callbackHandler.setSignAssertion(true);
+        callbackHandler.setConfirmationMethod(SAML1Constants.CONF_HOLDER_KEY);
+        outConfig.put(ConfigurationConstants.SAML_CALLBACK_REF, callbackHandler);
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new PasswordCallbackHandler());
+        outConfig.put(ConfigurationConstants.SIGNATURE_USER, "alice");
+        outConfig.put(ConfigurationConstants.SIG_PROP_FILE, "alice.properties");
+        outConfig.put(ConfigurationConstants.SIG_KEY_ID, "DirectReference");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new PasswordCallbackHandler());
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+        
+        try {
+            echo.echo("test");
+            fail("Failure expected on receiving sender vouches instead of HOK");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            // expected
+        }
+
+        validator.setRequireSenderVouches(false);
+        assertEquals("test", echo.echo("test"));
+    }
+    
+    @Test
     public void testSaml2TokenHOK() throws Exception {
         // Create + configure service
         Service service = createService();
@@ -346,6 +554,67 @@ public class StaxToDOMSamlTest extends A
         assertEquals("test", echo.echo("test"));
     }
     
+    @Test
+    public void testSaml2TokenHOKConfig() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        Map<String, Object> inProperties = new HashMap<String, Object>();
+        inProperties.put(
+            WSHandlerConstants.ACTION, 
+            WSHandlerConstants.SAML_TOKEN_SIGNED + " " + WSHandlerConstants.SIGNATURE
+        );
+        inProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE, "insecurity.properties");
+        final Map<QName, Object> customMap = new HashMap<QName, Object>();
+        CustomSamlValidator validator = new CustomSamlValidator();
+        customMap.put(WSSecurityEngine.SAML_TOKEN, validator);
+        customMap.put(WSSecurityEngine.SAML2_TOKEN, validator);
+        inProperties.put(WSS4JInInterceptor.VALIDATOR_MAP, customMap);
+        
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(inProperties);
+        service.getInInterceptors().add(inInterceptor);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> outConfig = new HashMap<String, Object>();
+        outConfig.put(ConfigurationConstants.ACTION, ConfigurationConstants.SAML_TOKEN_SIGNED);
+        SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
+        callbackHandler.setSignAssertion(true);
+        callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY);
+        outConfig.put(ConfigurationConstants.SAML_CALLBACK_REF, callbackHandler);
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new PasswordCallbackHandler());
+        outConfig.put(ConfigurationConstants.SIGNATURE_USER, "alice");
+        outConfig.put(ConfigurationConstants.SIG_PROP_FILE, "alice.properties");
+        outConfig.put(ConfigurationConstants.SIG_KEY_ID, "DirectReference");
+        outConfig.put(ConfigurationConstants.PW_CALLBACK_REF, new PasswordCallbackHandler());
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(outConfig);
+        
+        client.getOutInterceptors().add(ohandler);
+        
+        try {
+            echo.echo("test");
+            fail("Failure expected on receiving sender vouches instead of HOK");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            // expected
+        }
+        validator.setRequireSenderVouches(false);
+        
+        try {
+            echo.echo("test");
+            fail("Failure expected on receiving a SAML 1.1 Token instead of SAML 2.0");
+        } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+            // expected
+        }
+        validator.setRequireSAML1Assertion(false);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
     private Service createService() {
         // Create the Service
         JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();



Mime
View raw message