|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||

java.lang.Objectca.tnt.ldaputils.LdapManager
public class LdapManager
Encapsulates LDAP access in to an easy to use factory object. The purpose is to provide a method of access LDAP that is similar to JPA, but specifically customized for LDAP purposes. JPA's annotations did not seem to fit the bill enough to warrant creating a JPA provider for LDAP.
The main reason for starting this project is that I have found Sun JNDI interfaces too cumbersome to use for my simple purposes. Created : Feb 28, 2006 7:43:12 PM MST
| Field Summary | |
|---|---|
static int |
NO_ORDER
Return search results in no particular order. |
static int |
SEARCH_ORDER
Return search results in the order they were found. |
static int |
SORTED_ORDER
Return search result in alphanumeric order, sorting by the keyAttribute. |
| Constructor Summary | |
|---|---|
LdapManager()
Initializes internal data store parameters. |
|
LdapManager(String sLDAPHost,
String sLDAPPort,
String sLDAPManagerDN,
String sLDAPManagerPW)
Initialize LdapManager instance with the host, port, auth dn, and auth password set. |
|
| Method Summary | |
|---|---|
void |
bind(Object ldapEntry)
Binds the LdapEntity annotated object to ldap, with all of it's
attributes. |
Object |
find(Class annotatedClass,
LdapName dn)
Retrieves the exact LdapEntity POJO you specify, using the dn passed in. |
Map |
find(LdapName baseDN,
String searchFilter,
String keyAttribute,
String[] attributes,
Class ldapEntryClass,
int sorted,
int searchScope)
Do a search and return a Map of the entries. |
Attributes |
getAttributes(LdapName dn,
String[] attributes)
|
Object[] |
getAttributes(String baseDN,
String searchFilter,
String[] attributes)
Generic method for retrieving entry attributes from the LDAP store. |
DirContext |
getConnection()
|
static DirContext |
getConnection(boolean isPooled,
int timeout,
String sLDAPURL,
String sLDAPManagerDN,
String sLDAPManagerPW)
Gets an LDAP directory context. |
static String |
getNamingExceptionMessage(NamingException namingException)
Returns an appropriate message for the exception. |
static void |
logNamingException(NamingException namingException)
|
static void |
main(String[] args)
Hopefully provides an example of how to use all the basic features of the LDAP objects framework. |
static void |
releaseConnection(DirContext conn)
Releases an LDAP directory context. |
void |
unbind(ILdapEntry ldapEntry)
|
void |
unbind(LdapName dn)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int NO_ORDER
public static final int SEARCH_ORDER
public static final int SORTED_ORDER
| Constructor Detail |
|---|
public LdapManager()
public LdapManager(String sLDAPHost,
String sLDAPPort,
String sLDAPManagerDN,
String sLDAPManagerPW)
sLDAPHost - the ldap hostsLDAPPort - the ldap portsLDAPManagerDN - the fully qualified DN of the ldap manager account,
or one of sufficient privileges to carry out the
required operationssLDAPManagerPW - the password of the sLDAPManagerDN account.| Method Detail |
|---|
public Map find(LdapName baseDN,
String searchFilter,
String keyAttribute,
String[] attributes,
Class ldapEntryClass,
int sorted,
int searchScope)
SearchControls.ONELEVEL_SCOPE as the "searchScope" parameter.
baseDN - the base DN to search onsearchFilter - the ldap search filter to use for ldap entry
retreival.keyAttribute - the attribute that will be the key for the
getSortedAttributes() method that returns a
SortedMapattributes - the array of attribute names to retrieve. If you
want ALL attributes to be loaded for a particular
LDAPObject, then pass in a null value for this
parameterldapEntryClass - the clas of the object that is annotatedsorted - One of NO_ORDER, SEARCH_ORDER, SORTED_ORDERsearchScope - One of the scope values in SearchControls
LdapNamingException - if any naming problems occurNO_ORDER,
SEARCH_ORDER,
SORTED_ORDER
public Object find(Class annotatedClass,
LdapName dn)
annotatedClass - the class that has been annotated with ldaputil
annotationsdn - the LDAP Distinquished Name.
LdapEntity annotated POJO that you specified in
annotatedClass, or null if it was not found
LdapNamingException - if any ldap naming errors occur.
IllegalArgumentException - if the annotatedClass is not correctly
annotated in some way
public Object[] getAttributes(String baseDN,
String searchFilter,
String[] attributes)
baseDN - the DN given.searchFilter - the ldap search filter to use for ldap entry
retrieval.attributes - array with the attribute names to grab
LdapNamingException - if an ldap error occurs
public Attributes getAttributes(LdapName dn,
String[] attributes)
public static DirContext getConnection(boolean isPooled,
int timeout,
String sLDAPURL,
String sLDAPManagerDN,
String sLDAPManagerPW)
throws NamingException
isPooled - turn pooling on?timeout - the connection timeout valuesLDAPURL - the ldap urlsLDAPManagerDN - the manager dnsLDAPManagerPW - @return an LDAP directory context object
NamingException - if a JNDI error occurs.
public DirContext getConnection()
throws NamingException
NamingExceptionpublic static void releaseConnection(DirContext conn)
conn - LDAP directory context objectpublic static void logNamingException(NamingException namingException)
public static String getNamingExceptionMessage(NamingException namingException)
namingException - the exception
public static void main(String[] args)
args - the arguments to pass in.public void bind(Object ldapEntry)
LdapEntity annotated object to ldap, with all of it's
attributes.
CRITICAL updating annotation processor (issue-5)
ldapEntry - LdapEntity annotated object
UnsupportedOperationException - if there is some error in the code
that uses the recursive binding
functionality. This shouldn't
happen, if it does, it's a bug, and
needs to be reported.public void unbind(LdapName dn)
public void unbind(ILdapEntry ldapEntry)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
This documentation is part of the LDAP Persistence API (LPA).
Copyright Trenton D. Adams <lpa at trentonadams daught ca>
LPA is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
LPA is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with LPA. If not, see GNU Licenses.
See the COPYING file, in the git repository, for more information.