public class JNDIDir extends Object implements IDir
NameWrapper
Modifier and Type | Class and Description |
---|---|
protected class |
JNDIDir.SupportingData |
Constructor and Description |
---|
JNDIDir(ICS ics)
Initializes ObjectPool of DirContext instances, if pooling is enabled
|
Modifier and Type | Method and Description |
---|---|
void |
addAttrs(ICS ics,
IName dn,
Attributes attributes)
Add attributes to an existing entry.
|
Collection |
andSearch(ICS ics,
Attributes matchingAttributes)
Simple search returns all entries with matching attributes
(AND); searches under DirProperties.baseDN
|
Collection |
andSearch(ICS ics,
IName parent,
Attributes matchingAttributes)
Simple search returns all entries with matching attributes
(AND)
|
protected void |
attrsOp(ICS ics,
IName dn,
int op,
Attributes attributes) |
protected static String |
authtMech(ICS ics)
Do *not* use this to set the authentication mechanism.
|
Collection |
children(ICS ics,
IName dn)
Retrieves the immediate child entries of the specified parent.
|
void |
create(ICS ics,
IName entry,
Attributes attributes)
Create an object.
|
void |
delete(ICS ics,
IName dn)
Delete the specified entry.
|
void |
deleteAttrs(ICS ics,
IName dn,
Attributes attributes)
Delete the specified attributes from the specified entry.
|
protected boolean |
DNExists(ICS ics,
IName dn)
Ensure that the Distinguished name exists in the directory.
|
protected static IName |
fullName(ICS ics,
IName name)
Clone the name and prepend the basedn to it
|
Attributes |
getAttrs(ICS ics,
IName dn,
String[] attrIds)
Retrieve the specified attributes from the specified entry.
|
protected static IName |
getBaseDN(ICS ics)
Look up the baseDN in the object pool, if not there, create it
from the string in the property file.
|
Attributes |
getGroupAttributes(ICS ics,
String groupname,
Attributes attributes) |
protected com.openmarket.directory.jndi.JNDIInterface |
getJNDIInterface(ICS ics) |
Attributes |
getUserAttributes(ICS ics,
String name,
Attributes attributes) |
protected static void |
handleNamingException(ICS ics,
NamingException e,
JNDIDir.SupportingData data,
String className,
String methodName)
Added by Yu-Chun to call the modified handleNamingException() with throwException=true
|
protected static void |
handleNamingException(ICS ics,
NamingException e,
JNDIDir.SupportingData data,
String className,
String methodName,
boolean throwException)
The JNDI interface doesn't specify every type of Exception that
might be thrown by a particular method.
|
protected static int |
intPropertyValue(ICS ics,
String propName) |
protected boolean |
isMember(ICS ics,
IName member,
IName group)
Member is a name relative to baseDN
|
protected static Collection |
membersToCollection(ICS ics,
Attribute attr)
Don't use toCollection here because the Enumeration is of
Objects (Strings) not NameClassPair's.
|
protected Attributes |
mimeEncodedPropToAttributes(ICS ics,
String propname) |
protected List |
mimeEncodedPropToNameList(ICS ics,
String propname) |
protected Collection |
opSearch(ICS ics,
IName parent,
Attributes matchingAttributes,
String op) |
Collection |
orSearch(ICS ics,
Attributes matchingAttributes)
Simple search returns all entries with attributes matching any of
those specified (OR); searches under DirProperties.baseDN
|
Collection |
orSearch(ICS ics,
IName parent,
Attributes matchingAttributes)
Simple search returns all entries attributes matching any of
those specified (OR)
|
protected static String |
principal(ICS ics)
Returns the principal being used for JNDI SPI access, whether
it be the current user or something configured in the property
file.
|
protected static IName |
relativeName(ICS ics,
IName fName)
Clone the name and chop the basedn off it.
|
void |
replaceAttrs(ICS ics,
IName dn,
Attributes attributes)
Replace the existing attribute value(s) with the specified
value(s).
|
protected static Collection |
toCollection(ICS ics,
NamingEnumeration nEnum) |
protected static Collection |
toCollection(ICS ics,
NamingEnumeration nEnum,
IName prefix) |
protected Attribute |
uniquememberAttr(ICS ics,
IName group)
returns null if uniquemember attribute is not found.
|
public JNDIDir(ICS ics)
protected static String authtMech(ICS ics) throws DirectoryException
DirectoryException
protected static String principal(ICS ics) throws DirectoryException
DirectoryException
protected com.openmarket.directory.jndi.JNDIInterface getJNDIInterface(ICS ics) throws DirectoryException
DirectoryException
protected static void handleNamingException(ICS ics, NamingException e, JNDIDir.SupportingData data, String className, String methodName) throws DirectoryException
ics
- e
- data
- className
- methodName
- DirectoryException
protected static void handleNamingException(ICS ics, NamingException e, JNDIDir.SupportingData data, String className, String methodName, boolean throwException) throws DirectoryException
The JNDI interface doesn't specify every type of Exception that might be thrown by a particular method. Catch what you can in the calling method, and catch NamingException last. In that last catch, send the exception to this method for more detailed error interpretation.
Errors are translated to an end-user-friendly message which is logged as an error, and a trace message is logged containing the less user-friendly exception detail. 08/20/2014 Method modified by Yu-Chun to handle the throwException logic
DirectoryException
public void create(ICS ics, IName entry, Attributes attributes) throws DirectoryException
IDir
create
in interface IDir
entry
- Distinguished name of entry to be created.attributes
- Attribute(s) to create for this entry. If
null, creates entry with no attributes.DirectoryException
public void delete(ICS ics, IName dn) throws DirectoryException
IDir
delete
in interface IDir
dn
- Distinguished name of entry to be deleted.DirectoryException
protected static int intPropertyValue(ICS ics, String propName) throws DirectoryException
DirectoryException
protected static Collection toCollection(ICS ics, NamingEnumeration nEnum)
protected static Collection toCollection(ICS ics, NamingEnumeration nEnum, IName prefix)
protected Collection opSearch(ICS ics, IName parent, Attributes matchingAttributes, String op) throws DirectoryException
DirectoryException
public Collection andSearch(ICS ics, Attributes matchingAttributes) throws DirectoryException
andSearch
in interface IDir
matchingAttributes
- The name value pairs to matchDirectoryException
public Collection andSearch(ICS ics, IName parent, Attributes matchingAttributes) throws DirectoryException
IDir
andSearch
in interface IDir
parent
- The entry under which to searchmatchingAttributes
- The name value pairs to matchDirectoryException
public Collection orSearch(ICS ics, Attributes matchingAttributes) throws DirectoryException
orSearch
in interface IDir
matchingAttributes
- The name value pairs to matchDirectoryException
public Collection orSearch(ICS ics, IName parent, Attributes matchingAttributes) throws DirectoryException
IDir
orSearch
in interface IDir
parent
- The entry under which to searchmatchingAttributes
- The name value pairs to matchDirectoryException
public Collection children(ICS ics, IName dn) throws DirectoryException
IDir
children
in interface IDir
dn
- The distinguished name of the entry for which
children are to be found.DirectoryException
protected void attrsOp(ICS ics, IName dn, int op, Attributes attributes) throws DirectoryException
DirectoryException
public void addAttrs(ICS ics, IName dn, Attributes attributes) throws DirectoryException
IDir
addAttrs
in interface IDir
dn
- The distinguished name of the entry to which
attributes are added.attributes
- Attributes to be added.DirectoryException
public void replaceAttrs(ICS ics, IName dn, Attributes attributes) throws DirectoryException
IDir
replaceAttrs
in interface IDir
dn
- The distinguished name of the entry for which
attributes are being replaced.attributes
- Attributes to be replaced.DirectoryException
public void deleteAttrs(ICS ics, IName dn, Attributes attributes) throws DirectoryException
IDir
deleteAttrs
in interface IDir
attributes
- Attributes to be removed.DirectoryException
public Attributes getAttrs(ICS ics, IName dn, String[] attrIds) throws DirectoryException
IDir
getAttrs
in interface IDir
dn
- The distinguished name of the entry for which
attributes are being retrieved.attrIds
- The identifiers of the attributes to
retrieve. null indicates that all attributes should be
retrieved; an empty array indicates that none should be
retrieved.DirectoryException
protected Attribute uniquememberAttr(ICS ics, IName group) throws DirectoryException
DirectoryException
protected static IName getBaseDN(ICS ics) throws DirectoryException
DirectoryException
protected static IName fullName(ICS ics, IName name) throws DirectoryException
DirectoryException
protected static IName relativeName(ICS ics, IName fName) throws DirectoryException
DirectoryException
protected boolean isMember(ICS ics, IName member, IName group) throws DirectoryException
DirectoryException
protected static Collection membersToCollection(ICS ics, Attribute attr) throws DirectoryException
DirectoryException
protected boolean DNExists(ICS ics, IName dn)
public Attributes getUserAttributes(ICS ics, String name, Attributes attributes) throws DirectoryException
DirectoryException
public Attributes getGroupAttributes(ICS ics, String groupname, Attributes attributes) throws DirectoryException
DirectoryException
protected Attributes mimeEncodedPropToAttributes(ICS ics, String propname) throws DirectoryException
DirectoryException