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 2008/12/09 18:04:41 UTC

svn commit: r724780 - in /cxf/trunk: common/common/src/main/java/org/apache/cxf/common/util/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/main/java/org/apache...

Author: sergeyb
Date: Tue Dec  9 09:04:39 2008
New Revision: 724780

URL: http://svn.apache.org/viewvc?rev=724780&view=rev
Log:
JAXRS : spring security system tests

Added:
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AbstractSpringServer.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/AbstractSpringSecurityTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/BookServerSecuritySpringClass.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/BookServerSecuritySpringInterface.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/BookServerSecuritySpringNoAnnotations.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityClassTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityInterfaceTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityNoAnnotationsTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookInterface.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStore.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoAnnotations.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoInterface.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecurityExceptionMapper.java
    cxf/trunk/systests/src/test/resources/jaxrs_security/
    cxf/trunk/systests/src/test/resources/jaxrs_security_cglib/
    cxf/trunk/systests/src/test/resources/jaxrs_security_no_annotations/
    cxf/trunk/systests/src/test/resources/log4j.properties
Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SpringAopClassHelper.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
    cxf/trunk/systests/pom.xml
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookInterface.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SpringAopClassHelper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SpringAopClassHelper.java?rev=724780&r1=724779&r2=724780&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SpringAopClassHelper.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SpringAopClassHelper.java Tue Dec  9 09:04:39 2008
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.common.util;
 
