1 package org.apache.archiva.redback.common.ldap.role;
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 import com.google.common.collect.ArrayListMultimap;
22 import com.google.common.collect.Multimap;
23 import org.apache.archiva.redback.common.ldap.MappingException;
24 import org.apache.archiva.redback.configuration.UserConfiguration;
25 import org.apache.archiva.redback.configuration.UserConfigurationKeys;
26 import org.apache.commons.lang.StringUtils;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29 import org.springframework.stereotype.Service;
31 import javax.inject.Inject;
32 import javax.inject.Named;
33 import java.util.Collection;
34 import java.util.List;
38 * @author Olivier Lamy
41 @Service( "ldapRoleMapperConfiguration#default" )
42 public class DefaultLdapRoleMapperConfiguration
43 implements LdapRoleMapperConfiguration
46 private Logger log = LoggerFactory.getLogger( getClass() );
49 @Named( value = "userConfiguration#default" )
50 private UserConfiguration userConf;
52 public void addLdapMapping( String ldapGroup, List<String> roles )
53 throws MappingException
55 log.warn( "addLdapMapping not implemented" );
58 public void removeLdapMapping( String group )
60 log.warn( "removeLdapMapping not implemented" );
63 public void updateLdapMapping( String ldapGroup, List<String> roles )
64 throws MappingException
66 log.warn( "removeLdapMapping not implemented" );
69 public void setLdapGroupMappings( Map<String, Collection<String>> mappings )
70 throws MappingException
72 log.warn( "setLdapGroupMappings not implemented" );
75 public Map<String, Collection<String>> getLdapGroupMappings()
77 Multimap<String, String> map = ArrayListMultimap.create();
79 Collection<String> keys = userConf.getKeys();
81 for ( String key : keys )
83 if ( key.startsWith( UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY ) )
85 String val = userConf.getString( key );
86 String[] roles = StringUtils.split( val, ',' );
87 for ( String role : roles )
89 map.put( StringUtils.substringAfter( key, UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY ),