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
010 * docs/licenses/cddl.txt
011 * or http://www.opensource.org/licenses/cddl1.php.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * docs/licenses/cddl.txt.  If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 *      Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 *      Copyright 2010-2017 Ping Identity Corporation
026 */
027package com.unboundid.directory.sdk.common.types;
028
029
030
031import java.io.File;
032import java.util.List;
033import java.util.Set;
034import java.util.UUID;
035
036import com.unboundid.directory.sdk.ds.api.ChangeListener;
037import com.unboundid.directory.sdk.common.api.DiskSpaceConsumer;
038import com.unboundid.directory.sdk.common.api.MonitorProvider;
039import com.unboundid.directory.sdk.common.api.ServerShutdownListener;
040import com.unboundid.directory.sdk.common.api.ServerThread;
041import com.unboundid.directory.sdk.common.config.GenericConfig;
042import com.unboundid.directory.sdk.common.schema.Schema;
043import com.unboundid.directory.sdk.ds.types.RegisteredChangeListener;
044import com.unboundid.directory.sdk.proxy.types.Location;
045import com.unboundid.ldap.sdk.ChangeType;
046import com.unboundid.ldap.sdk.Filter;
047import com.unboundid.ldap.sdk.LDAPConnection;
048import com.unboundid.ldap.sdk.LDAPConnectionOptions;
049import com.unboundid.ldap.sdk.LDAPConnectionPool;
050import com.unboundid.ldap.sdk.LDAPException;
051import com.unboundid.ldap.sdk.LDAPInterface;
052import com.unboundid.util.NotExtensible;
053import com.unboundid.util.ThreadSafety;
054import com.unboundid.util.ThreadSafetyLevel;
055
056
057
058/**
059 * This interface may be used to obtain information about the server in
060 * which an extension is running.
061 */
062@NotExtensible()
063@ThreadSafety(level=ThreadSafetyLevel.INTERFACE_THREADSAFE)
064public interface ServerContext
065{
066  /**
067   * Retrieves the compact name of the server vendor.  The returned name will
068   * not have any spaces.
069   *
070   * @return  The compact name of the server vendor.
071   */
072  String getShortVendorName();
073
074
075
076  /**
077   * Retrieves the full name of the server vendor.  The returned name may
078   * contain spaces.
079   *
080   * @return  The full name of the server vendor.
081   */
082  String getFullVendorName();
083
084
085
086  /**
087   * Retrieves the compact name of the server.  The returned name will not have
088   * any spaces.
089   *
090   * @return  The compact name of the server.
091   */
092  String getCompactProductName();
093
094
095
096  /**
097   * Retrieves the package name of the server that is used for defining the
098   * server package ZIP file and root directory.  The returned name will not
099   * have any spaces.
100   *
101   * @return  The package name of the server.
102   */
103  String getPackageName();
104
105
106
107  /**
108   * Retrieves the full name of the server.  The returned name may contain
109   * spaces.
110   *
111   * @return  The full name of the server.
112   */
113  String getFullProductName();
114
115
116
117  /**
118   * Retrieves the base name of the server which is generally the full
119   * product name without the vendor information.  The returned name may
120   * contain spaces.
121   *
122   * @return  The full name of the server.
123   */
124  String getBasicProductName();
125
126
127
128  /**
129   * Retrieves the major version number for the server.  The major version
130   * number is the first number which appears in the full version string (e.g.,
131   * for a version string of "1.2.3.4-beta5", the major version number is 1).
132   *
133   * @return  The major version number for the server.
134   */
135  int getMajorVersionNumber();
136
137
138
139  /**
140   * Retrieves the minor version number for the server.  The minor version
141   * number is the second number which appears in the full version string (e.g.,
142   * for a version string of "1.2.3.4-beta5", the minor version number is 2).
143   *
144   * @return  The minor version number for the server.
145   */
146  int getMinorVersionNumber();
147
148
149
150  /**
151   * Retrieves the point version number for the server.  The point version
152   * number is the third number which appears in the full version string (e.g.,
153   * for a version string of "1.2.3.4-beta5", the point version number is 3).
154   *
155   * @return  The point version number for the server.
156   */
157  int getPointVersionNumber();
158
159
160
161  /**
162   * Retrieves the patch version number for the server.  The patch version
163   * number is the fourth number which appears in the full version string (e.g.,
164   * for a version string of "1.2.3.4-beta5", the patch version number is 4).
165   *
166   * @return  The point version number for the server.
167   */
168  int getPatchVersionNumber();
169
170
171
172  /**
173   * Retrieves a string that is the concatenation of the major, minor,
174   * point, and patch version numbers of the server.
175   *
176   * @return the server's version number string.
177   */
178  String getVersionNumber();
179
180
181
182  /**
183   * Retrieves a string that is the concatenation of the product name, the
184   * major, minor, point, and patch version numbers of the server and any
185   * any other unique version information.
186   *
187   * @return the server's full version number string.
188   */
189  String getFullVersion();
190
191
192
193  /**
194   * Retrieves the version qualifier string for the server.  The version
195   * qualifier is an optional string which may provide additional information
196   * about the server version.  If a version qualifier is present, then it will
197   * immediately follow the patch version number (e.g., for a version string of
198   * "1.2.3.4-beta5", the version qualifier is "-beta5").
199   *
200   * @return  The version qualifier for the server, or an empty string if no
201   *          version qualifier is defined.
202   */
203  String getVersionQualifier();
204
205
206
207  /**
208   * Retrieves a value which identifies the source revision (in the
209   * version control system used to hold the server source code) from which the
210   * server was built.
211   *
212   * @return  The source revision identifier for the server.
213   */
214  String getSourceRevision();
215
216
217
218  /**
219   * Indicates whether the server is in the process of starting up.
220   *
221   * @return  {@code true} if the server is in the process of starting up, or
222   *          {@code false} if not.
223   */
224  boolean isStarting();
225
226
227
228  /**
229   * Indicates whether the server is currently running.
230   *
231   * @return  {@code true} if the server is running, or {@code false} if not.
232   */
233  boolean isRunning();
234
235
236
237  /**
238   * Indicates whether the server is in the process of shutting down.
239   *
240   * @return  {@code true} if the server is in the process of shutting down, or
241   *          {@code false} if not.
242   */
243  boolean isShuttingDown();
244
245
246
247  /**
248   * Retrieves the time that the server was started.  The value returned will
249   * be an offset in milliseconds since 12:00 a.m. on January 1, 1970.
250   *
251   * @return  The time that the server was started.
252   */
253  long getStartTime();
254
255
256
257  /**
258   * Retrieves a compact ID that was generated at the time the server was
259   * started.  It is not guaranteed to be unique among all instances of the
260   * server, but is guaranteed to be unique across all invocations of a single
261   * server installation.  This is suitable for inclusion in log messages and
262   * can help differentiate operations with the same connection ID and operation
263   * ID across server restarts.
264   *
265   * @return  A compact ID that was generated at the time the server was
266   *          started.
267   */
268  String getStartupID();
269
270
271
272  /**
273   * Retrieves a unique identifier that was generated at the time the server was
274   * started.  It will be unique across all server instances and all invocations
275   * of the same instance.
276   *
277   * @return  A unique identifier that was generated at the time the server was
278   *          started.
279   */
280  UUID getStartupUUID();
281
282
283
284  /**
285   * Retrieves the instance name that has been assigned to the server.
286   *
287   * @return  The instance name that has been assigned to the server.
288   */
289  String getInstanceName();
290
291
292
293
294  /**
295    * Retrieves the location that has been assigned to the server, if any.
296    *
297    * @return  The location that has been assigned to the server, or
298   *           {@code null} if no location has been assigned.
299    */
300   Location getLocation();
301
302
303
304  /**
305   * Retrieves the path to the server root directory.
306   *
307   * @return  The path to the server root directory.
308   */
309  File getServerRoot();
310
311
312
313  /**
314   * Retrieves a ToolExecutor that can be used to internally execute select
315   * command line utilities.
316   *
317   * @return  A ToolExecutor that can be used to internally execute select
318   *          command line utilities.
319   */
320  ToolExecutor getToolExecutor();
321
322
323
324  /**
325   * Indicates whether the extension is running in a server that has Directory
326   * Server functionality available.
327   *
328   * @return  {@code true} if Directory Server functionality is available, or
329   *          {@code false} if not.
330   */
331  boolean isDirectoryFunctionalityAvailable();
332
333
334
335  /**
336   * Indicates whether the extension is running in a server that has Directory
337   * Proxy Server functionality available.
338   *
339   * @return  {@code true} if Directory Proxy Server functionality is available,
340   *          or {@code false} if not.
341   */
342  boolean isDirectoryProxyFunctionalityAvailable();
343
344
345
346  /**
347   * Indicates whether the extension is running in a server that has
348   * Synchronization Server functionality available.
349   *
350   * @return  {@code true} if Synchronization Server functionality is available,
351   *          or {@code false} if not.
352   */
353  boolean isSyncFunctionalityAvailable();
354
355
356
357  /**
358   * Retrieves an internal connection that is authenticated as a root user
359   * that is not subject to access control.
360   * <BR><BR>
361   * During operation processing, this connection is considered a root
362   * connection that is both internal and secure.
363   * <BR><BR>
364   * Note that the returned connection will use the client connection policy
365   * defined as the default policy for internal operations.  If you have access
366   * to a {@code ClientContext} and wish to use the client connection policy
367   * associated with that connection, use the
368   * {@link ClientContext#getInternalRootConnection(boolean)}  method.
369   *
370   * @return  An internal connection that is authenticated as a root user.
371   */
372  InternalConnection getInternalRootConnection();
373
374
375
376  /**
377   * Retrieves an internal connection that is authenticated as the specified
378   * user.  Operations on the connection may be subject to access control based
379   * on the privileges associated with the specified user.
380   * <BR><BR>
381   * During operation processing, this connection is considered a user
382   * connection that is both internal and secure.
383   * <BR><BR>
384   * Note that the returned connection will use the client connection policy
385   * defined as the default policy for internal operations.  If you have access
386   * to a {@code ClientContext} and wish to use the client connection policy
387   * associated with that connection, use the
388   * {@link ClientContext#getInternalConnection(String,boolean)} method.
389   *
390   * @param  dn  The DN of the user as whom the connection should be
391   *             authenticated.  It may be {@code null} or empty if the
392   *             connection should be unauthenticated.
393   *
394   * @return  An internal connection that is authenticated as the specified
395   *          user.
396   *
397   * @throws  LDAPException  If a problem occurs while attempting to
398   *                         authenticate as the specified user.
399   */
400  InternalConnection getInternalConnection(final String dn)
401        throws LDAPException;
402
403
404
405  /**
406   * Retrieves a client connection that is authenticated as a root user
407   * and is not subject to access control.
408   * <BR><BR>
409   * This method should be used when the connection will be used on behalf of
410   * some external client, and allows you to indicate whether the external
411   * client has a secure connection. This information is used by some of the
412   * internal security controls, such as password policies, which may reject
413   * password change operations if they are not over a secure connection, for
414   * example.
415   * <BR><BR>
416   * During operation processing, this connection is considered a root
417   * connection that is external and optionally secure, depending on the
418   * {@code isClientSecure} parameter.
419   *
420   * @param  isClientSecure Whether the external client is connected over a
421   *                        secure channel.
422   *
423   * @return  A client connection that is authenticated as a root user.
424   */
425  LDAPInterface getClientRootConnection(final boolean isClientSecure);
426
427
428
429  /**
430   * Retrieves a client connection that is authenticated as the specified
431   * user.  Operations on the connection may be subject to access control based
432   * on the privileges associated with the specified user.
433   * <BR><BR>
434   * This method should be used when the connection will be used on behalf of
435   * some external client, and allows you to indicate whether the external
436   * client has a secure connection. This information is used by some of the
437   * internal security controls, such as password policies, which may reject
438   * password change operations if they are not over a secure connection, for
439   * example.
440   * <BR><BR>
441   * During operation processing, this connection is considered a user
442   * connection that is external and optionally secure, depending on the
443   * {@code isClientSecure} parameter.
444   *
445   * @param  dn  The DN of the user as whom the connection should be
446   *             authenticated.  It may be {@code null} or empty if the
447   *             connection should be unauthenticated.
448   *
449   * @param  isClientSecure Whether the external client is connected over a
450   *                        secure channel.
451   *
452   * @return  An internal connection that is authenticated as the specified
453   *          user.
454   *
455   * @throws  LDAPException  If a problem occurs while attempting to
456   *                         authenticate as the specified user.
457   */
458  LDAPInterface getClientConnection(final String dn,
459                                    final boolean isClientSecure)
460       throws LDAPException;
461
462
463
464  /**
465   * Retrieves a reference to the server schema.
466   *
467   * @return  A reference to the server schema.
468   */
469  Schema getSchema();
470
471
472
473  /**
474   * Registers the provided OID with the server so that it will appear in the
475   * supportedControl attribute of the server's root DSE.  This method should
476   * only be used by extensions which implement some level of support for that
477   * control (e.g., a pre-parse plugin which performs all necessary processing
478   * from the control and removes it from the request so that it will not be
479   * seen and potentially rejected by the core server).
480   *
481   * @param  oid  The OID to be registered.
482   */
483  void registerSupportedControlOID(final String oid);
484
485
486
487  /**
488   * Deregisters the provided OID with the server so that it will no longer
489   * appear in the supportedControl attribute of the server's root DSE.
490   *
491   * @param  oid  The OID to be deregistered.
492   */
493  void deregisterSupportedControlOID(final String oid);
494
495
496
497  /**
498   * Registers the provided change listener with the server so that it may be
499   * notified of any changes matching the provided criteria.
500   *
501   * @param  listener     The change listener to be registered with the server.
502   *                      It must not be {@code null}.
503   * @param  changeTypes  The types of changes for which the listener should be
504   *                      registered.  It may be {@code null} or empty to
505   *                      indicate that the listener should be registered for
506   *                      all types of changes.
507   * @param  baseDNs      The set of base DNs for which the listener should be
508   *                      registered.  It may be {@code null} or empty to
509   *                      indicate that the listener should be registered for
510   *                      changes processed anywhere in the server.
511   * @param  filter       A filter which may be used to restrict the set of
512   *                      changes for which the listener is notified.  If a
513   *                      filter is provided, then only changes in which the
514   *                      target entry matches the given filter (either before
515   *                      or after the change was processed) will be notified.
516   *                      It may be {@code null} to indicate that the contents
517   *                      of the entry should not be considered.
518   *
519   * @return  An object representing the change listener that has been
520   *          registered with the server.
521   *
522   * @throws  LDAPException  If a problem is encountered while attempting to
523   *                         register the provided change listener (e.g., if any
524   *                         of the base DNs cannot be parsed as a valid DN).
525   */
526  RegisteredChangeListener registerChangeListener(final ChangeListener listener,
527                                final Set<ChangeType> changeTypes,
528                                final List<String> baseDNs,
529                                final Filter filter)
530       throws LDAPException;
531
532
533
534  /**
535   * Deregisters the provided change listener with the server.  This will have
536   * no effect if the provided listener is not registered.
537   *
538   * @param  listener  The change listener to be deregistered.  It must not be
539   *                   {@code null}.
540   */
541  void deregisterChangeListener(final RegisteredChangeListener listener);
542
543
544
545  /**
546   * Registers the provided disk space consumer with the server.
547   *
548   * @param  consumer  The disk space consumer to be registered with the server.
549   *                   It must not be {@code null}.
550   *
551   * @return  An object representing the disk space consumer that has been
552   *          registered with the server.
553   */
554  RegisteredDiskSpaceConsumer registerDiskSpaceConsumer(
555                                   final DiskSpaceConsumer consumer);
556
557
558
559  /**
560   * Deregisters the provided disk space consumer with the server.  This will no
561   * no effect if the provided consumer is not registered.
562   *
563   * @param  consumer  The disk space consumer to be deregistered with the
564   *                   server. It must not be {@code null}.
565   */
566  void deregisterDiskSpaceConsumer(final RegisteredDiskSpaceConsumer consumer);
567
568
569
570  /**
571   * Registers the provided listener to be notified when the server shutdown
572   * process has begun.
573   *
574   * @param  listener  The server shutdown listener to be registered.  It must
575   *                   not be {@code null}.
576   *
577   * @return  An object representing the shutdown listener that has been
578   *          registered with the server.
579   */
580  RegisteredServerShutdownListener registerShutdownListener(
581                                        final ServerShutdownListener listener);
582
583
584
585  /**
586   * Deregisters the provided server shutdown listener with the server.  This
587   * will have no effect if the provided listener is not registered.
588   *
589   * @param  listener  The server shutdown listener to be deregistered.  It must
590   *                   not be {@code null}.
591   */
592  void deregisterShutdownListener(
593            final RegisteredServerShutdownListener listener);
594
595
596
597  /**
598   * Registers the given monitor provider with the server. It is important that
599   * this monitor provider has a unique instance name across all monitor
600   * providers in the server. If there is already a monitor provider registered
601   * with the same instance name, an {@link IllegalStateException} will be
602   * thrown.
603   * <p>
604   * The generated monitor entry will have a DN in the following format:
605   * <code>cn={monitor-instance-name} [from {extension-type}:{extension-name}],
606   * cn=monitor</code> and it will contain three auto-generated attributes:
607   * <code>ds-extension-monitor-name</code>, <code>ds-extension-type</code>, and
608   * <code>ds-extension-name</code>. Note: the {extension-type} and
609   * {extension-name} are from the extension which owns this ServerContext
610   * instance, not from the given MonitorProvider object.
611   * <p>
612   * The specified monitor provider does not need any server-side configuration,
613   * and the configuration-related methods
614   * (<code>initalizeMonitorProvider()</code>,
615   *  <code>finalizeMonitorProvider()</code>,
616   *  <code>defineConfigArguments()</code>,
617   *  <code>isConfigurationAcceptable()</code>,
618   *  <code>applyConfiguration()</code>) do not need to be implemented because
619   *  they will not be called.
620   * <p>
621   * When an extension is disabled, all of its registered monitor
622   * providers will automatically deregister themselves from the server.
623   * You can also manually deregister them using
624   * {@link #deregisterMonitorProvider(RegisteredMonitorProvider)} or
625   * {@link #deregisterAllMonitorProviders()}.
626   *
627   * @param provider The monitor provider instance to be registered. It
628   *                 must not be {@code null}.
629   * @param config The configuration object from the extension that is
630   *               registering the given monitor provider. This is required so
631   *               that the monitor entry can be given a unique DN which
632   *               includes the name of the extension that registered it.
633   *
634   * @return An object representing the monitor provider that has been
635   *         registered with the server.
636   */
637  RegisteredMonitorProvider registerMonitorProvider(
638                                 final MonitorProvider provider,
639                                 final GenericConfig config);
640
641
642
643  /**
644   * Deregisters the given monitor provider with the server. This will have no
645   * effect if the given monitor provider is not registered.
646   *
647   * @param provider The monitor provider instance to be registered. It
648   *                 must not be {@code null}.
649   */
650  void deregisterMonitorProvider(final RegisteredMonitorProvider provider);
651
652
653
654  /**
655   * Deregisters all the monitor providers that were registered with the server
656   * by this instance of {@link ServerContext}. This can be useful during
657   * cleanup or if you want to clear out all the existing monitor data from a
658   * given extension and register new monitor providers.
659   * <p>
660   * This will be called automatically when your extension is unloaded or
661   * disabled.
662   */
663  void deregisterAllMonitorProviders();
664
665
666
667  /**
668   * Creates a new thread to run within the server.  The thread will not be
669   * started.
670   *
671   * @param  name          The name to use for the thread.  It must not be
672   *                       {@code null} or empty.
673   * @param  serverThread  The class providing the logic for the thread.  It
674   *                       must not be {@code null}.
675   *
676   * @return  The thread that has been created but not yet started.
677   */
678  Thread createThread(final ServerThread serverThread, final String name);
679
680
681
682  /**
683   * Writes a message to the server error log.
684   *
685   * @param  severity  The severity to use for the log message.  It must not be
686   *                   {@code null}.
687   * @param  message   The message to be logged.  It must not be {@code null}.
688   */
689  void logMessage(final LogSeverity severity, final String message);
690
691
692
693  /**
694   * Generates an administrative alert notification.
695   *
696   * @param  severity  The severity to use for the alert notification.  It must
697   *                   not be {@code null}.
698   * @param  message   The message to be used for the alert notification.  It
699   *                   must not be {@code null}.
700   */
701  void sendAlert(final AlertSeverity severity, final String message);
702
703
704
705  /**
706   * Generates an administrative alert notification.
707   *
708   * @param  alertTypeName  The name to use to identify the alert type.  Each
709   *                        kind of alert must have a distinct name and all
710   *                        alerts with this alert type must always be used with
711   *                        the same severity and OID values.  Alert type names
712   *                        must start with a lowercase ASCII letter and must
713   *                        contain only lowercase ASCII letters, numeric
714   *                        digits, and dashes.
715   * @param  severity       The severity to use for the alert notification.
716   *                        It must not be {@code null}.
717   * @param  alertTypeOID   The numeric OID for the alert type.  It must not be
718   *                        {@code null}, and it must be a valid numeric OID.
719   *                        The same OID must always be used for the associated
720   *                        alert type, and each different alert type must have
721   *                        a unique OID.
722   * @param  message        The message to be used for the alert notification.
723   *                        It must not be {@code null}.
724   *
725   * @throws  LDAPException  If the provided information cannot be used to
726   *                         generate a valid alert (e.g., if the alert type
727   *                         name does not meet the naming constraints or has
728   *                         already been used with a different severity and/or
729   *                         OID, or if the OID has already been used with a
730   *                         different alert type).
731   */
732  void sendAlert(final String alertTypeName, final AlertSeverity severity,
733                 final String alertTypeOID, final String message)
734       throws LDAPException;
735
736
737
738  /**
739   * Generates an administrative alert and updates the server's general monitor
740   * entry to list the specified alert type as a degraded alert type.  Once the
741   * condition that triggered the server to be considered degraded has been
742   * resolved, the {@link DegradedAlertType#setResolved} method should be used
743   * to remove the alert type from the list of degraded alert types.
744   * <BR><BR>
745   * If a server has one or more unavailable alert types, it will be considered
746   * unavailable for use by products which make use of this information.  If a
747   * server does not have any unavailable alert types but has one or more
748   * degraded alert types, then it will be considered degraded and less
749   * desirable for use by products which make use of this information.
750   *
751   * @param  alertTypeName  The name to use to identify the alert type.  Each
752   *                        kind of alert must have a distinct name and all
753   *                        alerts with this alert type must always be used with
754   *                        the same severity and OID values.  Alert type names
755   *                        must start with a lowercase ASCII letter and must
756   *                        contain only lowercase ASCII letters, numeric
757   *                        digits, and dashes.
758   * @param  severity       The severity to use for the alert notification.
759   *                        It must not be {@code null}.
760   * @param  alertTypeOID   The numeric OID for the alert type.  It must not be
761   *                        {@code null}, and it must be a valid numeric OID.
762   *                        The same OID must always be used for the associated
763   *                        alert type, and each different alert type must have
764   *                        a unique OID.
765   * @param  message        The message to be used for the alert notification.
766   *                        It must not be {@code null}.
767   *
768   * @return  An object that may be used to obtain information about the alert
769   *          type and indicate that the degraded condition has been resolved.
770   *
771   * @throws  LDAPException  If the provided information cannot be used to
772   *                         generate a valid alert (e.g., if the alert type
773   *                         name does not meet the naming constraints or has
774   *                         already been used with a different severity and/or
775   *                         OID, or if the OID has already been used with a
776   *                         different alert type).
777   */
778  DegradedAlertType sendDegradedAlertNotification(final String alertTypeName,
779                                                  final AlertSeverity severity,
780                                                  final String alertTypeOID,
781                                                  final String message)
782       throws LDAPException;
783
784
785
786  /**
787   * Generates an administrative alert and updates the server's general monitor
788   * entry to list the specified alert type as an unavailable alert type.  Once
789   * the condition that triggered the server to be considered unavailable has
790   * been resolved, the {@link UnavailableAlertType#setResolved} method should
791   * be used to remove the alert type from the list of unavailable alert types.
792   * <BR><BR>
793   * If a server has one or more unavailable alert types, it will be considered
794   * unavailable for use by products which make use of this information.  If a
795   * server does not have any unavailable alert types but has one or more
796   * degraded alert types, then it will be considered degraded and less
797   * desirable for use by products which make use of this information.
798   *
799   * @param  alertTypeName  The name to use to identify the alert type.  Each
800   *                        kind of alert must have a distinct name and all
801   *                        alerts with this alert type must always be used with
802   *                        the same severity and OID values.  Alert type names
803   *                        must start with a lowercase ASCII letter and must
804   *                        contain only lowercase ASCII letters, numeric
805   *                        digits, and dashes.
806   * @param  severity       The severity to use for the alert notification.
807   *                        It must not be {@code null}.
808   * @param  alertTypeOID   The numeric OID for the alert type.  It must not be
809   *                        {@code null}, and it must be a valid numeric OID.
810   *                        The same OID must always be used for the associated
811   *                        alert type, and each different alert type must have
812   *                        a unique OID.
813   * @param  message        The message to be used for the alert notification.
814   *                        It must not be {@code null}.
815   *
816   * @return  An object that may be used to obtain information about the alert
817   *          type and indicate that the unavailable condition has been
818   *          resolved.
819   *
820   * @throws  LDAPException  If the provided information cannot be used to
821   *                         generate a valid alert (e.g., if the alert type
822   *                         name does not meet the naming constraints or has
823   *                         already been used with a different severity and/or
824   *                         OID, or if the OID has already been used with a
825   *                         different alert type).
826   */
827  UnavailableAlertType sendUnavailableAlertNotification(
828                            final String alertTypeName,
829                            final AlertSeverity severity,
830                            final String alertTypeOID, final String message)
831       throws LDAPException;
832
833
834
835  /**
836   * Indicates whether debugging is enabled in the server.
837   * <BR><BR>
838   * Note that debug messages written by Server SDK extensions will be handled
839   * in the same way as debug messages generated in other areas of the server.
840   * However, the "Server SDK Extension Debug Logger" may be used to easily
841   * obtain only debug messages generated by Server SDK extensions, suppressing
842   * all messages generated in other areas of the server.
843   *
844   * @return  {@code true} if debugging is enabled in the server, or
845   *          {@code false} if not.
846   */
847  boolean debugEnabled();
848
849
850
851  /**
852   * Writes a debug message indicating that the provided exception has been
853   * caught.
854   * <BR><BR>
855   * Note that debug messages written by Server SDK extensions will be handled
856   * in the same way as debug messages generated in other areas of the server.
857   * However, the "Server SDK Extension Debug Logger" may be used to easily
858   * obtain only debug messages generated by Server SDK extensions, suppressing
859   * all messages generated in other areas of the server.
860   *
861   * @param  t  The exception that has been caught.
862   */
863  void debugCaught(final Throwable t);
864
865
866
867  /**
868   * Writes a debug message indicating that the provided exception will be
869   * thrown.
870   * <BR><BR>
871   * Note that debug messages written by Server SDK extensions will be handled
872   * in the same way as debug messages generated in other areas of the server.
873   * However, the "Server SDK Extension Debug Logger" may be used to easily
874   * obtain only debug messages generated by Server SDK extensions, suppressing
875   * all messages generated in other areas of the server.
876   *
877   * @param  t  The exception that will be thrown.
878   */
879  void debugThrown(final Throwable t);
880
881
882
883  /**
884   * Writes a debug message with an error severity.
885   * <BR><BR>
886   * Note that debug messages written by Server SDK extensions will be handled
887   * in the same way as debug messages generated in other areas of the server.
888   * However, the "Server SDK Extension Debug Logger" may be used to easily
889   * obtain only debug messages generated by Server SDK extensions, suppressing
890   * all messages generated in other areas of the server.
891   *
892   * @param  message  The message to be debugged.
893   */
894  void debugError(final String message);
895
896
897
898  /**
899   * Writes a debug message with a warning severity.
900   * <BR><BR>
901   * Note that debug messages written by Server SDK extensions will be handled
902   * in the same way as debug messages generated in other areas of the server.
903   * However, the "Server SDK Extension Debug Logger" may be used to easily
904   * obtain only debug messages generated by Server SDK extensions, suppressing
905   * all messages generated in other areas of the server.
906   *
907   * @param  message  The message to be debugged.
908   */
909  void debugWarning(final String message);
910
911
912
913  /**
914   * Writes a debug message with an informational severity.
915   * <BR><BR>
916   * Note that debug messages written by Server SDK extensions will be handled
917   * in the same way as debug messages generated in other areas of the server.
918   * However, the "Server SDK Extension Debug Logger" may be used to easily
919   * obtain only debug messages generated by Server SDK extensions, suppressing
920   * all messages generated in other areas of the server.
921   *
922   * @param  message  The message to be debugged.
923   */
924  void debugInfo(final String message);
925
926
927
928  /**
929   * Writes a debug message with a verbose severity.
930   * <BR><BR>
931   * Note that debug messages written by Server SDK extensions will be handled
932   * in the same way as debug messages generated in other areas of the server.
933   * However, the "Server SDK Extension Debug Logger" may be used to easily
934   * obtain only debug messages generated by Server SDK extensions, suppressing
935   * all messages generated in other areas of the server.
936   *
937   * @param  message  The message to be debugged.
938   */
939  void debugVerbose(final String message);
940
941
942
943  /**
944   * Retrieves a connection that is established and (if appropriate)
945   * authenticated to the specified LDAP External server.  This will be a
946   * newly-created connection that is not used for any other purpose, and the
947   * caller is responsible for closing that connection when it is no longer
948   * needed.
949   *
950   * @param  ldapExternalServerCfgObjectName  The name of the configuration
951   *                                          object for the LDAP external
952   *                                          server to which the connection
953   *                                          should be established.  It must
954   *                                          not be {@code null}.
955   * @param  connectionOptions                The set of options to use for the
956   *                                          connection that is established.
957   *                                          It may be {@code null} if a
958   *                                          default set of options should be
959   *                                          used.
960   *
961   * @return  The newly-created LDAP connection.
962   *
963   * @throws  LDAPException  If it is not possible to establish a connection to
964   *                         the target servers.
965   */
966  LDAPConnection getLDAPExternalServerConnection(
967                      final String ldapExternalServerCfgObjectName,
968                      final LDAPConnectionOptions connectionOptions)
969       throws LDAPException;
970
971
972
973  /**
974   * Retrieves a connection pool with connections to the specified server.  This
975   * will be a newly-created connection pool that is not used for any other
976   * purpose, and the caller is responsible for closing that connection pool
977   * when it is no longer needed.
978   *
979   * @param  ldapExternalServerCfgObjectName  The name of the configuration
980   *                                          object for the LDAP external
981   *                                          server to which the connections
982   *                                          should be established.  It must
983   *                                          not be {@code null}.
984   * @param  connectionOptions                The set of options to use for the
985   *                                          connection that is established.
986   *                                          It may be {@code null} if a
987   *                                          default set of options should be
988   *                                          used.
989   * @param  initialConnections               The initial number of connections
990   *                                          to attempt to establish.  It must
991   *                                          be greater than or equal to zero.
992   * @param  maxConnections                   The maximum number of connections
993   *                                          that should be established and
994   *                                          unused in the pool at any time.
995   *                                          It must be greater than or equal
996   *                                          to {@code initialConnections}, and
997   *                                          it must not be zero.
998   * @param  throwOnConnectFailure            Indicates whether to throw an
999   *                                          {@code LDAPException} if an error
1000   *                                          is encountered while attempting to
1001   *                                          connect or authenticate any of the
1002   *                                          initial connections.  If this is
1003   *                                          {@code false} and none of the
1004   *                                          initial connections can be
1005   *                                          established (or if the initial
1006   *                                          number of connections is zero),
1007   *                                          then the pool will be returned
1008   *                                          without any connections.
1009   *
1010   * @return  The newly-created LDAP connection pool.
1011   *
1012   * @throws  LDAPException  If it is not possible to establish a pool of
1013   *                         connections to the specified LDAP external server.
1014   */
1015  LDAPConnectionPool getLDAPExternalServerConnectionPool(
1016                          final String ldapExternalServerCfgObjectName,
1017                          final LDAPConnectionOptions connectionOptions,
1018                          final int initialConnections,
1019                          final int maxConnections,
1020                          final boolean throwOnConnectFailure)
1021       throws LDAPException;
1022
1023
1024
1025  /**
1026   * Retrieves the plaintext representation of the specified obscured value from
1027   * the server configuration.  Obscured values may be used to allow extensions
1028   * to store potentially sensitive information (for example, credentials needed
1029   * to access some external system) in the configuration in a manner that will
1030   * prevent them from being stored in the clear or displayed in the clear in
1031   * administrative interfaces.  If a server extension needs to be configured
1032   * with potentially sensitive information, it is recommended that each piece
1033   * of sensitive information be stored as an obscured value, and that the
1034   * extension be configured with the names of the relevant obscured values.
1035   *
1036   * @param  obscuredValueConfigObjectName  The name of the configuration object
1037   *                                        for the obscured value to retrieve.
1038   *                                        It must not be {@code null}.
1039   *
1040   * @return  The plaintext representation of the specified obscured value from
1041   *          the server configuration.
1042   *
1043   * @throws  LDAPException  If the provided name does not reference an obscured
1044   *                         value that is defined in the server configuration.
1045   */
1046  String getObscuredValue(final String obscuredValueConfigObjectName)
1047         throws LDAPException;
1048}