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 java.util.List;
27 * will map ldap group to redback role
29 * @author Olivier Lamy
32 public interface LdapRoleMapper
35 * @param role redback role
36 * @return corresponding LDAP group
38 String getLdapGroup( String role )
39 throws MappingException;
42 //String getLdapGroup( String role, String resource );
46 * read all groups from ldap
48 * @return all LDAP groups
50 List<String> getAllGroups()
51 throws MappingException;
54 * read all ldap groups then map to corresponding role (if no mapping found group is ignored)
59 List<String> getAllRoles()
60 throws MappingException;
64 * @return the base dn which contains all ldap groups
69 * @return the class used for group usually groupOfUniqueNames
71 String getLdapGroupClass();
74 * @param group ldap group
75 * @return uids of group members
76 * @throws MappingException
78 List<String> getGroupsMember( String group )
79 throws MappingException;
81 List<String> getGroups( String username )
82 throws MappingException;
84 List<String> getRoles( String username )
85 throws MappingException;
88 * add mapping redback role <-> ldap group
90 * @param role redback role
91 * @param ldapGroup ldap group
93 void addLdapMapping( String role, String ldapGroup )
94 throws MappingException;
99 * @param role redback role
101 void removeLdapMapping( String role )
102 throws MappingException;
105 * @return Map of corresponding LDAP group (key) and Redback role (value)
107 Map<String, String> getLdapGroupMappings()
108 throws MappingException;
110 void setLdapGroupMappings( Map<String, String> mappings )
111 throws MappingException;
114 * will save a ldap group corresponding to the mapping.
115 * <b>will do nothing in group already exists.</b>
118 * @return <code>true</code> if role was added, <code>false</code> if role already exists
119 * @throws MappingException
121 boolean saveRole( String roleName )
122 throws MappingException;
125 * associate role to user in ldap
129 * @return <code>true</code> if role was added to user, <code>false</code> if role already exists for the user
130 * @throws MappingException
132 boolean saveUserRole( String roleName, String username )
133 throws MappingException;
135 boolean removeUserRole( String roleName, String username )
136 throws MappingException;
138 void removeAllRoles()
139 throws MappingException;
141 void removeRole( String roleName )
142 throws MappingException;