You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ve...@apache.org on 2010/10/10 22:17:42 UTC
svn commit: r1006349 - in
/cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security: ./
src/test/java/org/apache/cxf/systest/security/
src/test/resources/META-INF/wsdl/ src/test/resources/security_wss_jaxws/
src/test/resources/security_wss_...
Author: veithen
Date: Sun Oct 10 20:17:41 2010
New Revision: 1006349
URL: http://svn.apache.org/viewvc?rev=1006349&view=rev
Log:
Sandbox: added a systest to check WS-Security (Username) + Spring Security (authentication only) + JAX-WS.
Added:
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/java/org/apache/cxf/systest/security/WssJaxwsTest.java (with props)
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/META-INF/wsdl/calculator-no-security.wsdl
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/META-INF/wsdl/calculator-username.wsdl
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/WEB-INF/
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/WEB-INF/beans.xml (with props)
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/WEB-INF/web.xml (with props)
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/clients.xml (with props)
Modified:
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/pom.xml
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/META-INF/wsdl/calculator.wsdl
Modified: cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/pom.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/pom.xml?rev=1006349&r1=1006348&r2=1006349&view=diff
==============================================================================
--- cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/pom.xml (original)
+++ cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/pom.xml Sun Oct 10 20:17:41 2010
@@ -79,12 +79,26 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-ws-security</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-ws-policy</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
+ <scope>test</scope>
</dependency>
<!-- Required by in-memory user details service -->
Added: cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/java/org/apache/cxf/systest/security/WssJaxwsTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/java/org/apache/cxf/systest/security/WssJaxwsTest.java?rev=1006349&view=auto
==============================================================================
--- cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/java/org/apache/cxf/systest/security/WssJaxwsTest.java (added)
+++ cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/java/org/apache/cxf/systest/security/WssJaxwsTest.java Sun Oct 10 20:17:41 2010
@@ -0,0 +1,78 @@
+/**
+ * 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.
+ */
+package org.apache.cxf.systest.security;
+
+import java.util.Map;
+
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import org.apache.cxf.testutil.common.AbstractClientServerTestBase;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import test.calculator.Calculator;
+
+public class WssJaxwsTest extends AbstractClientServerTestBase {
+ public static class SpringServer extends AbstractSpringServer {
+ public SpringServer() {
+ super("/security_wss_jaxws");
+ }
+
+ public static void main(String args[]) {
+ try {
+ SpringServer s = new SpringServer();
+ s.start();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ System.exit(-1);
+ } finally {
+ System.out.println("done!");
+ }
+ }
+ }
+
+ private static ClassPathXmlApplicationContext clientAppContext;
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ assertTrue(launchServer(SpringServer.class));
+ clientAppContext = new ClassPathXmlApplicationContext("security_wss_jaxws/clients.xml");
+ }
+
+ private Calculator getClientProxy(String id, String path) {
+ Calculator service = (Calculator)clientAppContext.getBean(id);
+ Map<String,Object> rc = ((BindingProvider)service).getRequestContext();
+ rc.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:9080" + path);
+ return service;
+ }
+
+ @Test
+ public void testUsername() {
+ Calculator service = getClientProxy("username", "/username");
+ assertEquals(5, service.add(2, 3));
+ }
+
+ @Test(expected=SOAPFaultException.class)
+ public void testUsernameWrongPassword() {
+ Calculator service = getClientProxy("username-wrong-password", "/username");
+ service.add(2, 3);
+ }
+}
Propchange: cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/java/org/apache/cxf/systest/security/WssJaxwsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/META-INF/wsdl/calculator-no-security.wsdl
URL: http://svn.apache.org/viewvc/cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/META-INF/wsdl/calculator-no-security.wsdl?rev=1006349&view=auto
==============================================================================
--- cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/META-INF/wsdl/calculator-no-security.wsdl (added)
+++ cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/META-INF/wsdl/calculator-no-security.wsdl Sun Oct 10 20:17:41 2010
@@ -0,0 +1,31 @@
+<?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.
+-->
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ targetNamespace="urn:test:calculator:no-security"
+ xmlns:calc="urn:test:calculator"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:import location="calculator.wsdl" namespace="urn:test:calculator"/>
+ <wsdl:service name="CalculatorService">
+ <wsdl:port binding="calc:CalculatorSOAP" name="CalculatorSOAP">
+ <soap:address location="REPLACE_WITH_ACTUAL_URI"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Added: cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/META-INF/wsdl/calculator-username.wsdl
URL: http://svn.apache.org/viewvc/cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/META-INF/wsdl/calculator-username.wsdl?rev=1006349&view=auto
==============================================================================
--- cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/META-INF/wsdl/calculator-username.wsdl (added)
+++ cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/META-INF/wsdl/calculator-username.wsdl Sun Oct 10 20:17:41 2010
@@ -0,0 +1,44 @@
+<?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.
+-->
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ targetNamespace="urn:test:calculator:username"
+ xmlns:calc="urn:test:calculator"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:import location="calculator.wsdl" namespace="urn:test:calculator"/>
+ <wsdl:service name="CalculatorService">
+ <wsdl:port binding="calc:CalculatorSOAP" name="CalculatorSOAP">
+ <wsp:Policy xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SupportingTokens>
+ <wsp:Policy>
+ <sp:UsernameToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient"/>
+ </wsp:Policy>
+ </sp:SupportingTokens>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ <soap:address location="REPLACE_WITH_ACTUAL_URI"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Modified: cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/META-INF/wsdl/calculator.wsdl
URL: http://svn.apache.org/viewvc/cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/META-INF/wsdl/calculator.wsdl?rev=1006349&r1=1006348&r2=1006349&view=diff
==============================================================================
--- cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/META-INF/wsdl/calculator.wsdl (original)
+++ cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/META-INF/wsdl/calculator.wsdl Sun Oct 10 20:17:41 2010
@@ -65,9 +65,4 @@
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="CalculatorService">
- <wsdl:port binding="tns:CalculatorSOAP" name="CalculatorSOAP">
- <soap:address location="REPLACE_WITH_ACTUAL_URI"/>
- </wsdl:port>
- </wsdl:service>
</wsdl:definitions>
Added: cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/WEB-INF/beans.xml?rev=1006349&view=auto
==============================================================================
--- cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/WEB-INF/beans.xml (added)
+++ cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/WEB-INF/beans.xml Sun Oct 10 20:17:41 2010
@@ -0,0 +1,55 @@
+<?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:security="http://www.springframework.org/schema/security"
+ xmlns:ssec="http://cxf.apache.org/spring-security"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd
+ http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+ http://cxf.apache.org/spring-security https://svn.apache.org/repos/asf/cxf/sandbox/veithen/cxf-spring-security/cxf-spring-security/src/main/resources/schemas/spring-security.xsd"
+ default-autowire="byName">
+
+ <import resource="classpath:META-INF/cxf/cxf.xml"/>
+ <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
+ <import resource="classpath:META-INF/cxf/cxf-extension-ws-security.xml" />
+ <import resource="classpath:META-INF/cxf/cxf-extension-policy.xml" />
+ <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
+
+ <security:authentication-provider>
+ <security:user-service>
+ <security:user name="joe" password="password" authorities="ROLE_USER,ROLE_ADMIN"/>
+ <security:user name="bob" password="password" authorities="ROLE_USER"/>
+ </security:user-service>
+ </security:authentication-provider>
+
+ <jaxws:endpoint xmlns:p="urn:test:calculator:username"
+ implementor="org.apache.cxf.systest.security.CalculatorImpl"
+ wsdlLocation="META-INF/wsdl/calculator-username.wsdl"
+ serviceName="p:CalculatorService"
+ address="/username">
+ <jaxws:properties>
+ <entry key="ws-security.callback-handler">
+ <ssec:server-password-callback-handler logExceptions="true" nestExceptions="false"/>
+ </entry>
+ </jaxws:properties>
+ </jaxws:endpoint>
+</beans>
Propchange: cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/WEB-INF/beans.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/WEB-INF/web.xml?rev=1006349&view=auto
==============================================================================
--- cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/WEB-INF/web.xml (added)
+++ cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/WEB-INF/web.xml Sun Oct 10 20:17:41 2010
@@ -0,0 +1,40 @@
+<?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.
+-->
+<web-app version="2.4"
+ xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>WEB-INF/beans.xml</param-value>
+ </context-param>
+ <listener>
+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>CXFServlet</servlet-name>
+ <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>CXFServlet</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>
Propchange: cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/WEB-INF/web.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/clients.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/clients.xml?rev=1006349&view=auto
==============================================================================
--- cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/clients.xml (added)
+++ cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/clients.xml Sun Oct 10 20:17:41 2010
@@ -0,0 +1,53 @@
+<?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:jaxws="http://cxf.apache.org/jaxws"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
+
+ <import resource="classpath:META-INF/cxf/cxf.xml"/>
+ <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
+ <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
+ <import resource="classpath:META-INF/cxf/cxf-extension-ws-security.xml" />
+ <import resource="classpath:META-INF/cxf/cxf-extension-policy.xml" />
+
+ <jaxws:client id="username"
+ xmlns:p="urn:test:calculator:username"
+ serviceClass="test.calculator.Calculator"
+ serviceName="p:CalculatorService"
+ wsdlLocation="META-INF/wsdl/calculator-username.wsdl">
+ <jaxws:properties>
+ <entry key="ws-security.username" value="joe"/>
+ <entry key="ws-security.password" value="password"/>
+ </jaxws:properties>
+ </jaxws:client>
+
+ <jaxws:client id="username-wrong-password"
+ xmlns:p="urn:test:calculator:username"
+ serviceClass="test.calculator.Calculator"
+ serviceName="p:CalculatorService"
+ wsdlLocation="META-INF/wsdl/calculator-username.wsdl">
+ <jaxws:properties>
+ <entry key="ws-security.username" value="joe"/>
+ <entry key="ws-security.password" value="wrong"/>
+ </jaxws:properties>
+ </jaxws:client>
+</beans>
Propchange: cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_wss_jaxws/clients.xml
------------------------------------------------------------------------------
svn:eol-style = native