|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.vt.middleware.ldap.AbstractLdap<LdapConfig>
edu.vt.middleware.ldap.Ldap
public class Ldap
Ldap contains functions for basic interaction with an LDAP.
Methods are provided for connecting, binding, querying and updating.
| Nested Class Summary | |
|---|---|
static class |
Ldap.AttributeModification
Enum to define the type of attribute modification. |
| Field Summary |
|---|
| Fields inherited from class edu.vt.middleware.ldap.AbstractLdap |
|---|
BINDING_COPY_RESULT_HANDLER, config, connectionHandler, COPY_RESULT_HANDLER, logger, NCP_COPY_RESULT_HANDLER, SR_COPY_RESULT_HANDLER |
| Constructor Summary | |
|---|---|
Ldap()
Default constructor. |
|
Ldap(LdapConfig ldapConfig)
This will create a new Ldap with the supplied
LdapConfig. |
|
| Method Summary | |
|---|---|
boolean |
compare(SearchFilter filter)
This will perform an LDAP compare operation with the supplied filter. |
boolean |
compare(String dn,
SearchFilter filter)
This will perform an LDAP compare operation with the supplied filter and dn. |
void |
create(String dn,
Attributes attrs)
This will create the supplied dn in the LDAP namespace with the supplied attributes. |
void |
delete(String dn)
This will delete the supplied dn from the LDAP namespace. |
Attributes |
getAttributes(String dn)
This will return all the attributes associated with the supplied dn. |
Attributes |
getAttributes(String dn,
String[] retAttrs)
This will return the matching attributes associated with the supplied dn. |
Attributes |
getAttributes(String dn,
String[] retAttrs,
AttributeHandler... handler)
This will return the matching attributes associated with the supplied dn. |
LdapConfig |
getLdapConfig()
This returns the LdapConfig of the Ldap. |
String[] |
getSaslMechanisms()
This will return a list of SASL mechanisms that this LDAP supports. |
Iterator<SearchResult> |
getSchema(String dn)
This will return the LDAP schema associated with the supplied dn. |
String[] |
getSupportedControls()
This will return a list of controls that this LDAP supports. |
Iterator<NameClassPair> |
list(String dn)
This will enumerate the names bounds to the specified context, along with the class names of objects bound to them. |
Iterator<Binding> |
listBindings(String dn)
This will enumerate the names bounds to the specified context, along with the objects bound to them. |
void |
loadFromProperties()
This will set the config parameters of this Ldap using the
default properties file, which must be located in your classpath. |
void |
loadFromProperties(InputStream is)
This will set the config parameters of this Ldap using the
supplied input stream. |
void |
modifyAttributes(String dn,
Ldap.AttributeModification mod,
Attributes attrs)
This will modify the supplied attributes for the supplied value given by the modification operation. |
void |
modifyAttributes(String dn,
ModificationItem[] mods)
This will modify the supplied dn using the supplied modifications. |
void |
rename(String oldDn,
String newDn)
This will rename the supplied dn in the LDAP namespace. |
Iterator<SearchResult> |
search(SearchFilter filter)
This will query the LDAP with the supplied filter. |
Iterator<SearchResult> |
search(SearchFilter filter,
SearchControls searchControls)
This will query the LDAP with the supplied filter and search controls. |
Iterator<SearchResult> |
search(SearchFilter filter,
String[] retAttrs)
This will query the LDAP with the supplied filter and return attributes. |
Iterator<SearchResult> |
search(String dn,
SearchFilter filter)
This will query the LDAP with the supplied dn and filter. |
Iterator<SearchResult> |
search(String dn,
SearchFilter filter,
SearchControls searchControls)
This will query the LDAP with the supplied dn, filter, and search controls. |
Iterator<SearchResult> |
search(String dn,
SearchFilter filter,
SearchControls searchControls,
SearchResultHandler... handler)
This will query the LDAP with the supplied dn, filter, search controls, and search result handler. |
Iterator<SearchResult> |
search(String dn,
SearchFilter filter,
String[] retAttrs)
This will query the LDAP with the supplied dn, filter, and return attributes. |
Iterator<SearchResult> |
search(String dn,
SearchFilter filter,
String[] retAttrs,
SearchResultHandler... handler)
This will query the LDAP with the supplied dn, filter, return attributes, and search result handler. |
Iterator<SearchResult> |
searchAttributes(Attributes matchAttrs)
This will query the LDAP for the supplied matching attributes. |
Iterator<SearchResult> |
searchAttributes(Attributes matchAttrs,
String[] retAttrs)
This will query the LDAP for the supplied matching attributes and return attributes. |
Iterator<SearchResult> |
searchAttributes(String dn,
Attributes matchAttrs)
This will query the LDAP for the supplied dn and matching attributes. |
Iterator<SearchResult> |
searchAttributes(String dn,
Attributes matchAttrs,
String[] retAttrs)
This will query the LDAP for the supplied dn, matching attributes and return attributes. |
Iterator<SearchResult> |
searchAttributes(String dn,
Attributes matchAttrs,
String[] retAttrs,
SearchResultHandler... handler)
This will query the LDAP for the supplied dn, matching attributes and return attributes. |
void |
setLdapConfig(LdapConfig ldapConfig)
This will set the config parameters of this Ldap. |
| Methods inherited from class edu.vt.middleware.ldap.AbstractLdap |
|---|
close, compare, connect, finalize, getContext, modifyAttributes, operationRetry, pagedSearch, reconnect, search, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Ldap()
public Ldap(LdapConfig ldapConfig)
Ldap with the supplied
LdapConfig.
ldapConfig - LdapConfig| Method Detail |
|---|
public void setLdapConfig(LdapConfig ldapConfig)
Ldap.
setLdapConfig in class AbstractLdap<LdapConfig>ldapConfig - LdapConfigpublic LdapConfig getLdapConfig()
LdapConfig of the Ldap.
LdapConfigpublic void loadFromProperties()
Ldap using the
default properties file, which must be located in your classpath.
public void loadFromProperties(InputStream is)
Ldap using the
supplied input stream.
is - InputStream
public boolean compare(SearchFilter filter)
throws NamingException
LdapConfig.getBaseDn() is used as the dn to compare. See compare(String, SearchFilter).
filter - SearchFilter expression to use for compare
boolean - result of compare operation
NamingException - if the LDAP returns an error
public boolean compare(String dn,
SearchFilter filter)
throws NamingException
dn - String name to comparefilter - SearchFilter expression to use for compare
boolean - result of compare operation
NamingException - if the LDAP returns an error
public Iterator<SearchResult> search(SearchFilter filter)
throws NamingException
LdapConfig.getBaseDn() is used as the start point for
searching. Search controls will be created from LdapConfig.getSearchControls(String[]). See search(String,SearchFilter,String[]).
filter - SearchFilter expression to use for the search
Iterator - of LDAP search results
NamingException - if the LDAP returns an error
public Iterator<SearchResult> search(SearchFilter filter,
String[] retAttrs)
throws NamingException
LdapConfig.getBaseDn() is used as the start point for searching.
Search controls will be created from LdapConfig.getSearchControls(String[]). See search(String,SearchFilter,String[]).
filter - SearchFilter expression to use for the searchretAttrs - String[] attributes to return
Iterator - of LDAP search results
NamingException - if the LDAP returns an error
public Iterator<SearchResult> search(SearchFilter filter,
SearchControls searchControls)
throws NamingException
LdapConfig.getBaseDn() is used as the start point for searching.
See search(String,SearchFilter,SearchControls).
filter - SearchFilter expression to use for the searchsearchControls - SearchControls to search with
Iterator - of LDAP search results
NamingException - if the LDAP returns an error
public Iterator<SearchResult> search(String dn,
SearchFilter filter)
throws NamingException
LdapConfig.getSearchControls(String[]). See search(String,SearchFilter,String[]).
dn - String name to begin search atfilter - SearchFilter expression to use for the search
Iterator - of LDAP search results
NamingException - if the LDAP returns an error
public Iterator<SearchResult> search(String dn,
SearchFilter filter,
String[] retAttrs)
throws NamingException
LdapConfig.getSearchControls(String[]). See search(String,SearchFilter,SearchControls,SearchResultHandler[]).
dn - String name to begin search atfilter - SearchFilter expression to use for the searchretAttrs - String[] attributes to return
Iterator - of LDAP search results
NamingException - if the LDAP returns an error
public Iterator<SearchResult> search(String dn,
SearchFilter filter,
SearchControls searchControls)
throws NamingException
search(String,SearchFilter,SearchControls,SearchResultHandler[]).
dn - String name to begin search atfilter - SearchFilter expression to use for the searchsearchControls - SearchControls to search with
Iterator - of LDAP search results
NamingException - if the LDAP returns an error
public Iterator<SearchResult> search(String dn,
SearchFilter filter,
String[] retAttrs,
SearchResultHandler... handler)
throws NamingException
LdapConfig.getSearchControls(String[]). See search(
String,SearchFilter,SearchControls,SearchResultHandler...).
dn - String name to begin search atfilter - SearchFilter expression to use for the searchretAttrs - String[] attributes to returnhandler - SearchResultHandler[] of handlers to execute
Iterator - of LDAP search results
NamingException - if the LDAP returns an error
public Iterator<SearchResult> search(String dn,
SearchFilter filter,
SearchControls searchControls,
SearchResultHandler... handler)
throws NamingException
LdapConfig.getPagedResultsSize() is
greater than 0, the PagedResultsControl will be invoked. See #search(String,String,Object[],SearchControls,SearchResultHandler[]).
dn - String name to begin search atfilter - SearchFilter expression to use for the searchsearchControls - SearchControls to search withhandler - SearchResultHandler[] of handlers to execute
Iterator - of LDAP search results
NamingException - if the LDAP returns an error
public Iterator<SearchResult> searchAttributes(Attributes matchAttrs)
throws NamingException
LdapConfig.getBaseDn() is used as the
name to search.
See searchAttributes(String, Attributes, String[]).
matchAttrs - Attributes attributes to match
Iterator - of LDAP search results
NamingException - if the LDAP returns an error
public Iterator<SearchResult> searchAttributes(Attributes matchAttrs,
String[] retAttrs)
throws NamingException
LdapConfig.getBaseDn() is used as the name to search.
See searchAttributes(String, Attributes, String[]).
matchAttrs - Attributes attributes to matchretAttrs - String[] attributes to return
Iterator - of LDAP search results
NamingException - if the LDAP returns an error
public Iterator<SearchResult> searchAttributes(String dn,
Attributes matchAttrs)
throws NamingException
searchAttributes(String,
Attributes, String[]).
dn - String name to search inmatchAttrs - Attributes attributes to match
Iterator - of LDAP search results
NamingException - if the LDAP returns an error
public Iterator<SearchResult> searchAttributes(String dn,
Attributes matchAttrs,
String[] retAttrs)
throws NamingException
searchAttributes( String, Attributes,
String[], SearchResultHandler[]). This method converts relative DNs to
fully qualified DNs, no post processing is required
dn - String name to search inmatchAttrs - Attributes attributes to matchretAttrs - String[] attributes to return
Iterator - of LDAP search results
NamingException - if the LDAP returns an error
public Iterator<SearchResult> searchAttributes(String dn,
Attributes matchAttrs,
String[] retAttrs,
SearchResultHandler... handler)
throws NamingException
Iterator is a deep copy of the original search
results. If matchAttrs is empty or null then all objects in the target
context are returned. If retAttrs is null then all attributes will be
returned. If retAttrs is an empty array then no attributes will be
returned. See DirContext.
searchAttributes in class AbstractLdap<LdapConfig>dn - String name to search inmatchAttrs - Attributes attributes to matchretAttrs - String[] attributes to returnhandler - SearchResultHandler[] to post process results
Iterator - of LDAP search results
NamingException - if the LDAP returns an error
public Iterator<NameClassPair> list(String dn)
throws NamingException
Iterator is a deep copy of the original search results. See Context.list(String).
list in class AbstractLdap<LdapConfig>dn - String LDAP context to list
Iterator - LDAP search result
NamingException - if the LDAP returns an error
public Iterator<Binding> listBindings(String dn)
throws NamingException
Iterator is a deep
copy of the original search results. See Context.listBindings(String).
listBindings in class AbstractLdap<LdapConfig>dn - String LDAP context to list
Iterator - LDAP search result
NamingException - if the LDAP returns an error
public Attributes getAttributes(String dn)
throws NamingException
getAttributes(String, String[]).
dn - String named object in the LDAP
Attributes
NamingException - if the LDAP returns an error
public Attributes getAttributes(String dn,
String[] retAttrs)
throws NamingException
getAttributes(String, String[], AttributeHandler[]).
dn - String named object in the LDAPretAttrs - String[] attributes to return
Attributes
NamingException - if the LDAP returns an error
public Attributes getAttributes(String dn,
String[] retAttrs,
AttributeHandler... handler)
throws NamingException
DirContext.
getAttributes in class AbstractLdap<LdapConfig>dn - String named object in the LDAPretAttrs - String[] attributes to returnhandler - AttributeHandler[] to post process results
Attributes
NamingException - if the LDAP returns an error
public Iterator<SearchResult> getSchema(String dn)
throws NamingException
Iterator is a deep copy of the original search
results. See DirContext.
getSchema in class AbstractLdap<LdapConfig>dn - String named object in the LDAP
Iterator - LDAP search result
NamingException - if the LDAP returns an error
public void modifyAttributes(String dn,
Ldap.AttributeModification mod,
Attributes attrs)
throws NamingException
AbstractLdap.modifyAttributes(String, int, Attributes).
dn - String named object in the LDAPmod - AttributeModification modification operationattrs - Attributes attributes to be used for the
operation, may be null
NamingException - if the LDAP returns an error
public void modifyAttributes(String dn,
ModificationItem[] mods)
throws NamingException
DirContext.
modifyAttributes in class AbstractLdap<LdapConfig>dn - String named object in the LDAPmods - ModificationItem[] modifications
NamingException - if the LDAP returns an error
public void create(String dn,
Attributes attrs)
throws NamingException
DirContext. Note that the context created by this operation is
immediately closed.
create in class AbstractLdap<LdapConfig>dn - String named object in the LDAPattrs - Attributes attributes to be added to this entry
NamingException - if the LDAP returns an error
public void rename(String oldDn,
String newDn)
throws NamingException
Context.rename(String, String).
rename in class AbstractLdap<LdapConfig>oldDn - String object to renamenewDn - String new name
NamingException - if the LDAP returns an error
public void delete(String dn)
throws NamingException
Context.destroySubcontext(String).
delete in class AbstractLdap<LdapConfig>dn - String named object in the LDAP
NamingException - if the LDAP returns an error
public String[] getSaslMechanisms()
throws NamingException
String[] - supported SASL mechanisms
NamingException - if the LDAP returns an error
public String[] getSupportedControls()
throws NamingException
String[] - supported controls
NamingException - if the LDAP returns an error
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||