cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1147016 - in /cxf/branches/2.4.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/interceptor/security/DefaultSecurityContext.java rt/core/src/test/java/org/apache/cxf/interceptor/security/DefaultSecurityContextTest.java
Date Fri, 15 Jul 2011 08:27:21 GMT
Author: ay
Date: Fri Jul 15 08:27:21 2011
New Revision: 1147016

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

........
  r1146773 | ay | 2011-07-14 18:09:39 +0200 (Thu, 14 Jul 2011) | 1 line
  
  [CXF-3655] DefaultSecurityContext to handle implicit roles
........

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/DefaultSecurityContext.java
    cxf/branches/2.4.x-fixes/rt/core/src/test/java/org/apache/cxf/interceptor/security/DefaultSecurityContextTest.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul 15 08:27:21 2011
@@ -1 +1 @@
-/cxf/trunk:1144977,1145682
+/cxf/trunk:1144977,1145682,1146773

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

Modified: cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/DefaultSecurityContext.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/DefaultSecurityContext.java?rev=1147016&r1=1147015&r2=1147016&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/DefaultSecurityContext.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/DefaultSecurityContext.java
Fri Jul 15 08:27:21 2011
@@ -68,7 +68,10 @@ public class DefaultSecurityContext impl
     public boolean isUserInRole(String role) {
         if (subject != null) {
             for (Principal principal : subject.getPrincipals()) {
-                if (principal instanceof Group && checkGroup((Group)principal, role))
{ 
+                if (principal instanceof Group && checkGroup((Group)principal, role))
{
+                    return true;
+                } else if (p != principal
+                           && role.equals(principal.getName())) {
                     return true;
                 }
             }

Modified: cxf/branches/2.4.x-fixes/rt/core/src/test/java/org/apache/cxf/interceptor/security/DefaultSecurityContextTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/core/src/test/java/org/apache/cxf/interceptor/security/DefaultSecurityContextTest.java?rev=1147016&r1=1147015&r2=1147016&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/core/src/test/java/org/apache/cxf/interceptor/security/DefaultSecurityContextTest.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/core/src/test/java/org/apache/cxf/interceptor/security/DefaultSecurityContextTest.java
Fri Jul 15 08:27:21 2011
@@ -100,5 +100,18 @@ public class DefaultSecurityContextTest 
         s.getPrincipals().add(group);
         assertTrue(new DefaultSecurityContext(p, s).isUserInRole("friend"));
     }
+
+    @Test
+    public void testUserInImplicitRoles() {
+        Subject s = new Subject();
+        Principal p = new SimplePrincipal("Barry");
+        s.getPrincipals().add(p);
+        Principal role = new SimplePrincipal("friend");
+        s.getPrincipals().add(role);
+        LoginSecurityContext context = new DefaultSecurityContext(p, s); 
+        assertTrue(context.isUserInRole("friend"));
+        assertFalse(context.isUserInRole("family"));
+        assertFalse(context.isUserInRole("Barry"));
+    }
     
 }



Mime
View raw message