]> source.dussan.org Git - archiva.git/commitdiff
add default in memory implementation for testing purpose
authorOlivier Lamy <olamy@apache.org>
Wed, 30 Jan 2013 17:46:43 +0000 (17:46 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 30 Jan 2013 17:46:43 +0000 (17:46 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1440552 13f79535-47bb-0310-9956-ffa450edef68

redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/DefaultLdapRoleMapperConfiguration.java
redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/LdapRoleMapperConfiguration.java

index 262fa4b8ee6503e601907e82218a0b2064936237..1ce52e5e1eb44ce964ced3e41d7dfd1b8efcca43 100644 (file)
@@ -31,6 +31,7 @@ import org.springframework.stereotype.Service;
 import javax.inject.Inject;
 import javax.inject.Named;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -45,6 +46,8 @@ public class DefaultLdapRoleMapperConfiguration
 
     private Logger log = LoggerFactory.getLogger( getClass() );
 
+    private Map<String, List<String>> ldapMappings = new HashMap<String, List<String>>();
+
     @Inject
     @Named( value = "userConfiguration#default" )
     private UserConfiguration userConf;
@@ -52,24 +55,27 @@ public class DefaultLdapRoleMapperConfiguration
     public void addLdapMapping( String ldapGroup, List<String> roles )
         throws MappingException
     {
-        log.warn( "addLdapMapping not implemented" );
+        ldapMappings.put( ldapGroup, roles );
+        log.warn( "addLdapMapping implemented but only in memory save" );
     }
 
     public void removeLdapMapping( String group )
     {
-        log.warn( "removeLdapMapping not implemented" );
+        ldapMappings.remove( group );
     }
 
     public void updateLdapMapping( String ldapGroup, List<String> roles )
         throws MappingException
     {
-        log.warn( "removeLdapMapping not implemented" );
+        ldapMappings.put( ldapGroup, roles );
+        log.warn( "updateLdapMapping implemented but only in memory save" );
     }
 
-    public void setLdapGroupMappings( Map<String, Collection<String>> mappings )
+    public void setLdapGroupMappings( Map<String, List<String>> mappings )
         throws MappingException
     {
-        log.warn( "setLdapGroupMappings not implemented" );
+        log.warn( "setLdapGroupMappings implemented but only in memory save" );
+        this.ldapMappings = mappings;
     }
 
     public Map<String, Collection<String>> getLdapGroupMappings()
@@ -92,6 +98,12 @@ public class DefaultLdapRoleMapperConfiguration
             }
         }
 
-        return map.asMap();
+        for ( Map.Entry<String, List<String>> entry : this.ldapMappings.entrySet() )
+        {
+            map.putAll( entry.getKey(), entry.getValue() );
+        }
+
+        Map<String, Collection<String>> mappings = map.asMap();
+        return mappings;
     }
 }
index f2f3aa19ec42101fdc1b1bcba9e33d053e89c719..0e1c4a853fcde40d063036b99162cee5555d2388 100644 (file)
@@ -62,6 +62,6 @@ public interface LdapRoleMapperConfiguration
     Map<String, Collection<String>> getLdapGroupMappings()
         throws MappingException;
 
-    void setLdapGroupMappings( Map<String, Collection<String>> mappings )
+    void setLdapGroupMappings( Map<String, List<String>> mappings )
         throws MappingException;
 }