archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1449113 - /archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java
Date Fri, 22 Feb 2013 16:51:08 GMT
Author: olamy
Date: Fri Feb 22 16:51:08 2013
New Revision: 1449113

URL: http://svn.apache.org/r1449113
Log:
fix chaining of rbac manager to get userassignements

Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java?rev=1449113&r1=1449112&r2=1449113&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java
Fri Feb 22 16:51:08 2013
@@ -700,17 +700,26 @@ public class ArchivaRbacManager
         {
             return el;
         }
-
+        UserAssignment ua = null;
         Exception lastException = null;
         for ( RBACManager rbacManager : rbacManagersPerId.values() )
         {
             try
             {
-                UserAssignment ua = rbacManager.getUserAssignment( principal );
-                if ( ua != null )
+                if ( ua == null )
+                {
+                    ua = rbacManager.getUserAssignment( principal );
+                }
+                else
                 {
-                    userAssignmentsCache.put( principal, ua );
-                    return ua;
+                    UserAssignment userAssignment = rbacManager.getUserAssignment( principal
);
+                    if ( userAssignment != null )
+                    {
+                        for ( String roleName : userAssignment.getRoleNames() )
+                        {
+                            ua.addRoleName( roleName );
+                        }
+                    }
                 }
             }
             catch ( Exception e )
@@ -719,6 +728,12 @@ public class ArchivaRbacManager
             }
         }
 
+        if ( ua != null )
+        {
+            userAssignmentsCache.put( principal, ua );
+            return ua;
+        }
+
         if ( lastException != null )
         {
             throw new RbacManagerException( lastException.getMessage(), lastException );
@@ -784,6 +799,14 @@ public class ArchivaRbacManager
                 List<UserAssignment> userAssignments = rbacManager.getAllUserAssignments();
                 for ( UserAssignment ua : userAssignments )
                 {
+                    UserAssignment userAssignment = allUserAssignments.get( ua.getPrincipal()
);
+                    if ( userAssignment != null )
+                    {
+                        for ( String roleName : ua.getRoleNames() )
+                        {
+                            userAssignment.addRoleName( roleName );
+                        }
+                    }
                     allUserAssignments.put( ua.getPrincipal(), ua );
                 }
                 allFailed = false;



Mime
View raw message