You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2011/08/04 12:10:58 UTC

svn commit: r1153825 - in /cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml: JAXRSXmlSecTest.java server.xml

Author: sergeyb
Date: Thu Aug  4 10:10:57 2011
New Revision: 1153825

URL: http://svn.apache.org/viewvc?rev=1153825&view=rev
Log:
CXF-3661,CXF-3677: Adding encryption/sig test using shared encryption properties

Modified:
    cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java
    cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/server.xml

Modified: cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java?rev=1153825&r1=1153824&r2=1153825&view=diff
==============================================================================
--- cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java (original)
+++ cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java Thu Aug  4 10:10:57 2011
@@ -32,7 +32,6 @@ import org.apache.cxf.jaxrs.client.WebCl
 import org.apache.cxf.systest.jaxrs.security.Book;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.xml.security.encryption.XMLCipher;
-
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -123,14 +122,6 @@ public class JAXRSXmlSecTest extends Abs
     @Test
     public void testPostEncryptedSignedBook() throws Exception {
         String address = "https://localhost:" + PORT + "/xmlsec/bookstore/books";
-        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
-        bean.setAddress(address);
-        
-        SpringBusFactory bf = new SpringBusFactory();
-        URL busFile = JAXRSXmlSecTest.class.getResource("client.xml");
-        Bus springBus = bf.createBus(busFile.toString());
-        bean.setBus(springBus);
-
         Map<String, Object> properties = new HashMap<String, Object>();
         properties.put("ws-security.callback-handler", 
                        "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback");
@@ -140,6 +131,34 @@ public class JAXRSXmlSecTest extends Abs
         properties.put("ws-security.signature.username", "alice");
         properties.put("ws-security.signature.properties", 
                        "org/apache/cxf/systest/jaxrs/security/alice.properties");
+        doTestPostEncryptedSignedBook(address, properties);
+        
+    }
+    
+    @Test
+    //Encryption properties are shared by encryption and signature handlers
+    public void testPostEncryptedSignedBookSharedProps() throws Exception {
+        String address = "https://localhost:" + PORT + "/xmlsec2/bookstore/books";
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put("ws-security.callback-handler", 
+                       "org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback");
+        properties.put("ws-security.encryption.username", "bob");
+        properties.put("ws-security.encryption.properties", 
+                       "org/apache/cxf/systest/jaxrs/security/bob.properties");
+        doTestPostEncryptedSignedBook(address, properties);
+        
+    }
+    
+    public void doTestPostEncryptedSignedBook(String address, Map<String, Object> properties) 
+        throws Exception {
+        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
+        bean.setAddress(address);
+        
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = JAXRSXmlSecTest.class.getResource("client.xml");
+        Bus springBus = bf.createBus(busFile.toString());
+        bean.setBus(springBus);
+
         bean.setProperties(properties);
         bean.getOutInterceptors().add(new XmlSigOutInterceptor());
         XmlEncOutInterceptor encInterceptor = new XmlEncOutInterceptor();

Modified: cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/server.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/server.xml?rev=1153825&r1=1153824&r2=1153825&view=diff
==============================================================================
--- cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/server.xml (original)
+++ cxf/trunk/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/server.xml Thu Aug  4 10:10:57 2011
@@ -120,4 +120,23 @@ under the License.
      
     </jaxrs:server>
 
+    <!-- Encryption properties are shared by encryption and signature handlers -->     
+    <jaxrs:server 
+       address="https://localhost:${testutil.ports.jaxrs-xmlsec}/xmlsec2"> 
+       <jaxrs:serviceBeans>
+          <ref bean="serviceBean"/>
+       </jaxrs:serviceBeans>
+       <jaxrs:providers>
+          <ref bean="xmlEncHandler"/>
+          <ref bean="xmlSigHandler"/>
+       </jaxrs:providers> 
+       <jaxrs:properties>
+           <entry key="ws-security.callback-handler" 
+                  value="org.apache.cxf.systest.jaxrs.security.saml.KeystorePasswordCallback"/>
+           <entry key="ws-security.encryption.properties" 
+                  value="org/apache/cxf/systest/jaxrs/security/bob.properties"/>
+       </jaxrs:properties> 
+     
+    </jaxrs:server>
+
 </beans>