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
This commit is contained in:
Olivier Lamy 2013-02-22 16:51:08 +00:00
parent ac6dc59b94
commit 74f2b9475e
1 changed files with 28 additions and 5 deletions

View File

@ -700,17 +700,26 @@ public class ArchivaRbacManager
{ {
return el; return el;
} }
UserAssignment ua = null;
Exception lastException = null; Exception lastException = null;
for ( RBACManager rbacManager : rbacManagersPerId.values() ) for ( RBACManager rbacManager : rbacManagersPerId.values() )
{ {
try try
{ {
UserAssignment ua = rbacManager.getUserAssignment( principal ); if ( ua == null )
if ( ua != null )
{ {
userAssignmentsCache.put( principal, ua ); ua = rbacManager.getUserAssignment( principal );
return ua; }
else
{
UserAssignment userAssignment = rbacManager.getUserAssignment( principal );
if ( userAssignment != null )
{
for ( String roleName : userAssignment.getRoleNames() )
{
ua.addRoleName( roleName );
}
}
} }
} }
catch ( Exception e ) catch ( Exception e )
@ -719,6 +728,12 @@ public class ArchivaRbacManager
} }
} }
if ( ua != null )
{
userAssignmentsCache.put( principal, ua );
return ua;
}
if ( lastException != null ) if ( lastException != null )
{ {
throw new RbacManagerException( lastException.getMessage(), lastException ); throw new RbacManagerException( lastException.getMessage(), lastException );
@ -784,6 +799,14 @@ public class ArchivaRbacManager
List<UserAssignment> userAssignments = rbacManager.getAllUserAssignments(); List<UserAssignment> userAssignments = rbacManager.getAllUserAssignments();
for ( UserAssignment ua : userAssignments ) 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 ); allUserAssignments.put( ua.getPrincipal(), ua );
} }
allFailed = false; allFailed = false;