cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1467329 - 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/
Date Fri, 12 Apr 2013 16:03:36 GMT
Author: coheigea
Date: Fri Apr 12 16:03:35 2013
New Revision: 1467329

URL: http://svn.apache.org/r1467329
Log:
Added some SignatureConfirmation Interop tests

Modified:
    cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java
    cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxRoundTripTest.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/WSS4JInOutTest.java

Modified: cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java?rev=1467329&r1=1467328&r2=1467329&view=diff
==============================================================================
--- cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java
(original)
+++ cxf/branches/wss4j2.0-port/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java
Fri Apr 12 16:03:35 2013
@@ -241,11 +241,6 @@ public class WSS4JInInterceptor extends 
 
             reqData.setCallbackHandler(getCallback(reqData, doAction, utWithCallbacks));
             
-            String passwordTypeStrict = (String)getOption(WSHandlerConstants.PASSWORD_TYPE_STRICT);
-            if (passwordTypeStrict == null) {
-                setProperty(WSHandlerConstants.PASSWORD_TYPE_STRICT, "true");
-            }
-            
             // Configure replay caching
             ReplayCache nonceCache = 
                 getReplayCache(

Modified: cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxRoundTripTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxRoundTripTest.java?rev=1467329&r1=1467328&r2=1467329&view=diff
==============================================================================
--- cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxRoundTripTest.java
(original)
+++ cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/DOMToStaxRoundTripTest.java
Fri Apr 12 16:03:35 2013
@@ -36,6 +36,7 @@ import org.apache.wss4j.dom.WSConstants;
 import org.apache.wss4j.dom.handler.WSHandlerConstants;
 import org.apache.wss4j.stax.ext.WSSConstants;
 import org.apache.wss4j.stax.ext.WSSSecurityProperties;
+import org.apache.xml.security.stax.ext.XMLSecurityConstants;
 import org.junit.Test;
 
 
@@ -372,6 +373,58 @@ public class DOMToStaxRoundTripTest exte
         assertEquals("test", echo.echo("test"));
     }
     
