1 /* 2 * Copyright 2013–2019 Michael Osipov 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package net.sf.michaelo.tomcat.realm.mapper; 17 18 import javax.naming.NamingException; 19 import javax.naming.directory.DirContext; 20 21 import org.ietf.jgss.GSSName; 22 23 import net.sf.michaelo.tomcat.realm.ActiveDirectoryRealm; 24 25 /** 26 * A mapper interface (strategy pattern) for translating GSS names to Active Directory search 27 * parameters. 28 * 29 * @version $Id: UsernameSearchMapper.java 317 2019-03-09 21:26:28Z michael-o $ 30 */ 31 public interface UsernameSearchMapper { 32 33 /** 34 * Mapped values holder. The {@link ActiveDirectoryRealm} uses these mapped values to search for 35 * a user. 36 */ 37 interface MappedValues { 38 39 String getSearchBase(); 40 41 String getSearchAttributeName(); 42 43 String getSearchUsername(); 44 45 } 46 47 /** 48 * Maps a GSS name to AD search parameters. A mapper implementation must assure that the user 49 * can be found in the given {@code context} when an approriate GSS name is presented. The 50 * implementor must be aware that the returned search base might need to be relativized to the 51 * root DN of the context. 52 * 53 * @param context 54 * the search context 55 * @param gssName 56 * the GSS name to be mapped 57 * @return mapped values for user retrieval 58 * @throws NamingException 59 * if a context-related error has occured 60 */ 61 MappedValues map(DirContext context, GSSName gssName) throws NamingException; 62 63 }