You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2010/01/23 07:07:24 UTC
svn commit: r902346 - in
/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test:
java/org/apache/servicemix/cxfbc/ws/security/
resources/org/apache/servicemix/cxfbc/ws/security/
Author: ffang
Date: Sat Jan 23 06:07:24 2010
New Revision: 902346
URL: http://svn.apache.org/viewvc?rev=902346&view=rev
Log:
[SMXCOMP-703]also add test to verify we can get the expected exception
Added:
servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas-dummy.xml
servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas-password-mismatch.xml
Modified:
servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/CxfBcSecurityJAASTest.java
servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/KeystorePasswordCallback.java
servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas.xml
servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/users.properties
servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/xbean-jaas.xml
Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/CxfBcSecurityJAASTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/CxfBcSecurityJAASTest.java?rev=902346&r1=902345&r2=902346&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/CxfBcSecurityJAASTest.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/CxfBcSecurityJAASTest.java Sat Jan 23 06:07:24 2010
@@ -81,8 +81,8 @@
assertEquals(ret, "Hello ffang");
}
- public void testAuthFailed() {
- LOG.info("test security");
+ public void testUserNotExist() {
+ LOG.info("test user not exist");
Bus bus = new SpringBusFactory().createBus(
"org/apache/servicemix/cxfbc/ws/security/client-jaas-dummy.xml");
BusFactory.setDefaultBus(bus);
@@ -107,6 +107,32 @@
}
}
+ public void testPasswordMismatch() {
+ LOG.info("test password not match");
+ Bus bus = new SpringBusFactory().createBus(
+ "org/apache/servicemix/cxfbc/ws/security/client-jaas-password-mismatch.xml");
+ BusFactory.setDefaultBus(bus);
+ LoggingInInterceptor in = new LoggingInInterceptor();
+ bus.getInInterceptors().add(in);
+ bus.getInFaultInterceptors().add(in);
+ LoggingOutInterceptor out = new LoggingOutInterceptor();
+ bus.getOutInterceptors().add(out);
+ bus.getOutFaultInterceptors().add(out);
+ final javax.xml.ws.Service svc = javax.xml.ws.Service.create(WSDL_LOC,
+ new javax.xml.namespace.QName(
+ "http://apache.org/hello_world_soap_http",
+ "SOAPServiceWSSecurity"));
+ final Greeter greeter = svc.getPort(new javax.xml.namespace.QName(
+ "http://apache.org/hello_world_soap_http",
+ "TimestampSignEncrypt"), Greeter.class);
+ try {
+ greeter.sayHi();
+ fail("should catch exception");
+ } catch (Exception e) {
+ assertEquals(e.getMessage(), "Password does not match");
+ }
+ }
+
@Override
protected AbstractXmlApplicationContext createBeanFactory() {
// load cxf se and bc from spring config file
Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/KeystorePasswordCallback.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/KeystorePasswordCallback.java?rev=902346&r1=902345&r2=902346&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/KeystorePasswordCallback.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/security/KeystorePasswordCallback.java Sat Jan 23 06:07:24 2010
@@ -35,6 +35,7 @@
passwords.put("alice", "password");
passwords.put("bob", "password");
passwords.put("dummy", "dummy");
+ passwords.put("joe", "dummypassword");
}
/**
Added: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas-dummy.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas-dummy.xml?rev=902346&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas-dummy.xml (added)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas-dummy.xml Sat Jan 23 06:07:24 2010
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+ ">
+
+ <jaxws:client name="{http://apache.org/hello_world_soap_http}TimestampSignEncrypt" createdFromAPI="true">
+ <jaxws:features>
+ <bean class="org.apache.cxf.feature.LoggingFeature"/>
+ </jaxws:features>
+ <jaxws:outInterceptors>
+ <bean class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor"/>
+ <ref bean="TimestampSignEncrypt_Request"/>
+ </jaxws:outInterceptors>
+ <jaxws:inInterceptors>
+ <ref bean="TimestampSignEncrypt_Response"/>
+ <bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"/>
+ </jaxws:inInterceptors>
+ </jaxws:client>
+
+ <!-- -->
+ <!-- This bean is an Out interceptor which will add a Timestamp, -->
+ <!-- sign the Timstamp and Body, and then encrypt the Timestamp -->
+ <!-- and Body. It uses 3DES as the symmetric key algorithm. -->
+ <!-- -->
+ <bean
+ class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"
+ id="TimestampSignEncrypt_Request">
+ <constructor-arg>
+ <map>
+ <entry key="action" value="UsernameToken"/>
+ <entry key="passwordType" value="PasswordText" />
+ <entry key="user" value="dummy"/>
+ <entry key="passwordCallbackClass" value="org.apache.servicemix.cxfbc.ws.security.KeystorePasswordCallback"/>
+ </map>
+ </constructor-arg>
+ </bean>
+
+ <!-- -->
+ <!-- This bean is an In interceptor which validated a signed, -->
+ <!-- encrypted resposne, and timestamped. -->
+ <!-- -->
+ <!-- -->
+ <bean
+ class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor"
+ id="TimestampSignEncrypt_Response">
+ <constructor-arg>
+ <map>
+ <entry key="action" value="Timestamp Signature Encrypt"/>
+ <entry key="signaturePropFile" value="org/apache/servicemix/cxfbc/ws/security/bob.properties"/>
+ <entry key="decryptionPropFile" value="org/apache/servicemix/cxfbc/ws/security/alice.properties"/>
+ <entry key="passwordCallbackClass" value="org.apache.servicemix.cxfbc.ws.security.KeystorePasswordCallback"/>
+ </map>
+ </constructor-arg>
+ </bean>
+
+</beans>
Added: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas-password-mismatch.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas-password-mismatch.xml?rev=902346&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas-password-mismatch.xml (added)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas-password-mismatch.xml Sat Jan 23 06:07:24 2010
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+ ">
+
+ <jaxws:client name="{http://apache.org/hello_world_soap_http}TimestampSignEncrypt" createdFromAPI="true">
+ <jaxws:features>
+ <bean class="org.apache.cxf.feature.LoggingFeature"/>
+ </jaxws:features>
+ <jaxws:outInterceptors>
+ <bean class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor"/>
+ <ref bean="TimestampSignEncrypt_Request"/>
+ </jaxws:outInterceptors>
+ <jaxws:inInterceptors>
+ <ref bean="TimestampSignEncrypt_Response"/>
+ <bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"/>
+ </jaxws:inInterceptors>
+ </jaxws:client>
+
+ <!-- -->
+ <!-- This bean is an Out interceptor which will add a Timestamp, -->
+ <!-- sign the Timstamp and Body, and then encrypt the Timestamp -->
+ <!-- and Body. It uses 3DES as the symmetric key algorithm. -->
+ <!-- -->
+ <bean
+ class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"
+ id="TimestampSignEncrypt_Request">
+ <constructor-arg>
+ <map>
+ <entry key="action" value="UsernameToken"/>
+ <entry key="passwordType" value="PasswordText" />
+ <entry key="user" value="joe"/>
+ <entry key="passwordCallbackClass" value="org.apache.servicemix.cxfbc.ws.security.KeystorePasswordCallback"/>
+ </map>
+ </constructor-arg>
+ </bean>
+
+ <!-- -->
+ <!-- This bean is an In interceptor which validated a signed, -->
+ <!-- encrypted resposne, and timestamped. -->
+ <!-- -->
+ <!-- -->
+ <bean
+ class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor"
+ id="TimestampSignEncrypt_Response">
+ <constructor-arg>
+ <map>
+ <entry key="action" value="Timestamp Signature Encrypt"/>
+ <entry key="signaturePropFile" value="org/apache/servicemix/cxfbc/ws/security/bob.properties"/>
+ <entry key="decryptionPropFile" value="org/apache/servicemix/cxfbc/ws/security/alice.properties"/>
+ <entry key="passwordCallbackClass" value="org.apache.servicemix.cxfbc.ws.security.KeystorePasswordCallback"/>
+ </map>
+ </constructor-arg>
+ </bean>
+
+</beans>
Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas.xml?rev=902346&r1=902345&r2=902346&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas.xml (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/client-jaas.xml Sat Jan 23 06:07:24 2010
@@ -39,11 +39,6 @@
</jaxws:inInterceptors>
</jaxws:client>
- <!-- -->
- <!-- This bean is an Out interceptor which will add a Timestamp, -->
- <!-- sign the Timstamp and Body, and then encrypt the Timestamp -->
- <!-- and Body. It uses 3DES as the symmetric key algorithm. -->
- <!-- -->
<bean
class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"
id="TimestampSignEncrypt_Request">
@@ -52,18 +47,7 @@
<entry key="action" value="UsernameToken"/>
<entry key="passwordType" value="PasswordText" />
<entry key="user" value="alice"/>
- <entry key="signaturePropFile" value="org/apache/servicemix/cxfbc/ws/security/alice.properties"/>
- <entry key="encryptionPropFile" value="org/apache/servicemix/cxfbc/ws/security/bob.properties"/>
- <entry key="encryptionUser" value="Bob"/>
- <entry key="signatureKeyIdentifier" value="DirectReference"/>
<entry key="passwordCallbackClass" value="org.apache.servicemix.cxfbc.ws.security.KeystorePasswordCallback"/>
- <entry key="signatureParts" value="{Element}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp;{Element}{http://schemas.xmlsoap.org/soap/envelope/}Body"/>
- <!-- -->
- <!-- Recommendation: signatures should be encrypted -->
- <!-- -->
- <entry key="encryptionParts" value="{Element}{http://www.w3.org/2000/09/xmldsig#}Signature;{Content}{http://schemas.xmlsoap.org/soap/envelope/}Body"/>
- <!-- <entry key="encryptionKeyTransportAlgorithm" value="RSA15"/> -->
- <entry key="encryptionSymAlgorithm" value="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/>
</map>
</constructor-arg>
</bean>
Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/users.properties
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/users.properties?rev=902346&r1=902345&r2=902346&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/users.properties (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/users.properties Sat Jan 23 06:07:24 2010
@@ -18,3 +18,4 @@
#
#
alice=password
+joe=password
Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/xbean-jaas.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/xbean-jaas.xml?rev=902346&r1=902345&r2=902346&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/xbean-jaas.xml (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/security/xbean-jaas.xml Sat Jan 23 06:07:24 2010
@@ -108,14 +108,8 @@
id="TimestampSignEncrypt_Request">
<constructor-arg>
<map>
- <!-- Use this action order for local clients -->
<entry key="action" value="UsernameToken"/>
<entry key="passwordType" value="PasswordText" />
- <!-- Use this action spec for WCF clients
- <entry key="action" value="Signature Encrypt Timestamp"/>
- -->
- <entry key="signaturePropFile" value="org/apache/servicemix/cxfbc/ws/security/alice.properties"/>
- <entry key="decryptionPropFile" value="org/apache/servicemix/cxfbc/ws/security/bob.properties"/>
<entry key="passwordCallbackClass" value="org.apache.servicemix.cxfbc.ws.security.KeystorePasswordCallback"/>
</map>
</constructor-arg>