LDAP Chai API

com.novell.ldapchai.provider
Class ChaiConfiguration

java.lang.Object
  extended by com.novell.ldapchai.provider.ChaiConfiguration
All Implemented Interfaces:
Serializable, Cloneable

public class ChaiConfiguration
extends Object
implements Cloneable, Serializable

LDAP Chai API configuration settings. This class represents the primary means of controling Chai behavior. Instances of ChaiConfiguration are semi-mutable. Once instantiated, the setters may be called to modify the instance. However, once lock() is called, all setters will throw an IllegalStateException.

When a ChaiConfiguration instance is used to configure a new ChaiProvider instance, it is automatically locked. Thus, a ChaiProvider's configuration can not be modifed once it is used to create a ChaiProvider.

This class is cloneable and clones are created in an unlocked state.

Author:
Jason D. Rivard
See Also:
ChaiSetting, Serialized Form

Field Summary
static String LDAP_URL_SEPERATOR_REGEX_PATTERN
           
 
Constructor Summary
ChaiConfiguration()
          Construct a default ChaiConfiguration
ChaiConfiguration(List<String> ldapURLs, String bindDN, String bindPassword)
          Construct a default ChaiConfiguration
ChaiConfiguration(String ldapURL, String bindDN, String bindPassword)
          Construct a default ChaiConfiguration
 
Method Summary
 List<String> bindURLsAsList()
          Returns an immutable list of the ldap URLs.
 Object clone()
          Clone this configuration and all of its settings, including the bind DN, password and ldap URLs.
 boolean getBooleanSetting(ChaiSetting setting)
          Get an individual setting value and test it as a boolean
static Properties getDefaultSettings()
          Get a properties containing the default settings used by a newly constructed ChaiConfiguration.
 Object getImplementationConfiguration()
          Return the current implementation configuration object.
 String getSetting(ChaiSetting setting)
          Get an individual setting value
 Properties getSettings()
          Get the current settings of the ChaiProvider.
 X509TrustManager[] getTrustManager()
          Get the current settings of the ChaiProvider.
 boolean isLocked()
          Indicates the lock status of this ChaiConfiguration.
 void lock()
          Lock this ChaiConfiguration.
 ChaiConfiguration setImplementationConfiguration(Serializable implementationConfiguration)
          Set an object to be used for the ChaiProvider implementation to be used for its configuration.
 ChaiConfiguration setSetting(ChaiSetting setting, String value)
          Set a single settings.
 void setSettings(Properties settings)
          Set the settings in the ChaiConfiguration.
 ChaiConfiguration setTrustManager(X509TrustManager[] trustManager)
          Add a TrustManager to be used when connecting to ssl ldap servers.
 String toString()
          Returns a string value suitable for debugging.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LDAP_URL_SEPERATOR_REGEX_PATTERN

public static final String LDAP_URL_SEPERATOR_REGEX_PATTERN
See Also:
Constant Field Values
Constructor Detail

ChaiConfiguration

public ChaiConfiguration()
Construct a default ChaiConfiguration


ChaiConfiguration

public ChaiConfiguration(List<String> ldapURLs,
                         String bindDN,
                         String bindPassword)
Construct a default ChaiConfiguration

Parameters:
bindDN - ldap bind DN, in ldap fully qualified syntax. Also used as the DN of the returned ChaiUser.
bindPassword - password for the bind DN.
ldapURLs - an ordered list fo ldap server and port in url format, example: ldap://127.0.0.1:389

ChaiConfiguration

public ChaiConfiguration(String ldapURL,
                         String bindDN,
                         String bindPassword)
Construct a default ChaiConfiguration

Parameters:
bindDN - ldap bind DN, in ldap fully qualified syntax. Also used as the DN of the returned ChaiUser.
bindPassword - password for the bind DN.
ldapURL - ldap server and port in url format, example: ldap://127.0.0.1:389
Method Detail

getDefaultSettings

public static Properties getDefaultSettings()
Get a properties containing the default settings used by a newly constructed ChaiConfiguration.

Returns:
The default settings.

setSetting

public ChaiConfiguration setSetting(ChaiSetting setting,
                                    String value)
Set a single settings. Each setting is avalable in the ChaiSetting enumeration.

Parameters:
setting - the setting to set
value - the value to set
Returns:
this instance of the ChaiConfiguration to facilitate chaining
Throws:
IllegalArgumentException - if the value is not syntactically correct
See Also:
ChaiSetting.validateValue(String)

getImplementationConfiguration

public Object getImplementationConfiguration()
Return the current implementation configuration object.

Returns:
current implementation configuration object.

isLocked

public boolean isLocked()
Indicates the lock status of this ChaiConfiguration.

Returns:
true if this ChaiConfiguration is locked

clone

public Object clone()
             throws CloneNotSupportedException
Clone this configuration and all of its settings, including the bind DN, password and ldap URLs. The returned clone will always be unlocked.

Overrides:
clone in class Object
Returns:
An unlocked copy of the current configuration.
Throws:
CloneNotSupportedException

toString

public String toString()
Returns a string value suitable for debugging. Sensitive values such as passwords are not included.

Overrides:
toString in class Object
Returns:
a string value suitable for debugging

getSetting

public String getSetting(ChaiSetting setting)
Get an individual setting value

Parameters:
setting - the setting to return
Returns:
the value or the default value if no value exists.

getBooleanSetting

public boolean getBooleanSetting(ChaiSetting setting)
Get an individual setting value and test it as a boolean

Parameters:
setting - the setting to return
Returns:
the value or the default value if no value exists.

bindURLsAsList

public List<String> bindURLsAsList()
Returns an immutable list of the ldap URLs.

Returns:
an immutable list of the ldapURLS.

getSettings

public Properties getSettings()
Get the current settings of the ChaiProvider.

Returns:
a copy of the settings for this ChaiConfiguration

getTrustManager

public X509TrustManager[] getTrustManager()
Get the current settings of the ChaiProvider.

Returns:
a copy of the settings for this ChaiConfiguration

lock

public void lock()
Lock this ChaiConfiguration. Once locked, all of the setter methods will throw an IllegalStateException. In order to be locked, both an implementation class and implementation configuration must be set.


setImplementationConfiguration

public ChaiConfiguration setImplementationConfiguration(Serializable implementationConfiguration)
Set an object to be used for the ChaiProvider implementation to be used for its configuration. Depending on the implementation, this could be any type of object such as a Properties, Map, or even an implementation specific object.

When used with the default provider, JNDIProviderImpl, this object must be a Hashtable environment as specified by the InitialLdapContext.

Parameters:
implementationConfiguration - an object suitable to be used as a configuration for whatever ChaiProvider implementation is to be used.
Returns:
this instance of the ChaiConfiguration to facilitate chaining

setTrustManager

public ChaiConfiguration setTrustManager(X509TrustManager[] trustManager)
Add a TrustManager to be used when connecting to ssl ldap servers.

Parameters:
trustManager - A serializable trustmanager to be used for connecting to ldap servers.
Returns:
this instance of the ChaiConfiguration to facilitate chaining

setSettings

public void setSettings(Properties settings)
Set the settings in the ChaiConfiguration. Each setting key is available as a constant publicly defined by ChaiConfiguration. The default settings are available in getDefaultSettings().

Parameters:
settings - a Properties containing settings to be used by the provider. If a setting is missing in the supplied Properties, the current setting will be unchanged.

LDAP Chai API