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-2021 Ping Identity Corporation
026 */
027package com.unboundid.directory.sdk.common.types;
028
029
030
031import java.io.File;
032import java.io.InputStream;
033import java.io.IOException;
034import java.io.OutputStream;
035import java.security.GeneralSecurityException;
036import java.util.Collection;
037import java.util.List;
038import java.util.Map;
039import java.util.Set;
040import java.util.UUID;
041
042import javax.mail.MessagingException;
043
044import com.unboundid.directory.sdk.ds.api.ChangeListener;
045import com.unboundid.directory.sdk.common.api.DiskSpaceConsumer;
046import com.unboundid.directory.sdk.common.api.MonitorProvider;
047import com.unboundid.directory.sdk.common.api.ServerShutdownListener;
048import com.unboundid.directory.sdk.common.api.ServerThread;
049import com.unboundid.directory.sdk.common.config.GenericConfig;
050import com.unboundid.directory.sdk.common.schema.Schema;
051import com.unboundid.directory.sdk.ds.types.RegisteredChangeListener;
052import com.unboundid.directory.sdk.proxy.types.Location;
053import com.unboundid.ldap.sdk.ChangeType;
054import com.unboundid.ldap.sdk.DN;
055import com.unboundid.ldap.sdk.Filter;
056import com.unboundid.ldap.sdk.LDAPConnection;
057import com.unboundid.ldap.sdk.LDAPConnectionOptions;
058import com.unboundid.ldap.sdk.LDAPConnectionPool;
059import com.unboundid.ldap.sdk.LDAPException;
060import com.unboundid.ldap.sdk.LDAPInterface;
061import com.unboundid.util.NotExtensible;
062import com.unboundid.util.ThreadSafety;
063import com.unboundid.util.ThreadSafetyLevel;
064
065
066
067/**
068 * This interface may be used to obtain information about the server in
069 * which an extension is running.
070 */
071@NotExtensible()
072@ThreadSafety(level=ThreadSafetyLevel.INTERFACE_THREADSAFE)
073public interface ServerContext
074{
075  /**
076   * Retrieves the compact name of the server vendor.  The returned name will
077   * not have any spaces.
078   *
079   * @return  The compact name of the server vendor.
080   */
081  String getShortVendorName();
082
083
084
085  /**
086   * Retrieves the full name of the server vendor.  The returned name may
087   * contain spaces.
088   *
089   * @return  The full name of the server vendor.
090   */
091  String getFullVendorName();
092
093
094
095  /**
096   * Retrieves the compact name of the server.  The returned name will not have
097   * any spaces.
098   *
099   * @return  The compact name of the server.
100   */
101  String getCompactProductName();
102
103
104
105  /**
106   * Retrieves the package name of the server that is used for defining the
107   * server package ZIP file and root directory.  The returned name will not
108   * have any spaces.
109   *
110   * @return  The package name of the server.
111   */
112  String getPackageName();
113
114
115
116  /**
117   * Retrieves the full name of the server.  The returned name may contain
118   * spaces.
119   *
120   * @return  The full name of the server.
121   */
122  String getFullProductName();
123
124
125
126  /**
127   * Retrieves the base name of the server which is generally the full
128   * product name without the vendor information.  The returned name may
129   * contain spaces.
130   *
131   * @return  The full name of the server.
132   */
133  String getBasicProductName();
134
135
136
137  /**
138   * Retrieves the major version number for the server.  The major version
139   * number is the first number which appears in the full version string (e.g.,
140   * for a version string of "1.2.3.4-beta5", the major version number is 1).
141   *
142   * @return  The major version number for the server.
143   */
144  int getMajorVersionNumber();
145
146
147
148  /**
149   * Retrieves the minor version number for the server.  The minor version
150   * number is the second number which appears in the full version string (e.g.,
151   * for a version string of "1.2.3.4-beta5", the minor version number is 2).
152   *
153   * @return  The minor version number for the server.
154   */
155  int getMinorVersionNumber();
156
157
158
159  /**
160   * Retrieves the point version number for the server.  The point version
161   * number is the third number which appears in the full version string (e.g.,
162   * for a version string of "1.2.3.4-beta5", the point version number is 3).
163   *
164   * @return  The point version number for the server.
165   */
166  int getPointVersionNumber();
167
168
169
170  /**
171   * Retrieves the patch version number for the server.  The patch version
172   * number is the fourth number which appears in the full version string (e.g.,
173   * for a version string of "1.2.3.4-beta5", the patch version number is 4).
174   *
175   * @return  The point version number for the server.
176   */
177  int getPatchVersionNumber();
178
179
180
181  /**
182   * Retrieves a string that is the concatenation of the major, minor,
183   * point, and patch version numbers of the server.
184   *
185   * @return the server's version number string.
186   */
187  String getVersionNumber();
188
189
190
191  /**
192   * Retrieves a string that is the concatenation of the product name, the
193   * major, minor, point, and patch version numbers of the server and any
194   * any other unique version information.
195   *
196   * @return the server's full version number string.
197   */
198  String getFullVersion();
199
200
201
202  /**
203   * Retrieves the version qualifier string for the server.  The version
204   * qualifier is an optional string which may provide additional information
205   * about the server version.  If a version qualifier is present, then it will
206   * immediately follow the patch version number (e.g., for a version string of
207   * "1.2.3.4-beta5", the version qualifier is "-beta5").
208   *
209   * @return  The version qualifier for the server, or an empty string if no
210   *          version qualifier is defined.
211   */
212  String getVersionQualifier();
213
214
215
216  /**
217   * Retrieves a value which identifies the source revision (in the
218   * version control system used to hold the server source code) from which the
219   * server was built.
220   *
221   * @return  The source revision identifier for the server.
222   */
223  String getSourceRevision();
224
225
226
227  /**
228   * Indicates whether the server is in the process of starting up.
229   *
230   * @return  {@code true} if the server is in the process of starting up, or
231   *          {@code false} if not.
232   */
233  boolean isStarting();
234
235
236
237  /**
238   * Indicates whether the server is currently running.
239   *
240   * @return  {@code true} if the server is running, or {@code false} if not.
241   */
242  boolean isRunning();
243
244
245
246  /**
247   * Indicates whether the server is in the process of shutting down.
248   *
249   * @return  {@code true} if the server is in the process of shutting down, or
250   *          {@code false} if not.
251   */
252  boolean isShuttingDown();
253
254
255
256  /**
257   * Retrieves the time that the server was started.  The value returned will
258   * be an offset in milliseconds since 12:00 a.m. on January 1, 1970.
259   *
260   * @return  The time that the server was started.
261   */
262  long getStartTime();
263
264
265
266  /**
267   * Retrieves a compact ID that was generated at the time the server was
268   * started.  It is not guaranteed to be unique among all instances of the
269   * server, but is guaranteed to be unique across all invocations of a single
270   * server installation.  This is suitable for inclusion in log messages and
271   * can help differentiate operations with the same connection ID and operation
272   * ID across server restarts.
273   *
274   * @return  A compact ID that was generated at the time the server was
275   *          started.
276   */
277  String getStartupID();
278
279
280
281  /**
282   * Retrieves a unique identifier that was generated at the time the server was
283   * started.  It will be unique across all server instances and all invocations
284   * of the same instance.
285   *
286   * @return  A unique identifier that was generated at the time the server was
287   *          started.
288   */
289  UUID getStartupUUID();
290
291
292
293  /**
294   * Retrieves the instance name that has been assigned to the server.
295   *
296   * @return  The instance name that has been assigned to the server.
297   */
298  String getInstanceName();
299
300
301
302
303  /**
304    * Retrieves the location that has been assigned to the server, if any.
305    *
306    * @return  The location that has been assigned to the server, or
307   *           {@code null} if no location has been assigned.
308    */
309   Location getLocation();
310
311
312
313  /**
314   * Retrieves the path to the server root directory.
315   *
316   * @return  The path to the server root directory.
317   */
318  File getServerRoot();
319
320
321
322  /**
323   * Retrieves a ToolExecutor that can be used to internally execute select
324   * command line utilities.
325   *
326   * @return  A ToolExecutor that can be used to internally execute select
327   *          command line utilities.
328   */
329  ToolExecutor getToolExecutor();
330
331
332
333  /**
334   * Indicates whether the extension is running in a server that has Directory
335   * Server functionality available.
336   *
337   * @return  {@code true} if Directory Server functionality is available, or
338   *          {@code false} if not.
339   */
340  boolean isDirectoryFunctionalityAvailable();
341
342
343
344  /**
345   * Indicates whether the extension is running in a server that has Directory
346   * Proxy Server functionality available.
347   *
348   * @return  {@code true} if Directory Proxy Server functionality is available,
349   *          or {@code false} if not.
350   */
351  boolean isDirectoryProxyFunctionalityAvailable();
352
353
354
355  /**
356   * Indicates whether the extension is running in a server that has
357   * Data Sync Server functionality available.
358   *
359   * @return  {@code true} if Data Sync Server functionality is
360   *          available, or {@code false} if not.
361   */
362  boolean isSyncFunctionalityAvailable();
363
364
365
366  /**
367   * Retrieves an internal connection that is authenticated as a root user
368   * that is not subject to access control.
369   * <BR><BR>
370   * During operation processing, this connection is considered a root
371   * connection that is both internal and secure.
372   * <BR><BR>
373   * Note that the returned connection will use the client connection policy
374   * defined as the default policy for internal operations.  If you have access
375   * to a {@code ClientContext} and wish to use the client connection policy
376   * associated with that connection, use the
377   * {@link ClientContext#getInternalRootConnection(boolean)}  method.
378   *
379   * @return  An internal connection that is authenticated as a root user.
380   */
381  InternalConnection getInternalRootConnection();
382
383
384
385  /**
386   * Retrieves an internal connection that is authenticated as the specified
387   * user.  Operations on the connection may be subject to access control based
388   * on the privileges associated with the specified user.
389   * <BR><BR>
390   * During operation processing, this connection is considered a user
391   * connection that is both internal and secure.
392   * <BR><BR>
393   * Note that the returned connection will use the client connection policy
394   * defined as the default policy for internal operations.  If you have access
395   * to a {@code ClientContext} and wish to use the client connection policy
396   * associated with that connection, use the
397   * {@link ClientContext#getInternalConnection(String,boolean)} method.
398   *
399   * @param  dn  The DN of the user as whom the connection should be
400   *             authenticated.  It may be {@code null} or empty if the
401   *             connection should be unauthenticated.
402   *
403   * @return  An internal connection that is authenticated as the specified
404   *          user.
405   *
406   * @throws  LDAPException  If a problem occurs while attempting to
407   *                         authenticate as the specified user.
408   */
409  InternalConnection getInternalConnection(final String dn)
410        throws LDAPException;
411
412
413
414  /**
415   * Retrieves a client connection that is authenticated as a root user
416   * and is not subject to access control.
417   * <BR><BR>
418   * This method should be used when the connection will be used on behalf of
419   * some external client, and allows you to indicate whether the external
420   * client has a secure connection. This information is used by some of the
421   * internal security controls, such as password policies, which may reject
422   * password change operations if they are not over a secure connection, for
423   * example.
424   * <BR><BR>
425   * During operation processing, this connection is considered a root
426   * connection that is external and optionally secure, depending on the
427   * {@code isClientSecure} parameter.
428   *
429   * @param  isClientSecure Whether the external client is connected over a
430   *                        secure channel.
431   *
432   * @return  A client connection that is authenticated as a root user.
433   */
434  LDAPInterface getClientRootConnection(final boolean isClientSecure);
435
436
437
438  /**
439   * Retrieves a client connection that is authenticated as the specified
440   * user.  Operations on the connection may be subject to access control based
441   * on the privileges associated with the specified user.
442   * <BR><BR>
443   * This method should be used when the connection will be used on behalf of
444   * some external client, and allows you to indicate whether the external
445   * client has a secure connection. This information is used by some of the
446   * internal security controls, such as password policies, which may reject
447   * password change operations if they are not over a secure connection, for
448   * example.
449   * <BR><BR>
450   * During operation processing, this connection is considered a user
451   * connection that is external and optionally secure, depending on the
452   * {@code isClientSecure} parameter.
453   *
454   * @param  dn  The DN of the user as whom the connection should be
455   *             authenticated.  It may be {@code null} or empty if the
456   *             connection should be unauthenticated.
457   *
458   * @param  isClientSecure Whether the external client is connected over a
459   *                        secure channel.
460   *
461   * @return  An internal connection that is authenticated as the specified
462   *          user.
463   *
464   * @throws  LDAPException  If a problem occurs while attempting to
465   *                         authenticate as the specified user.
466   */
467  LDAPInterface getClientConnection(final String dn,
468                                    final boolean isClientSecure)
469       throws LDAPException;
470
471
472
473  /**
474   * Retrieves a reference to the server schema.
475   *
476   * @return  A reference to the server schema.
477   */
478  Schema getSchema();
479
480
481
482  /**
483   * Registers the provided OID with the server so that it will appear in the
484   * supportedControl attribute of the server's root DSE.  This method should
485   * only be used by extensions which implement some level of support for that
486   * control (e.g., a pre-parse plugin which performs all necessary processing
487   * from the control and removes it from the request so that it will not be
488   * seen and potentially rejected by the core server).
489   *
490   * @param  oid  The OID to be registered.
491   */
492  void registerSupportedControlOID(final String oid);
493
494
495
496  /**
497   * Deregisters the provided OID with the server so that it will no longer
498   * appear in the supportedControl attribute of the server's root DSE.
499   *
500   * @param  oid  The OID to be deregistered.
501   */
502  void deregisterSupportedControlOID(final String oid);
503
504
505
506  /**
507   * Registers the provided change listener with the server so that it may be
508   * notified of any changes matching the provided criteria.
509   *
510   * @param  listener     The change listener to be registered with the server.
511   *                      It must not be {@code null}.
512   * @param  changeTypes  The types of changes for which the listener should be
513   *                      registered.  It may be {@code null} or empty to
514   *                      indicate that the listener should be registered for
515   *                      all types of changes.
516   * @param  baseDNs      The set of base DNs for which the listener should be
517   *                      registered.  It may be {@code null} or empty to
518   *                      indicate that the listener should be registered for
519   *                      changes processed anywhere in the server.
520   * @param  filter       A filter which may be used to restrict the set of
521   *                      changes for which the listener is notified.  If a
522   *                      filter is provided, then only changes in which the
523   *                      target entry matches the given filter (either before
524   *                      or after the change was processed) will be notified.
525   *                      It may be {@code null} to indicate that the contents
526   *                      of the entry should not be considered.
527   *
528   * @return  An object representing the change listener that has been
529   *          registered with the server.
530   *
531   * @throws  LDAPException  If a problem is encountered while attempting to
532   *                         register the provided change listener (e.g., if any
533   *                         of the base DNs cannot be parsed as a valid DN).
534   */
535  RegisteredChangeListener registerChangeListener(final ChangeListener listener,
536                                final Set<ChangeType> changeTypes,
537                                final List<String> baseDNs,
538                                final Filter filter)
539       throws LDAPException;
540
541
542
543  /**
544   * Deregisters the provided change listener with the server.  This will have
545   * no effect if the provided listener is not registered.
546   *
547   * @param  listener  The change listener to be deregistered.  It must not be
548   *                   {@code null}.
549   */
550  void deregisterChangeListener(final RegisteredChangeListener listener);
551
552
553
554  /**
555   * Registers the provided disk space consumer with the server.
556   *
557   * @param  consumer  The disk space consumer to be registered with the server.
558   *                   It must not be {@code null}.
559   *
560   * @return  An object representing the disk space consumer that has been
561   *          registered with the server.
562   */
563  RegisteredDiskSpaceConsumer registerDiskSpaceConsumer(
564                                   final DiskSpaceConsumer consumer);
565
566
567
568  /**
569   * Deregisters the provided disk space consumer with the server.  This will no
570   * no effect if the provided consumer is not registered.
571   *
572   * @param  consumer  The disk space consumer to be deregistered with the
573   *                   server. It must not be {@code null}.
574   */
575  void deregisterDiskSpaceConsumer(final RegisteredDiskSpaceConsumer consumer);
576
577
578
579  /**
580   * Registers the provided listener to be notified when the server shutdown
581   * process has begun.
582   *
583   * @param  listener  The server shutdown listener to be registered.  It must
584   *                   not be {@code null}.
585   *
586   * @return  An object representing the shutdown listener that has been
587   *          registered with the server.
588   */
589  RegisteredServerShutdownListener registerShutdownListener(
590                                        final ServerShutdownListener listener);
591
592
593
594  /**
595   * Deregisters the provided server shutdown listener with the server.  This
596   * will have no effect if the provided listener is not registered.
597   *
598   * @param  listener  The server shutdown listener to be deregistered.  It must
599   *                   not be {@code null}.
600   */
601  void deregisterShutdownListener(
602            final RegisteredServerShutdownListener listener);
603
604
605
606  /**
607   * Registers the given monitor provider with the server. It is important that
608   * this monitor provider has a unique instance name across all monitor
609   * providers in the server. If there is already a monitor provider registered
610   * with the same instance name, an {@link IllegalStateException} will be
611   * thrown.
612   * <p>
613   * The generated monitor entry will have a DN in the following format:
614   * <code>cn={monitor-instance-name} [from {extension-type}:{extension-name}],
615   * cn=monitor</code> and it will contain three auto-generated attributes:
616   * <code>ds-extension-monitor-name</code>, <code>ds-extension-type</code>, and
617   * <code>ds-extension-name</code>. Note: the {extension-type} and
618   * {extension-name} are from the extension which owns this ServerContext
619   * instance, not from the given MonitorProvider object.
620   * <p>
621   * The specified monitor provider does not need any server-side configuration,
622   * and the configuration-related methods
623   * (<code>initalizeMonitorProvider()</code>,
624   *  <code>finalizeMonitorProvider()</code>,
625   *  <code>defineConfigArguments()</code>,
626   *  <code>isConfigurationAcceptable()</code>,
627   *  <code>applyConfiguration()</code>) do not need to be implemented because
628   *  they will not be called.
629   * <p>
630   * When an extension is disabled, all of its registered monitor
631   * providers will automatically deregister themselves from the server.
632   * You can also manually deregister them using
633   * {@link #deregisterMonitorProvider(RegisteredMonitorProvider)} or
634   * {@link #deregisterAllMonitorProviders()}.
635   *
636   * @param provider The monitor provider instance to be registered. It
637   *                 must not be {@code null}.
638   * @param config The configuration object from the extension that is
639   *               registering the given monitor provider. This is required so
640   *               that the monitor entry can be given a unique DN which
641   *               includes the name of the extension that registered it.
642   *
643   * @return An object representing the monitor provider that has been
644   *         registered with the server.
645   */
646  RegisteredMonitorProvider registerMonitorProvider(
647                                 final MonitorProvider provider,
648                                 final GenericConfig config);
649
650
651
652  /**
653   * Deregisters the given monitor provider with the server. This will have no
654   * effect if the given monitor provider is not registered.
655   *
656   * @param provider The monitor provider instance to be registered. It
657   *                 must not be {@code null}.
658   */
659  void deregisterMonitorProvider(final RegisteredMonitorProvider provider);
660
661
662
663  /**
664   * Deregisters all the monitor providers that were registered with the server
665   * by this instance of {@link ServerContext}. This can be useful during
666   * cleanup or if you want to clear out all the existing monitor data from a
667   * given extension and register new monitor providers.
668   * <p>
669   * This will be called automatically when your extension is unloaded or
670   * disabled.
671   */
672  void deregisterAllMonitorProviders();
673
674
675
676  /**
677   * Creates a new thread to run within the server.  The thread will not be
678   * started.
679   *
680   * @param  name          The name to use for the thread.  It must not be
681   *                       {@code null} or empty.
682   * @param  serverThread  The class providing the logic for the thread.  It
683   *                       must not be {@code null}.
684   *
685   * @return  The thread that has been created but not yet started.
686   */
687  Thread createThread(final ServerThread serverThread, final String name);
688
689
690
691  /**
692   * Writes a message to the server error log.
693   *
694   * @param  severity  The severity to use for the log message.  It must not be
695   *                   {@code null}.
696   * @param  message   The message to be logged.  It must not be {@code null}.
697   */
698  void logMessage(final LogSeverity severity, final String message);
699
700
701
702  /**
703   * Generates an administrative alert notification.
704   *
705   * @param  severity  The severity to use for the alert notification.  It must
706   *                   not be {@code null}.
707   * @param  message   The message to be used for the alert notification.  It
708   *                   must not be {@code null}.
709   */
710  void sendAlert(final AlertSeverity severity, final String message);
711
712
713
714  /**
715   * Generates an administrative alert notification.
716   *
717   * @param  alertTypeName  The name to use to identify the alert type.  Each
718   *                        kind of alert must have a distinct name and all
719   *                        alerts with this alert type must always be used with
720   *                        the same severity and OID values.  Alert type names
721   *                        must start with a lowercase ASCII letter and must
722   *                        contain only lowercase ASCII letters, numeric
723   *                        digits, and dashes.
724   * @param  severity       The severity to use for the alert notification.
725   *                        It must not be {@code null}.
726   * @param  alertTypeOID   The numeric OID for the alert type.  It must not be
727   *                        {@code null}, and it must be a valid numeric OID.
728   *                        The same OID must always be used for the associated
729   *                        alert type, and each different alert type must have
730   *                        a unique OID.
731   * @param  message        The message to be used for the alert notification.
732   *                        It must not be {@code null}.
733   *
734   * @throws  LDAPException  If the provided information cannot be used to
735   *                         generate a valid alert (e.g., if the alert type
736   *                         name does not meet the naming constraints or has
737   *                         already been used with a different severity and/or
738   *                         OID, or if the OID has already been used with a
739   *                         different alert type).
740   */
741  void sendAlert(final String alertTypeName, final AlertSeverity severity,
742                 final String alertTypeOID, final String message)
743       throws LDAPException;
744
745
746
747  /**
748   * Generates an administrative alert and updates the server's general monitor
749   * entry to list the specified alert type as a degraded alert type.  Once the
750   * condition that triggered the server to be considered degraded has been
751   * resolved, the {@link DegradedAlertType#setResolved} method should be used
752   * to remove the alert type from the list of degraded alert types.
753   * <BR><BR>
754   * If a server has one or more unavailable alert types, it will be considered
755   * unavailable for use by products which make use of this information.  If a
756   * server does not have any unavailable alert types but has one or more
757   * degraded alert types, then it will be considered degraded and less
758   * desirable for use by products which make use of this information.
759   *
760   * @param  alertTypeName  The name to use to identify the alert type.  Each
761   *                        kind of alert must have a distinct name and all
762   *                        alerts with this alert type must always be used with
763   *                        the same severity and OID values.  Alert type names
764   *                        must start with a lowercase ASCII letter and must
765   *                        contain only lowercase ASCII letters, numeric
766   *                        digits, and dashes.
767   * @param  severity       The severity to use for the alert notification.
768   *                        It must not be {@code null}.
769   * @param  alertTypeOID   The numeric OID for the alert type.  It must not be
770   *                        {@code null}, and it must be a valid numeric OID.
771   *                        The same OID must always be used for the associated
772   *                        alert type, and each different alert type must have
773   *                        a unique OID.
774   * @param  message        The message to be used for the alert notification.
775   *                        It must not be {@code null}.
776   *
777   * @return  An object that may be used to obtain information about the alert
778   *          type and indicate that the degraded condition has been resolved.
779   *
780   * @throws  LDAPException  If the provided information cannot be used to
781   *                         generate a valid alert (e.g., if the alert type
782   *                         name does not meet the naming constraints or has
783   *                         already been used with a different severity and/or
784   *                         OID, or if the OID has already been used with a
785   *                         different alert type).
786   */
787  DegradedAlertType sendDegradedAlertNotification(final String alertTypeName,
788                                                  final AlertSeverity severity,
789                                                  final String alertTypeOID,
790                                                  final String message)
791       throws LDAPException;
792
793
794
795  /**
796   * Generates an administrative alert and updates the server's general monitor
797   * entry to list the specified alert type as an unavailable alert type.  Once
798   * the condition that triggered the server to be considered unavailable has
799   * been resolved, the {@link UnavailableAlertType#setResolved} method should
800   * be used to remove the alert type from the list of unavailable alert types.
801   * <BR><BR>
802   * If a server has one or more unavailable alert types, it will be considered
803   * unavailable for use by products which make use of this information.  If a
804   * server does not have any unavailable alert types but has one or more
805   * degraded alert types, then it will be considered degraded and less
806   * desirable for use by products which make use of this information.
807   *
808   * @param  alertTypeName  The name to use to identify the alert type.  Each
809   *                        kind of alert must have a distinct name and all
810   *                        alerts with this alert type must always be used with
811   *                        the same severity and OID values.  Alert type names
812   *                        must start with a lowercase ASCII letter and must
813   *                        contain only lowercase ASCII letters, numeric
814   *                        digits, and dashes.
815   * @param  severity       The severity to use for the alert notification.
816   *                        It must not be {@code null}.
817   * @param  alertTypeOID   The numeric OID for the alert type.  It must not be
818   *                        {@code null}, and it must be a valid numeric OID.
819   *                        The same OID must always be used for the associated
820   *                        alert type, and each different alert type must have
821   *                        a unique OID.
822   * @param  message        The message to be used for the alert notification.
823   *                        It must not be {@code null}.
824   *
825   * @return  An object that may be used to obtain information about the alert
826   *          type and indicate that the unavailable condition has been
827   *          resolved.
828   *
829   * @throws  LDAPException  If the provided information cannot be used to
830   *                         generate a valid alert (e.g., if the alert type
831   *                         name does not meet the naming constraints or has
832   *                         already been used with a different severity and/or
833   *                         OID, or if the OID has already been used with a
834   *                         different alert type).
835   */
836  UnavailableAlertType sendUnavailableAlertNotification(
837                            final String alertTypeName,
838                            final AlertSeverity severity,
839                            final String alertTypeOID, final String message)
840       throws LDAPException;
841
842
843
844  /**
845   * Indicates whether debugging is enabled in the server.
846   * <BR><BR>
847   * Note that debug messages written by Server SDK extensions will be handled
848   * in the same way as debug messages generated in other areas of the server.
849   * However, the "Server SDK Extension Debug Logger" may be used to easily
850   * obtain only debug messages generated by Server SDK extensions, suppressing
851   * all messages generated in other areas of the server.
852   *
853   * @return  {@code true} if debugging is enabled in the server, or
854   *          {@code false} if not.
855   */
856  boolean debugEnabled();
857
858
859
860  /**
861   * Writes a debug message indicating that the provided exception has been
862   * caught.
863   * <BR><BR>
864   * Note that debug messages written by Server SDK extensions will be handled
865   * in the same way as debug messages generated in other areas of the server.
866   * However, the "Server SDK Extension Debug Logger" may be used to easily
867   * obtain only debug messages generated by Server SDK extensions, suppressing
868   * all messages generated in other areas of the server.
869   *
870   * @param  t  The exception that has been caught.
871   */
872  void debugCaught(final Throwable t);
873
874
875
876  /**
877   * Writes a debug message indicating that the provided exception will be
878   * thrown.
879   * <BR><BR>
880   * Note that debug messages written by Server SDK extensions will be handled
881   * in the same way as debug messages generated in other areas of the server.
882   * However, the "Server SDK Extension Debug Logger" may be used to easily
883   * obtain only debug messages generated by Server SDK extensions, suppressing
884   * all messages generated in other areas of the server.
885   *
886   * @param  t  The exception that will be thrown.
887   */
888  void debugThrown(final Throwable t);
889
890
891
892  /**
893   * Writes a debug message with an error severity.
894   * <BR><BR>
895   * Note that debug messages written by Server SDK extensions will be handled
896   * in the same way as debug messages generated in other areas of the server.
897   * However, the "Server SDK Extension Debug Logger" may be used to easily
898   * obtain only debug messages generated by Server SDK extensions, suppressing
899   * all messages generated in other areas of the server.
900   *
901   * @param  message  The message to be debugged.
902   */
903  void debugError(final String message);
904
905
906
907  /**
908   * Writes a debug message with a warning severity.
909   * <BR><BR>
910   * Note that debug messages written by Server SDK extensions will be handled
911   * in the same way as debug messages generated in other areas of the server.
912   * However, the "Server SDK Extension Debug Logger" may be used to easily
913   * obtain only debug messages generated by Server SDK extensions, suppressing
914   * all messages generated in other areas of the server.
915   *
916   * @param  message  The message to be debugged.
917   */
918  void debugWarning(final String message);
919
920
921
922  /**
923   * Writes a debug message with an informational severity.
924   * <BR><BR>
925   * Note that debug messages written by Server SDK extensions will be handled
926   * in the same way as debug messages generated in other areas of the server.
927   * However, the "Server SDK Extension Debug Logger" may be used to easily
928   * obtain only debug messages generated by Server SDK extensions, suppressing
929   * all messages generated in other areas of the server.
930   *
931   * @param  message  The message to be debugged.
932   */
933  void debugInfo(final String message);
934
935
936
937  /**
938   * Writes a debug message with a verbose severity.
939   * <BR><BR>
940   * Note that debug messages written by Server SDK extensions will be handled
941   * in the same way as debug messages generated in other areas of the server.
942   * However, the "Server SDK Extension Debug Logger" may be used to easily
943   * obtain only debug messages generated by Server SDK extensions, suppressing
944   * all messages generated in other areas of the server.
945   *
946   * @param  message  The message to be debugged.
947   */
948  void debugVerbose(final String message);
949
950
951
952  /**
953   * Retrieves a connection that is established and (if appropriate)
954   * authenticated to the specified LDAP External server.  This will be a
955   * newly-created connection that is not used for any other purpose, and the
956   * caller is responsible for closing that connection when it is no longer
957   * needed.
958   *
959   * @param  ldapExternalServerCfgObjectName  The name of the configuration
960   *                                          object for the LDAP external
961   *                                          server to which the connection
962   *                                          should be established.  It must
963   *                                          not be {@code null}.
964   * @param  connectionOptions                The set of options to use for the
965   *                                          connection that is established.
966   *                                          It may be {@code null} if a
967   *                                          default set of options should be
968   *                                          used.
969   *
970   * @return  The newly-created LDAP connection.
971   *
972   * @throws  LDAPException  If it is not possible to establish a connection to
973   *                         the target servers.
974   */
975  LDAPConnection getLDAPExternalServerConnection(
976                      final String ldapExternalServerCfgObjectName,
977                      final LDAPConnectionOptions connectionOptions)
978       throws LDAPException;
979
980
981
982  /**
983   * Retrieves a connection pool with connections to the specified server.  This
984   * will be a newly-created connection pool that is not used for any other
985   * purpose, and the caller is responsible for closing that connection pool
986   * when it is no longer needed.
987   *
988   * @param  ldapExternalServerCfgObjectName  The name of the configuration
989   *                                          object for the LDAP external
990   *                                          server to which the connections
991   *                                          should be established.  It must
992   *                                          not be {@code null}.
993   * @param  connectionOptions                The set of options to use for the
994   *                                          connection that is established.
995   *                                          It may be {@code null} if a
996   *                                          default set of options should be
997   *                                          used.
998   * @param  initialConnections               The initial number of connections
999   *                                          to attempt to establish.  It must
1000   *                                          be greater than or equal to zero.
1001   * @param  maxConnections                   The maximum number of connections
1002   *                                          that should be established and
1003   *                                          unused in the pool at any time.
1004   *                                          It must be greater than or equal
1005   *                                          to {@code initialConnections}, and
1006   *                                          it must not be zero.
1007   * @param  throwOnConnectFailure            Indicates whether to throw an
1008   *                                          {@code LDAPException} if an error
1009   *                                          is encountered while attempting to
1010   *                                          connect or authenticate any of the
1011   *                                          initial connections.  If this is
1012   *                                          {@code false} and none of the
1013   *                                          initial connections can be
1014   *                                          established (or if the initial
1015   *                                          number of connections is zero),
1016   *                                          then the pool will be returned
1017   *                                          without any connections.
1018   *
1019   * @return  The newly-created LDAP connection pool.
1020   *
1021   * @throws  LDAPException  If it is not possible to establish a pool of
1022   *                         connections to the specified LDAP external server.
1023   */
1024  LDAPConnectionPool getLDAPExternalServerConnectionPool(
1025                          final String ldapExternalServerCfgObjectName,
1026                          final LDAPConnectionOptions connectionOptions,
1027                          final int initialConnections,
1028                          final int maxConnections,
1029                          final boolean throwOnConnectFailure)
1030       throws LDAPException;
1031
1032
1033
1034  /**
1035   * Retrieves the plaintext representation of the specified obscured value from
1036   * the server configuration.  Obscured values may be used to allow extensions
1037   * to store potentially sensitive information (for example, credentials needed
1038   * to access some external system) in the configuration in a manner that will
1039   * prevent them from being stored in the clear or displayed in the clear in
1040   * administrative interfaces.  If a server extension needs to be configured
1041   * with potentially sensitive information, it is recommended that each piece
1042   * of sensitive information be stored as an obscured value, and that the
1043   * extension be configured with the names of the relevant obscured values.
1044   *
1045   * @param  obscuredValueConfigObjectName  The name of the configuration object
1046   *                                        for the obscured value to retrieve.
1047   *                                        It must not be {@code null}.
1048   *
1049   * @return  The plaintext representation of the specified obscured value from
1050   *          the server configuration.
1051   *
1052   * @throws  LDAPException  If the provided name does not reference an obscured
1053   *                         value that is defined in the server configuration.
1054   */
1055  String getObscuredValue(final String obscuredValueConfigObjectName)
1056         throws LDAPException;
1057
1058
1059
1060  /**
1061   * Returns a ValueConstructor built from the provided value template. A
1062   * ValueConstructor can be used to construct string values from a template
1063   * that can reference attributes on an entry.
1064   *
1065   * @param  constructedValueTemplate  The constructed value pattern. See
1066   *                                   {@link ValueConstructor} for details on
1067   *                                   the syntax for the template.
1068   *
1069   * @return  A ValueConstructor based on the provided template.
1070   *
1071   * @throws  LDAPException  If the provided value template is invalid.
1072   */
1073  ValueConstructor createValueConstructor(final String constructedValueTemplate)
1074        throws LDAPException;
1075
1076
1077
1078  /**
1079   * Retrieves the group defined in the specified entry.
1080   *
1081   * @param  groupDN  The DN of the entry containing the group to retrieve.  It
1082   *                  must not be {@code null}.
1083   *
1084   * @return  The group defined in the specified entry.
1085   *
1086   * @throws  LDAPException  If the specified entry does not exist, if it exists
1087   *                         but does not represent a group, or if a problem is
1088   *                         encountered while retrieving the group.
1089   */
1090  Group getGroup(final String groupDN)
1091        throws LDAPException;
1092
1093
1094
1095  /**
1096   * Retrieves the set of groups in which the specified user is a member,
1097   * indexed by group DN.
1098   *
1099   * @param  userDN                The DN of the user for whom to retrieve the
1100   *                               associated groups.  It must not be
1101   *                               {@code null}.
1102   * @param  directMembershipOnly  Indicates whether to only consider the user a
1103   *                               member of the group if that user is directly
1104   *                               named as a member of the group.  If this
1105   *                               parameter is {@code true}, then the method
1106   *                               will return {@code true} only if the user is
1107   *                               directly listed as a member of the group, and
1108   *                               will not included dynamic or nested
1109   *                               membership.  If this parameter is
1110   *                               {@code false}, then the method will return
1111   *                               {@code true} if the user is a direct member
1112   *                               of the group, is a member of a dynamic group
1113   *                               in which the user matches the membership
1114   *                               criteria, or if the user is a member of a
1115   *                               nested group.
1116   *
1117   * @return  A map of the groups in which the specified user is a member, or an
1118   *          empty map if the specified user is not a member of any groups.
1119   *
1120   * @throws  LDAPException  If the specified user does not exist or if a
1121   *                         problem is encountered while attempting to retrieve
1122   *                         the groups in which the user is a member.
1123   */
1124  Map<DN,Group> getGroupsForUser(final String userDN,
1125                                 final boolean directMembershipOnly)
1126                throws LDAPException;
1127
1128
1129
1130  /**
1131   * Indicates whether the specified user has the indicated privilege.  The set
1132   * of defined privileges may be found in the privilege-list.html and
1133   * privilege-list.csv files in the server docs directory.
1134   *
1135   * @param  userDN         The DN of the user for whom to make the
1136   *                        determination.  It must not be {@code null}.
1137   * @param  privilegeName  The name of the privilege for which to make the
1138   *                        determination.  It must not be {@code null}.
1139   *
1140   * @return  {@code true} if the specified user has the indicated privilege, or
1141   *          {@code false} if not.
1142   *
1143   * @throws  LDAPException  If the specified user does not exist, if the
1144   *                         indicated privilege is not defined in the server,
1145   *                         or if a problem is encountered while trying to make
1146   *                         the determination.
1147   */
1148  boolean hasPrivilege(final String userDN, final String privilegeName)
1149          throws LDAPException;
1150
1151
1152
1153  /**
1154   * Retrieves the names of the privileges held by the specified user.  The set
1155   * of defined privileges may be found in the privilege-list.html and
1156   * privilege-list.csv files in the server docs directory.
1157   *
1158   * @param  userDN  The DN of the user for whom to retrieve the privileges.  It
1159   *                  must not be {@code null}.
1160   *
1161   * @return  The names of the privileges held by the specified user, or an
1162   *          empty set if the user does not have any privileges.
1163   *
1164   * @throws  LDAPException  If the specified user does not exist, or if a
1165   *                         problem is encountered while attempting to retrieve
1166   *                         the user's privileges.
1167   */
1168  Set<String> getPrivilegeNames(final String userDN)
1169              throws LDAPException;
1170
1171
1172
1173  /**
1174   * Reload the key and trust manager providers associated with any HTTP
1175   * connection handlers.that provide support for HTTPS.  This can cause any
1176   * changes to the certificates in those stores to be applied to the running
1177   * instance without the need to disable and re-enable the connection handler
1178   * or to restart the server. Note that this reload does have the potential
1179   * to interfere with the ability for clients to resume a TLS session created
1180   * before the reload was invoked.
1181   *
1182   * @throws LDAPException  If an error occurs.
1183   */
1184  void reloadHTTPConnectionHandlerCertificates()
1185       throws LDAPException;
1186
1187
1188
1189  /**
1190   * Opens an input stream that may be used to read data from the provided
1191   * file.  The contents of the file may optionally have been encrypted with the
1192   * LDAP SDK's {@code PassphraseEncryptedOutputStream} using a key from the
1193   * server's encryption settings database, and may have optionally been
1194   * compressed with the GZIP compression algorithm.  If the file is both
1195   * compressed and encrypted, then the data must have been compressed before
1196   * it was encrypted.
1197   *
1198   * @param  file  The file to be read.  It must not be {@code null}.
1199   *
1200   * @return  The input stream that may be used to read the optionally
1201   *          compressed and/or encrypted file.
1202   *
1203   * @throws  LDAPException  If a problem is encountered while interacting with
1204   *                         the server's encryption framework, or if the data
1205   *                         is encrypted with a key not contained in the
1206   *                         encryption settings database.
1207   *
1208   * @throws  GeneralSecurityException  If a problem is encountered while
1209   *                                    preparing to decrypt the data.
1210   *
1211   * @throws  IOException  If a problem is encountered while attempting to read
1212   *                       or decompress the data.
1213   */
1214  InputStream getPossiblyCompressedAndEncryptedInputStream(final File file)
1215              throws LDAPException, GeneralSecurityException, IOException;
1216
1217
1218
1219  /**
1220   * Examines the provided input stream and determines whether its contents have
1221   * been encrypted with a {@code PassphraseEncryptedOutputStream}, and if so,
1222   * retrieves an input stream that may be used to read its decrypted content.
1223   * Also examines the input stream to determine whether its contents may have
1224   * been GZIP-compressed, and if so, retrieves an input stream that may be used
1225   * to read its decompressed content.  If the data is encrypted, it must start
1226   * with a {@code PassphraseEncryptedStreamHeader}, and it must have been
1227   * encrypted with a key contained in the server's encryption settings
1228   * database.  If the data is both compressed and encrypted, then it must have
1229   * been compressed before it was encrypted.
1230   * <BR><BR>
1231   * Note that if a problem occurs that causes this method to throw an
1232   * exception, then the provided stream will have been closed before control
1233   * returns to the caller.
1234   *
1235   * @param  inputStream  The input stream from which the data is to be
1236   *                      obtained.  It must not be {@code null}.
1237   *
1238   * @return  The input stream that may be used to read the optionally
1239   *          compressed and/or encrypted data from the provided input stream.
1240   *
1241   * @throws  LDAPException  If a problem is encountered while interacting with
1242   *                         the server's encryption framework, or if the data
1243   *                         is encrypted with a key not contained in the
1244   *                         encryption settings database.
1245   *
1246   * @throws  GeneralSecurityException  If a problem is encountered while
1247   *                                    preparing to decrypt the data.
1248   *
1249   * @throws  IOException  If a problem is encountered while attempting to read
1250   *                       or decompress the data.
1251   */
1252  InputStream getPossiblyCompressedAndEncryptedInputStream(
1253                   final InputStream inputStream)
1254              throws LDAPException, GeneralSecurityException, IOException;
1255
1256
1257
1258  /**
1259   * Wraps the provided output stream in a
1260   * {@code PassphraseEncryptedOutputStream} so that data written to it will be
1261   * encrypted, optionally after also wrapping it in a {@code GZIPOutputStream}
1262   * to ensure that the data is compressed before it is encrypted.  The
1263   * encryption key will be obtained from the server's preferred encryption
1264   * settings definition.
1265   *
1266   * @param  outputStream  The output stream to be wrapped.  It must not be
1267   *                       {@code null}.
1268   * @param  compress      Indicates whether to GZIP-compress the data before
1269   *                       encrypting it.
1270   *
1271   * @return  The output stream that may be used to write encrypted (and
1272   *          possibly compressed) data.
1273   *
1274   * @throws  LDAPException  If a problem is encountered while interacting with
1275   *                         the server's encryption framework or if the server
1276   *                         encryption settings database does not have a
1277   *                         preferred definition.
1278   *
1279   * @throws  GeneralSecurityException  If a problem is encountered while
1280   *                                    preparing to encrypt the data.
1281   *
1282   * @throws  IOException  If a problem occurs while preparing to compress the
1283   *                       the data.
1284   */
1285  OutputStream getEncryptedOutputStream(final OutputStream outputStream,
1286                                        final boolean compress)
1287               throws LDAPException, IOException, GeneralSecurityException;
1288
1289
1290
1291  /**
1292   * Wraps the provided output stream in a
1293   * {@code PassphraseEncryptedOutputStream} so that data written to it will be
1294   * encrypted, optionally after also wrapping it in a {@code GZIPOutputStream}
1295   * to ensure that the data is compressed before it is encrypted.
1296   *
1297   * @param  outputStream                    The output stream to be wrapped.
1298   *                                         It must not be {@code null}.
1299   * @param  encryptionSettingsDefinitionID  The identifier of the encryption
1300   *                                         settings definition that should be
1301   *                                         used to encrypt the data.  It must
1302   *                                         not be {@code null}.
1303   * @param  compress                        Indicates whether to GZIP-compress
1304   *                                         the data before encrypting it.
1305   *
1306   * @return  The output stream that may be used to write encrypted (and
1307   *          possibly compressed) data.
1308   *
1309   * @throws  LDAPException  If a problem is encountered while interacting with
1310   *                         the server's encryption framework, or if the
1311   *                         encryption settings database does not have a
1312   *                         definition with the specified ID.
1313   *
1314   * @throws  GeneralSecurityException  If a problem is encountered while
1315   *                                    preparing to encrypt the data.
1316   *
1317   * @throws  IOException  If a problem occurs while preparing to compress the
1318   *                       the data.
1319   */
1320  OutputStream getEncryptedOutputStream(final OutputStream outputStream,
1321                    final String encryptionSettingsDefinitionID,
1322                    final boolean compress)
1323               throws LDAPException, GeneralSecurityException, IOException;
1324
1325
1326
1327  /**
1328   * Retrieves information about the server's preferred encryption settings
1329   * definition, which is the default definition that will be used for new
1330   * encryption operations if no other definition is requested.
1331   *
1332   * @return  Information about the server's preferred encryption settings
1333   *          definition, or {@code null} if the server does not have a
1334   *          preferred encryption settings definition.
1335   */
1336  EncryptionSettingsDefinition getPreferredEncryptionSettingsDefinition();
1337
1338
1339
1340  /**
1341   * Retrieves the encryption settings definition with the specified ID.
1342   *
1343   * @param  id  The identifier for the encryption settings definition to
1344   *             retrieve.  It must not be {@code null}.
1345   *
1346   * @return  The encryption settings definition with the specified ID, or
1347   *          {@code null} if the encryption settings database does not have a
1348   *          definition with the specified ID.
1349   */
1350  EncryptionSettingsDefinition getEncryptionSettingsDefinition(final String id);
1351
1352
1353
1354  /**
1355   * Retrieves a list of all of the encryption settings definitions contained
1356   * in the server's encryption settings database.
1357   *
1358   * @return  A list of all the encryption settings definitions contained in
1359   *          the server's encryption settings database.
1360   */
1361  List<EncryptionSettingsDefinition> getEncryptionSettingsDefinitions();
1362
1363
1364
1365  /**
1366   * Creates a multi-part email message with the provided information.
1367   *
1368   * @param  senderAddress   The sender address for the email message.  It must
1369   *                         not be {@code null} or empty.
1370   * @param  replyToAddress  The reply-to address for this email message.  It
1371   *                         may be {@code null} if no reply-to address is
1372   *                         needed.  If it is non-{@code null}, then it must
1373   *                         not be empty.
1374   * @param  toAddresses     The set of "to" addresses for the email message.
1375   *                         At least one of the {@code toAddresses},
1376   *                         {@code ccAddresses}, and {@code bccAddresses}
1377   *                         arguments must be non-{@code null} and non-empty.
1378   * @param  ccAddresses     The set of "cc" addresses for the email message.
1379   *                         At least one of the {@code toAddresses},
1380   *                         {@code ccAddresses}, and {@code bccAddresses}
1381   *                         arguments must be non-{@code null} and non-empty.
1382   * @param  bccAddresses    The set of "bcc" addresses for the email message.
1383   *                         At least one of the {@code toAddresses},
1384   *                         {@code ccAddresses}, and {@code bccAddresses}
1385   *                         arguments must be non-{@code null} and non-empty.
1386   * @param  subject         The subject for the email message.  It must not be
1387   *                         {@code null} or empty.
1388   * @param  plainTextPart   The content for the plain-text-formatted body of
1389   *                         the message.  It must not be {@code null} if
1390   *                         {@code htmlPart} is {@code null}.  If it is
1391   *                         non-{@code null}, then it must not be empty.
1392   * @param  htmlPart        The content for the HTML-formatted body of the
1393   *                         message.  It must not be {@code null} if
1394   *                         {@code plainTextPart} is {@code null}.  If it is
1395   *                         non-{@code null}, then it must not be empty.
1396   * @param  customHeaders   An optional map of custom headers to include in the
1397   *                         email message.  It may be {@code null} or empty if
1398   *                         no custom headers should be included.
1399   * @param  attachments     An optional set of attachments to include in the
1400   *                         email message.  It may be {@code null} or empty if
1401   *                         the message should not include any attachments.
1402   *
1403   * @return  The email message that was created.
1404   *
1405   * @throws  MessagingException  If there is a problem with any of the
1406   *                              provided addresses.
1407   */
1408  EMailMessage createEMailMessage(final String senderAddress,
1409                                  final String replyToAddress,
1410                                  final Collection<String> toAddresses,
1411                                  final Collection<String> ccAddresses,
1412                                  final Collection<String> bccAddresses,
1413                                  final String subject,
1414                                  final String plainTextPart,
1415                                  final String htmlPart,
1416                                  final Map<String,List<String>> customHeaders,
1417                                  final List<EMailAttachment> attachments)
1418       throws MessagingException;
1419
1420
1421
1422  /**
1423   * Creates an email attachment with the provided information.
1424   *
1425   * @param  filename     The filename for this attachment.  It must not be
1426   *                      {@code null} or empty.  It must be just the name of
1427   *                      the file, without any path information.
1428   * @param  contentType  The MIME type for the email attachment.  If this is
1429   *                      {@code null}, then a default value of
1430   *                      "application/octet-stream" will be used.
1431   * @param  isInline     Indicates whether the attachment is intended to be
1432   *                      referenced inline within the body of the email
1433   *                      message (e.g., an image displayed within the
1434   *                      HTML-formatted message).
1435   * @param  data         The bytes that comprise the data for the attachment.
1436   *                      It must not be {@code null} or empty.
1437   *
1438   * @return  The email attachment that has been created.
1439   */
1440  EMailAttachment createEMailAttachment(final String filename,
1441                                        final String contentType,
1442                                        final boolean isInline,
1443                                        final byte[] data);
1444}