001 /*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License"). You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at
010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 * Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 * Copyright 2008 Sun Microsystems, Inc.
026 */
027 package org.opends.server.admin.std.meta;
028
029
030
031 import org.opends.server.admin.AdministratorAction;
032 import org.opends.server.admin.BooleanPropertyDefinition;
033 import org.opends.server.admin.ClassPropertyDefinition;
034 import org.opends.server.admin.client.AuthorizationException;
035 import org.opends.server.admin.client.CommunicationException;
036 import org.opends.server.admin.client.ConcurrentModificationException;
037 import org.opends.server.admin.client.ManagedObject;
038 import org.opends.server.admin.client.MissingMandatoryPropertiesException;
039 import org.opends.server.admin.client.OperationRejectedException;
040 import org.opends.server.admin.ManagedObjectAlreadyExistsException;
041 import org.opends.server.admin.ManagedObjectDefinition;
042 import org.opends.server.admin.PropertyOption;
043 import org.opends.server.admin.PropertyProvider;
044 import org.opends.server.admin.server.ConfigurationChangeListener;
045 import org.opends.server.admin.server.ServerManagedObject;
046 import org.opends.server.admin.std.client.IdentityMapperCfgClient;
047 import org.opends.server.admin.std.server.IdentityMapperCfg;
048 import org.opends.server.admin.Tag;
049 import org.opends.server.admin.TopCfgDefn;
050 import org.opends.server.admin.UndefinedDefaultBehaviorProvider;
051 import org.opends.server.types.DN;
052
053
054
055 /**
056 * An interface for querying the Identity Mapper managed object
057 * definition meta information.
058 * <p>
059 * Identity Mappers are responsible for establishing a mapping between
060 * an identifier string provided by a client, and the entry for the
061 * user that corresponds to that identifier. Identity Mappers are used
062 * to process several SASL mechanisms to map an authorization ID (e.g.,
063 * a Kerberos principal when using GSSAPI) to a directory user. They
064 * are also used when processing requests with the proxied
065 * authorization control.
066 */
067 public final class IdentityMapperCfgDefn extends ManagedObjectDefinition<IdentityMapperCfgClient, IdentityMapperCfg> {
068
069 // The singleton configuration definition instance.
070 private static final IdentityMapperCfgDefn INSTANCE = new IdentityMapperCfgDefn();
071
072
073
074 // The "enabled" property definition.
075 private static final BooleanPropertyDefinition PD_ENABLED;
076
077
078
079 // The "java-class" property definition.
080 private static final ClassPropertyDefinition PD_JAVA_CLASS;
081
082
083
084 // Build the "enabled" property definition.
085 static {
086 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "enabled");
087 builder.setOption(PropertyOption.MANDATORY);
088 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "enabled"));
089 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<Boolean>());
090 PD_ENABLED = builder.getInstance();
091 INSTANCE.registerPropertyDefinition(PD_ENABLED);
092 }
093
094
095
096 // Build the "java-class" property definition.
097 static {
098 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
099 builder.setOption(PropertyOption.MANDATORY);
100 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class"));
101 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>());
102 builder.addInstanceOf("org.opends.server.api.IdentityMapper");
103 PD_JAVA_CLASS = builder.getInstance();
104 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
105 }
106
107
108
109 // Register the tags associated with this managed object definition.
110 static {
111 INSTANCE.registerTag(Tag.valueOf("security"));
112 INSTANCE.registerTag(Tag.valueOf("user-management"));
113 }
114
115
116
117 /**
118 * Get the Identity Mapper configuration definition singleton.
119 *
120 * @return Returns the Identity Mapper configuration definition
121 * singleton.
122 */
123 public static IdentityMapperCfgDefn getInstance() {
124 return INSTANCE;
125 }
126
127
128
129 /**
130 * Private constructor.
131 */
132 private IdentityMapperCfgDefn() {
133 super("identity-mapper", TopCfgDefn.getInstance());
134 }
135
136
137
138 /**
139 * {@inheritDoc}
140 */
141 public IdentityMapperCfgClient createClientConfiguration(
142 ManagedObject<? extends IdentityMapperCfgClient> impl) {
143 return new IdentityMapperCfgClientImpl(impl);
144 }
145
146
147
148 /**
149 * {@inheritDoc}
150 */
151 public IdentityMapperCfg createServerConfiguration(
152 ServerManagedObject<? extends IdentityMapperCfg> impl) {
153 return new IdentityMapperCfgServerImpl(impl);
154 }
155
156
157
158 /**
159 * {@inheritDoc}
160 */
161 public Class<IdentityMapperCfg> getServerConfigurationClass() {
162 return IdentityMapperCfg.class;
163 }
164
165
166
167 /**
168 * Get the "enabled" property definition.
169 * <p>
170 * Indicates whether the Identity Mapper is enabled for use.
171 *
172 * @return Returns the "enabled" property definition.
173 */
174 public BooleanPropertyDefinition getEnabledPropertyDefinition() {
175 return PD_ENABLED;
176 }
177
178
179
180 /**
181 * Get the "java-class" property definition.
182 * <p>
183 * Specifies the fully-qualified name of the Java class that
184 * provides the Identity Mapper implementation.
185 *
186 * @return Returns the "java-class" property definition.
187 */
188 public ClassPropertyDefinition getJavaClassPropertyDefinition() {
189 return PD_JAVA_CLASS;
190 }
191
192
193
194 /**
195 * Managed object client implementation.
196 */
197 private static class IdentityMapperCfgClientImpl implements
198 IdentityMapperCfgClient {
199
200 // Private implementation.
201 private ManagedObject<? extends IdentityMapperCfgClient> impl;
202
203
204
205 // Private constructor.
206 private IdentityMapperCfgClientImpl(
207 ManagedObject<? extends IdentityMapperCfgClient> impl) {
208 this.impl = impl;
209 }
210
211
212
213 /**
214 * {@inheritDoc}
215 */
216 public Boolean isEnabled() {
217 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
218 }
219
220
221
222 /**
223 * {@inheritDoc}
224 */
225 public void setEnabled(boolean value) {
226 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
227 }
228
229
230
231 /**
232 * {@inheritDoc}
233 */
234 public String getJavaClass() {
235 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
236 }
237
238
239
240 /**
241 * {@inheritDoc}
242 */
243 public void setJavaClass(String value) {
244 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
245 }
246
247
248
249 /**
250 * {@inheritDoc}
251 */
252 public ManagedObjectDefinition<? extends IdentityMapperCfgClient, ? extends IdentityMapperCfg> definition() {
253 return INSTANCE;
254 }
255
256
257
258 /**
259 * {@inheritDoc}
260 */
261 public PropertyProvider properties() {
262 return impl;
263 }
264
265
266
267 /**
268 * {@inheritDoc}
269 */
270 public void commit() throws ManagedObjectAlreadyExistsException,
271 MissingMandatoryPropertiesException, ConcurrentModificationException,
272 OperationRejectedException, AuthorizationException,
273 CommunicationException {
274 impl.commit();
275 }
276
277 }
278
279
280
281 /**
282 * Managed object server implementation.
283 */
284 private static class IdentityMapperCfgServerImpl implements
285 IdentityMapperCfg {
286
287 // Private implementation.
288 private ServerManagedObject<? extends IdentityMapperCfg> impl;
289
290 // The value of the "enabled" property.
291 private final boolean pEnabled;
292
293 // The value of the "java-class" property.
294 private final String pJavaClass;
295
296
297
298 // Private constructor.
299 private IdentityMapperCfgServerImpl(ServerManagedObject<? extends IdentityMapperCfg> impl) {
300 this.impl = impl;
301 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
302 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
303 }
304
305
306
307 /**
308 * {@inheritDoc}
309 */
310 public void addChangeListener(
311 ConfigurationChangeListener<IdentityMapperCfg> listener) {
312 impl.registerChangeListener(listener);
313 }
314
315
316
317 /**
318 * {@inheritDoc}
319 */
320 public void removeChangeListener(
321 ConfigurationChangeListener<IdentityMapperCfg> listener) {
322 impl.deregisterChangeListener(listener);
323 }
324
325
326
327 /**
328 * {@inheritDoc}
329 */
330 public boolean isEnabled() {
331 return pEnabled;
332 }
333
334
335
336 /**
337 * {@inheritDoc}
338 */
339 public String getJavaClass() {
340 return pJavaClass;
341 }
342
343
344
345 /**
346 * {@inheritDoc}
347 */
348 public Class<? extends IdentityMapperCfg> configurationClass() {
349 return IdentityMapperCfg.class;
350 }
351
352
353
354 /**
355 * {@inheritDoc}
356 */
357 public DN dn() {
358 return impl.getDN();
359 }
360
361 }
362 }