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 legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2008 Sun Microsystems, Inc. 025 */ 026package org.forgerock.opendj.server.config.meta; 027 028 029 030import org.forgerock.opendj.config.AdministratorAction; 031import org.forgerock.opendj.config.BooleanPropertyDefinition; 032import org.forgerock.opendj.config.ClassPropertyDefinition; 033import org.forgerock.opendj.config.client.ConcurrentModificationException; 034import org.forgerock.opendj.config.client.ManagedObject; 035import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException; 036import org.forgerock.opendj.config.client.OperationRejectedException; 037import org.forgerock.opendj.config.DefaultBehaviorProvider; 038import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider; 039import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException; 040import org.forgerock.opendj.config.ManagedObjectDefinition; 041import org.forgerock.opendj.config.PropertyOption; 042import org.forgerock.opendj.config.PropertyProvider; 043import org.forgerock.opendj.config.server.ConfigurationChangeListener; 044import org.forgerock.opendj.config.server.ServerManagedObject; 045import org.forgerock.opendj.config.Tag; 046import org.forgerock.opendj.ldap.DN; 047import org.forgerock.opendj.ldap.LdapException; 048import org.forgerock.opendj.server.config.client.StaticGroupImplementationCfgClient; 049import org.forgerock.opendj.server.config.server.GroupImplementationCfg; 050import org.forgerock.opendj.server.config.server.StaticGroupImplementationCfg; 051 052 053 054/** 055 * An interface for querying the Static Group Implementation managed 056 * object definition meta information. 057 * <p> 058 * The Static Group Implementation provides a grouping mechanism in 059 * which the group membership is based on an explicit list of the DNs 060 * of the users that are members of the group. 061 */ 062public final class StaticGroupImplementationCfgDefn extends ManagedObjectDefinition<StaticGroupImplementationCfgClient, StaticGroupImplementationCfg> { 063 064 /** The singleton configuration definition instance. */ 065 private static final StaticGroupImplementationCfgDefn INSTANCE = new StaticGroupImplementationCfgDefn(); 066 067 068 069 /** The "java-class" property definition. */ 070 private static final ClassPropertyDefinition PD_JAVA_CLASS; 071 072 073 074 /** Build the "java-class" property definition. */ 075 static { 076 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 077 builder.setOption(PropertyOption.MANDATORY); 078 builder.setOption(PropertyOption.ADVANCED); 079 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class")); 080 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.extensions.StaticGroup"); 081 builder.setDefaultBehaviorProvider(provider); 082 builder.addInstanceOf("org.opends.server.api.Group"); 083 PD_JAVA_CLASS = builder.getInstance(); 084 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 085 } 086 087 088 089 // Register the tags associated with this managed object definition. 090 static { 091 INSTANCE.registerTag(Tag.valueOf("core-server")); 092 } 093 094 095 096 /** 097 * Get the Static Group Implementation configuration definition 098 * singleton. 099 * 100 * @return Returns the Static Group Implementation configuration 101 * definition singleton. 102 */ 103 public static StaticGroupImplementationCfgDefn getInstance() { 104 return INSTANCE; 105 } 106 107 108 109 /** 110 * Private constructor. 111 */ 112 private StaticGroupImplementationCfgDefn() { 113 super("static-group-implementation", GroupImplementationCfgDefn.getInstance()); 114 } 115 116 117 118 /** {@inheritDoc} */ 119 public StaticGroupImplementationCfgClient createClientConfiguration( 120 ManagedObject<? extends StaticGroupImplementationCfgClient> impl) { 121 return new StaticGroupImplementationCfgClientImpl(impl); 122 } 123 124 125 126 /** {@inheritDoc} */ 127 public StaticGroupImplementationCfg createServerConfiguration( 128 ServerManagedObject<? extends StaticGroupImplementationCfg> impl) { 129 return new StaticGroupImplementationCfgServerImpl(impl); 130 } 131 132 133 134 /** {@inheritDoc} */ 135 public Class<StaticGroupImplementationCfg> getServerConfigurationClass() { 136 return StaticGroupImplementationCfg.class; 137 } 138 139 140 141 /** 142 * Get the "enabled" property definition. 143 * <p> 144 * Indicates whether the Static Group Implementation is enabled. 145 * 146 * @return Returns the "enabled" property definition. 147 */ 148 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 149 return GroupImplementationCfgDefn.getInstance().getEnabledPropertyDefinition(); 150 } 151 152 153 154 /** 155 * Get the "java-class" property definition. 156 * <p> 157 * Specifies the fully-qualified name of the Java class that 158 * provides the Static Group Implementation implementation. 159 * 160 * @return Returns the "java-class" property definition. 161 */ 162 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 163 return PD_JAVA_CLASS; 164 } 165 166 167 168 /** 169 * Managed object client implementation. 170 */ 171 private static class StaticGroupImplementationCfgClientImpl implements 172 StaticGroupImplementationCfgClient { 173 174 /** Private implementation. */ 175 private ManagedObject<? extends StaticGroupImplementationCfgClient> impl; 176 177 178 179 /** Private constructor. */ 180 private StaticGroupImplementationCfgClientImpl( 181 ManagedObject<? extends StaticGroupImplementationCfgClient> impl) { 182 this.impl = impl; 183 } 184 185 186 187 /** {@inheritDoc} */ 188 public Boolean isEnabled() { 189 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 190 } 191 192 193 194 /** {@inheritDoc} */ 195 public void setEnabled(boolean value) { 196 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 197 } 198 199 200 201 /** {@inheritDoc} */ 202 public String getJavaClass() { 203 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 204 } 205 206 207 208 /** {@inheritDoc} */ 209 public void setJavaClass(String value) { 210 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 211 } 212 213 214 215 /** {@inheritDoc} */ 216 public ManagedObjectDefinition<? extends StaticGroupImplementationCfgClient, ? extends StaticGroupImplementationCfg> definition() { 217 return INSTANCE; 218 } 219 220 221 222 /** {@inheritDoc} */ 223 public PropertyProvider properties() { 224 return impl; 225 } 226 227 228 229 /** {@inheritDoc} */ 230 public void commit() throws ManagedObjectAlreadyExistsException, 231 MissingMandatoryPropertiesException, ConcurrentModificationException, 232 OperationRejectedException, LdapException { 233 impl.commit(); 234 } 235 236 237 238 /** {@inheritDoc} */ 239 public String toString() { 240 return impl.toString(); 241 } 242 } 243 244 245 246 /** 247 * Managed object server implementation. 248 */ 249 private static class StaticGroupImplementationCfgServerImpl implements 250 StaticGroupImplementationCfg { 251 252 /** Private implementation. */ 253 private ServerManagedObject<? extends StaticGroupImplementationCfg> impl; 254 255 /** The value of the "enabled" property. */ 256 private final boolean pEnabled; 257 258 /** The value of the "java-class" property. */ 259 private final String pJavaClass; 260 261 262 263 /** Private constructor. */ 264 private StaticGroupImplementationCfgServerImpl(ServerManagedObject<? extends StaticGroupImplementationCfg> impl) { 265 this.impl = impl; 266 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 267 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 268 } 269 270 271 272 /** {@inheritDoc} */ 273 public void addStaticChangeListener( 274 ConfigurationChangeListener<StaticGroupImplementationCfg> listener) { 275 impl.registerChangeListener(listener); 276 } 277 278 279 280 /** {@inheritDoc} */ 281 public void removeStaticChangeListener( 282 ConfigurationChangeListener<StaticGroupImplementationCfg> listener) { 283 impl.deregisterChangeListener(listener); 284 } 285 /** {@inheritDoc} */ 286 public void addChangeListener( 287 ConfigurationChangeListener<GroupImplementationCfg> listener) { 288 impl.registerChangeListener(listener); 289 } 290 291 292 293 /** {@inheritDoc} */ 294 public void removeChangeListener( 295 ConfigurationChangeListener<GroupImplementationCfg> listener) { 296 impl.deregisterChangeListener(listener); 297 } 298 299 300 301 /** {@inheritDoc} */ 302 public boolean isEnabled() { 303 return pEnabled; 304 } 305 306 307 308 /** {@inheritDoc} */ 309 public String getJavaClass() { 310 return pJavaClass; 311 } 312 313 314 315 /** {@inheritDoc} */ 316 public Class<? extends StaticGroupImplementationCfg> configurationClass() { 317 return StaticGroupImplementationCfg.class; 318 } 319 320 321 322 /** {@inheritDoc} */ 323 public DN dn() { 324 return impl.getDN(); 325 } 326 327 328 329 /** {@inheritDoc} */ 330 public String toString() { 331 return impl.toString(); 332 } 333 } 334}