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;
37 * @author Olivier Lamy
39 @Service( "ldapRoleMapperConfiguration#default" )
40 public class DefaultLdapRoleMapperConfiguration
41 implements LdapRoleMapperConfiguration
44 private Logger log = LoggerFactory.getLogger( getClass() );
47 @Named( value = "userConfiguration#default" )
48 private UserConfiguration userConf;
50 public void addLdapMapping( String role, String ldapGroup )
52 log.warn( "addLdapMapping not implemented" );
55 public void removeLdapMapping( String role )
57 log.warn( "removeLdapMapping not implemented" );
60 public void setLdapGroupMappings( Map<String, Collection<String>> mappings )
61 throws MappingException
63 log.warn( "setLdapGroupMappings not implemented" );
66 public Map<String, Collection<String>> getLdapGroupMappings()
68 Multimap<String, String> map = ArrayListMultimap.create();
70 Collection<String> keys = userConf.getKeys();
72 for ( String key : keys )
74 if ( key.startsWith( UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY ) )
76 String val = userConf.getString( key );
77 String[] roles = StringUtils.split( val, ',' );
78 for ( String role : roles )
80 map.put( StringUtils.substringAfter( key, UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY ),