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