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 java.util.Collection; 021import org.forgerock.opendj.config.AdministratorAction; 022import org.forgerock.opendj.config.BooleanPropertyDefinition; 023import org.forgerock.opendj.config.ClassPropertyDefinition; 024import org.forgerock.opendj.config.client.ConcurrentModificationException; 025import org.forgerock.opendj.config.client.IllegalManagedObjectNameException; 026import org.forgerock.opendj.config.client.ManagedObject; 027import org.forgerock.opendj.config.client.ManagedObjectDecodingException; 028import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException; 029import org.forgerock.opendj.config.client.OperationRejectedException; 030import org.forgerock.opendj.config.DefaultBehaviorProvider; 031import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider; 032import org.forgerock.opendj.config.DefinitionDecodingException; 033import org.forgerock.opendj.config.EnumPropertyDefinition; 034import org.forgerock.opendj.config.InstantiableRelationDefinition; 035import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException; 036import org.forgerock.opendj.config.ManagedObjectDefinition; 037import org.forgerock.opendj.config.ManagedObjectNotFoundException; 038import org.forgerock.opendj.config.PropertyException; 039import org.forgerock.opendj.config.PropertyOption; 040import org.forgerock.opendj.config.PropertyProvider; 041import org.forgerock.opendj.config.server.ConfigException; 042import org.forgerock.opendj.config.server.ConfigurationAddListener; 043import org.forgerock.opendj.config.server.ConfigurationChangeListener; 044import org.forgerock.opendj.config.server.ConfigurationDeleteListener; 045import org.forgerock.opendj.config.server.ServerManagedObject; 046import org.forgerock.opendj.config.StringPropertyDefinition; 047import org.forgerock.opendj.config.Tag; 048import org.forgerock.opendj.config.UndefinedDefaultBehaviorProvider; 049import org.forgerock.opendj.ldap.DN; 050import org.forgerock.opendj.ldap.LdapException; 051import org.forgerock.opendj.server.config.client.AccessLogFilteringCriteriaCfgClient; 052import org.forgerock.opendj.server.config.client.ExternalAccessLogPublisherCfgClient; 053import org.forgerock.opendj.server.config.meta.AccessLogPublisherCfgDefn.FilteringPolicy; 054import org.forgerock.opendj.server.config.server.AccessLogFilteringCriteriaCfg; 055import org.forgerock.opendj.server.config.server.AccessLogPublisherCfg; 056import org.forgerock.opendj.server.config.server.ExternalAccessLogPublisherCfg; 057import org.forgerock.opendj.server.config.server.LogPublisherCfg; 058 059 060 061/** 062 * An interface for querying the External Access Log Publisher managed 063 * object definition meta information. 064 * <p> 065 * External Access Log Publishers publish access messages to an 066 * external handler. 067 */ 068public final class ExternalAccessLogPublisherCfgDefn extends ManagedObjectDefinition<ExternalAccessLogPublisherCfgClient, ExternalAccessLogPublisherCfg> { 069 070 /** The singleton configuration definition instance. */ 071 private static final ExternalAccessLogPublisherCfgDefn INSTANCE = new ExternalAccessLogPublisherCfgDefn(); 072 073 074 075 /** The "config-file" property definition. */ 076 private static final StringPropertyDefinition PD_CONFIG_FILE; 077 078 079 080 /** The "java-class" property definition. */ 081 private static final ClassPropertyDefinition PD_JAVA_CLASS; 082 083 084 085 /** The "log-control-oids" property definition. */ 086 private static final BooleanPropertyDefinition PD_LOG_CONTROL_OIDS; 087 088 089 090 /** Build the "config-file" property definition. */ 091 static { 092 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "config-file"); 093 builder.setOption(PropertyOption.MANDATORY); 094 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "config-file")); 095 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 096 builder.setPattern(".*", "FILE"); 097 PD_CONFIG_FILE = builder.getInstance(); 098 INSTANCE.registerPropertyDefinition(PD_CONFIG_FILE); 099 } 100 101 102 103 /** Build the "java-class" property definition. */ 104 static { 105 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 106 builder.setOption(PropertyOption.MANDATORY); 107 builder.setOption(PropertyOption.ADVANCED); 108 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class")); 109 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.loggers.ExternalAccessLogPublisher"); 110 builder.setDefaultBehaviorProvider(provider); 111 builder.addInstanceOf("org.opends.server.loggers.LogPublisher"); 112 PD_JAVA_CLASS = builder.getInstance(); 113 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 114 } 115 116 117 118 /** Build the "log-control-oids" property definition. */ 119 static { 120 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "log-control-oids"); 121 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "log-control-oids")); 122 DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false"); 123 builder.setDefaultBehaviorProvider(provider); 124 PD_LOG_CONTROL_OIDS = builder.getInstance(); 125 INSTANCE.registerPropertyDefinition(PD_LOG_CONTROL_OIDS); 126 } 127 128 129 130 // Register the tags associated with this managed object definition. 131 static { 132 INSTANCE.registerTag(Tag.valueOf("logging")); 133 } 134 135 136 137 /** 138 * Get the External Access Log Publisher configuration definition 139 * singleton. 140 * 141 * @return Returns the External Access Log Publisher configuration 142 * definition singleton. 143 */ 144 public static ExternalAccessLogPublisherCfgDefn getInstance() { 145 return INSTANCE; 146 } 147 148 149 150 /** 151 * Private constructor. 152 */ 153 private ExternalAccessLogPublisherCfgDefn() { 154 super("external-access-log-publisher", AccessLogPublisherCfgDefn.getInstance()); 155 } 156 157 158 159 /** {@inheritDoc} */ 160 public ExternalAccessLogPublisherCfgClient createClientConfiguration( 161 ManagedObject<? extends ExternalAccessLogPublisherCfgClient> impl) { 162 return new ExternalAccessLogPublisherCfgClientImpl(impl); 163 } 164 165 166 167 /** {@inheritDoc} */ 168 public ExternalAccessLogPublisherCfg createServerConfiguration( 169 ServerManagedObject<? extends ExternalAccessLogPublisherCfg> impl) { 170 return new ExternalAccessLogPublisherCfgServerImpl(impl); 171 } 172 173 174 175 /** {@inheritDoc} */ 176 public Class<ExternalAccessLogPublisherCfg> getServerConfigurationClass() { 177 return ExternalAccessLogPublisherCfg.class; 178 } 179 180 181 182 /** 183 * Get the "config-file" property definition. 184 * <p> 185 * The JSON configuration file that defines the External Access Log 186 * Publisher. The content of the JSON configuration file depends on 187 * the type of external audit event handler. The path to the file is 188 * relative to the server root. 189 * 190 * @return Returns the "config-file" property definition. 191 */ 192 public StringPropertyDefinition getConfigFilePropertyDefinition() { 193 return PD_CONFIG_FILE; 194 } 195 196 197 198 /** 199 * Get the "enabled" property definition. 200 * <p> 201 * Indicates whether the External Access Log Publisher is enabled 202 * for use. 203 * 204 * @return Returns the "enabled" property definition. 205 */ 206 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 207 return AccessLogPublisherCfgDefn.getInstance().getEnabledPropertyDefinition(); 208 } 209 210 211 212 /** 213 * Get the "filtering-policy" property definition. 214 * <p> 215 * Specifies how filtering criteria should be applied to log 216 * records. 217 * 218 * @return Returns the "filtering-policy" property definition. 219 */ 220 public EnumPropertyDefinition<FilteringPolicy> getFilteringPolicyPropertyDefinition() { 221 return AccessLogPublisherCfgDefn.getInstance().getFilteringPolicyPropertyDefinition(); 222 } 223 224 225 226 /** 227 * Get the "java-class" property definition. 228 * <p> 229 * The fully-qualified name of the Java class that provides the 230 * External Access Log Publisher implementation. 231 * 232 * @return Returns the "java-class" property definition. 233 */ 234 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 235 return PD_JAVA_CLASS; 236 } 237 238 239 240 /** 241 * Get the "log-control-oids" property definition. 242 * <p> 243 * Specifies whether control OIDs will be included in operation log 244 * records. 245 * 246 * @return Returns the "log-control-oids" property definition. 247 */ 248 public BooleanPropertyDefinition getLogControlOidsPropertyDefinition() { 249 return PD_LOG_CONTROL_OIDS; 250 } 251 252 253 254 /** 255 * Get the "suppress-internal-operations" property definition. 256 * <p> 257 * Indicates whether internal operations (for example, operations 258 * that are initiated by plugins) should be logged along with the 259 * operations that are requested by users. 260 * 261 * @return Returns the "suppress-internal-operations" property definition. 262 */ 263 public BooleanPropertyDefinition getSuppressInternalOperationsPropertyDefinition() { 264 return AccessLogPublisherCfgDefn.getInstance().getSuppressInternalOperationsPropertyDefinition(); 265 } 266 267 268 269 /** 270 * Get the "suppress-synchronization-operations" property definition. 271 * <p> 272 * Indicates whether access messages that are generated by 273 * synchronization operations should be suppressed. 274 * 275 * @return Returns the "suppress-synchronization-operations" property definition. 276 */ 277 public BooleanPropertyDefinition getSuppressSynchronizationOperationsPropertyDefinition() { 278 return AccessLogPublisherCfgDefn.getInstance().getSuppressSynchronizationOperationsPropertyDefinition(); 279 } 280 281 282 283 /** 284 * Get the "access-log-filtering-criteria" relation definition. 285 * 286 * @return Returns the "access-log-filtering-criteria" relation definition. 287 */ 288 public InstantiableRelationDefinition<AccessLogFilteringCriteriaCfgClient,AccessLogFilteringCriteriaCfg> getAccessLogFilteringCriteriaRelationDefinition() { 289 return AccessLogPublisherCfgDefn.getInstance().getAccessLogFilteringCriteriaRelationDefinition(); 290 } 291 292 293 294 /** 295 * Managed object client implementation. 296 */ 297 private static class ExternalAccessLogPublisherCfgClientImpl implements 298 ExternalAccessLogPublisherCfgClient { 299 300 /** Private implementation. */ 301 private ManagedObject<? extends ExternalAccessLogPublisherCfgClient> impl; 302 303 304 305 /** Private constructor. */ 306 private ExternalAccessLogPublisherCfgClientImpl( 307 ManagedObject<? extends ExternalAccessLogPublisherCfgClient> impl) { 308 this.impl = impl; 309 } 310 311 312 313 /** {@inheritDoc} */ 314 public String getConfigFile() { 315 return impl.getPropertyValue(INSTANCE.getConfigFilePropertyDefinition()); 316 } 317 318 319 320 /** {@inheritDoc} */ 321 public void setConfigFile(String value) { 322 impl.setPropertyValue(INSTANCE.getConfigFilePropertyDefinition(), value); 323 } 324 325 326 327 /** {@inheritDoc} */ 328 public Boolean isEnabled() { 329 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 330 } 331 332 333 334 /** {@inheritDoc} */ 335 public void setEnabled(boolean value) { 336 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 337 } 338 339 340 341 /** {@inheritDoc} */ 342 public FilteringPolicy getFilteringPolicy() { 343 return impl.getPropertyValue(INSTANCE.getFilteringPolicyPropertyDefinition()); 344 } 345 346 347 348 /** {@inheritDoc} */ 349 public void setFilteringPolicy(FilteringPolicy value) { 350 impl.setPropertyValue(INSTANCE.getFilteringPolicyPropertyDefinition(), value); 351 } 352 353 354 355 /** {@inheritDoc} */ 356 public String getJavaClass() { 357 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 358 } 359 360 361 362 /** {@inheritDoc} */ 363 public void setJavaClass(String value) { 364 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 365 } 366 367 368 369 /** {@inheritDoc} */ 370 public boolean isLogControlOids() { 371 return impl.getPropertyValue(INSTANCE.getLogControlOidsPropertyDefinition()); 372 } 373 374 375 376 /** {@inheritDoc} */ 377 public void setLogControlOids(Boolean value) { 378 impl.setPropertyValue(INSTANCE.getLogControlOidsPropertyDefinition(), value); 379 } 380 381 382 383 /** {@inheritDoc} */ 384 public boolean isSuppressInternalOperations() { 385 return impl.getPropertyValue(INSTANCE.getSuppressInternalOperationsPropertyDefinition()); 386 } 387 388 389 390 /** {@inheritDoc} */ 391 public void setSuppressInternalOperations(Boolean value) { 392 impl.setPropertyValue(INSTANCE.getSuppressInternalOperationsPropertyDefinition(), value); 393 } 394 395 396 397 /** {@inheritDoc} */ 398 public boolean isSuppressSynchronizationOperations() { 399 return impl.getPropertyValue(INSTANCE.getSuppressSynchronizationOperationsPropertyDefinition()); 400 } 401 402 403 404 /** {@inheritDoc} */ 405 public void setSuppressSynchronizationOperations(Boolean value) { 406 impl.setPropertyValue(INSTANCE.getSuppressSynchronizationOperationsPropertyDefinition(), value); 407 } 408 409 410 411 /** {@inheritDoc} */ 412 public String[] listAccessLogFilteringCriteria() throws ConcurrentModificationException, 413 LdapException { 414 return impl.listChildren(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition()); 415 } 416 417 418 419 /** {@inheritDoc} */ 420 public AccessLogFilteringCriteriaCfgClient getAccessLogFilteringCriteria(String name) 421 throws DefinitionDecodingException, ManagedObjectDecodingException, 422 ManagedObjectNotFoundException, ConcurrentModificationException, 423 LdapException { 424 return impl.getChild(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition(), name).getConfiguration(); 425 } 426 427 428 429 /** {@inheritDoc} */ 430 public <M extends AccessLogFilteringCriteriaCfgClient> M createAccessLogFilteringCriteria( 431 ManagedObjectDefinition<M, ? extends AccessLogFilteringCriteriaCfg> d, String name, Collection<PropertyException> exceptions) throws IllegalManagedObjectNameException { 432 return impl.createChild(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition(), d, name, exceptions).getConfiguration(); 433 } 434 435 436 437 /** {@inheritDoc} */ 438 public void removeAccessLogFilteringCriteria(String name) 439 throws ManagedObjectNotFoundException, ConcurrentModificationException, 440 OperationRejectedException, LdapException { 441 impl.removeChild(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition(), name); 442 } 443 444 445 446 /** {@inheritDoc} */ 447 public ManagedObjectDefinition<? extends ExternalAccessLogPublisherCfgClient, ? extends ExternalAccessLogPublisherCfg> definition() { 448 return INSTANCE; 449 } 450 451 452 453 /** {@inheritDoc} */ 454 public PropertyProvider properties() { 455 return impl; 456 } 457 458 459 460 /** {@inheritDoc} */ 461 public void commit() throws ManagedObjectAlreadyExistsException, 462 MissingMandatoryPropertiesException, ConcurrentModificationException, 463 OperationRejectedException, LdapException { 464 impl.commit(); 465 } 466 467 468 469 /** {@inheritDoc} */ 470 public String toString() { 471 return impl.toString(); 472 } 473 } 474 475 476 477 /** 478 * Managed object server implementation. 479 */ 480 private static class ExternalAccessLogPublisherCfgServerImpl implements 481 ExternalAccessLogPublisherCfg { 482 483 /** Private implementation. */ 484 private ServerManagedObject<? extends ExternalAccessLogPublisherCfg> impl; 485 486 /** The value of the "config-file" property. */ 487 private final String pConfigFile; 488 489 /** The value of the "enabled" property. */ 490 private final boolean pEnabled; 491 492 /** The value of the "filtering-policy" property. */ 493 private final FilteringPolicy pFilteringPolicy; 494 495 /** The value of the "java-class" property. */ 496 private final String pJavaClass; 497 498 /** The value of the "log-control-oids" property. */ 499 private final boolean pLogControlOids; 500 501 /** The value of the "suppress-internal-operations" property. */ 502 private final boolean pSuppressInternalOperations; 503 504 /** The value of the "suppress-synchronization-operations" property. */ 505 private final boolean pSuppressSynchronizationOperations; 506 507 508 509 /** Private constructor. */ 510 private ExternalAccessLogPublisherCfgServerImpl(ServerManagedObject<? extends ExternalAccessLogPublisherCfg> impl) { 511 this.impl = impl; 512 this.pConfigFile = impl.getPropertyValue(INSTANCE.getConfigFilePropertyDefinition()); 513 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 514 this.pFilteringPolicy = impl.getPropertyValue(INSTANCE.getFilteringPolicyPropertyDefinition()); 515 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 516 this.pLogControlOids = impl.getPropertyValue(INSTANCE.getLogControlOidsPropertyDefinition()); 517 this.pSuppressInternalOperations = impl.getPropertyValue(INSTANCE.getSuppressInternalOperationsPropertyDefinition()); 518 this.pSuppressSynchronizationOperations = impl.getPropertyValue(INSTANCE.getSuppressSynchronizationOperationsPropertyDefinition()); 519 } 520 521 522 523 /** {@inheritDoc} */ 524 public void addExternalAccessChangeListener( 525 ConfigurationChangeListener<ExternalAccessLogPublisherCfg> listener) { 526 impl.registerChangeListener(listener); 527 } 528 529 530 531 /** {@inheritDoc} */ 532 public void removeExternalAccessChangeListener( 533 ConfigurationChangeListener<ExternalAccessLogPublisherCfg> listener) { 534 impl.deregisterChangeListener(listener); 535 } 536 /** {@inheritDoc} */ 537 public void addAccessChangeListener( 538 ConfigurationChangeListener<AccessLogPublisherCfg> listener) { 539 impl.registerChangeListener(listener); 540 } 541 542 543 544 /** {@inheritDoc} */ 545 public void removeAccessChangeListener( 546 ConfigurationChangeListener<AccessLogPublisherCfg> listener) { 547 impl.deregisterChangeListener(listener); 548 } 549 /** {@inheritDoc} */ 550 public void addChangeListener( 551 ConfigurationChangeListener<LogPublisherCfg> listener) { 552 impl.registerChangeListener(listener); 553 } 554 555 556 557 /** {@inheritDoc} */ 558 public void removeChangeListener( 559 ConfigurationChangeListener<LogPublisherCfg> listener) { 560 impl.deregisterChangeListener(listener); 561 } 562 563 564 565 /** {@inheritDoc} */ 566 public String getConfigFile() { 567 return pConfigFile; 568 } 569 570 571 572 /** {@inheritDoc} */ 573 public boolean isEnabled() { 574 return pEnabled; 575 } 576 577 578 579 /** {@inheritDoc} */ 580 public FilteringPolicy getFilteringPolicy() { 581 return pFilteringPolicy; 582 } 583 584 585 586 /** {@inheritDoc} */ 587 public String getJavaClass() { 588 return pJavaClass; 589 } 590 591 592 593 /** {@inheritDoc} */ 594 public boolean isLogControlOids() { 595 return pLogControlOids; 596 } 597 598 599 600 /** {@inheritDoc} */ 601 public boolean isSuppressInternalOperations() { 602 return pSuppressInternalOperations; 603 } 604 605 606 607 /** {@inheritDoc} */ 608 public boolean isSuppressSynchronizationOperations() { 609 return pSuppressSynchronizationOperations; 610 } 611 612 613 614 /** {@inheritDoc} */ 615 public String[] listAccessLogFilteringCriteria() { 616 return impl.listChildren(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition()); 617 } 618 619 620 621 /** {@inheritDoc} */ 622 public AccessLogFilteringCriteriaCfg getAccessLogFilteringCriteria(String name) throws ConfigException { 623 return impl.getChild(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition(), name).getConfiguration(); 624 } 625 626 627 628 /** {@inheritDoc} */ 629 public void addAccessLogFilteringCriteriaAddListener( 630 ConfigurationAddListener<AccessLogFilteringCriteriaCfg> listener) throws ConfigException { 631 impl.registerAddListener(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition(), listener); 632 } 633 634 635 636 /** {@inheritDoc} */ 637 public void removeAccessLogFilteringCriteriaAddListener( 638 ConfigurationAddListener<AccessLogFilteringCriteriaCfg> listener) { 639 impl.deregisterAddListener(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition(), listener); 640 } 641 642 643 644 /** {@inheritDoc} */ 645 public void addAccessLogFilteringCriteriaDeleteListener( 646 ConfigurationDeleteListener<AccessLogFilteringCriteriaCfg> listener) throws ConfigException { 647 impl.registerDeleteListener(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition(), listener); 648 } 649 650 651 652 /** {@inheritDoc} */ 653 public void removeAccessLogFilteringCriteriaDeleteListener( 654 ConfigurationDeleteListener<AccessLogFilteringCriteriaCfg> listener) { 655 impl.deregisterDeleteListener(INSTANCE.getAccessLogFilteringCriteriaRelationDefinition(), listener); 656 } 657 658 659 660 /** {@inheritDoc} */ 661 public Class<? extends ExternalAccessLogPublisherCfg> configurationClass() { 662 return ExternalAccessLogPublisherCfg.class; 663 } 664 665 666 667 /** {@inheritDoc} */ 668 public DN dn() { 669 return impl.getDN(); 670 } 671 672 673 674 /** {@inheritDoc} */ 675 public String toString() { 676 return impl.toString(); 677 } 678 } 679}