Class ConnectionData
- java.lang.Object
-
- de.hybris.platform.ldap.connection.ConnectionData
-
public class ConnectionData extends java.lang.ObjectThe ConnectionData inner class is used to pass connection data around. Not all fields are guaranteed to be valid values.
-
-
Constructor Summary
Constructors Constructor Description ConnectionData()Empty constructor - data fields are intended to be set directly.ConnectionData(int version, java.lang.String url, java.lang.String userDN, char[] pwd, boolean tracing, java.lang.String referralType, java.lang.String aliasType)I18nUtility method for test routinesConnectionData(int version, java.lang.String url, java.lang.String userDN, char[] pwd, boolean tracing, java.lang.String referralType, java.lang.String aliasType, boolean useSSL, java.lang.String cacerts, java.lang.String clientcerts, char[] caKeystorePwd, char[] clientKeystorePwd, java.lang.String caKeystoreType, java.lang.String clientKeystoreType, boolean useGSSAPI, java.util.Properties extraProperties)This sets up a full connection data object with the information needed to create a jndi environment properties object.ConnectionData(LDAPConfigProxyItem config)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckData()This method confirms that the data entered in the ConnectionData object is consistent, complete and valid.voidclearPasswords()This should be used to clear all the passwords saved in this data object when they have been used and are no longer needed...char[]getCredentials()java.lang.StringgetHost()Gets the host name from the url string.java.util.HashtablegetJNDIEnvironment()This returns the connection data as a jndi env object suitable for use in opening a directory context.java.util.List<java.util.Hashtable<java.lang.String,java.lang.String>>getLDAPEnvironments()intgetMaxRetries()intgetMaxSize()intgetMinFailbackTime()intgetPort()Gets the port number from the url string.java.lang.StringgetRootDN()java.lang.StringgetURL()java.lang.StringgetUserDN()voidputExtraProperty(java.lang.String key, java.lang.String property)voidsetProtocol(java.lang.String newProtocol)static voidsetupBasicProperties(java.util.Hashtable env, java.lang.String url, boolean tracing, java.lang.String referralType, java.lang.String aliasType)static voidsetupSimpleSecurityProperties(java.util.Hashtable env, java.lang.String userDN, char[] pwd)This sets the environment properties needed for a simple username + password authenticated jndi connection.static voidsetupSSLProperties(java.util.Hashtable env, java.lang.String cacerts, java.lang.String clientcerts, char[] caKeystorePwd, char[] clientKeystorePwd, java.lang.String caKeystoreType, java.lang.String clientKeystoreType, boolean sslTracing, java.lang.String sslSocketFactory)voidsetURL(java.lang.String URL)Sets the url from the host & port, e.g.voidsetURL(java.lang.String host, int port)Sets the url from the host & port, e.g.java.lang.StringtoString()Returns this data object as a string (doesn't include passwords)..
-
-
-
Field Detail
-
LDAP
public static final java.lang.String LDAP
Which protocol to use (currently "ldap", "dsml", "ssl")- See Also:
- Constant Field Values
-
DSML
public static final java.lang.String DSML
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ConnectionData
public ConnectionData()
Empty constructor - data fields are intended to be set directly.
-
ConnectionData
public ConnectionData(LDAPConfigProxyItem config) throws javax.naming.NamingException
- Throws:
javax.naming.NamingException
-
ConnectionData
public ConnectionData(int version, java.lang.String url, java.lang.String userDN, char[] pwd, boolean tracing, java.lang.String referralType, java.lang.String aliasType, boolean useSSL, java.lang.String cacerts, java.lang.String clientcerts, char[] caKeystorePwd, char[] clientKeystorePwd, java.lang.String caKeystoreType, java.lang.String clientKeystoreType, boolean useGSSAPI, java.util.Properties extraProperties)This sets up a full connection data object with the information needed to create a jndi environment properties object. Usually you won't need to use the full method, and can use one of the shorter versions that sets empty defaults for the unused bits.- Parameters:
version-url-userDN-pwd-tracing-referralType-aliasType-useSSL-cacerts-clientcerts-caKeystorePwd-clientKeystorePwd-caKeystoreType-clientKeystoreType-useGSSAPI- whether to use the GSSAPI protocol (e.g. for Kerberos support)extraProperties- a 'get out of jail free' for any bizarre properties that haven't already been covered, or that are introduced in the future. Using this isn't really good coding practice, since we don't know what there properties are, but is sometimes required...
-
ConnectionData
public ConnectionData(int version, java.lang.String url, java.lang.String userDN, char[] pwd, boolean tracing, java.lang.String referralType, java.lang.String aliasType)I18nUtility method for test routines- Parameters:
version-url-userDN-pwd-tracing-referralType-aliasType-
-
-
Method Detail
-
setProtocol
public void setProtocol(java.lang.String newProtocol)
-
clearPasswords
public void clearPasswords()
This should be used to clear all the passwords saved in this data object when they have been used and are no longer needed... make sure however that no references to the passwords remain to be used by other parts of the program first :-)! (note: since JNDI uses the passwords as Strings, they can still be sniffed from JNDI :-( ).
-
setURL
public void setURL(java.lang.String host, int port)Sets the url from the host & port, e.g. "ldap://" + host + ":" + port". (note: if the protocol is NOT LDAP, (e.g. DSML) this must be set first.- Parameters:
host- the host name to connect to, e.g. schmiedefix or 192.168.145.138.port- the host port to connect to, e.g. 389.
-
setURL
public void setURL(java.lang.String URL)
Sets the url from the host & port, e.g. "ldap://" + host + ":" + port". (NB: If the protocol is NOT LDAP, (e.g. DSML) this must be set first.- Parameters:
URL- The full URL to connect to
-
getURL
public java.lang.String getURL()
-
getUserDN
public java.lang.String getUserDN()
-
getHost
public java.lang.String getHost()
Gets the host name from the url string.- Returns:
- the host name for example: schmiedefix.
-
getPort
public int getPort()
Gets the port number from the url string.- Returns:
- the port number for example: 389.
-
getRootDN
public java.lang.String getRootDN()
-
toString
public java.lang.String toString()
Returns this data object as a string (doesn't include passwords)..- Overrides:
toStringin classjava.lang.Object- Returns:
- the data object as a string.
-
getJNDIEnvironment
public java.util.Hashtable getJNDIEnvironment() throws javax.naming.NamingExceptionThis returns the connection data as a jndi env object suitable for use in opening a directory context.- Returns:
- jndi environment values
- Throws:
javax.naming.NamingException- a large range of exceptions, ranging from invalid data through to problems setting up the SSL connection.
-
checkData
public void checkData() throws javax.naming.NamingExceptionThis method confirms that the data entered in the ConnectionData object is consistent, complete and valid.- Throws:
javax.naming.NamingException- thrown if the data is inconsistent or incomplete.
-
putExtraProperty
public void putExtraProperty(java.lang.String key, java.lang.String property)
-
setupBasicProperties
public static void setupBasicProperties(java.util.Hashtable env, java.lang.String url, boolean tracing, java.lang.String referralType, java.lang.String aliasType) throws javax.naming.NamingException- Throws:
javax.naming.NamingException
-
setupSimpleSecurityProperties
public static void setupSimpleSecurityProperties(java.util.Hashtable env, java.lang.String userDN, char[] pwd)This sets the environment properties needed for a simple username + password authenticated jndi connection. It is used by openSimpleSecurityContext(). This method is provided as a convenience for people wishing to append or modify the jndi environment, without setting it up entirely from scratch.- Parameters:
env-userDN-pwd-
-
setupSSLProperties
public static void setupSSLProperties(java.util.Hashtable env, java.lang.String cacerts, java.lang.String clientcerts, char[] caKeystorePwd, char[] clientKeystorePwd, java.lang.String caKeystoreType, java.lang.String clientKeystoreType, boolean sslTracing, java.lang.String sslSocketFactory) throws javax.naming.NamingException- Throws:
javax.naming.NamingException
-
getMinFailbackTime
public int getMinFailbackTime()
-
getMaxRetries
public int getMaxRetries()
-
getMaxSize
public int getMaxSize()
-
getLDAPEnvironments
public java.util.List<java.util.Hashtable<java.lang.String,java.lang.String>> getLDAPEnvironments()
-
getCredentials
public char[] getCredentials()
-
-