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.opends.server.admin.std.meta; 027 028 029 030import java.util.Collection; 031import java.util.SortedSet; 032import org.opends.server.admin.ACIPropertyDefinition; 033import org.opends.server.admin.AdministratorAction; 034import org.opends.server.admin.AliasDefaultBehaviorProvider; 035import org.opends.server.admin.BooleanPropertyDefinition; 036import org.opends.server.admin.ClassPropertyDefinition; 037import org.opends.server.admin.client.AuthorizationException; 038import org.opends.server.admin.client.CommunicationException; 039import org.opends.server.admin.client.ConcurrentModificationException; 040import org.opends.server.admin.client.ManagedObject; 041import org.opends.server.admin.client.MissingMandatoryPropertiesException; 042import org.opends.server.admin.client.OperationRejectedException; 043import org.opends.server.admin.DefaultBehaviorProvider; 044import org.opends.server.admin.DefinedDefaultBehaviorProvider; 045import org.opends.server.admin.ManagedObjectAlreadyExistsException; 046import org.opends.server.admin.ManagedObjectDefinition; 047import org.opends.server.admin.PropertyOption; 048import org.opends.server.admin.PropertyProvider; 049import org.opends.server.admin.server.ConfigurationChangeListener; 050import org.opends.server.admin.server.ServerManagedObject; 051import org.opends.server.admin.std.client.DseeCompatAccessControlHandlerCfgClient; 052import org.opends.server.admin.std.server.AccessControlHandlerCfg; 053import org.opends.server.admin.std.server.DseeCompatAccessControlHandlerCfg; 054import org.opends.server.admin.Tag; 055import org.opends.server.authorization.dseecompat.Aci; 056import org.opends.server.types.DN; 057 058 059 060/** 061 * An interface for querying the Dsee Compat Access Control Handler 062 * managed object definition meta information. 063 * <p> 064 * The Dsee Compat Access Control Handler provides an implementation 065 * that uses syntax compatible with the Sun Java System Directory 066 * Server Enterprise Edition access control handlers. 067 */ 068public final class DseeCompatAccessControlHandlerCfgDefn extends ManagedObjectDefinition<DseeCompatAccessControlHandlerCfgClient, DseeCompatAccessControlHandlerCfg> { 069 070 // The singleton configuration definition instance. 071 private static final DseeCompatAccessControlHandlerCfgDefn INSTANCE = new DseeCompatAccessControlHandlerCfgDefn(); 072 073 074 075 // The "global-aci" property definition. 076 private static final ACIPropertyDefinition PD_GLOBAL_ACI; 077 078 079 080 // The "java-class" property definition. 081 private static final ClassPropertyDefinition PD_JAVA_CLASS; 082 083 084 085 // Build the "global-aci" property definition. 086 static { 087 ACIPropertyDefinition.Builder builder = ACIPropertyDefinition.createBuilder(INSTANCE, "global-aci"); 088 builder.setOption(PropertyOption.MULTI_VALUED); 089 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "global-aci")); 090 builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<Aci>(INSTANCE, "global-aci")); 091 PD_GLOBAL_ACI = builder.getInstance(); 092 INSTANCE.registerPropertyDefinition(PD_GLOBAL_ACI); 093 } 094 095 096 097 // Build the "java-class" property definition. 098 static { 099 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 100 builder.setOption(PropertyOption.MANDATORY); 101 builder.setOption(PropertyOption.ADVANCED); 102 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "java-class")); 103 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.authorization.dseecompat.AciHandler"); 104 builder.setDefaultBehaviorProvider(provider); 105 builder.addInstanceOf("org.opends.server.api.AccessControlHandler"); 106 PD_JAVA_CLASS = builder.getInstance(); 107 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 108 } 109 110 111 112 // Register the tags associated with this managed object definition. 113 static { 114 INSTANCE.registerTag(Tag.valueOf("security")); 115 } 116 117 118 119 /** 120 * Get the Dsee Compat Access Control Handler configuration 121 * definition singleton. 122 * 123 * @return Returns the Dsee Compat Access Control Handler 124 * configuration definition singleton. 125 */ 126 public static DseeCompatAccessControlHandlerCfgDefn getInstance() { 127 return INSTANCE; 128 } 129 130 131 132 /** 133 * Private constructor. 134 */ 135 private DseeCompatAccessControlHandlerCfgDefn() { 136 super("dsee-compat-access-control-handler", AccessControlHandlerCfgDefn.getInstance()); 137 } 138 139 140 141 /** 142 * {@inheritDoc} 143 */ 144 public DseeCompatAccessControlHandlerCfgClient createClientConfiguration( 145 ManagedObject<? extends DseeCompatAccessControlHandlerCfgClient> impl) { 146 return new DseeCompatAccessControlHandlerCfgClientImpl(impl); 147 } 148 149 150 151 /** 152 * {@inheritDoc} 153 */ 154 public DseeCompatAccessControlHandlerCfg createServerConfiguration( 155 ServerManagedObject<? extends DseeCompatAccessControlHandlerCfg> impl) { 156 return new DseeCompatAccessControlHandlerCfgServerImpl(impl); 157 } 158 159 160 161 /** 162 * {@inheritDoc} 163 */ 164 public Class<DseeCompatAccessControlHandlerCfg> getServerConfigurationClass() { 165 return DseeCompatAccessControlHandlerCfg.class; 166 } 167 168 169 170 /** 171 * Get the "enabled" property definition. 172 * <p> 173 * Indicates whether the Dsee Compat Access Control Handler is 174 * enabled. If set to FALSE, then no access control is enforced, and 175 * any client (including unauthenticated or anonymous clients) could 176 * be allowed to perform any operation if not subject to other 177 * restrictions, such as those enforced by the privilege subsystem. 178 * 179 * @return Returns the "enabled" property definition. 180 */ 181 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 182 return AccessControlHandlerCfgDefn.getInstance().getEnabledPropertyDefinition(); 183 } 184 185 186 187 /** 188 * Get the "global-aci" property definition. 189 * <p> 190 * Defines global access control rules. 191 * <p> 192 * Global access control rules apply to all entries anywhere in the 193 * data managed by the OpenDJ directory server. The global access 194 * control rules may be overridden by more specific access control 195 * rules placed in the data. 196 * 197 * @return Returns the "global-aci" property definition. 198 */ 199 public ACIPropertyDefinition getGlobalACIPropertyDefinition() { 200 return PD_GLOBAL_ACI; 201 } 202 203 204 205 /** 206 * Get the "java-class" property definition. 207 * <p> 208 * Specifies the fully-qualified name of the Java class that 209 * provides the Dsee Compat Access Control Handler implementation. 210 * 211 * @return Returns the "java-class" property definition. 212 */ 213 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 214 return PD_JAVA_CLASS; 215 } 216 217 218 219 /** 220 * Managed object client implementation. 221 */ 222 private static class DseeCompatAccessControlHandlerCfgClientImpl implements 223 DseeCompatAccessControlHandlerCfgClient { 224 225 // Private implementation. 226 private ManagedObject<? extends DseeCompatAccessControlHandlerCfgClient> impl; 227 228 229 230 // Private constructor. 231 private DseeCompatAccessControlHandlerCfgClientImpl( 232 ManagedObject<? extends DseeCompatAccessControlHandlerCfgClient> impl) { 233 this.impl = impl; 234 } 235 236 237 238 /** 239 * {@inheritDoc} 240 */ 241 public Boolean isEnabled() { 242 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 243 } 244 245 246 247 /** 248 * {@inheritDoc} 249 */ 250 public void setEnabled(boolean value) { 251 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 252 } 253 254 255 256 /** 257 * {@inheritDoc} 258 */ 259 public SortedSet<Aci> getGlobalACI() { 260 return impl.getPropertyValues(INSTANCE.getGlobalACIPropertyDefinition()); 261 } 262 263 264 265 /** 266 * {@inheritDoc} 267 */ 268 public void setGlobalACI(Collection<Aci> values) { 269 impl.setPropertyValues(INSTANCE.getGlobalACIPropertyDefinition(), values); 270 } 271 272 273 274 /** 275 * {@inheritDoc} 276 */ 277 public String getJavaClass() { 278 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 279 } 280 281 282 283 /** 284 * {@inheritDoc} 285 */ 286 public void setJavaClass(String value) { 287 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 288 } 289 290 291 292 /** 293 * {@inheritDoc} 294 */ 295 public ManagedObjectDefinition<? extends DseeCompatAccessControlHandlerCfgClient, ? extends DseeCompatAccessControlHandlerCfg> definition() { 296 return INSTANCE; 297 } 298 299 300 301 /** 302 * {@inheritDoc} 303 */ 304 public PropertyProvider properties() { 305 return impl; 306 } 307 308 309 310 /** 311 * {@inheritDoc} 312 */ 313 public void commit() throws ManagedObjectAlreadyExistsException, 314 MissingMandatoryPropertiesException, ConcurrentModificationException, 315 OperationRejectedException, AuthorizationException, 316 CommunicationException { 317 impl.commit(); 318 } 319 320 321 322 /** {@inheritDoc} */ 323 public String toString() { 324 return impl.toString(); 325 } 326 } 327 328 329 330 /** 331 * Managed object server implementation. 332 */ 333 private static class DseeCompatAccessControlHandlerCfgServerImpl implements 334 DseeCompatAccessControlHandlerCfg { 335 336 // Private implementation. 337 private ServerManagedObject<? extends DseeCompatAccessControlHandlerCfg> impl; 338 339 // The value of the "enabled" property. 340 private final boolean pEnabled; 341 342 // The value of the "global-aci" property. 343 private final SortedSet<Aci> pGlobalACI; 344 345 // The value of the "java-class" property. 346 private final String pJavaClass; 347 348 349 350 // Private constructor. 351 private DseeCompatAccessControlHandlerCfgServerImpl(ServerManagedObject<? extends DseeCompatAccessControlHandlerCfg> impl) { 352 this.impl = impl; 353 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 354 this.pGlobalACI = impl.getPropertyValues(INSTANCE.getGlobalACIPropertyDefinition()); 355 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 356 } 357 358 359 360 /** 361 * {@inheritDoc} 362 */ 363 public void addDseeCompatChangeListener( 364 ConfigurationChangeListener<DseeCompatAccessControlHandlerCfg> listener) { 365 impl.registerChangeListener(listener); 366 } 367 368 369 370 /** 371 * {@inheritDoc} 372 */ 373 public void removeDseeCompatChangeListener( 374 ConfigurationChangeListener<DseeCompatAccessControlHandlerCfg> listener) { 375 impl.deregisterChangeListener(listener); 376 } 377 /** 378 * {@inheritDoc} 379 */ 380 public void addChangeListener( 381 ConfigurationChangeListener<AccessControlHandlerCfg> listener) { 382 impl.registerChangeListener(listener); 383 } 384 385 386 387 /** 388 * {@inheritDoc} 389 */ 390 public void removeChangeListener( 391 ConfigurationChangeListener<AccessControlHandlerCfg> listener) { 392 impl.deregisterChangeListener(listener); 393 } 394 395 396 397 /** 398 * {@inheritDoc} 399 */ 400 public boolean isEnabled() { 401 return pEnabled; 402 } 403 404 405 406 /** 407 * {@inheritDoc} 408 */ 409 public SortedSet<Aci> getGlobalACI() { 410 return pGlobalACI; 411 } 412 413 414 415 /** 416 * {@inheritDoc} 417 */ 418 public String getJavaClass() { 419 return pJavaClass; 420 } 421 422 423 424 /** 425 * {@inheritDoc} 426 */ 427 public Class<? extends DseeCompatAccessControlHandlerCfg> configurationClass() { 428 return DseeCompatAccessControlHandlerCfg.class; 429 } 430 431 432 433 /** 434 * {@inheritDoc} 435 */ 436 public DN dn() { 437 return impl.getDN(); 438 } 439 440 441 442 /** {@inheritDoc} */ 443 public String toString() { 444 return impl.toString(); 445 } 446 } 447}