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