com.waveset.util
Class JndiUtil

java.lang.Object
  extended bycom.waveset.util.JndiUtil

public class JndiUtil
extends java.lang.Object

Various JDBC utilities.


Field Summary
static java.lang.String code_id
           
 
Constructor Summary
JndiUtil()
           
 
Method Summary
static java.lang.String buildUrl(java.util.Map args, java.lang.String baseDn)
           
static void closeConnection(javax.naming.directory.DirContext ctx)
          Close a connection.
static javax.naming.directory.InitialDirContext getConnection(java.util.Map args)
          Establish a connection using a Map of arguments.
static javax.naming.directory.InitialDirContext getConnection(java.lang.String host, java.lang.String port, java.lang.String baseDn, java.lang.String bindDn, java.lang.String bindPass, java.lang.String ssl)
           
static java.util.Hashtable getContextEnv(java.lang.String host, java.lang.String port, java.lang.String baseDn, java.lang.String bindDn, java.lang.String bindPass, java.lang.String ssl)
          Return a Hashtable of properties for the connection
static java.lang.Object getValue(javax.naming.directory.Attribute a)
           
static java.lang.String getValueAsString(javax.naming.directory.Attribute attr, boolean tolerateMultipleValues)
           
static java.lang.String getValueAsString(javax.naming.directory.Attributes attrs, java.lang.String attrId)
           
static void main(java.lang.String[] args)
           
static java.util.List search(javax.naming.directory.DirContext context, java.lang.String baseDn, java.lang.String url, java.lang.String filter, javax.naming.directory.SearchControls controls)
          Run an LDAP search, return a List of Maps
static java.lang.Object search(java.util.Map args)
          Search using a Map of arguments.
static java.lang.Object searchAttribute(java.util.Map args, java.lang.String attname)
          A wrapper around search() that returns one attribute.
static java.util.Map searchObject(java.util.Map args)
          A wrapper around search() that returns one object rather than a List of objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values
Constructor Detail

JndiUtil

public JndiUtil()
Method Detail

getValueAsString

public static java.lang.String getValueAsString(javax.naming.directory.Attributes attrs,
                                                java.lang.String attrId)
                                         throws InvalidArgument,
                                                javax.naming.NamingException
Parameters:
attrs - the Attributes expected to contain the attribute.
attrId - the name of the attribute

Returns:
the value (coerced to a String) of a single-valued JNDI Attribute.
Throws:
InvalidArgument - if the specified attribute is multi-valued.
javax.naming.NamingException

getValueAsString

public static java.lang.String getValueAsString(javax.naming.directory.Attribute attr,
                                                boolean tolerateMultipleValues)
                                         throws InvalidArgument,
                                                javax.naming.NamingException
Parameters:
attr - the attribute
tolerateMultipleValues - if true, the attribute may contain multiple values.

Returns:
the first value (coerced to a String) of a JNDI Attribute.
Throws:
InvalidArgument - if tolerateMultipleValues is false and the specified attribute has multiple values.
javax.naming.NamingException

getContextEnv

public static java.util.Hashtable getContextEnv(java.lang.String host,
                                                java.lang.String port,
                                                java.lang.String baseDn,
                                                java.lang.String bindDn,
                                                java.lang.String bindPass,
                                                java.lang.String ssl)
Return a Hashtable of properties for the connection


getConnection

public static javax.naming.directory.InitialDirContext getConnection(java.lang.String host,
                                                                     java.lang.String port,
                                                                     java.lang.String baseDn,
                                                                     java.lang.String bindDn,
                                                                     java.lang.String bindPass,
                                                                     java.lang.String ssl)
                                                              throws WavesetException
Throws:
WavesetException

getConnection

public static javax.naming.directory.InitialDirContext getConnection(java.util.Map args)
                                                              throws WavesetException
Establish a connection using a Map of arguments. The map here doesn't use the same names as those in the context environment hashtable, it could but I think these are more obvious. host host name port port number baseDn base Dn used with provider url user bind DN, or security principal password bind password, or security credentials ssl "true" to enable ssl

Throws:
WavesetException

closeConnection

public static void closeConnection(javax.naming.directory.DirContext ctx)
Close a connection.


search

public static java.util.List search(javax.naming.directory.DirContext context,
                                    java.lang.String baseDn,
                                    java.lang.String url,
                                    java.lang.String filter,
                                    javax.naming.directory.SearchControls controls)
                             throws WavesetException
Run an LDAP search, return a List of Maps

Throws:
WavesetException

getValue

public static java.lang.Object getValue(javax.naming.directory.Attribute a)

buildUrl

public static java.lang.String buildUrl(java.util.Map args,
                                        java.lang.String baseDn)

search

public static java.lang.Object search(java.util.Map args)
                               throws WavesetException
Search using a Map of arguments. Return a List of Map objects. The map may contain all of the connection parameters supported by getConnection. In addition these are used to specify the search. searchDn - object or container in which to search called "url" in the javadoc, is this more general? filter - optional filter attributes - attributes to return, if null all are returned scope - object, oneLevel, subTree timeLimit - milliseconds to wait before returning countLimit - maximum number of results to return Not supporting "dereference links" or "return object".

Throws:
WavesetException

searchObject

public static java.util.Map searchObject(java.util.Map args)
                                  throws WavesetException
A wrapper around search() that returns one object rather than a List of objects.

Throws:
WavesetException

searchAttribute

public static java.lang.Object searchAttribute(java.util.Map args,
                                               java.lang.String attname)
                                        throws WavesetException
A wrapper around search() that returns one attribute.

Throws:
WavesetException

main

public static void main(java.lang.String[] args)
                 throws WavesetException
Throws:
WavesetException