You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by gm...@apache.org on 2011/12/01 15:04:58 UTC
svn commit: r1209091 - in
/cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security: ./
src/main/java/demo/jaxrs/client/ src/main/java/demo/jaxrs/servlet/
src/main/resources/ src/main/webapp/ src/main/webapp/WEB-INF/ webapp/
Author: gmazza
Date: Thu Dec 1 14:04:55 2011
New Revision: 1209091
URL: http://svn.apache.org/viewvc?rev=1209091&view=rev
Log:
Better Mavenized the spring_security sample.
Added:
cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/resources/
cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/resources/add_customer.xml
cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/resources/update_customer.xml
cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/webapp/
cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/webapp/WEB-INF/
cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/webapp/WEB-INF/beans.xml
cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/webapp/WEB-INF/web.xml
Removed:
cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/log4j.properties
cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/java/demo/jaxrs/client/add_customer.xml
cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/java/demo/jaxrs/client/update_customer.xml
cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/webapp/
Modified:
cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/pom.xml
cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/java/demo/jaxrs/client/Client.java
cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/java/demo/jaxrs/servlet/Server.java
Modified: cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/pom.xml?rev=1209091&r1=1209090&r2=1209091&view=diff
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/pom.xml (original)
+++ cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/pom.xml Thu Dec 1 14:04:55 2011
@@ -20,10 +20,11 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.cxf.samples</groupId>
- <name>JAX-RS Spring Security Demo</name>
- <description>JAX-RS Spring Security Demo</description>
<artifactId>jax_rs_spring_security</artifactId>
<version>2.5.1-SNAPSHOT</version>
+ <name>JAX-RS Spring Security Demo</name>
+ <description>JAX-RS Spring Security Demo</description>
+ <packaging>war</packaging>
<parent>
<groupId>org.apache.cxf.samples</groupId>
@@ -36,33 +37,7 @@
<aspectj.version>1.5.4</aspectj.version>
</properties>
<build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>copyxmlfiles</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <copy file="${basedir}/src/main/java/demo/jaxrs/client/add_customer.xml" todir="${basedir}/target/classes/demo/jaxrs/client" />
- <copy file="${basedir}/src/main/java/demo/jaxrs/client/update_customer.xml" todir="${basedir}/target/classes/demo/jaxrs/client" />
- </tasks>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
+ <finalName>JAXRSSpringSecurity</finalName>
</build>
<profiles>
<profile>
Modified: cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/java/demo/jaxrs/client/Client.java
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/java/demo/jaxrs/client/Client.java?rev=1209091&r1=1209090&r2=1209091&view=diff
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/java/demo/jaxrs/client/Client.java (original)
+++ cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/java/demo/jaxrs/client/Client.java Thu Dec 1 14:04:55 2011
@@ -83,7 +83,7 @@ public final class Client {
PostMethod post = new PostMethod("http://localhost:9002/customerservice/customers");
setMethodHeaders(post, name, password);
RequestEntity entity = new InputStreamRequestEntity(
- this.getClass().getResourceAsStream("add_customer.xml"));
+ this.getClass().getClassLoader().getResourceAsStream("add_customer.xml"));
post.setRequestEntity(entity);
handleHttpMethod(post);
@@ -96,7 +96,7 @@ public final class Client {
PutMethod put = new PutMethod("http://localhost:9002/customerservice/customers/123");
setMethodHeaders(put, name, password);
RequestEntity entity = new InputStreamRequestEntity(
- this.getClass().getResourceAsStream("update_customer.xml"));
+ this.getClass().getClassLoader().getResourceAsStream("update_customer.xml"));
put.setRequestEntity(entity);
handleHttpMethod(put);
Modified: cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/java/demo/jaxrs/servlet/Server.java
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/java/demo/jaxrs/servlet/Server.java?rev=1209091&r1=1209090&r2=1209091&view=diff
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/java/demo/jaxrs/servlet/Server.java (original)
+++ cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/java/demo/jaxrs/servlet/Server.java Thu Dec 1 14:04:55 2011
@@ -46,7 +46,7 @@ public class Server {
WebAppContext webappcontext = new WebAppContext();
webappcontext.setContextPath("/");
- webappcontext.setWar("webapp");
+ webappcontext.setWar("target/JAXRSSpringSecurity.war");
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] {webappcontext, new DefaultHandler()});
Added: cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/resources/add_customer.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/resources/add_customer.xml?rev=1209091&view=auto
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/resources/add_customer.xml (added)
+++ cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/resources/add_customer.xml Thu Dec 1 14:04:55 2011
@@ -0,0 +1,4 @@
+<Customer>
+ <name>Jack</name>
+</Customer>
+
Added: cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/resources/update_customer.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/resources/update_customer.xml?rev=1209091&view=auto
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/resources/update_customer.xml (added)
+++ cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/resources/update_customer.xml Thu Dec 1 14:04:55 2011
@@ -0,0 +1,5 @@
+<Customer>
+ <name>Mary</name>
+ <id>123</id>
+</Customer>
+
Added: cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/webapp/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/webapp/WEB-INF/beans.xml?rev=1209091&view=auto
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/webapp/WEB-INF/beans.xml (added)
+++ cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/webapp/WEB-INF/beans.xml Thu Dec 1 14:04:55 2011
@@ -0,0 +1,82 @@
+<?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:jaxrs="http://cxf.apache.org/jaxrs"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xmlns:security="http://www.springframework.org/schema/security"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans
+http://www.springframework.org/schema/beans/spring-beans.xsd
+http://www.springframework.org/schema/aop
+http://www.springframework.org/schema/aop/spring-aop.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">
+
+ <import resource="classpath:META-INF/cxf/cxf.xml" />
+ <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
+
+ <jaxrs:server id="bookservice" address="/">
+ <jaxrs:serviceBeans>
+ <ref bean="customerservice"/>
+ </jaxrs:serviceBeans>
+ <jaxrs:providers>
+ <bean class="demo.jaxrs.service.SecurityExceptionMapper"/>
+ </jaxrs:providers>
+ </jaxrs:server>
+
+ <bean id="customerservice" class="demo.jaxrs.service.CustomerServiceImpl"/>
+<!--
+ <bean id="customerservice" class="demo.jaxrs.service.CustomerServiceSecuredImpl"/>
+-->
+
+
+ <security:global-method-security secured-annotations="enabled">
+ <security:protect-pointcut
+ expression="execution(* demo.jaxrs.service.CustomerService.getCustomer(*))"
+ access="ROLE_CUSTOMER, ROLE_ADMIN"/>
+ <security:protect-pointcut
+ expression="execution(* demo.jaxrs.service.CustomerService.addCustomer(*))"
+ access="ROLE_ADMIN"/>
+ <security:protect-pointcut
+ expression="execution(* demo.jaxrs.service.CustomerService.updateCustomer(Long,demo.jaxrs.service.Customer))"
+ access="ROLE_ADMIN"/>
+ <security:protect-pointcut
+ expression="execution(* demo.jaxrs.service.CustomerService.deleteCustomer(*))"
+ access="ROLE_ADMIN"/>
+ <security:protect-pointcut
+ expression="execution(* demo.jaxrs.service.CustomerService.getOrder(*))"
+ access="ROLE_CUSTOMER, ROLE_ADMIN"/>
+ </security:global-method-security>
+
+ <security:http auto-config='true'>
+ <security:http-basic />
+ </security:http>
+
+ <security:authentication-provider>
+ <security:user-service>
+ <security:user name="bob" password="bobspassword" authorities="ROLE_CUSTOMER" />
+ <security:user name="fred" password="fredspassword" authorities="ROLE_CUSTOMER, ROLE_ADMIN" />
+ </security:user-service>
+ </security:authentication-provider>
+</beans>
+
Added: cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/webapp/WEB-INF/web.xml?rev=1209091&view=auto
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/webapp/WEB-INF/web.xml (added)
+++ cxf/trunk/distribution/src/main/release/samples/jax_rs/spring_security/src/main/webapp/WEB-INF/web.xml Thu Dec 1 14:04:55 2011
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ 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.5" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_2_5.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>
+
+ <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>
+