001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2006-2008 Sun Microsystems, Inc. 015 * Portions Copyright 2014-2016 ForgeRock AS. 016 */ 017package org.opends.server.api; 018import org.forgerock.i18n.LocalizableMessage; 019 020 021 022import java.util.List; 023 024import org.forgerock.opendj.server.config.server.IdentityMapperCfg; 025import org.forgerock.opendj.config.server.ConfigException; 026import org.opends.server.types.DirectoryException; 027import org.opends.server.types.Entry; 028import org.opends.server.types.InitializationException; 029 030 031 032/** 033 * This class defines the set of methods and structures that must be 034 * implemented by a Directory Server identity mapper. An identity 035 * mapper is used to identify exactly one user associated with a given 036 * identification value. This API may be used by a number of SASL 037 * mechanisms to identify the user that is authenticating to the 038 * server. It may also be used in other areas, like in conjunction 039 * with the proxied authorization control. 040 * 041 * @param <T> The type of configuration handled by this identity 042 * mapper. 043 */ 044@org.opends.server.types.PublicAPI( 045 stability=org.opends.server.types.StabilityLevel.VOLATILE, 046 mayInstantiate=false, 047 mayExtend=true, 048 mayInvoke=true) 049public abstract class IdentityMapper 050 <T extends IdentityMapperCfg> 051{ 052 /** 053 * Initializes this identity mapper based on the information in the 054 * provided configuration entry. 055 * 056 * @param configuration The configuration for the identity mapper. 057 * 058 * @throws ConfigException If an unrecoverable problem arises in 059 * the process of performing the 060 * initialization. 061 * 062 * @throws InitializationException If a problem occurs during 063 * initialization that is not 064 * related to the server 065 * configuration. 066 */ 067 public abstract void initializeIdentityMapper(T configuration) 068 throws ConfigException, InitializationException; 069 070 071 072 /** 073 * Indicates whether the provided configuration is acceptable for 074 * this identity mapper. It should be possible to call this method 075 * on an uninitialized identity mapper instance in order to 076 * determine whether the identity mapper would be able to use the 077 * provided configuration. 078 * <BR><BR> 079 * Note that implementations which use a subclass of the provided 080 * configuration class will likely need to cast the configuration 081 * to the appropriate subclass type. 082 * 083 * @param configuration The identity mapper configuration 084 * for which to make the determination. 085 * @param unacceptableReasons A list that may be used to hold the 086 * reasons that the provided 087 * configuration is not acceptable. 088 * 089 * @return {@code true} if the provided configuration is acceptable 090 * for this identity mapper, or {@code false} if not. 091 */ 092 public boolean isConfigurationAcceptable( 093 IdentityMapperCfg configuration, 094 List<LocalizableMessage> unacceptableReasons) 095 { 096 // This default implementation does not perform any special 097 // validation. It should be overridden by identity mapper 098 // implementations that wish to perform more detailed validation. 099 return true; 100 } 101 102 103 104 /** 105 * Performs any finalization that may be necessary for this identity 106 * mapper. By default, no finalization is performed. 107 */ 108 public void finalizeIdentityMapper() 109 { 110 // No implementation is required by default. 111 } 112 113 114 115 /** 116 * Retrieves the user entry that was mapped to the provided 117 * identification string. 118 * 119 * @param id The identification string that is to be mapped to a 120 * user. 121 * 122 * @return The user entry that was mapped to the provided 123 * identification, or {@code null} if no users were found 124 * that could be mapped to the provided ID. 125 * 126 * @throws DirectoryException If a problem occurs while attempting 127 * to map the given ID to a user entry, 128 * or if there are multiple user 129 * entries that could map to the 130 * provided ID. 131 */ 132 public abstract Entry getEntryForID(String id) 133 throws DirectoryException; 134} 135