1package org.apache.archiva.redback.common.ldap.role;
2/*3 * Licensed to the Apache Software Foundation (ASF) under one4 * or more contributor license agreements. See the NOTICE file5 * distributed with this work for additional information6 * regarding copyright ownership. The ASF licenses this file7 * to you under the Apache License, Version 2.0 (the8 * "License"); you may not use this file except in compliance9 * with the License. You may obtain a copy of the License at10 *11 * http://www.apache.org/licenses/LICENSE-2.012 *13 * Unless required by applicable law or agreed to in writing,14 * software distributed under the License is distributed on an15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY16 * KIND, either express or implied. See the License for the17 * specific language governing permissions and limitations18 * under the License.19 */2021import org.apache.archiva.redback.common.ldap.MappingException;
2223import javax.naming.directory.DirContext;
24import java.util.Collection;
25import java.util.List;
26import java.util.Map;
2728/**29 * will map ldap group to redback role30 *31 * @author Olivier Lamy32 * @since 2.133 */34publicinterfaceLdapRoleMapper35 {
3637/**38 * read all groups from ldap39 *40 * @return all LDAP groups41 */42 List<String> getAllGroups( DirContext context )
43throws MappingException;
4445/**46 * read all ldap groups then map to corresponding role (if no mapping found group is ignored)47 *48 * @return all roles49 * @throws Exception50 */51 List<String> getAllRoles( DirContext context )
52throws MappingException;
5354boolean hasRole( DirContext context, String role )
55throws MappingException;
565758/**59 * @return the base dn which contains all ldap groups60 */61 String getGroupsDn();
6263/**64 * @return the class used for group usually groupOfUniqueNames65 */66 String getLdapGroupClass();
6768/**69 * @param group ldap group70 * @return uids of group members71 * @throws MappingException72 */73 List<String> getGroupsMember( String group, DirContext context )
74throws MappingException;
7576 List<String> getGroups( String username, DirContext context )
77throws MappingException;
7879 List<String> getRoles( String username, DirContext context, Collection<String> realRoles )
80throws MappingException;
81828384/**85 * will save a ldap group corresponding to the mapping.86 * <b>will do nothing in group already exists.</b>87 *88 * @param roleName89 * @return <code>true</code> if role was added, <code>false</code> if role already exists90 * @throws MappingException91 */92boolean saveRole( String roleName, DirContext context )
93throws MappingException;
9495/**96 * associate role to user in ldap97 *98 * @param roleName99 * @param username100 * @return <code>true</code> if role was added to user, <code>false</code> if role already exists for the user101 * @throws MappingException102 */103boolean saveUserRole( String roleName, String username, DirContext context )
104throws MappingException;
105106boolean removeUserRole( String roleName, String username, DirContext context )
107throws MappingException;
108109void removeAllRoles( DirContext context )
110throws MappingException;
111112void removeRole( String roleName, DirContext context )
113throws MappingException;
114115 String getUserIdAttribute();
116117boolean isUseDefaultRoleName();
118119 }