+    @Test
+    public void testSignatureConfirmation() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setSignatureVerificationCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        WSSSecurityProperties outProperties = new WSSSecurityProperties();
+        outProperties.setOutAction(new XMLSecurityConstants.Action[]{WSSConstants.SIGNATURE_CONFIRMATION});
+        outProperties.setSignatureUser("myalias");
+        
+        Properties outCryptoProperties = 
+            CryptoFactory.getProperties("outsecurity.properties", this.getClass().getClassLoader());
+        outProperties.setSignatureCryptoProperties(outCryptoProperties);
+        outProperties.setCallbackHandler(new TestPwdCallback());
+        WSS4JStaxOutInterceptor staxOhandler = new WSS4JStaxOutInterceptor(outProperties);
+        service.getOutInterceptors().add(staxOhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
+        properties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        properties.put(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties");
+        properties.put(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION, "true");
+        properties.put(WSHandlerConstants.USER, "myalias");
+        
+        WSS4JOutInterceptor ohandler = new WSS4JOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+        
+        Map<String, Object> domInProperties = new HashMap<String, Object>();
+        domInProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
+        domInProperties.put(WSHandlerConstants.PW_CALLBACK_REF, new TestPwdCallback());
+        domInProperties.put(WSHandlerConstants.SIG_VER_PROP_FILE, "insecurity.properties");
+        domInProperties.put(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION, "true");
+        WSS4JInInterceptor inInterceptor = new WSS4JInInterceptor(domInProperties);
+        client.getInInterceptors().add(inInterceptor);
+
+        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/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=1467329&r1=1467328&r2=1467329&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
Fri Apr 12 16:03:35 2013
@@ -355,6 +355,60 @@ public class StaxRoundTripTest extends A
         assertEquals("test", echo.echo("test"));
     }
     
+    @Test
+    public void testSignatureConfirmation() throws Exception {
+        // Create + configure service
+        Service service = createService();
+        
+        WSSSecurityProperties inProperties = new WSSSecurityProperties();
+        inProperties.setCallbackHandler(new TestPwdCallback());
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        inProperties.setSignatureVerificationCryptoProperties(cryptoProperties);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(inProperties);
+        service.getInInterceptors().add(inhandler);
+        
+        WSSSecurityProperties outProperties = new WSSSecurityProperties();
+        outProperties.setOutAction(new XMLSecurityConstants.Action[]{WSSConstants.SIGNATURE_CONFIRMATION});
+        outProperties.setSignatureUser("myalias");
+        
+        Properties outCryptoProperties = 
+            CryptoFactory.getProperties("outsecurity.properties", this.getClass().getClassLoader());
+        outProperties.setSignatureCryptoProperties(outCryptoProperties);
+        outProperties.setCallbackHandler(new TestPwdCallback());
+        WSS4JStaxOutInterceptor staxOhandler = new WSS4JStaxOutInterceptor(outProperties);
+        service.getOutInterceptors().add(staxOhandler);
+        
+        // Create + configure client
+        Echo echo = createClientProxy();
+        
+        Client client = ClientProxy.getClient(echo);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        client.getOutInterceptors().add(new LoggingOutInterceptor());
+        
+        WSSSecurityProperties properties = new WSSSecurityProperties();
+        properties.setOutAction(new XMLSecurityConstants.Action[]{WSSConstants.SIGNATURE});
+        properties.setSignatureUser("myalias");
+        
+        Properties clientOutCryptoProperties = 
+            CryptoFactory.getProperties("outsecurity.properties", this.getClass().getClassLoader());
+        properties.setSignatureCryptoProperties(clientOutCryptoProperties);
+        properties.setCallbackHandler(new TestPwdCallback());
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+        
+        WSSSecurityProperties staxInProperties = new WSSSecurityProperties();
+        staxInProperties.setCallbackHandler(new TestPwdCallback());
+        Properties staxInCryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        staxInProperties.setSignatureVerificationCryptoProperties(staxInCryptoProperties);
+        staxInProperties.setEnableSignatureConfirmationVerification(true);
+        WSS4JStaxInInterceptor inhandler2 = new WSS4JStaxInInterceptor(staxInProperties);
+        client.getInInterceptors().add(inhandler2);
+
+        assertEquals("test", echo.echo("test"));
+    }
+    
    /*
     * TODO
     @Test

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=1467329&r1=1467328&r2=1467329&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
Fri Apr 12 16:03:35 2013
@@ -413,6 +413,58 @@ public class StaxToDOMRoundTripTest exte
         assertEquals("test", echo.echo("test"));
     }
     
+    @Test
+    public void testSignatureConfirmation() 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());
+        
+        WSSSecurityProperties properties = new WSSSecurityProperties();
+        properties.setOutAction(new XMLSecurityConstants.Action[]{WSSConstants.SIGNATURE});
+        properties.setSignatureUser("myalias");
+        
+        Properties cryptoProperties = 
+            CryptoFactory.getProperties("outsecurity.properties", this.getClass().getClassLoader());
+        properties.setSignatureCryptoProperties(cryptoProperties);
+        properties.setCallbackHandler(new TestPwdCallback());
+        WSS4JStaxOutInterceptor ohandler = new WSS4JStaxOutInterceptor(properties);
+        client.getOutInterceptors().add(ohandler);
+        
+        WSSSecurityProperties staxInProperties = new WSSSecurityProperties();
+        staxInProperties.setCallbackHandler(new TestPwdCallback());
+        Properties staxInCryptoProperties = 
+            CryptoFactory.getProperties("insecurity.properties", this.getClass().getClassLoader());
+        staxInProperties.setSignatureVerificationCryptoProperties(staxInCryptoProperties);
+        staxInProperties.setEnableSignatureConfirmationVerification(true);
+        WSS4JStaxInInterceptor inhandler = new WSS4JStaxInInterceptor(staxInProperties);
+        client.getInInterceptors().add(inhandler);
+
+        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/WSS4JInOutTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JInOutTest.java?rev=1467329&r1=1467328&r2=1467329&view=diff
==============================================================================
--- cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JInOutTest.java
(original)
+++ cxf/branches/wss4j2.0-port/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/WSS4JInOutTest.java
Fri Apr 12 16:03:35 2013
@@ -262,7 +262,6 @@ public class WSS4JInOutTest extends Abst
         Map<String, String> inProperties = new HashMap<String, String>();
         inProperties.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
         inProperties.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
-        inProperties.put(WSHandlerConstants.PASSWORD_TYPE_STRICT, "false");
         inProperties.put(
             WSHandlerConstants.PW_CALLBACK_CLASS, 
             "org.apache.cxf.ws.security.wss4j.TestPwdCallback"
@@ -272,16 +271,8 @@ public class WSS4JInOutTest extends Abst
         xpaths.add("//wsse:Security");
 
         //
-        // This should pass, as even though passwordType is set to digest, we are 
-        // overriding the default handler behaviour of requiring a strict password
-        // type
-        //
-        makeInvocation(outProperties, xpaths, inProperties);
-        
-        //
         // This should fail, as we are requiring a digest password type
         //
-        inProperties.put(WSHandlerConstants.PASSWORD_TYPE_STRICT, "true");
         try {
             makeInvocation(outProperties, xpaths, inProperties);
             fail("Failure expected on the wrong password type");



Mime
View raw message