@Extensible @ThreadSafety(level=INTERFACE_NOT_THREADSAFE) public abstract class LDAPCommandLineTool extends CommandLineTool
getConnection()
and getConnectionPool(int,int)
methods may
be invoked concurrently by multiple threads accessing the same instance only
while that instance is in the process of invoking the
CommandLineTool.doToolProcessing()
method.Constructor and Description |
---|
LDAPCommandLineTool(java.io.OutputStream outStream,
java.io.OutputStream errStream)
Creates a new instance of this LDAP-enabled command-line tool with the
provided information.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
addNonLDAPArguments(ArgumentParser parser)
Adds the arguments needed by this command-line tool to the provided
argument parser which are not related to connecting or authenticating to
the directory server.
|
void |
addToolArguments(ArgumentParser parser)
Adds the command-line arguments supported for use with this tool to the
provided argument parser.
|
boolean |
anyLDAPArgumentsProvided()
Indicates whether any of the LDAP-related arguments maintained by the
LDAPCommandLineTool class were provided on the command line. |
BindRequest |
createBindRequest()
Creates the bind request to use to authenticate to the server.
|
ServerSet |
createServerSet()
Creates the server set to use when creating connections or connection
pools.
|
SSLUtil |
createSSLUtil()
Creates the SSLUtil instance to use for secure communication.
|
SSLUtil |
createSSLUtil(boolean force)
Creates the SSLUtil instance to use for secure communication.
|
protected boolean |
defaultToPromptForBindPassword()
Indicates whether this tool should default to interactively prompting for
the bind password if a password is required but no argument was provided
to indicate how to get the password.
|
void |
doExtendedArgumentValidation()
Performs any necessary processing that should be done to ensure that the
provided set of command-line arguments were valid.
|
void |
doExtendedNonLDAPArgumentValidation()
Performs any necessary processing that should be done to ensure that the
provided set of command-line arguments were valid.
|
protected java.util.List<Control> |
getBindControls()
Retrieves a set of controls that should be included in any bind request
generated by this tool.
|
LDAPConnection |
getConnection()
Retrieves a connection that may be used to communicate with the target
directory server.
|
LDAPConnectionOptions |
getConnectionOptions()
Retrieves the connection options that should be used for connections that
are created with this command line tool.
|
protected LDAPConnectionOptions |
getConnectionOptionsWithRequestedSettings()
Retrieves the connection options that should be used for connections that
are created with this command-line tool, including any options that may be
set as a result of command-line arguments.
|
LDAPConnectionPool |
getConnectionPool(int initialConnections,
int maxConnections)
Retrieves a connection pool that may be used to communicate with the target
directory server.
|
LDAPConnectionPool |
getConnectionPool(int initialConnections,
int maxConnections,
int initialConnectThreads,
PostConnectProcessor beforeStartTLSProcessor,
PostConnectProcessor afterStartTLSProcessor,
boolean throwOnConnectFailure,
LDAPConnectionPoolHealthCheck healthCheck)
Retrieves a connection pool that may be used to communicate with the target
directory server.
|
protected java.util.Set<java.lang.Character> |
getSuppressedShortIdentifiers()
Retrieves a set containing any short identifiers that should be suppressed
in the set of generic tool arguments so that they can be used by a
tool-specific argument instead.
|
LDAPConnection |
getUnauthenticatedConnection()
Retrieves an unauthenticated connection that may be used to communicate
with the target directory server.
|
protected boolean |
includeAlternateLongIdentifiers()
Indicates whether the LDAP-specific arguments should include alternate
versions of all long identifiers that consist of multiple words so that
they are available in both camelCase and dash-separated versions.
|
protected boolean |
supportsAuthentication()
Indicates whether this tool should provide the arguments that allow it to
bind via simple or SASL authentication.
|
protected boolean |
supportsMultipleServers()
Indicates whether this tool supports creating connections to multiple
servers.
|
protected boolean |
supportsSASLHelp()
Indicates whether this tool should provide a "--help-sasl" argument that
provides information about the supported SASL mechanisms and their
associated properties.
|
protected boolean |
supportsSSLDebugging()
Indicates whether this tool should provide a command-line argument that
allows for low-level SSL debugging.
|
addEnableSSLDebuggingArgument, createArgumentParser, defaultsToInteractiveMode, doShutdownHookProcessing, doToolProcessing, err, getAdditionalDescriptionParagraphs, getErr, getExampleUsages, getMaxTrailingArguments, getMinTrailingArguments, getOriginalErr, getOriginalOut, getOut, getPasswordFileReader, getToolCompletionMessage, getToolDescription, getToolName, getToolVersion, getTrailingArgumentsPlaceholder, logToolInvocationByDefault, out, registerShutdownHook, requestToolArgumentsInteractively, runTool, supportsDebugLogging, supportsInteractiveMode, supportsOutputFile, supportsPropertiesFile, wrapErr, wrapOut
public LDAPCommandLineTool(@Nullable java.io.OutputStream outStream, @Nullable java.io.OutputStream errStream)
outStream
- The output stream to use for standard output. It may be
System.out
for the JVM's default standard output
stream, null
if no output should be generated,
or a custom output stream if the output should be sent
to an alternate location.errStream
- The output stream to use for standard error. It may be
System.err
for the JVM's default standard error
stream, null
if no output should be generated,
or a custom output stream if the output should be sent
to an alternate location.@NotNull protected java.util.Set<java.lang.Character> getSuppressedShortIdentifiers()
null
.public final void addToolArguments(@NotNull ArgumentParser parser) throws ArgumentException
addToolArguments
in class CommandLineTool
parser
- The argument parser to which the arguments are to be added.ArgumentException
- If a problem occurs while adding any of the
tool-specific arguments to the provided
argument parser.public abstract void addNonLDAPArguments(@NotNull ArgumentParser parser) throws ArgumentException
parser
- The argument parser to which the arguments should be added.ArgumentException
- If a problem occurs while adding the arguments.public final void doExtendedArgumentValidation() throws ArgumentException
CommandLineTool.doToolProcessing()
method is invoked.
Note that if the tool supports interactive mode, then this method may be
invoked multiple times to allow the user to interactively fix validation
errors.doExtendedArgumentValidation
in class CommandLineTool
ArgumentException
- If there was a problem with the command-line
arguments provided to this program.protected boolean supportsAuthentication()
true
if this tool should provide the arguments that allow
it to bind via simple or SASL authentication, or false
if
not.protected boolean defaultToPromptForBindPassword()
true
if this tool should default to interactively
prompting for the bind password, or false
if not.protected boolean supportsSASLHelp()
true
if this tool should provide a "--help-sasl" argument,
or false
if not.protected boolean includeAlternateLongIdentifiers()
true
if this tool should provide multiple versions of
long identifiers for LDAP-specific arguments, or false
if
not.@Nullable protected java.util.List<Control> getBindControls()
null
or empty if no
controls should be included in the bind request.protected boolean supportsMultipleServers()
true
if this tool supports creating connections to
multiple servers, or false
if not.protected boolean supportsSSLDebugging()
true
, then an
"--enableSSLDebugging" argument will be added that sets the
"javax.net.debug" system property to "all" before attempting any
communication.true
if this tool should offer an "--enableSSLDebugging"
argument, or false
if not.public void doExtendedNonLDAPArgumentValidation() throws ArgumentException
CommandLineTool.doToolProcessing()
method is invoked.ArgumentException
- If there was a problem with the command-line
arguments provided to this program.@NotNull public LDAPConnectionOptions getConnectionOptions()
@NotNull protected final LDAPConnectionOptions getConnectionOptionsWithRequestedSettings()
getConnectionOptions()
method, but with any alterations applied as appropriate for the configured
set of command-line options.@ThreadSafety(level=METHOD_THREADSAFE) @NotNull public final LDAPConnection getConnection() throws LDAPException
CommandLineTool.doToolProcessing()
method.LDAPException
- If a problem occurs while creating the connection.@ThreadSafety(level=METHOD_THREADSAFE) @NotNull public final LDAPConnection getUnauthenticatedConnection() throws LDAPException
CommandLineTool.doToolProcessing()
method.LDAPException
- If a problem occurs while creating the connection.@ThreadSafety(level=METHOD_THREADSAFE) @NotNull public final LDAPConnectionPool getConnectionPool(int initialConnections, int maxConnections) throws LDAPException
CommandLineTool.doToolProcessing()
method.initialConnections
- The number of connections that should be
initially established in the pool.maxConnections
- The maximum number of connections to maintain
in the pool.LDAPException
- If a problem occurs while creating the connection
pool.@ThreadSafety(level=METHOD_THREADSAFE) @NotNull public final LDAPConnectionPool getConnectionPool(int initialConnections, int maxConnections, int initialConnectThreads, @Nullable PostConnectProcessor beforeStartTLSProcessor, @Nullable PostConnectProcessor afterStartTLSProcessor, boolean throwOnConnectFailure, @Nullable LDAPConnectionPoolHealthCheck healthCheck) throws LDAPException
CommandLineTool.doToolProcessing()
method.initialConnections
- The number of connections that should be
initially established in the pool.maxConnections
- The maximum number of connections to
maintain in the pool.initialConnectThreads
- The number of concurrent threads to use to
establish the initial set of connections.
A value greater than one indicates that
the attempt to establish connections
should be parallelized.beforeStartTLSProcessor
- An optional post-connect processor that
should be used for the connection pool and
should be invoked before any StartTLS
post-connect processor that may be needed
based on the selected arguments. It may
be null
if no such post-connect
processor is needed.afterStartTLSProcessor
- An optional post-connect processor that
should be used for the connection pool and
should be invoked after any StartTLS
post-connect processor that may be needed
based on the selected arguments. It may
be null
if no such post-connect
processor is needed.throwOnConnectFailure
- If an exception should be thrown if a
problem is encountered while attempting to
create the specified initial number of
connections. If true
, then the
attempt to create the pool will fail if
any connection cannot be established. If
false
, then the pool will be
created but may have fewer than the
initial number of connections (or possibly
no connections).healthCheck
- An optional health check that should be
configured for the connection pool. It
may be null
if the default health
checking should be performed.LDAPException
- If a problem occurs while creating the connection
pool.@NotNull public ServerSet createServerSet() throws LDAPException
LDAPException
- If a problem occurs while creating the server set.@Nullable public SSLUtil createSSLUtil() throws LDAPException
null
if secure communication is not needed.LDAPException
- If a problem occurs while creating the SSLUtil
instance.@Nullable public SSLUtil createSSLUtil(boolean force) throws LDAPException
force
- Indicates whether to create the SSLUtil object even if
neither the "--useSSL" nor the "--useStartTLS" argument was
provided. The key store and/or trust store paths must still
have been provided. This may be useful for tools that
accept SSL-based communication but do not themselves intend
to perform SSL-based communication as an LDAP client.null
if secure communication is not needed.LDAPException
- If a problem occurs while creating the SSLUtil
instance.@Nullable public BindRequest createBindRequest() throws LDAPException
null
if no bind should be performed.LDAPException
- If a problem occurs while creating the bind
request.public final boolean anyLDAPArgumentsProvided()
LDAPCommandLineTool
class were provided on the command line.true
if any of the LDAP-related arguments maintained by
the LDAPCommandLineTool
were provided on the command line,
or false
if not.