@Named( value = "userConfiguration#default" )
private UserConfiguration userConf;
+ @Inject
+ @Named( value = "ldapRoleMapperConfiguration#default" )
+ private LdapRoleMapperConfiguration ldapRoleMapperConfiguration;
+
//---------------------------
// fields
//---------------------------
Set<String> roles = new HashSet<String>( groups.size() );
- Map<String, Collection<String>> mapping = getLdapGroupMappings();
+ Map<String, Collection<String>> mapping = ldapRoleMapperConfiguration.getLdapGroupMappings();
for ( String group : groups )
{
{
List<String> groups = getGroups( username, context );
- Map<String, Collection<String>> rolesMapping = getLdapGroupMappings();
+ Map<String, Collection<String>> rolesMapping = ldapRoleMapperConfiguration.getLdapGroupMappings();
Set<String> roles = new HashSet<String>( groups.size() );
return this.ldapGroupClass;
}
- public void addLdapMapping( String role, String ldapGroup )
- {
- log.warn( "addLdapMapping not implemented" );
- }
-
- public void removeLdapMapping( String role )
- {
- log.warn( "removeLdapMapping not implemented" );
- }
-
- public void setLdapGroupMappings( Map<String, Collection<String>> mappings )
- throws MappingException
- {
- log.warn( "setLdapGroupMappings not implemented" );
- }
-
- public Map<String, Collection<String>> getLdapGroupMappings()
- {
- Multimap<String, String> map = ArrayListMultimap.create();
-
- Collection<String> keys = userConf.getKeys();
-
- for ( String key : keys )
- {
- if ( key.startsWith( UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY ) )
- {
- String val = userConf.getString( key );
- String[] roles = StringUtils.split( val, ',' );
- for ( String role : roles )
- {
- map.put( StringUtils.substringAfter( key, UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY ),
- role );
- }
- }
- }
-
- return map.asMap();
- }
public boolean saveRole( String roleName, DirContext context )
throws MappingException
throws MappingException
{
//all mapped roles
- Collection<String> groups = getLdapGroupMappings().keySet();
+ Collection<String> groups = ldapRoleMapperConfiguration.getLdapGroupMappings().keySet();
try
{
}
}
+ //------------------------------------
+ // Mapping part
+ //------------------------------------
+
//---------------------------------
// setters for unit tests
//---------------------------------
//-------------------
protected String findGroupName( String role )
+ throws MappingException
{
- Map<String, Collection<String>> mapping = getLdapGroupMappings();
+ Map<String, Collection<String>> mapping = ldapRoleMapperConfiguration.getLdapGroupMappings();
for ( Map.Entry<String, Collection<String>> entry : mapping.entrySet() )
{
List<String> getRoles( String username, DirContext context, Collection<String> realRoles )
throws MappingException;
- /**
- * add mapping redback role <-> ldap group
- *
- * @param role redback role
- * @param ldapGroup ldap group
- */
- void addLdapMapping( String role, String ldapGroup )
- throws MappingException;
- /**
- * remove a mapping
- *
- * @param role redback role
- */
- void removeLdapMapping( String role )
- throws MappingException;
-
- /**
- * @return Map of corresponding LDAP group (key) and Redback roles (value)
- */
- Map<String, Collection<String>> getLdapGroupMappings()
- throws MappingException;
-
- void setLdapGroupMappings( Map<String, Collection<String>> mappings )
- throws MappingException;
/**
* will save a ldap group corresponding to the mapping.