001package org.apache.archiva.redback.users.ldap.ctl;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import org.apache.archiva.redback.common.ldap.user.LdapUser;
023import org.apache.archiva.redback.users.User;
024import org.apache.archiva.redback.common.ldap.MappingException;
025import org.apache.archiva.redback.users.ldap.LdapUserQuery;
026
027import javax.naming.directory.DirContext;
028import java.util.Collection;
029import java.util.List;
030import java.util.Map;
031
032/**
033 *
034 */
035public interface LdapController
036{
037
038    void removeUser( String principal, DirContext context )
039        throws LdapControllerException;
040
041    void updateUser( User user, DirContext context )
042        throws LdapControllerException, MappingException;
043
044    boolean userExists( String key, DirContext context )
045        throws LdapControllerException;
046
047    Collection<User> getUsers( DirContext context )
048        throws LdapControllerException, MappingException;
049
050    void createUser( User user, DirContext context, boolean encodePasswordIfChanged )
051        throws LdapControllerException, MappingException;
052
053    LdapUser getUser( String key, DirContext context )
054        throws LdapControllerException, MappingException;
055
056    List<User> getUsersByQuery( LdapUserQuery query, DirContext context )
057        throws LdapControllerException, MappingException;
058
059    void initialize();
060
061    /**
062     * @param dirContext
063     * @return Map key == username and value == list of role names
064     * @throws LdapControllerException
065     */
066    Map<String, Collection<String>> findUsersWithRoles( DirContext dirContext )
067        throws LdapControllerException;
068}