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