001/*
002 * Copyright 2020 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2020 Ping Identity Corporation
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020/*
021 * Copyright (C) 2020 Ping Identity Corporation
022 *
023 * This program is free software; you can redistribute it and/or modify
024 * it under the terms of the GNU General Public License (GPLv2 only)
025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
026 * as published by the Free Software Foundation.
027 *
028 * This program is distributed in the hope that it will be useful,
029 * but WITHOUT ANY WARRANTY; without even the implied warranty of
030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
031 * GNU General Public License for more details.
032 *
033 * You should have received a copy of the GNU General Public License
034 * along with this program; if not, see <http://www.gnu.org/licenses>.
035 */
036package com.unboundid.ldap.sdk;
037
038
039
040import java.io.Serializable;
041import java.util.Arrays;
042import java.util.Collection;
043import java.util.EnumSet;
044import java.util.Iterator;
045import java.util.LinkedHashSet;
046import java.util.Set;
047
048import com.unboundid.ldap.sdk.schema.Schema;
049import com.unboundid.util.Debug;
050import com.unboundid.util.Mutable;
051import com.unboundid.util.StaticUtils;
052import com.unboundid.util.ThreadSafety;
053import com.unboundid.util.ThreadSafetyLevel;
054
055
056
057/**
058 * This class provides a data structure that can be used to define the
059 * properties to use when creating a {@link JSONLDAPConnectionLogger}.
060 */
061@Mutable()
062@ThreadSafety(level=ThreadSafetyLevel.NOT_THREADSAFE)
063public final class JSONLDAPConnectionLoggerProperties
064       implements Serializable
065{
066  /**
067   * The serial version UID for this serializable class.
068   */
069  private static final long serialVersionUID = 709385948984934296L;
070
071
072
073  // Indicates whether to flush the handler after logging information about each
074  // successful for failed connection attempt.
075  private boolean flushAfterConnectMessages;
076
077  // Indicates whether to flush the handler after logging information about each
078  // disconnect.
079  private boolean flushAfterDisconnectMessages;
080
081  // Indicates whether to flush the handler after logging information about each
082  // request.
083  private boolean flushAfterRequestMessages;
084
085  // Indicates whether to flush the handler after logging information about the
086  // final result for each operation.
087  private boolean flushAfterFinalResultMessages;
088
089  // Indicates whether to flush the handler after logging information about each
090  // non-final results (including search result entries, search result
091  // references, and intermediate response messages) for each operation.
092  private boolean flushAfterNonFinalResultMessages;
093
094  // Indicates whether to include the names of attributes provided in add
095  // requests.
096  private boolean includeAddAttributeNames;
097
098  // Indicates whether to include the values of attributes provided in add
099  // requests.
100  private boolean includeAddAttributeValues;
101
102  // Indicates whether to include the names of attributes targeted by modify
103  // requests.
104  private boolean includeModifyAttributeNames;
105
106  // Indicates whether to include the values of attributes targeted by modify
107  // requests.
108  private boolean includeModifyAttributeValues;
109
110  // Indicates whether to include the OIDs of controls included in requests and
111  // results.
112  private boolean includeControlOIDs;
113
114  // Indicates whether to include the names of attributes provided in search
115  // result entries.
116  private boolean includeSearchEntryAttributeNames;
117
118  // Indicates whether to include the values of attributes provided in search
119  // result entries.
120  private boolean includeSearchEntryAttributeValues;
121
122  // Indicates whether to log successful and failed connection attempts.
123  private boolean logConnects;
124
125  // Indicates whether to log disconnects.
126  private boolean logDisconnects;
127
128  // Indicates whether to log intermediate response messages.
129  private boolean logIntermediateResponses;
130
131  // Indicates whether to log operation requests for enabled operation types.
132  private boolean logRequests;
133
134  // Indicates whether to log final operation results for enabled operation
135  // types.
136  private boolean logFinalResults;
137
138  // Indicates whether to log search result entries.
139  private boolean logSearchEntries;
140
141  // Indicates whether to log search result references.
142  private boolean logSearchReferences;
143
144  // The schema to use for identifying alternate attribute type names.
145  private Schema schema;
146
147  // The types of operations for which requests should be logged.
148  private final Set<OperationType> operationTypes;
149
150  // The names or OIDs of the attributes whose values should be redacted.
151  private final Set<String> attributesToRedact;
152
153
154
155  /**
156   * Creates a new set of JSON LDAP connection logger properties with the
157   * default settings.
158   */
159  public JSONLDAPConnectionLoggerProperties()
160  {
161    flushAfterConnectMessages = true;
162    flushAfterDisconnectMessages = true;
163    flushAfterRequestMessages = false;
164    flushAfterFinalResultMessages = true;
165    flushAfterNonFinalResultMessages = false;
166    includeAddAttributeNames = true;
167    includeAddAttributeValues = false;
168    includeModifyAttributeNames = true;
169    includeModifyAttributeValues = false;
170    includeControlOIDs = true;
171    includeSearchEntryAttributeNames = true;
172    includeSearchEntryAttributeValues = false;
173    logConnects = true;
174    logDisconnects = true;
175    logIntermediateResponses = true;
176    logRequests = true;
177    logFinalResults = true;
178    logSearchEntries = false;
179    logSearchReferences = false;
180    operationTypes = EnumSet.allOf(OperationType.class);
181
182    try
183    {
184      schema = Schema.getDefaultStandardSchema();
185    }
186    catch (final Exception e)
187    {
188      Debug.debugException(e);
189      schema = null;
190    }
191
192    attributesToRedact =
193         new LinkedHashSet<>(StaticUtils.computeMapCapacity(10));
194    attributesToRedact.add("userPassword");
195    attributesToRedact.add("authPassword");
196    attributesToRedact.add("unicodePwd");
197  }
198
199
200
201  /**
202   * Creates a new set of JSON LDAP connection logger properties that is a clone
203   * of the provided set of properties.
204   *
205   * @param  properties  The set of properties to copy.  It must not be
206   *                     {@code null}.
207   */
208  public JSONLDAPConnectionLoggerProperties(
209       final JSONLDAPConnectionLoggerProperties properties)
210  {
211    flushAfterConnectMessages = properties.flushAfterConnectMessages;
212    flushAfterDisconnectMessages = properties.flushAfterDisconnectMessages;
213    flushAfterRequestMessages = properties.flushAfterRequestMessages;
214    flushAfterFinalResultMessages =
215         properties.flushAfterFinalResultMessages;
216    flushAfterNonFinalResultMessages =
217         properties.flushAfterNonFinalResultMessages;
218    includeAddAttributeNames = properties.includeAddAttributeNames;
219    includeAddAttributeValues = properties.includeAddAttributeValues;
220    includeModifyAttributeNames = properties.includeModifyAttributeNames;
221    includeModifyAttributeValues = properties.includeModifyAttributeValues;
222    includeControlOIDs = properties.includeControlOIDs;
223    includeSearchEntryAttributeNames =
224         properties.includeSearchEntryAttributeNames;
225    includeSearchEntryAttributeValues =
226         properties.includeSearchEntryAttributeValues;
227    logConnects = properties.logConnects;
228    logDisconnects = properties.logDisconnects;
229    logIntermediateResponses = properties.logIntermediateResponses;
230    logRequests = properties.logRequests;
231    logFinalResults = properties.logFinalResults;
232    logSearchEntries = properties.logSearchEntries;
233    logSearchReferences = properties.logSearchReferences;
234    schema = properties.schema;
235    attributesToRedact = new LinkedHashSet<>(properties.attributesToRedact);
236
237    operationTypes = EnumSet.noneOf(OperationType.class);
238    operationTypes.addAll(properties.operationTypes);
239  }
240
241
242
243  /**
244   * Creates a new set of JSON LDAP connection logger properties using the
245   * configuration for the provided logger.
246   *
247   * @param  logger  The JSON LDAP connection logger whose configuration should
248   *                 be used to create the set of properties.
249   */
250  public JSONLDAPConnectionLoggerProperties(
251       final JSONLDAPConnectionLogger logger)
252  {
253    flushAfterConnectMessages = logger.flushAfterConnectMessages();
254    flushAfterDisconnectMessages = logger.flushAfterDisconnectMessages();
255    flushAfterRequestMessages = logger.flushAfterRequestMessages();
256    flushAfterFinalResultMessages = logger.flushAfterFinalResultMessages();
257    flushAfterNonFinalResultMessages =
258         logger.flushAfterNonFinalResultMessages();
259    includeAddAttributeNames = logger.includeAddAttributeNames();
260    includeAddAttributeValues = logger.includeAddAttributeValues();
261    includeModifyAttributeNames = logger.includeModifyAttributeNames();
262    includeModifyAttributeValues = logger.includeModifyAttributeValues();
263    includeControlOIDs = logger.includeControlOIDs();
264    includeSearchEntryAttributeNames =
265         logger.includeSearchEntryAttributeNames();
266    includeSearchEntryAttributeValues =
267         logger.includeSearchEntryAttributeValues();
268    logConnects = logger.logConnects();
269    logDisconnects = logger.logDisconnects();
270    logIntermediateResponses = logger.logIntermediateResponses();
271    logRequests = logger.logRequests();
272    logFinalResults = logger.logFinalResults();
273    logSearchEntries = logger.logSearchEntries();
274    logSearchReferences = logger.logSearchReferences();
275    schema = logger.getSchema();
276    attributesToRedact = new LinkedHashSet<>(logger.getAttributesToRedact());
277
278    operationTypes = EnumSet.noneOf(OperationType.class);
279    operationTypes.addAll(logger.getOperationTypes());
280  }
281
282
283
284  /**
285   * Indicates whether to log successful and failed connection attempts.
286   * Connection attempts will be logged by default.
287   *
288   * @return  {@code true} if connection attempts should be logged, or
289   *          {@code false} if not.
290   */
291  public boolean logConnects()
292  {
293    return logConnects;
294  }
295
296
297
298  /**
299   * Specifies whether to log successful and failed connection attempts.
300   *
301   * @param  logConnects  Indicates whether to log successful and failed
302   *                      connection attempts.
303   */
304  public void setLogConnects(final boolean logConnects)
305  {
306    this.logConnects = logConnects;
307  }
308
309
310
311  /**
312   * Indicates whether to log disconnects.  Disconnects will be logged by
313   * default.
314   *
315   * @return  {@code true} if disconnects should be logged, or {@code false} if
316   *          not.
317   */
318  public boolean logDisconnects()
319  {
320    return logDisconnects;
321  }
322
323
324
325  /**
326   * Specifies whether to log disconnects.  Disconnects will be logged by
327   * default.
328   *
329   * @param  logDisconnects  Indicates whether to log disconnects.
330   */
331  public void setLogDisconnects(final boolean logDisconnects)
332  {
333    this.logDisconnects = logDisconnects;
334  }
335
336
337
338  /**
339   * Indicates whether to log messages about requests for operations included
340   * in the set of operation types returned by the {@link #getOperationTypes}
341   * method.  Operation requests will be logged by default.
342   *
343   * @return  {@code true} if operation requests should be logged for
344   *          appropriate operation types, or {@code false} if not.
345   */
346  public boolean logRequests()
347  {
348    return logRequests;
349  }
350
351
352
353  /**
354   * Specifies whether to log messages about requests for operations included
355   * in the set of operation types returned by the {@link #getOperationTypes}
356   * method.
357   *
358   * @param  logRequests  Indicates whether to log messages about operation
359   *                      requests.
360   */
361  public void setLogRequests(final boolean logRequests)
362  {
363    this.logRequests = logRequests;
364  }
365
366
367
368  /**
369   * Indicates whether to log messages about the final results for operations
370   * included in the set of operation types returned by the
371   * {@link #getOperationTypes} method.  Final operation results will be
372   * logged by default.
373   *
374   * @return  {@code true} if operation requests should be logged for
375   *          appropriate operation types, or {@code false} if not.
376   */
377  public boolean logFinalResults()
378  {
379    return logFinalResults;
380  }
381
382
383
384  /**
385   * Specifies whether to log messages about the final results for operations
386   * included in the set of operation types returned by the
387   * {@link #getOperationTypes} method.
388   *
389   * @param  logFinalResults  Indicates whether to log messages about final
390   *                          operation results.
391   */
392  public void setLogFinalResults(final boolean logFinalResults)
393  {
394    this.logFinalResults = logFinalResults;
395  }
396
397
398
399  /**
400   * Indicates whether to log messages about each search result entry returned
401   * for search operations.  This property will only be used if the set returned
402   * by the  {@link #getOperationTypes} method includes
403   * {@link OperationType#SEARCH}.  Search result entries will not be logged by
404   * default.
405   *
406   * @return  {@code true} if search result entries should be logged, or
407   *          {@code false} if not.
408   */
409  public boolean logSearchEntries()
410  {
411    return logSearchEntries;
412  }
413
414
415
416  /**
417   * Specifies whether to log messages about each search result entry returned
418   * for search operations.  This property will only be used if the set returned
419   * by the  {@link #getOperationTypes} method includes
420   * {@link OperationType#SEARCH}.
421   *
422   * @param  logSearchEntries  Indicates whether to log search result entry
423   *                           messages.
424   */
425  public void setLogSearchEntries(final boolean logSearchEntries)
426  {
427    this.logSearchEntries = logSearchEntries;
428  }
429
430
431
432  /**
433   * Indicates whether to log messages about each search result reference
434   * returned for search operations.  This property will only be used if the set
435   * returned by the  {@link #getOperationTypes} method includes
436   * {@link OperationType#SEARCH}.  Search result references will not be logged
437   * by default.
438   *
439   * @return  {@code true} if search result references should be logged, or
440   *          {@code false} if not.
441   */
442  public boolean logSearchReferences()
443  {
444    return logSearchReferences;
445  }
446
447
448
449  /**
450   * Specifies whether to log messages about each search result reference
451   * returned for search operations.  This property will only be used if the set
452   * returned by the  {@link #getOperationTypes} method includes
453   * {@link OperationType#SEARCH}.
454   *
455   * @param  logSearchReferences  Indicates whether to log search result
456   *                              reference messages.
457   */
458  public void setLogSearchReferences(final boolean logSearchReferences)
459  {
460    this.logSearchReferences = logSearchReferences;
461  }
462
463
464
465  /**
466   * Indicates whether to log messages about each intermediate response returned
467   * in the course of processing an operation.  Intermediate response messages
468   * will be logged by default.
469   *
470   * @return  {@code true} if intermediate response messages should be logged,
471   *          or {@code false} if not.
472   */
473  public boolean logIntermediateResponses()
474  {
475    return logIntermediateResponses;
476  }
477
478
479
480  /**
481   * Specifies whether to log messages about each intermediate response returned
482   * in the course of processing an operation.
483   *
484   * @param  logIntermediateResponses  Indicates whether to log intermediate
485   *                                   response messages.
486   */
487  public void setLogIntermediateResponses(
488                   final boolean logIntermediateResponses)
489  {
490    this.logIntermediateResponses = logIntermediateResponses;
491  }
492
493
494
495  /**
496   * Retrieves the set of operation types for which to log requests and results.
497   * All operation types will be logged by default.
498   *
499   * @return  The set of operation types for which to log requests and results.
500   */
501  public Set<OperationType> getOperationTypes()
502  {
503    return operationTypes;
504  }
505
506
507
508  /**
509   * Specifies the set of operation types for which to log requests and results.
510   *
511   * @param  operationTypes  The set of operation types for which to log
512   *                         requests and results.  It may be {@code null} or
513   *                         empty if no operation types should be logged.
514   */
515  public void setOperationTypes(final OperationType... operationTypes)
516  {
517    this.operationTypes.clear();
518    if (operationTypes != null)
519    {
520      this.operationTypes.addAll(Arrays.asList(operationTypes));
521    }
522  }
523
524
525
526  /**
527   * Specifies the set of operation types for which to log requests and results.
528   *
529   * @param  operationTypes  The set of operation types for which to log
530   *                         requests and results.  It may be {@code null} or
531   *                         empty if no operation types should be logged.
532   */
533  public void setOperationTypes(final Collection<OperationType> operationTypes)
534  {
535    this.operationTypes.clear();
536    if (operationTypes != null)
537    {
538      this.operationTypes.addAll(operationTypes);
539    }
540  }
541
542
543
544  /**
545   * Indicates whether log messages about add requests should include the names
546   * of the attributes provided in the request.  Add attribute names (but not
547   * values) will be logged by default.
548   *
549   * @return  {@code true} if add attribute names should be logged, or
550   *          {@code false} if not.
551   */
552  public boolean includeAddAttributeNames()
553  {
554    return includeAddAttributeNames;
555  }
556
557
558
559  /**
560   * Specifies whether log messages about add requests should include the names
561   * of the attributes provided in the request.
562   *
563   * @param  includeAddAttributeNames  Indicates whether to include attribute
564   *                                   names in add request log messages.
565   */
566  public void setIncludeAddAttributeNames(
567                   final boolean includeAddAttributeNames)
568  {
569    this.includeAddAttributeNames = includeAddAttributeNames;
570  }
571
572
573
574  /**
575   * Indicates whether log messages about add requests should include the values
576   * of the attributes provided in the request.  This property will only be used
577   * if {@link #includeAddAttributeNames} returns {@code true}.  Values for
578   * attributes named in the set returned by the
579   * {@link #getAttributesToRedact} method will be replaced with a value of
580   * "[REDACTED]".  Add attribute names (but not values) will be logged by
581   * default.
582   *
583   * @return  {@code true} if add attribute values should be logged, or
584   *          {@code false} if not.
585   */
586  public boolean includeAddAttributeValues()
587  {
588    return includeAddAttributeValues;
589  }
590
591
592
593  /**
594   * Specifies whether log messages about add requests should include the values
595   * of the attributes provided in the request.  This property will only be used
596   * if {@link #includeAddAttributeNames} returns {@code true}.  Values for
597   * attributes named in the set returned by the
598   * {@link #getAttributesToRedact} method will be replaced with a value of
599   * "[REDACTED]".
600   *
601   * @param  includeAddAttributeValues  Indicates whether to include attribute
602   *                                    values in add request log messages.
603   */
604  public void setIncludeAddAttributeValues(
605                   final boolean includeAddAttributeValues)
606  {
607    this.includeAddAttributeValues = includeAddAttributeValues;
608  }
609
610
611
612  /**
613   * Indicates whether log messages about modify requests should include the
614   * names of the attributes modified in the request.  Modified attribute names
615   * (but not values) will be logged by default.
616   *
617   * @return  {@code true} if modify attribute names should be logged, or
618   *          {@code false} if not.
619   */
620  public boolean includeModifyAttributeNames()
621  {
622    return includeModifyAttributeNames;
623  }
624
625
626
627  /**
628   * Specifies whether log messages about modify requests should include the
629   * names of the attributes modified in the request.
630   *
631   * @param  includeModifyAttributeNames  Indicates whether to include attribute
632   *                                      names in modify request log messages.
633   */
634  public void setIncludeModifyAttributeNames(
635                   final boolean includeModifyAttributeNames)
636  {
637    this.includeModifyAttributeNames = includeModifyAttributeNames;
638  }
639
640
641
642  /**
643   * Indicates whether log messages about modify requests should include the
644   * values of the attributes modified in the request.  This property will only
645   * be used if {@link #includeModifyAttributeNames} returns {@code true}.
646   * Values for attributes named in the set returned by the
647   * {@link #getAttributesToRedact} method will be replaced with a value of
648   * "[REDACTED]".  Modify attribute names (but not values) will be logged by
649   * default.
650   *
651   * @return  {@code true} if modify attribute values should be logged, or
652   *          {@code false} if not.
653   */
654  public boolean includeModifyAttributeValues()
655  {
656    return includeModifyAttributeValues;
657  }
658
659
660
661  /**
662   * Specifies whether log messages about modify requests should include the
663   * values of the attributes modified in the request.  This property will only
664   * be used if {@link #includeModifyAttributeNames} returns {@code true}.
665   * Values for attributes named in the set returned by the
666   * {@link #getAttributesToRedact} method will be replaced with a value of
667   * "[REDACTED]".
668   *
669   * @param  includeModifyAttributeValues  Indicates whether to include
670   *                                       attribute values in modify request
671   *                                       log messages.
672   */
673  public void setIncludeModifyAttributeValues(
674                   final boolean includeModifyAttributeValues)
675  {
676    this.includeModifyAttributeValues = includeModifyAttributeValues;
677  }
678
679
680
681  /**
682   * Indicates whether log messages about search result entries should include
683   * the names of the attributes in the returned entry.  Entry attribute names
684   * (but not values) will be logged by default.
685   *
686   * @return  {@code true} if search result entry attribute names should be
687   *          logged, or {@code false} if not.
688   */
689  public boolean includeSearchEntryAttributeNames()
690  {
691    return includeSearchEntryAttributeNames;
692  }
693
694
695
696  /**
697   * Specifies whether log messages about search result entries should include
698   * the names of the attributes in the returned entry.
699   *
700   * @param  includeSearchEntryAttributeNames  Indicates whether to include
701   *                                           attribute names in search result
702   *                                           entry log messages.
703   */
704  public void setIncludeSearchEntryAttributeNames(
705                   final boolean includeSearchEntryAttributeNames)
706  {
707    this.includeSearchEntryAttributeNames = includeSearchEntryAttributeNames;
708  }
709
710
711
712  /**
713   * Indicates whether log messages about search result entries should include
714   * the values of the attributes in the returned entry.  This property will
715   * only be used if {@link #includeSearchEntryAttributeNames} returns
716   * {@code true}.  Values for attributes named in the set returned by the
717   * {@link #getAttributesToRedact} method will be replaced with a value of
718   * "[REDACTED]".  Entry attribute names (but not values) will be logged by
719   * default.
720   *
721   * @return  {@code true} if search result entry attribute values should be
722   *          logged, or {@code false} if not.
723   */
724  public boolean includeSearchEntryAttributeValues()
725  {
726    return includeSearchEntryAttributeValues;
727  }
728
729
730
731  /**
732   * Specifies whether log messages about search result entries should include
733   * the values of the attributes in the returned entry.  This property will
734   * only be used if {@link #includeSearchEntryAttributeNames} returns
735   * {@code true}.  Values for attributes named in the set returned by the
736   * {@link #getAttributesToRedact} method will be replaced with a value of
737   * "[REDACTED]".
738   *
739   * @param  includeSearchEntryAttributeValues  Indicates whether to include
740   *                                            attribute values in search
741   *                                            result entry log messages.
742   */
743  public void setIncludeSearchEntryAttributeValues(
744                   final boolean includeSearchEntryAttributeValues)
745  {
746    this.includeSearchEntryAttributeValues = includeSearchEntryAttributeValues;
747  }
748
749
750
751  /**
752   * Retrieves a set containing the names or OIDs of the attributes whose values
753   * should be redacted from log messages.  Values of the userPassword,
754   * authPassword, and unicodePWD attributes will be redacted by default.
755   *
756   * @return  A set containing the names or OIDs of the attributes whose values
757   *          should be redacted from log messages, or an empty set if no
758   *          attribute values should be redacted.
759   */
760  public Set<String> getAttributesToRedact()
761  {
762    return attributesToRedact;
763  }
764
765
766
767  /**
768   * Specifies the names or OIDs of the attributes whose values should be
769   * redacted from log messages.
770   *
771   * @param  attributesToRedact  The names or OIDs of the attributes whose
772   *                             values should be redacted.  It may be
773   *                             {@code null} or empty if no attribute values
774   *                             should be redacted.
775   */
776  public void setAttributesToRedact(final String... attributesToRedact)
777  {
778    this.attributesToRedact.clear();
779    if (attributesToRedact != null)
780    {
781      this.attributesToRedact.addAll(Arrays.asList(attributesToRedact));
782    }
783  }
784
785
786
787  /**
788   * Specifies the names or OIDs of the attributes whose values should be
789   * redacted from log messages.
790   *
791   * @param  attributesToRedact  The names or OIDs of the attributes whose
792   *                             values should be redacted.  It may be
793   *                             {@code null} or empty if no attribute values
794   *                             should be redacted.
795   */
796  public void setAttributesToRedact(final Collection<String> attributesToRedact)
797  {
798    this.attributesToRedact.clear();
799    if (attributesToRedact != null)
800    {
801      this.attributesToRedact.addAll(attributesToRedact);
802    }
803  }
804
805
806
807  /**
808   * Indicates whether request and result log messages should include the OIDs
809   * of any controls included in that request or result.  Control OIDs will
810   * be logged by default.
811   *
812   * @return  {@code true} if request control OIDs should be logged, or
813   *          {@code false} if not.
814   */
815  public boolean includeControlOIDs()
816  {
817    return includeControlOIDs;
818  }
819
820
821
822  /**
823   * Specifies whether request and result log messages should include the OIDs
824   * of any controls included in that request or result.
825   *
826   * @param  includeControlOIDs  Indicates whether to include control OIDs in
827   *                             request and result log messages.
828   */
829  public void setIncludeControlOIDs(final boolean includeControlOIDs)
830  {
831    this.includeControlOIDs = includeControlOIDs;
832  }
833
834
835
836  /**
837   * Indicates whether the log handler should be flushed after logging each
838   * successful or failed connection attempt.  By default, the handler will be
839   * flushed after logging each connection attempt.
840   *
841   * @return  {@code true} if the log handler should be flushed after logging
842   *          each connection attempt, or {@code false} if not.
843   */
844  public boolean flushAfterConnectMessages()
845  {
846    return flushAfterConnectMessages;
847  }
848
849
850
851  /**
852   * Specifies whether the log handler should be flushed after logging each
853   * successful or failed connection attempt.
854   *
855   * @param  flushAfterConnectMessages  Indicates whether the log handler should
856   *                                    be flushed after logging each connection
857   *                                    attempt.
858   */
859  public void setFlushAfterConnectMessages(
860                   final boolean flushAfterConnectMessages)
861  {
862    this.flushAfterConnectMessages = flushAfterConnectMessages;
863  }
864
865
866
867  /**
868   * Indicates whether the log handler should be flushed after logging each
869   * disconnect.  By default, the handler will be flushed after logging each
870   * disconnect.
871   *
872   * @return  {@code true} if the log handler should be flushed after logging
873   *          each disconnect, or {@code false} if not.
874   */
875  public boolean flushAfterDisconnectMessages()
876  {
877    return flushAfterDisconnectMessages;
878  }
879
880
881
882  /**
883   * Specifies whether the log handler should be flushed after logging each
884   * disconnect.
885   *
886   * @param  flushAfterDisconnectMessages  Indicates whether the log handler
887   *                                       should be flushed after logging each
888   *                                       disconnect.
889   */
890  public void setFlushAfterDisconnectMessages(
891                   final boolean flushAfterDisconnectMessages)
892  {
893    this.flushAfterDisconnectMessages = flushAfterDisconnectMessages;
894  }
895
896
897
898  /**
899   * Indicates whether the log handler should be flushed after logging each
900   * request.  By default, the handler will be flushed after logging each final
901   * result, but not after logging requests or non-final results.
902   *
903   * @return  {@code true} if the log handler should be flushed after logging
904   *          each request, or {@code false} if not.
905   */
906  public boolean flushAfterRequestMessages()
907  {
908    return flushAfterRequestMessages;
909  }
910
911
912
913  /**
914   * Specifies whether the log handler should be flushed after logging each
915   * request.
916   *
917   * @param  flushAfterRequestMessages  Indicates whether the log handler should
918   *                                    be flushed after logging each request.
919   */
920  public void setFlushAfterRequestMessages(
921                   final boolean flushAfterRequestMessages)
922  {
923    this.flushAfterRequestMessages = flushAfterRequestMessages;
924  }
925
926
927
928  /**
929   * Indicates whether the log handler should be flushed after logging each
930   * non-final result (including search result entries, search result
931   * references, and intermediate response messages).  By default, the handler
932   * will be flushed after logging each final result, but not after logging
933   * requests or non-final results.
934   *
935   * @return  {@code true} if the log handler should be flushed after logging
936   *          each non-final result, or {@code false} if not.
937   */
938  public boolean flushAfterNonFinalResultMessages()
939  {
940    return flushAfterNonFinalResultMessages;
941  }
942
943
944
945  /**
946   * Specifies whether the log handler should be flushed after logging each
947   * non-final result (including search result entries, search result
948   * references, and intermediate result messages).
949   *
950   * @param  flushAfterNonFinalResultMessages  Indicates whether the log
951   *                                           handler should be flushed after
952   *                                           logging each non-final result.
953   */
954  public void setFlushAfterNonFinalResultMessages(
955                   final boolean flushAfterNonFinalResultMessages)
956  {
957    this.flushAfterNonFinalResultMessages =
958         flushAfterNonFinalResultMessages;
959  }
960
961
962
963  /**
964   * Indicates whether the log handler should be flushed after logging the final
965   * result for each operation.  By default, the handler will be flushed after
966   * logging each final result, but not after logging requests or non-final
967   * results.
968   *
969   * @return  {@code true} if the log handler should be flushed after logging
970   *          each final result, or {@code false} if not.
971   */
972  public boolean flushAfterFinalResultMessages()
973  {
974    return flushAfterFinalResultMessages;
975  }
976
977
978
979  /**
980   * Specifies whether the log handler should be flushed after logging the final
981   * result for each operation.
982   *
983   * @param  flushAfterFinalResultMessages  Indicates whether the log handler
984   *                                        should be flushed after logging
985   *                                        each final result.
986   */
987  public void setFlushAfterFinalResultMessages(
988                   final boolean flushAfterFinalResultMessages)
989  {
990    this.flushAfterFinalResultMessages = flushAfterFinalResultMessages;
991  }
992
993
994
995  /**
996   * Retrieves the schema that will be used to identify alternate names and OIDs
997   * for attributes whose values should be redacted.  The LDAP SDK's default
998   * standard schema will be used by default.
999   *
1000   * @return  The schema that will be used to identify alternate names and OIDs
1001   *          for attributes whose values should be redacted, or {@code null}
1002   *          if no schema should be used.
1003   */
1004  public Schema getSchema()
1005  {
1006    return schema;
1007  }
1008
1009
1010
1011  /**
1012   * Specifies the schema that will be used to identify alternate names and OIDs
1013   * for attributes whose values should be redacted.
1014   *
1015   * @param  schema  The schema that will be used to identify alternate names
1016   *                 and OIDs for attributes whose values should be redacted.
1017   *                 It may be {@code null} if no schema should be used.
1018   */
1019  public void setSchema(final Schema schema)
1020  {
1021    this.schema = schema;
1022  }
1023
1024
1025
1026  /**
1027   * Retrieves a string representation of this
1028   * {@code JSONLDAPConnectionLoggerProperties} object.
1029   *
1030   * @return  A string representation of this
1031   *          {@code JSONLDAPConnectionLoggerProperties} object.
1032   */
1033  @Override()
1034  public String toString()
1035  {
1036    final StringBuilder buffer = new StringBuilder();
1037    toString(buffer);
1038    return buffer.toString();
1039  }
1040
1041
1042
1043  /**
1044   * Appends a string representation of this
1045   * {@code JSONLDAPConnectionLoggerProperties} object to the provided buffer.
1046   *
1047   * @param  buffer  The buffer to which the information should be appended.  It
1048   *                 must not be {@code null}.
1049   */
1050  public void toString(final StringBuilder buffer)
1051  {
1052    buffer.append("JSONLDAPConnectionLoggerProperties(logConnects=");
1053    buffer.append(logConnects);
1054    buffer.append(", logDisconnects=");
1055    buffer.append(logDisconnects);
1056    buffer.append(", logRequests=");
1057    buffer.append(logRequests);
1058    buffer.append(", logFinalResults=");
1059    buffer.append(logFinalResults);
1060    buffer.append(", logSearchEntries=");
1061    buffer.append(logSearchEntries);
1062    buffer.append(", logSearchReferences=");
1063    buffer.append(logSearchReferences);
1064    buffer.append(", logIntermediateResponses=");
1065    buffer.append(logIntermediateResponses);
1066    buffer.append(", operationTypes={");
1067
1068    final Iterator<OperationType> operationTypeIterator =
1069         operationTypes.iterator();
1070    while (operationTypeIterator.hasNext())
1071    {
1072      buffer.append(operationTypeIterator.next().toString());
1073
1074      if (operationTypeIterator.hasNext())
1075      {
1076        buffer.append(',');
1077      }
1078    }
1079
1080    buffer.append(", includeAddAttributeNames=");
1081    buffer.append(includeAddAttributeNames);
1082    buffer.append(", includeAddAttributeValues=");
1083    buffer.append(includeAddAttributeValues);
1084    buffer.append(", includeModifyAttributeNames=");
1085    buffer.append(includeModifyAttributeNames);
1086    buffer.append(", includeModifyAttributeValues=");
1087    buffer.append(includeModifyAttributeValues);
1088    buffer.append(", includeSearchEntryAttributeNames=");
1089    buffer.append(includeSearchEntryAttributeNames);
1090    buffer.append(", includeSearchEntryAttributeValues=");
1091    buffer.append(includeSearchEntryAttributeValues);
1092    buffer.append(", attributesToRedact={");
1093
1094    final Iterator<String> redactAttributeIterator =
1095         attributesToRedact.iterator();
1096    while (redactAttributeIterator.hasNext())
1097    {
1098      buffer.append('\'');
1099      buffer.append(redactAttributeIterator.next());
1100      buffer.append('\'');
1101
1102      if (redactAttributeIterator.hasNext())
1103      {
1104        buffer.append(',');
1105      }
1106    }
1107
1108    buffer.append("}, includeControlOIDs=");
1109    buffer.append(includeControlOIDs);
1110    buffer.append(", flushAfterConnectMessages");
1111    buffer.append(flushAfterConnectMessages);
1112    buffer.append(", flushAfterDisconnectMessages");
1113    buffer.append(flushAfterDisconnectMessages);
1114    buffer.append(", flushAfterRequestMessages");
1115    buffer.append(flushAfterRequestMessages);
1116    buffer.append(", flushAfterFinalResultMessages");
1117    buffer.append(flushAfterFinalResultMessages);
1118    buffer.append(", flushAfterNonFinalResultMessages");
1119    buffer.append(flushAfterNonFinalResultMessages);
1120    buffer.append(')');
1121  }
1122}