Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 86067 invoked from network); 8 Jan 2011 20:38:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Jan 2011 20:38:34 -0000 Received: (qmail 60971 invoked by uid 500); 8 Jan 2011 20:38:33 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 60917 invoked by uid 500); 8 Jan 2011 20:38:33 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 60910 invoked by uid 99); 8 Jan 2011 20:38:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Jan 2011 20:38:33 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Jan 2011 20:38:33 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D3FC423889E1; Sat, 8 Jan 2011 20:38:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1056794 - in /cxf/trunk: rt/core/src/main/java/org/apache/cxf/interceptor/security/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/ Date: Sat, 08 Jan 2011 20:38:12 -0000 To: commits@cxf.apache.org From: sergeyb@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110108203812.D3FC423889E1@eris.apache.org> Author: sergeyb Date: Sat Jan 8 20:38:12 2011 New Revision: 1056794 URL: http://svn.apache.org/viewvc?rev=1056794&view=rev Log: Adding some log statements to authorizing interceptors Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/security/AbstractAuthorizingInInterceptor.java cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptor.java cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSimpleSecurityTest.java Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/security/AbstractAuthorizingInInterceptor.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/security/AbstractAuthorizingInInterceptor.java?rev=1056794&r1=1056793&r2=1056794&view=diff ============================================================================== --- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/security/AbstractAuthorizingInInterceptor.java (original) +++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/security/AbstractAuthorizingInInterceptor.java Sat Jan 8 20:38:12 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 { + 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/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptor.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptor.java?rev=1056794&r1=1056793&r2=1056794&view=diff ============================================================================== --- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptor.java (original) +++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptor.java Sat Jan 8 20:38:12 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 SKIP_METHODS; @@ -58,6 +62,13 @@ public class SecureAnnotationsIntercepto Class cls = ClassHelper.getRealClass(object); Map rolesMap = new HashMap(); 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 entry : rolesMap.entrySet()) { + LOG.fine("Method: " + entry.getKey() + ", roles: " + entry.getValue()); + } + } super.setMethodRolesMap(rolesMap); } Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSimpleSecurityTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSimpleSecurityTest.java?rev=1056794&r1=1056793&r2=1056794&view=diff ============================================================================== --- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSimpleSecurityTest.java (original) +++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSimpleSecurityTest.java Sat Jan 8 20:38:12 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