+import org.springframework.aop.framework.Advised;
 import org.springframework.aop.support.AopUtils;
 
 /**
@@ -27,12 +28,23 @@
 class SpringAopClassHelper extends ClassHelper {
     SpringAopClassHelper() throws Exception {
         Class.forName("org.springframework.aop.support.AopUtils");
+        Class.forName("org.springframework.aop.framework.Advised");
     }
     
     protected Class getRealClassInternal(Object o) {
         if (AopUtils.isAopProxy(o)) {
-            return AopUtils.getTargetClass(o);
+            Advised advised = (Advised)o;
+            if (advised == null) {
+                return AopUtils.getTargetClass(o);
+            }
+            try {
+                return getRealClassInternal(advised.getTargetSource().getTarget());
+            } catch (Exception ex) {
+                // ignore
+            }
+            
         } 
         return o.getClass();
     }
+    
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java?rev=724780&r1=724779&r2=724780&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java Tue Dec  9 09:04:39 2008
@@ -136,13 +136,16 @@
     public void setResourceClassesFromBeans(List<Object> beans) {
         for (Object bean : beans) {
             
+            Class<?> realClass = ClassHelper.getRealClass(bean);
+            
             ClassResourceInfo classResourceInfo = 
-                createClassResourceInfo(bean.getClass(), 
-                                        ClassHelper.getRealClass(bean),
-                                            true);
-            classResourceInfos.add(classResourceInfo);
-            classResourceInfo.setResourceProvider(
-                               new SingletonResourceProvider(bean));
+                createClassResourceInfo(bean.getClass(), realClass, true);
+            if (classResourceInfo != null) {
+                classResourceInfos.add(classResourceInfo);
+                
+                classResourceInfo.setResourceProvider(
+                                   new SingletonResourceProvider(bean));
+            }
         }
     }
     

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=724780&r1=724779&r2=724780&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java Tue Dec  9 09:04:39 2008
@@ -27,6 +27,7 @@
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
@@ -166,6 +167,9 @@
     @SuppressWarnings("unchecked")
     private static <T extends Throwable> ExceptionMapper<T> doCreateExceptionMapper(
         List<ProviderInfo<ExceptionMapper>> mappers, Class<?> exceptionType, Message m) {
+        
+        List<ExceptionMapper<T>> candidates = new LinkedList<ExceptionMapper<T>>();
+        
         for (ProviderInfo<ExceptionMapper> em : mappers) {
             Type[] types = em.getProvider().getClass().getGenericInterfaces();
             for (Type t : types) {
@@ -176,13 +180,17 @@
                         if (((Class<?>)args[i]).isAssignableFrom(exceptionType)) {
                             InjectionUtils.injectContextFields(em.getProvider(), em, m);
                             InjectionUtils.injectContextMethods(em.getProvider(), em, m);
-                            return em.getProvider();
+                            candidates.add(em.getProvider());
                         }
                     }
                 }
             }
         }
-        return null;
+        if (candidates.size() == 0) {
+            return null;
+        }
+        Collections.sort(candidates, new ExceptionMapperComparator());
+        return candidates.get(0);
     }
     
     public <T> MessageBodyReader<T> createMessageBodyReader(Class<T> bodyType,
@@ -542,4 +550,26 @@
             }
         }
     }
+    
+    private static class ExceptionMapperComparator implements 
+        Comparator<ExceptionMapper<? extends Throwable>> {
+
+        public int compare(ExceptionMapper<? extends Throwable> em1, 
+                           ExceptionMapper<? extends Throwable> em2) {
+            Type[] types1 = em1.getClass().getGenericInterfaces();
+            Type[] types2 = em2.getClass().getGenericInterfaces();
+            
+            Class<?> realClass1 = InjectionUtils.getActualType(types1[0]);
+            Class<?> realClass2 = InjectionUtils.getActualType(types2[0]);
+            if (realClass1 == realClass2) {
+                return 0;
+            }
+            if (realClass1.isAssignableFrom(realClass2)) {
+                // subclass should go first
+                return 1;
+            }
+            return -1;
+        }
+        
+    }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=724780&r1=724779&r2=724780&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java Tue Dec  9 09:04:39 2008
@@ -81,7 +81,6 @@
 
     public static Method checkProxy(Method methodToInvoke, Object resourceObject) {
         if (Proxy.class.isInstance(resourceObject)) {
-            
             for (Class<?> c : resourceObject.getClass().getInterfaces()) {
                 try {
                     Method m = c.getMethod(
@@ -93,7 +92,6 @@
                     //ignore
                 }
             }
-            
         }
         return methodToInvoke; 
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java?rev=724780&r1=724779&r2=724780&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java Tue Dec  9 09:04:39 2008
@@ -35,6 +35,7 @@
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
 import javax.ws.rs.ext.ContextResolver;
 import javax.ws.rs.ext.ExceptionMapper;
 import javax.ws.rs.ext.MessageBodyReader;
@@ -71,18 +72,45 @@
     }
     
     @Test
-    public void testExceptionMappers() throws Exception {
+    public void testDefaultUserExceptionMappers() throws Exception {
         ProviderFactory pf = ProviderFactory.getInstance();
         ExceptionMapper<?> mapper = 
             pf.createExceptionMapper(WebApplicationException.class, new MessageImpl());
         assertNotNull(mapper);
-        WebApplicationExceptionMapper m = new WebApplicationExceptionMapper(); 
-        pf.registerUserProvider(m);
+        WebApplicationExceptionMapper wm = new WebApplicationExceptionMapper(); 
+        pf.registerUserProvider(wm);
         ExceptionMapper<?> mapper2 = 
             pf.createExceptionMapper(WebApplicationException.class, new MessageImpl());
         assertNotSame(mapper, mapper2);
-        assertSame(m, mapper2);
+        assertSame(wm, mapper2);
+    }
+    
+    @Test
+    public void testExceptionMappersHierarchy1() throws Exception {
+        ProviderFactory pf = ProviderFactory.getInstance();
+        WebApplicationExceptionMapper wm = new WebApplicationExceptionMapper(); 
+        pf.registerUserProvider(wm);
+        assertSame(wm, pf.createExceptionMapper(WebApplicationException.class, new MessageImpl()));
+        assertNull(pf.createExceptionMapper(RuntimeException.class, new MessageImpl()));
+        TestRuntimeExceptionMapper rm = new TestRuntimeExceptionMapper(); 
+        pf.registerUserProvider(rm);
+        assertSame(wm, pf.createExceptionMapper(WebApplicationException.class, new MessageImpl()));
+        assertSame(rm, pf.createExceptionMapper(RuntimeException.class, new MessageImpl()));
+    }
+    
+    @Test
+    public void testExceptionMappersHierarchy2() throws Exception {
+        ProviderFactory pf = ProviderFactory.getInstance();
         
+        TestRuntimeExceptionMapper rm = new TestRuntimeExceptionMapper(); 
+        pf.registerUserProvider(rm);
+        assertSame(rm, pf.createExceptionMapper(WebApplicationException.class, new MessageImpl()));
+        assertSame(rm, pf.createExceptionMapper(RuntimeException.class, new MessageImpl()));
+        
+        WebApplicationExceptionMapper wm = new WebApplicationExceptionMapper(); 
+        pf.registerUserProvider(wm);
+        assertSame(wm, pf.createExceptionMapper(WebApplicationException.class, new MessageImpl()));
+        assertSame(rm, pf.createExceptionMapper(RuntimeException.class, new MessageImpl()));
     }
     
     @Test
@@ -362,4 +390,13 @@
         assertNotNull("schema can not be read from classpath", s);
     }
     
+    private static class TestRuntimeExceptionMapper implements ExceptionMapper<RuntimeException> {
+
+        public Response toResponse(RuntimeException exception) {
+            // TODO Auto-generated method stub
+            return null;
+        }
+        
+    }
+    
 }

Modified: cxf/trunk/systests/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/pom.xml?rev=724780&r1=724779&r2=724780&view=diff
==============================================================================
--- cxf/trunk/systests/pom.xml (original)
+++ cxf/trunk/systests/pom.xml Tue Dec  9 09:04:39 2008
@@ -332,6 +332,63 @@
             <version>${spring.version}</version>
         </dependency>
         <dependency>
+           <groupId>org.springframework.security</groupId>
+           <artifactId>spring-security-core-tiger</artifactId>
+           <version>2.0.4</version>
+           <scope>test</scope> 
+           <exclusions>
+             <exclusion>
+              <groupId>org.springframework</groupId>
+              <artifactId>spring-core</artifactId>
+             </exclusion>
+             <exclusion>
+               <groupId>org.springframework</groupId>
+               <artifactId>spring-dao</artifactId>
+             </exclusion>
+             <exclusion>
+               <groupId>org.springframework</groupId>
+               <artifactId>spring-jdbc</artifactId>
+             </exclusion>
+             <exclusion>
+               <groupId>org.springframework</groupId>
+               <artifactId>spring-remoting</artifactId>
+             </exclusion> 
+             <exclusion>
+              <groupId>org.springframework</groupId>
+              <artifactId>spring-support</artifactId>
+             </exclusion>
+           </exclusions>
+        </dependency> 
+        
+        <dependency>
+           <groupId>org.springframework.security</groupId>
+           <artifactId>spring-security-acl</artifactId>
+           <version>2.0.4</version>
+           <scope>test</scope> 
+           <exclusions>
+             <exclusion>
+              <groupId>org.springframework</groupId>
+              <artifactId>spring-core</artifactId>
+             </exclusion>
+             <exclusion>
+               <groupId>org.springframework</groupId>
+               <artifactId>spring-dao</artifactId>
+             </exclusion>
+             <exclusion>
+               <groupId>org.springframework</groupId>
+               <artifactId>spring-jdbc</artifactId>
+             </exclusion>
+             <exclusion>
+               <groupId>org.springframework</groupId>
+               <artifactId>spring-remoting</artifactId>
+             </exclusion> 
+             <exclusion>
+              <groupId>org.springframework</groupId>
+              <artifactId>spring-support</artifactId>
+             </exclusion>
+           </exclusions>
+        </dependency>  
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AbstractSpringServer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AbstractSpringServer.java?rev=724780&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AbstractSpringServer.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AbstractSpringServer.java Tue Dec  9 09:04:39 2008
@@ -0,0 +1,95 @@
+/**
+ * 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.jaxrs;
+
+import java.net.URISyntaxException;
+
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.handler.DefaultHandler;
+import org.mortbay.jetty.handler.HandlerCollection;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.mortbay.jetty.webapp.WebAppContext;
+
+public abstract class AbstractSpringServer extends AbstractBusTestServerBase {
+
+    private org.mortbay.jetty.Server server;
+    private String resourcePath;
+    private String contextPath;
+    private int port;
+    
+    protected AbstractSpringServer(String path) {
+        this(path, "/", 9080);
+    }
+    
+    protected AbstractSpringServer(String path, int portNumber) {
+        this(path, "/", portNumber);
+    }
+    
+    protected AbstractSpringServer(String path, String cPath, int portNumber) {
+        resourcePath = path;
+        contextPath = "/";
+        port = portNumber;
+    }
+    
+    protected void run() {
+        System.out.println("Starting Server");
+
+        server = new org.mortbay.jetty.Server();
+
+        SelectChannelConnector connector = new SelectChannelConnector();
+        connector.setPort(port);
+        server.setConnectors(new Connector[] {connector});
+
+        WebAppContext webappcontext = new WebAppContext();
+        webappcontext.setContextPath(contextPath);
+
+        String warPath = null;
+        try {
+            warPath = getClass().getResource(resourcePath).toURI().getPath();
+        } catch (URISyntaxException e1) {
+            e1.printStackTrace();
+        }
+        
+        webappcontext.setWar(warPath);
+
+        HandlerCollection handlers = new HandlerCollection();
+        handlers.setHandlers(new Handler[] {webappcontext, new DefaultHandler()});
+
+        server.setHandler(handlers);
+        try {
+            server.start();
+                       
+        } catch (Exception e) {
+            e.printStackTrace();
+        }     
+    }
+    
+    public void tearDown() throws Exception {
+        super.tearDown();
+        if (server != null) {
+            server.stop();
+            server.destroy();
+            server = null;
+        }
+    }
+}

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookInterface.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookInterface.java?rev=724780&r1=724779&r2=724780&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookInterface.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookInterface.java Tue Dec  9 09:04:39 2008
@@ -30,4 +30,16 @@
     @Path("/thosebooks/{bookId}/")
     @Produces("application/xml")
     Book getThatBook(@PathParam("bookId") Long id) throws BookNotFoundFault;
+    
+    
+    @GET
+    @Path("/thosebooks/{bookId}/{id}")
+    @Produces("application/xml")
+    Book getThatBook(@PathParam("bookId") Long id, @PathParam("id") String s) throws BookNotFoundFault;
+    
+    @GET
+    @Path("/thosebooks")
+    @Produces("application/xml")
+    Book getThatBook() throws BookNotFoundFault;
+    
 }

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java?rev=724780&r1=724779&r2=724780&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreWithInterface.java Tue Dec  9 09:04:39 2008
@@ -47,6 +47,12 @@
         books.put(book.getId(), book);
     }
     
+    public Book getThatBook(Long id, String s) throws BookNotFoundFault {
+        if (!id.toString().equals(s)) {
+            throw new RuntimeException();
+        }
+        return doGetBook(id);
+    }
     
     public Book getThatBook(Long id) throws BookNotFoundFault {
         return doGetBook(id);
@@ -64,4 +70,8 @@
         }
     }
 
+    public Book getThatBook() throws BookNotFoundFault {
+        return books.get(123L);
+    }
+
 }

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java?rev=724780&r1=724779&r2=724780&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java Tue Dec  9 09:04:39 2008
@@ -54,6 +54,38 @@
     }
     
     @Test
+    public void testGetThatBookOverloaded() throws Exception {
+        String endpointAddress =
+            "http://localhost:9080/bookstorestorage/thosebooks/123/123"; 
+        URL url = new URL(endpointAddress);
+        URLConnection connect = url.openConnection();
+        connect.addRequestProperty("Accept", "application/xml");
+        InputStream in = connect.getInputStream();           
+
+        InputStream expected = getClass()
+            .getResourceAsStream("resources/expected_get_book123.txt");
+
+        //System.out.println("---" + getStringFromInputStream(in));
+        assertEquals(getStringFromInputStream(expected), getStringFromInputStream(in)); 
+    }
+    
+    @Test
+    public void testGetThatBookOverloaded2() throws Exception {
+        String endpointAddress =
+            "http://localhost:9080/bookstorestorage/thosebooks"; 
+        URL url = new URL(endpointAddress);
+        URLConnection connect = url.openConnection();
+        connect.addRequestProperty("Accept", "application/xml");
+        InputStream in = connect.getInputStream();           
+
+        InputStream expected = getClass()
+            .getResourceAsStream("resources/expected_get_book123.txt");
+
+        //System.out.println("---" + getStringFromInputStream(in));
+        assertEquals(getStringFromInputStream(expected), getStringFromInputStream(in)); 
+    }
+    
+    @Test
     public void testGetBook123() throws Exception {
         String endpointAddress =
             "http://localhost:9080/bookstore/books/123"; 

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/AbstractSpringSecurityTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/AbstractSpringSecurityTest.java?rev=724780&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/AbstractSpringSecurityTest.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/AbstractSpringSecurityTest.java Tue Dec  9 09:04:39 2008
@@ -0,0 +1,71 @@
+/**
+ * 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.jaxrs.security;
+
+import java.io.InputStream;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.cxf.common.util.Base64Utility;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+
+public abstract class AbstractSpringSecurityTest extends AbstractBusClientServerTestBase {
+
+    private String getStringFromInputStream(InputStream in) throws Exception {        
+        CachedOutputStream bos = new CachedOutputStream();
+        IOUtils.copy(in, bos);
+        in.close();
+        bos.close();
+        //System.out.println(bos.getOut().toString());        
+        return bos.getOut().toString();        
+    }
+    
+    private String base64Encode(String value) {
+        return Base64Utility.encode(value.getBytes());
+    }
+    
+    protected void getBook(String endpointAddress, String user, String password, 
+                         int expectedStatus) 
+        throws Exception {
+        
+        GetMethod get = new GetMethod(endpointAddress);
+        get.setRequestHeader("Accept", "application/xml");
+        get.setRequestHeader("Authorization", 
+                             "Basic " + base64Encode(user + ":" + password));
+        HttpClient httpClient = new HttpClient();
+        try {
+            int result = httpClient.executeMethod(get);
+            assertEquals(expectedStatus, result);
+            if (expectedStatus == 200) {
+                String content = getStringFromInputStream(get.getResponseBodyAsStream());
+                String resource = "/org/apache/cxf/systest/jaxrs/resources/expected_get_book123.txt";
+                InputStream expected = getClass().getResourceAsStream(resource);
+                assertEquals("Expected value is wrong", 
+                             getStringFromInputStream(expected), content);
+            }
+        } finally {
+            get.releaseConnection();
+        }
+        
+    }
+   
+}

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/BookServerSecuritySpringClass.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/BookServerSecuritySpringClass.java?rev=724780&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/BookServerSecuritySpringClass.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/BookServerSecuritySpringClass.java Tue Dec  9 09:04:39 2008
@@ -0,0 +1,44 @@
+/**
+ * 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.jaxrs.security;
+
+import org.apache.cxf.systest.jaxrs.AbstractSpringServer;
+
+
+
+public class BookServerSecuritySpringClass extends AbstractSpringServer {
+
+    public BookServerSecuritySpringClass() {
+        super("/jaxrs_security");
+    }
+    
+    public static void main(String args[]) {
+        try {
+            BookServerSecuritySpringClass s = new BookServerSecuritySpringClass();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally {
+            System.out.println("done!");
+        }
+    }
+
+}

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/BookServerSecuritySpringInterface.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/BookServerSecuritySpringInterface.java?rev=724780&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/BookServerSecuritySpringInterface.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/BookServerSecuritySpringInterface.java Tue Dec  9 09:04:39 2008
@@ -0,0 +1,43 @@
+/**
+ * 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.jaxrs.security;
+
+import org.apache.cxf.systest.jaxrs.AbstractSpringServer;
+
+
+public class BookServerSecuritySpringInterface extends AbstractSpringServer {
+
+    public BookServerSecuritySpringInterface() {
+        super("/jaxrs_security_cglib");
+    }    
+    
+    public static void main(String args[]) {
+        try {
+            BookServerSecuritySpringInterface s = new BookServerSecuritySpringInterface();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally {
+            System.out.println("done!");
+        }
+    }
+
+}

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/BookServerSecuritySpringNoAnnotations.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/BookServerSecuritySpringNoAnnotations.java?rev=724780&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/BookServerSecuritySpringNoAnnotations.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/BookServerSecuritySpringNoAnnotations.java Tue Dec  9 09:04:39 2008
@@ -0,0 +1,44 @@
+/**
+ * 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.jaxrs.security;
+
+import org.apache.cxf.systest.jaxrs.AbstractSpringServer;
+
+
+
+public class BookServerSecuritySpringNoAnnotations extends AbstractSpringServer {
+
+    public BookServerSecuritySpringNoAnnotations() {
+        super("/jaxrs_security_no_annotations");
+    }
+    
+    public static void main(String args[]) {
+        try {
+            BookServerSecuritySpringNoAnnotations s = new BookServerSecuritySpringNoAnnotations();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally {
+            System.out.println("done!");
+        }
+    }
+
+}

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityClassTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityClassTest.java?rev=724780&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityClassTest.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityClassTest.java Tue Dec  9 09:04:39 2008
@@ -0,0 +1,66 @@
+/**
+ * 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.jaxrs.security;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JAXRSSpringSecurityClassTest extends AbstractSpringSecurityTest {
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue("server did not launch correctly", 
+                   launchServer(BookServerSecuritySpringClass.class));
+    }
+    
+    @Test
+    public void testFailedAuthentication() throws Exception {
+        String endpointAddress =
+            "http://localhost:9080/bookstorestorage/thosebooks/123"; 
+        getBook(endpointAddress, "foo", "ba", 401);
+    }
+    
+    @Test
+    public void testGetBookUserAdmin() throws Exception {
+        String endpointAddress =
+            "http://localhost:9080/bookstorestorage/thosebooks/123"; 
+        getBook(endpointAddress, "foo", "bar", 200);
+        getBook(endpointAddress, "bob", "bobspassword", 200);
+    }
+    
+    
+    @Test
+    public void testGetBookUser() throws Exception {
+        String endpointAddress =
+            "http://localhost:9080/bookstorestorage/thosebooks/123/123"; 
+        getBook(endpointAddress, "foo", "bar", 200);
+        getBook(endpointAddress, "bob", "bobspassword", 200);
+    }
+    
+    @Test
+    public void testGetBookAdmin() throws Exception {
+        String endpointAddress =
+            "http://localhost:9080/bookstorestorage/thosebooks"; 
+        getBook(endpointAddress, "foo", "bar", 200); 
+        getBook(endpointAddress, "bob", "bobspassword", 403);
+    }
+    
+      
+}

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityInterfaceTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityInterfaceTest.java?rev=724780&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityInterfaceTest.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityInterfaceTest.java Tue Dec  9 09:04:39 2008
@@ -0,0 +1,65 @@
+/**
+ * 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.jaxrs.security;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JAXRSSpringSecurityInterfaceTest extends AbstractSpringSecurityTest {
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue("server did not launch correctly", 
+                   launchServer(BookServerSecuritySpringInterface.class));
+    }
+    
+    @Test
+    public void testFailedAuthentication() throws Exception {
+        String endpointAddress =
+            "http://localhost:9080/bookstorestorage/thosebooks/123"; 
+        getBook(endpointAddress, "foo", "ba", 401);
+    }
+    
+    @Test
+    public void testGetBookUserAdmin() throws Exception {
+        String endpointAddress =
+            "http://localhost:9080/bookstorestorage/thosebooks/123"; 
+        getBook(endpointAddress, "foo", "bar", 200);
+        getBook(endpointAddress, "bob", "bobspassword", 200);
+    }
+    
+    @Test
+    public void testGetBookUser() throws Exception {
+        String endpointAddress =
+            "http://localhost:9080/bookstorestorage/thosebooks/123/123"; 
+        getBook(endpointAddress, "foo", "bar", 200);
+        getBook(endpointAddress, "bob", "bobspassword", 200);
+    }
+    
+    @Test
+    public void testGetBookAdmin() throws Exception {
+        String endpointAddress =
+            "http://localhost:9080/bookstorestorage/thosebooks"; 
+        getBook(endpointAddress, "foo", "bar", 200); 
+        getBook(endpointAddress, "bob", "bobspassword", 403);
+    }
+    
+       
+}

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityNoAnnotationsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityNoAnnotationsTest.java?rev=724780&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityNoAnnotationsTest.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityNoAnnotationsTest.java Tue Dec  9 09:04:39 2008
@@ -0,0 +1,66 @@
+/**
+ * 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.jaxrs.security;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JAXRSSpringSecurityNoAnnotationsTest extends AbstractSpringSecurityTest {
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue("server did not launch correctly", 
+                   launchServer(BookServerSecuritySpringNoAnnotations.class));
+    }
+    
+    @Test
+    public void testFailedAuthentication() throws Exception {
+        String endpointAddress =
+            "http://localhost:9080/bookstorestorage/thosebooks/123"; 
+        getBook(endpointAddress, "foo", "ba", 401);
+    }
+    
+    @Test
+    public void testGetBookUserAdmin() throws Exception {
+        String endpointAddress =
+            "http://localhost:9080/bookstorestorage/thosebooks/123"; 
+        getBook(endpointAddress, "foo", "bar", 200);
+        getBook(endpointAddress, "bob", "bobspassword", 200);
+    }
+    
+    
+    @Test
+    public void testGetBookUser() throws Exception {
+        String endpointAddress =
+            "http://localhost:9080/bookstorestorage/thosebooks/123/123"; 
+        getBook(endpointAddress, "foo", "bar", 200);
+        getBook(endpointAddress, "bob", "bobspassword", 200);
+    }
+    
+    @Test
+    public void testGetBookAdmin() throws Exception {
+        String endpointAddress =
+            "http://localhost:9080/bookstorestorage/thosebooks"; 
+        getBook(endpointAddress, "foo", "bar", 200); 
+        getBook(endpointAddress, "bob", "bobspassword", 403);
+    }
+    
+      
+}

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookInterface.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookInterface.java?rev=724780&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookInterface.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookInterface.java Tue Dec  9 09:04:39 2008
@@ -0,0 +1,52 @@
+/**
+ * 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.jaxrs.security;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+
+import org.apache.cxf.systest.jaxrs.Book;
+import org.apache.cxf.systest.jaxrs.BookNotFoundFault;
+import org.springframework.security.annotation.Secured;
+
+public interface SecureBookInterface {
+
+    @GET
+    @Path("/thosebooks/{bookId}/")
+    @Produces("application/xml")
+    @Secured({"ROLE_USER", "ROLE_ADMIN" })
+    Book getThatBook(@PathParam("bookId") Long id) throws BookNotFoundFault;
+    
+    
+    @GET
+    @Path("/thosebooks/{bookId}/{id}")
+    @Produces("application/xml")
+    @Secured("ROLE_USER")
+    Book getThatBook(@PathParam("bookId") Long id, @PathParam("id") String s) throws BookNotFoundFault;
+    
+    @GET
+    @Path("/thosebooks")
+    @Produces("application/xml")
+    @Secured("ROLE_ADMIN")
+    Book getThatBook() throws BookNotFoundFault;
+    
+}

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStore.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStore.java?rev=724780&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStore.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStore.java Tue Dec  9 09:04:39 2008
@@ -0,0 +1,55 @@
+/**
+ * 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.jaxrs.security;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.Path;
+
+import org.apache.cxf.systest.jaxrs.Book;
+import org.apache.cxf.systest.jaxrs.BookNotFoundFault;
+
+@Path("/bookstorestorage/")
+public class SecureBookStore implements SecureBookInterface {
+    private Map<Long, Book> books = new HashMap<Long, Book>();
+  
+    public SecureBookStore() {
+        Book book = new Book();
+        book.setId(123L);
+        book.setName("CXF in Action");
+        books.put(book.getId(), book);
+    }
+    
+    public Book getThatBook(Long id) {
+        return books.get(id);
+    }
+
+    public Book getThatBook(Long id, String s) {
+        if (s == null) {
+            throw new RuntimeException();
+        }
+        return books.get(id);
+    }
+    
+    public Book getThatBook() throws BookNotFoundFault {
+        return books.get(123L);
+    }
+}

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoAnnotations.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoAnnotations.java?rev=724780&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoAnnotations.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoAnnotations.java Tue Dec  9 09:04:39 2008
@@ -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.jaxrs.security;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.Path;
+
+import org.apache.cxf.systest.jaxrs.Book;
+import org.apache.cxf.systest.jaxrs.BookInterface;
+import org.apache.cxf.systest.jaxrs.BookNotFoundFault;
+
+@Path("/bookstorestorage/")
+public class SecureBookStoreNoAnnotations implements BookInterface {
+    private Map<Long, Book> books = new HashMap<Long, Book>();
+  
+    public SecureBookStoreNoAnnotations() {
+        Book book = new Book();
+        book.setId(123L);
+        book.setName("CXF in Action");
+        books.put(book.getId(), book);
+    }
+    
+    public Book getThatBook(Long id) {
+        return books.get(id);
+    }
+
+    public Book getThatBook(Long id, String s) {
+        if (s == null) {
+            throw new RuntimeException();
+        }
+        return books.get(id);
+    }
+    
+    public Book getThatBook() throws BookNotFoundFault {
+        return books.get(123L);
+    }
+}

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoInterface.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoInterface.java?rev=724780&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoInterface.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecureBookStoreNoInterface.java Tue Dec  9 09:04:39 2008
@@ -0,0 +1,71 @@
+/**
+ * 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.jaxrs.security;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+
+import org.apache.cxf.systest.jaxrs.Book;
+import org.apache.cxf.systest.jaxrs.BookNotFoundFault;
+import org.springframework.security.annotation.Secured;
+
+@Path("/bookstorestorage/")
+public class SecureBookStoreNoInterface {
+    private Map<Long, Book> books = new HashMap<Long, Book>();
+  
+    public SecureBookStoreNoInterface() {
+        Book book = new Book();
+        book.setId(123L);
+        book.setName("CXF in Action");
+        books.put(book.getId(), book);
+    }
+    
+    @GET
+    @Path("/thosebooks/{bookId}/{id}")
+    @Produces("application/xml")
+    @Secured({"ROLE_USER", "ROLE_ADMIN" })
+    public Book getThatBook(@PathParam("bookId") Long id, @PathParam("id") String s) {
+        if (s == null) {
+            throw new RuntimeException();
+        }
+        return books.get(id);
+    }
+    
+    @GET
+    @Path("/thosebooks/{bookId}/")
+    @Produces("application/xml")
+    @Secured("ROLE_USER")
+    public Book getThatBook(@PathParam("bookId") Long id) {
+        return books.get(id);
+    }
+
+    @GET
+    @Path("/thosebooks")
+    @Produces("application/xml")
+    @Secured("ROLE_ADMIN")
+    public Book getThatBook() throws BookNotFoundFault {
+        return books.get(123L);
+    }
+}

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecurityExceptionMapper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecurityExceptionMapper.java?rev=724780&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecurityExceptionMapper.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/SecurityExceptionMapper.java Tue Dec  9 09:04:39 2008
@@ -0,0 +1,33 @@
+/**
+ * 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.jaxrs.security;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+import org.springframework.security.AccessDeniedException;
+
+public class SecurityExceptionMapper implements ExceptionMapper<AccessDeniedException> {
+
+    public Response toResponse(AccessDeniedException exception) {
+        return Response.status(Response.Status.FORBIDDEN).build();
+    }
+
+}

Added: cxf/trunk/systests/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/resources/log4j.properties?rev=724780&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/resources/log4j.properties (added)
+++ cxf/trunk/systests/src/test/resources/log4j.properties Tue Dec  9 09:04:39 2008
@@ -0,0 +1,30 @@
+#
+#
+#    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.
+#
+#
+
+# Global logging configuration
+log4j.rootLogger=WARN, stdout
+
+log4j.logger.org.springframework.security=DEBUG, stdout
+
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.conversionPattern=[%p,%c{1},%t] %m%n