Package org.bedework.util.directory.ldap
Class LdapDirectory
- java.lang.Object
-
- org.bedework.util.directory.common.Directory
-
- org.bedework.util.directory.ldap.LdapDirectory
-
- All Implemented Interfaces:
org.bedework.util.logging.Logged
public class LdapDirectory extends Directory
Provide access to ldap directory services. If the object is provided with a Properties object it will be queried for a number of properties. If they are absent or no Properties object is provided they will default to some value. Properties are defined in javax.naming.Context and are: java.naming.factory.initial java.naming.provider.url Service provider, e.g. ldap://ldap.myhost.edu:389 java.naming.security.authentication e.g. "simple" java.naming.security.principal e.g. cn=dirManager java.naming.security.credentials Usually the password
-
-
Constructor Summary
Constructors Constructor Description LdapDirectory()Constructor required so we can instantiate object dynamicallyLdapDirectory(Properties pr, String mngrDN, String pw)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcheckProp(Properties pr, String name, String defaultVal)If the named property is present and has a value use that.voidclose()booleancreate(DirRecord rec)voiddestroy(String dn)PropertiesgetEnvironment()org.bedework.util.logging.BwLoggergetLogger()voidinit(Properties pr, String mngrDN, String pw)voidmodify(String dn, ModificationItem[] mods)DirRecordnextRecord()voidreInit()If possible, reInit should allow reuse after a closevoidreplace(String dn, String attrName, Object val)Replace an entire attribute with one containing only the given valuevoidreplace(String dn, String attrName, Object[] val)Replace an entire attribute with one containing only the given valuesvoidreplace(String dn, String attrName, Object oldval, Object newval)Replace a single given attribute value with the given valuebooleansearch(String base, String filter, int scope)Carry out a search with specified scope.-
Methods inherited from class org.bedework.util.directory.common.Directory
newRecord, search, searchBase, searchOne
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.bedework.util.logging.Logged
audit, debug, debug, enableAuditLogger, enableErrorLogger, enableMetricsLogger, error, error, error, getLogLevel, info, isAuditLoggerEnabled, isErrorLoggerEnabled, isMetricsDebugEnabled, isMetricsLoggerEnabled, metrics, setLoggerClass, setLoggerClass, trace, trace, warn
-
-
-
-
Constructor Detail
-
LdapDirectory
public LdapDirectory() throws ExceptionConstructor required so we can instantiate object dynamically- Throws:
Exception
-
LdapDirectory
public LdapDirectory(Properties pr, String mngrDN, String pw) throws NamingException
- Parameters:
pr-mngrDN-pw-- Throws:
NamingException
-
-
Method Detail
-
init
public void init(Properties pr, String mngrDN, String pw) throws NamingException
- Throws:
NamingException
-
reInit
public void reInit() throws NamingExceptionDescription copied from class:DirectoryIf possible, reInit should allow reuse after a close- Specified by:
reInitin classDirectory- Throws:
NamingException- on fatal error
-
destroy
public void destroy(String dn) throws NamingException
- Specified by:
destroyin classDirectory- Throws:
NamingException- on fatal error
-
search
public boolean search(String base, String filter, int scope) throws NamingException
Description copied from class:DirectoryCarry out a search with specified scope.- Specified by:
searchin classDirectory- Parameters:
base- for searchfilter- ldap filter- Returns:
- false means no record(s) found. true means it's safe to call nextRecord.
- Throws:
NamingException
-
nextRecord
public DirRecord nextRecord() throws NamingException
- Specified by:
nextRecordin classDirectory- Throws:
NamingException
-
create
public boolean create(DirRecord rec) throws NamingException
- Specified by:
createin classDirectory- Parameters:
rec- directory record- Returns:
- boolean true if created, false if already exists
- Throws:
NamingException- on fatal error
-
replace
public void replace(String dn, String attrName, Object val) throws NamingException
Description copied from class:DirectoryReplace an entire attribute with one containing only the given value- Specified by:
replacein classDirectory- Parameters:
dn- for recordattrName- name of attributeval- new value- Throws:
NamingException- on fatal error
-
replace
public void replace(String dn, String attrName, Object[] val) throws NamingException
Description copied from class:DirectoryReplace an entire attribute with one containing only the given values- Specified by:
replacein classDirectory- Parameters:
dn- for recordattrName- name of attributeval- new value- Throws:
NamingException- on fatal error
-
replace
public void replace(String dn, String attrName, Object oldval, Object newval) throws NamingException
Description copied from class:DirectoryReplace a single given attribute value with the given value- Specified by:
replacein classDirectory- Parameters:
dn- for recordattrName- name of attributeoldval- current valuenewval- new value- Throws:
NamingException- on fatal error
-
modify
public void modify(String dn, ModificationItem[] mods) throws NamingException
- Specified by:
modifyin classDirectory- Parameters:
dn- for recordmods- list of changes- Throws:
NamingException- on fatal error
-
getEnvironment
public Properties getEnvironment() throws NamingException
- Throws:
NamingException
-
checkProp
public String checkProp(Properties pr, String name, String defaultVal)
If the named property is present and has a value use that. Otherwise, set the value to the given default and use that.- Parameters:
pr-name-defaultVal-- Returns:
- String
-
getLogger
public org.bedework.util.logging.BwLogger getLogger()
-
-