Package org.ldaptive
Class BindConnectionInitializer
- java.lang.Object
-
- org.ldaptive.BindConnectionInitializer
-
- All Implemented Interfaces:
ConnectionInitializer
public class BindConnectionInitializer extends Object 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.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()
-
-
-
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
-
getBindDn
public String getBindDn()
Returns the bind DN.- Returns:
- DN to bind as
-
setBindDn
public void setBindDn(String dn)
Sets the bind DN to authenticate as before performing operations.- Parameters:
dn
- to bind as
-
getBindCredential
public Credential getBindCredential()
Returns the credential used with the bind DN.- Returns:
- bind DN credential
-
setBindCredential
public void setBindCredential(Credential credential)
Sets the credential of the bind DN.- Parameters:
credential
- to use with bind DN
-
getBindSaslConfig
public SaslConfig getBindSaslConfig()
Returns the bind sasl config.- Returns:
- sasl config
-
setBindSaslConfig
public void setBindSaslConfig(SaslConfig config)
Sets the bind sasl config.- Parameters:
config
- sasl config
-
getBindControls
public RequestControl[] getBindControls()
Returns the bind controls.- Returns:
- controls
-
setBindControls
public 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
-
-