Package org.ldaptive
Class BindConnectionInitializer
- java.lang.Object
-
- org.ldaptive.AbstractFreezable
-
- org.ldaptive.BindConnectionInitializer
-
- All Implemented Interfaces:
ConnectionInitializer
,Freezable
public class BindConnectionInitializer extends AbstractFreezable implements ConnectionInitializer
Initializes a connection by performing a bind operation. Useful if you need all connections to bind as the same principal.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BindConnectionInitializer.Builder
-
Field Summary
Fields Modifier and Type Field Description private RequestControl[]
bindControls
Bind controls.private Credential
bindCredential
Credential for the bind DN.private String
bindDn
DN to bind as before performing operations.private SaslConfig
bindSaslConfig
Configuration for bind SASL authentication.protected Logger
logger
Logger for this class.
-
Constructor Summary
Constructors Constructor Description BindConnectionInitializer()
Default constructor.BindConnectionInitializer(String dn, String credential)
Creates a new bind connection initializer.BindConnectionInitializer(String dn, Credential credential)
Creates a new bind connection initializer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BindConnectionInitializer.Builder
builder()
Creates a builder for this class.void
freeze()
Freezes this object, making it immutable.RequestControl[]
getBindControls()
Returns the bind controls.Credential
getBindCredential()
Returns the credential used with the bind DN.String
getBindDn()
Returns the bind DN.SaslConfig
getBindSaslConfig()
Returns the bind sasl config.Result
initialize(Connection c)
Initialize the supplied connection.boolean
isEmpty()
Returns whether this connection initializer contains any configuration data.void
setBindControls(RequestControl... cntrls)
Sets the bind controls.void
setBindCredential(Credential credential)
Sets the credential of the bind DN.void
setBindDn(String dn)
Sets the bind DN to authenticate as before performing operations.void
setBindSaslConfig(SaslConfig config)
Sets the bind sasl config.String
toString()
-
Methods inherited from class org.ldaptive.AbstractFreezable
assertMutable, freeze, freeze, isFrozen
-
-
-
-
Field Detail
-
logger
protected final Logger logger
Logger for this class.
-
bindDn
private String bindDn
DN to bind as before performing operations.
-
bindCredential
private Credential bindCredential
Credential for the bind DN.
-
bindSaslConfig
private SaslConfig bindSaslConfig
Configuration for bind SASL authentication.
-
bindControls
private RequestControl[] bindControls
Bind controls.
-
-
Constructor Detail
-
BindConnectionInitializer
public BindConnectionInitializer()
Default constructor.
-
BindConnectionInitializer
public BindConnectionInitializer(String dn, String credential)
Creates a new bind connection initializer.- Parameters:
dn
- bind dncredential
- bind credential
-
BindConnectionInitializer
public BindConnectionInitializer(String dn, Credential credential)
Creates a new bind connection initializer.- Parameters:
dn
- bind dncredential
- bind credential
-
-
Method Detail
-
freeze
public void freeze()
Description copied from interface:Freezable
Freezes this object, making it immutable.- Specified by:
freeze
in interfaceFreezable
- Overrides:
freeze
in classAbstractFreezable
-
getBindDn
public final String getBindDn()
Returns the bind DN.- Returns:
- DN to bind as
-
setBindDn
public final void setBindDn(String dn)
Sets the bind DN to authenticate as before performing operations.- Parameters:
dn
- to bind as
-
getBindCredential
public final Credential getBindCredential()
Returns the credential used with the bind DN.- Returns:
- bind DN credential
-
setBindCredential
public final void setBindCredential(Credential credential)
Sets the credential of the bind DN.- Parameters:
credential
- to use with bind DN
-
getBindSaslConfig
public final SaslConfig getBindSaslConfig()
Returns the bind sasl config.- Returns:
- sasl config
-
setBindSaslConfig
public final void setBindSaslConfig(SaslConfig config)
Sets the bind sasl config.- Parameters:
config
- sasl config
-
getBindControls
public final RequestControl[] getBindControls()
Returns the bind controls.- Returns:
- controls
-
setBindControls
public final void setBindControls(RequestControl... cntrls)
Sets the bind controls.- Parameters:
cntrls
- controls to set
-
initialize
public Result initialize(Connection c) throws LdapException
Description copied from interface:ConnectionInitializer
Initialize the supplied connection.- Specified by:
initialize
in interfaceConnectionInitializer
- Parameters:
c
- connection to initialize- Returns:
- result associated with the initialization or an empty result
- Throws:
LdapException
- if initialization fails
-
isEmpty
public boolean isEmpty()
Returns whether this connection initializer contains any configuration data.- Returns:
- whether all properties are null
-
builder
public static BindConnectionInitializer.Builder builder()
Creates a builder for this class.- Returns:
- new builder
-
-