You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2011/01/10 22:31:47 UTC

svn commit: r1057379 - in /cxf/branches/2.3.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/interceptor/security/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/

Author: dkulp
Date: Mon Jan 10 21:31:46 2011
New Revision: 1057379

URL: http://svn.apache.org/viewvc?rev=1057379&view=rev
Log:
Merged revisions 1056794 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1056794 | sergeyb | 2011-01-08 15:38:12 -0500 (Sat, 08 Jan 2011) | 1 line
  
  Adding some log statements to authorizing interceptors
........

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/AbstractAuthorizingInInterceptor.java
    cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptor.java
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSimpleSecurityTest.java

Propchange: cxf/branches/2.3.x-fixes/
            ('svn:mergeinfo' removed)

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/AbstractAuthorizingInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/AbstractAuthorizingInInterceptor.java?rev=1057379&r1=1057378&r2=1057379&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/AbstractAuthorizingInInterceptor.java (original)
+++ cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/AbstractAuthorizingInInterceptor.java Mon Jan 10 21:31:46 2011
@@ -21,7 +21,9 @@ package org.apache.cxf.interceptor.secur
 import java.lang.reflect.Method;
 import java.util.Collections;
 import java.util.List;
+import java.util.logging.Logger;
 
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.frontend.MethodDispatcher;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Message;
@@ -33,6 +35,7 @@ import org.apache.cxf.service.model.Bind
 
 public abstract class AbstractAuthorizingInInterceptor extends AbstractPhaseInterceptor<Message> {
 
+    private static final Logger LOG = LogUtils.getL7dLogger(AbstractAuthorizingInInterceptor.class);
     private static final String ALL_ROLES = "*";
     
     
@@ -81,7 +84,9 @@ public abstract class AbstractAuthorizin
         if (isUserInRole(sc, expectedRoles, false)) {
             return true;
         }
-        
+        if (sc.getUserPrincipal() != null) {
+            LOG.fine(sc.getUserPrincipal().getName() + " is not authorized");
+        }
         return false;
     }
     

Modified: cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptor.java?rev=1057379&r1=1057378&r2=1057379&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptor.java (original)
+++ cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptor.java Mon Jan 10 21:31:46 2011
@@ -25,13 +25,17 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.ClassHelper;
 
 
 public class SecureAnnotationsInterceptor extends SimpleAuthorizingInterceptor {
 
+    private static final Logger LOG = LogUtils.getL7dLogger(SecureAnnotationsInterceptor.class);
     private static final String DEFAULT_ANNOTATION_CLASS_NAME = "javax.annotation.security.RolesAllowed";
     
     private static final Set<String> SKIP_METHODS;
@@ -58,6 +62,13 @@ public class SecureAnnotationsIntercepto
         Class<?> cls = ClassHelper.getRealClass(object);
         Map<String, String> rolesMap = new HashMap<String, String>();
         findRoles(cls, rolesMap);
+        if (rolesMap.isEmpty()) {
+            LOG.warning("The roles map is empty, the service object is not protected");
+        } else if (LOG.isLoggable(Level.FINE)) {
+            for (Map.Entry<String, String> entry : rolesMap.entrySet()) {
+                LOG.fine("Method: " + entry.getKey() + ", roles: " + entry.getValue());
+            }
+        }
         super.setMethodRolesMap(rolesMap);
     }
 

Modified: cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSimpleSecurityTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSimpleSecurityTest.java?rev=1057379&r1=1057378&r2=1057379&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSimpleSecurityTest.java (original)
+++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSimpleSecurityTest.java Mon Jan 10 21:31:46 2011
@@ -28,7 +28,7 @@ public class JAXRSSimpleSecurityTest ext
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly", 
-                   launchServer(BookServerSimpleSecurity.class));
+                   launchServer(BookServerSimpleSecurity.class, true));
     }
     
     @Test