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 org.apache.archiva.redback.common.ldap.MappingException;
23 import javax.naming.directory.DirContext;
24 import java.util.List;
28 * will map ldap group to redback role
30 * @author Olivier Lamy
33 public interface LdapRoleMapper
36 * @param role redback role
37 * @return corresponding LDAP group
39 String getLdapGroup( String role )
40 throws MappingException;
43 //String getLdapGroup( String role, String resource );
47 * read all groups from ldap
49 * @return all LDAP groups
51 List<String> getAllGroups( DirContext context )
52 throws MappingException;
55 * read all ldap groups then map to corresponding role (if no mapping found group is ignored)
60 List<String> getAllRoles( DirContext context )
61 throws MappingException;
65 * @return the base dn which contains all ldap groups
70 * @return the class used for group usually groupOfUniqueNames
72 String getLdapGroupClass();
75 * @param group ldap group
76 * @return uids of group members
77 * @throws MappingException
79 List<String> getGroupsMember( String group, DirContext context )
80 throws MappingException;
82 List<String> getGroups( String username, DirContext context )
83 throws MappingException;
85 List<String> getRoles( String username, DirContext context )
86 throws MappingException;
89 * add mapping redback role <-> ldap group
91 * @param role redback role
92 * @param ldapGroup ldap group
94 void addLdapMapping( String role, String ldapGroup )
95 throws MappingException;
100 * @param role redback role
102 void removeLdapMapping( String role )
103 throws MappingException;
106 * @return Map of corresponding LDAP group (key) and Redback role (value)
108 Map<String, String> getLdapGroupMappings()
109 throws MappingException;
111 void setLdapGroupMappings( Map<String, String> mappings )
112 throws MappingException;
115 * will save a ldap group corresponding to the mapping.
116 * <b>will do nothing in group already exists.</b>
119 * @return <code>true</code> if role was added, <code>false</code> if role already exists
120 * @throws MappingException
122 boolean saveRole( String roleName, DirContext context )
123 throws MappingException;
126 * associate role to user in ldap
130 * @return <code>true</code> if role was added to user, <code>false</code> if role already exists for the user
131 * @throws MappingException
133 boolean saveUserRole( String roleName, String username, DirContext context )
134 throws MappingException;
136 boolean removeUserRole( String roleName, String username, DirContext context )
137 throws MappingException;
139 void removeAllRoles( DirContext context )
140 throws MappingException;
142 void removeRole( String roleName, DirContext context )
143 throws MappingException;