Author: veithen
Date: Fri Mar 5 21:18:05 2010
New Revision: 919622
URL: http://svn.apache.org/viewvc?rev=919622&view=rev
Log:
Added a systest for JAX-RS oneway methods with servlet filter based HTTP
authentication.
Added:
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/java/org/apache/cxf/systest/security/OnewayResource.java
(with props)
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/java/org/apache/cxf/systest/security/SpringHttpAuthJaxrsOnewayTest.java
(with props)
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_spring_http_auth_jaxrs_oneway/
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_spring_http_auth_jaxrs_oneway/WEB-INF/
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_spring_http_auth_jaxrs_oneway/WEB-INF/beans.xml
(with props)
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_spring_http_auth_jaxrs_oneway/WEB-INF/web.xml
(with props)
Modified:
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/pom.xml
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=919622&r1=919621&r2=919622&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
Fri Mar 5 21:18:05 2010
@@ -65,6 +65,13 @@
<version>${project.version}</version>
<!-- scope>test</scope -->
</dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
<!-- Required by in-memory user details service -->
<dependency>
<groupId>org.springframework</groupId>
Added:
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/java/org/apache/cxf/systest/security/OnewayResource.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/OnewayResource.java?rev=919622&view=auto
==============================================================================
---
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/java/org/apache/cxf/systest/security/OnewayResource.java
(added)
+++
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/java/org/apache/cxf/systest/security/OnewayResource.java
Fri Mar 5 21:18:05 2010
@@ -0,0 +1,57 @@
+/**
+ * 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.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.apache.cxf.jaxrs.ext.Oneway;
+import org.springframework.security.Authentication;
+import org.springframework.security.context.SecurityContextHolder;
+
+...@path("/")
+public class OnewayResource {
+ private BlockingQueue<String> lastCallerQueue = new
LinkedBlockingQueue<String>();
+
+ @PUT
+ @Consumes("text/plain")
+ @Oneway
+ public void test(String arg) {
+ Authentication authentication =
SecurityContextHolder.getContext().getAuthentication();
+ lastCallerQueue.add(authentication == null ? null :
authentication.getName());
+ }
+
+ @GET
+ @Produces("text/plain")
+ public String getLastCaller() {
+ try {
+ return lastCallerQueue.poll(60, TimeUnit.SECONDS);
+ } catch (InterruptedException ex) {
+ Thread.currentThread().interrupt();
+ return null;
+ }
+ }
+}
Propchange:
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/java/org/apache/cxf/systest/security/OnewayResource.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/java/org/apache/cxf/systest/security/SpringHttpAuthJaxrsOnewayTest.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/SpringHttpAuthJaxrsOnewayTest.java?rev=919622&view=auto
==============================================================================
---
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/java/org/apache/cxf/systest/security/SpringHttpAuthJaxrsOnewayTest.java
(added)
+++
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/java/org/apache/cxf/systest/security/SpringHttpAuthJaxrsOnewayTest.java
Fri Mar 5 21:18:05 2010
@@ -0,0 +1,56 @@
+/**
+ * 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 org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.testutil.common.AbstractClientServerTestBase;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class SpringHttpAuthJaxrsOnewayTest extends
AbstractClientServerTestBase {
+ public static class SpringServer extends AbstractSpringServer {
+ public SpringServer() {
+ super("/security_spring_http_auth_jaxrs_oneway");
+ }
+
+ 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!");
+ }
+ }
+ }
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ assertTrue(launchServer(SpringServer.class));
+ }
+
+ @Test
+ public void test() {
+ WebClient client = WebClient.create("http://localhost:9080/oneway",
"joe", "password", null);
+ client.header("Content-Type", "text/plain").put("test");
+ assertEquals("joe", client.accept("text/plain").get(String.class));
+ }
+}
Propchange:
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/java/org/apache/cxf/systest/security/SpringHttpAuthJaxrsOnewayTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_spring_http_auth_jaxrs_oneway/WEB-INF/beans.xml
URL:
http://svn.apache.org/viewvc/cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_spring_http_auth_jaxrs_oneway/WEB-INF/beans.xml?rev=919622&view=auto
==============================================================================
---
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_spring_http_auth_jaxrs_oneway/WEB-INF/beans.xml
(added)
+++
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_spring_http_auth_jaxrs_oneway/WEB-INF/beans.xml
Fri Mar 5 21:18:05 2010
@@ -0,0 +1,57 @@
+<?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:security="http://www.springframework.org/schema/security"
+ xmlns:ssec="http://cxf.apache.org/spring-security"
+ xmlns:jaxrs="http://cxf.apache.org/jaxrs"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.4.xsd
+ http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.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">
+
+ <import resource="classpath:META-INF/cxf/cxf.xml"/>
+ <import resource="classpath*:META-INF/cxf/cxf-*.xml"/>
+ <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
+
+ <security:http>
+ <security:intercept-url pattern="/**" access="ROLE_USER"/>
+ <security:http-basic/>
+ </security:http>
+
+ <security:authentication-provider>
+ <security:user-service>
+ <security:user name="joe" password="password"
authorities="ROLE_USER"/>
+ <security:user name="bob" password="password"
authorities="ROLE_USER"/>
+ </security:user-service>
+ </security:authentication-provider>
+
+ <jaxrs:server address="/oneway">
+ <jaxrs:serviceBeans>
+ <bean class="org.apache.cxf.systest.security.OnewayResource"/>
+ </jaxrs:serviceBeans>
+ <jaxrs:inInterceptors>
+ <ssec:spring-security-context-consumer-interceptor/>
+ </jaxrs:inInterceptors>
+ <jaxrs:features>
+ <ssec:spring-security-context-feature/>
+ </jaxrs:features>
+ </jaxrs:server>
+</beans>
Propchange:
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_spring_http_auth_jaxrs_oneway/WEB-INF/beans.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_spring_http_auth_jaxrs_oneway/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_spring_http_auth_jaxrs_oneway/WEB-INF/web.xml?rev=919622&view=auto
==============================================================================
---
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_spring_http_auth_jaxrs_oneway/WEB-INF/web.xml
(added)
+++
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_spring_http_auth_jaxrs_oneway/WEB-INF/web.xml
Fri Mar 5 21:18:05 2010
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE web-app
+ PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<!--
+ 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.
+-->
+<!-- START SNIPPET: webxml -->
+<web-app>
+ <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>
+
+ <filter>
+ <filter-name>springSecurityFilterChain</filter-name>
+
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>springSecurityFilterChain</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <servlet>
+ <servlet-name>CXFServlet</servlet-name>
+ <display-name>CXF Servlet</display-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>
+<!-- END SNIPPET: webxml -->
Propchange:
cxf/sandbox/veithen/cxf-spring-security/cxf-systests-spring-security/src/test/resources/security_spring_http_auth_jaxrs_oneway/WEB-INF/web.xml
------------------------------------------------------------------------------
svn:eol-style = native