@Named( value = "cache#ldapRoles" )
private Cache<String, Role> rolesCache;
- private boolean writableLdap = false;
+ @Inject
+ @Named( value = "cache#userAssignments" )
+ private Cache<String, UserAssignment> userAssignmentsCache;
+ private boolean writableLdap = false;
@PostConstruct
public void initialize()
}
}
this.rolesCache.clear();
+ this.userAssignmentsCache.clear();
this.rbacImpl.eraseDatabase();
}
{
UserAssignment userAssignment = new UserAssignmentImpl( entry.getKey(), entry.getValue() );
userAssignments.add( userAssignment );
+ userAssignmentsCache.put( userAssignment.getPrincipal(), userAssignment );
}
return userAssignments;
public UserAssignment getUserAssignment( String username )
throws RbacManagerException
{
+ UserAssignment ua = userAssignmentsCache.get( username );
+ if ( ua != null )
+ {
+ return ua;
+ }
LdapConnection ldapConnection = null;
DirContext context = null;
try
context = ldapConnection.getDirContext();
List<String> roles = ldapRoleMapper.getRoles( username, context, getRealRoles() );
- return new UserAssignmentImpl( username, roles );
+ ua = new UserAssignmentImpl( username, roles );
+
+ userAssignmentsCache.put( username, ua );
+
+ return ua;
}
catch ( MappingException e )
{
throws RbacManagerException
{
// TODO ldap cannot or isWritable ldap ?
+ userAssignmentsCache.remove( username );
this.rbacImpl.removeUserAssignment( username );
}
public void removeUserAssignment( UserAssignment userAssignment )
throws RbacManagerException
{
+ if ( userAssignment != null )
+ {
+ userAssignmentsCache.remove( userAssignment.getPrincipal() );
+ }
// TODO ldap cannot or isWritable ldap ?
this.rbacImpl.removeUserAssignment( userAssignment );
}
}
}
+ userAssignmentsCache.put( userAssignment.getPrincipal(), userAssignment );
return userAssignment;
}
catch ( UserManagerException e )
public boolean userAssignmentExists( String principal )
{
+ if ( userAssignmentsCache.hasKey( principal ) )
+ {
+ return true;
+ }
LdapConnection ldapConnection = null;
DirContext context = null;
try
<property name="userPermissionsCache" ref="cache#userPermissions"/>
</bean>
- <bean name="cache#userAssignments" class="org.apache.archiva.redback.components.cache.ehcache.EhcacheCache"
- init-method="initialize">
- <property name="diskPersistent" value="false"/>
- <property name="eternal" value="false"/>
- <property name="maxElementsInMemory" value="1000"/>
- <property name="memoryEvictionPolicy" value="LRU"/>
- <property name="name" value="userAssignments"/>
- <property name="timeToIdleSeconds" value="300"/>
- <property name="timeToLiveSeconds" value="600"/>
+ <bean name="cache#userAssignments" class="org.apache.archiva.redback.components.cache.impl.NoCacheCache">
</bean>
<bean name="cache#userPermissions" class="org.apache.archiva.redback.components.cache.ehcache.EhcacheCache"