From 74f2b9475e8ded89a25f30d199d2497cccd8cc96 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Fri, 22 Feb 2013 16:51:08 +0000 Subject: [PATCH] fix chaining of rbac manager to get userassignements git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1449113 13f79535-47bb-0310-9956-ffa450edef68 --- .../web/security/ArchivaRbacManager.java | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java index e5b144be9..2a08e1a4c 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaRbacManager.java @@ -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 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; -- 2.39.5