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