|
Spring LDAP Framework | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.ldap.core.DirContextAdapter
public class DirContextAdapter
Adapter that implements the interesting methods of the DirContext interface.
In particular it contains utility methods for getting and setting attributes.
Using the
DefaultDirObjectFactory in your
ContextSource (which is the default) you will receive instances
of this class from searches and lookups. This can be particularly useful when
updating data, since this class implements
AttributeModificationsAware, providing a
getModificationItems() method. When in update mode, an object of
this class keeps track of the changes made to its attributes, making them
available as an array of ModificationItem objects, suitable as
input to LdapTemplate.modifyAttributes(DirContextOperations).
Note that this is not a complete implementation of DirContext. Several
methods are not relevant for the intended usage of this class, so they
throw UnsupportOperationException.
setAttributeValue(String, Object),
setAttributeValues(String, Object[]),
getStringAttribute(String),
getStringAttributes(String),
getObjectAttribute(String),
addAttributeValue(String, Object),
removeAttributeValue(String, Object),
setUpdateMode(boolean),
isUpdateMode()| Field Summary |
|---|
| Fields inherited from interface javax.naming.directory.DirContext |
|---|
ADD_ATTRIBUTE, REMOVE_ATTRIBUTE, REPLACE_ATTRIBUTE |
| Fields inherited from interface javax.naming.Context |
|---|
APPLET, AUTHORITATIVE, BATCHSIZE, DNS_URL, INITIAL_CONTEXT_FACTORY, LANGUAGE, OBJECT_FACTORIES, PROVIDER_URL, REFERRAL, SECURITY_AUTHENTICATION, SECURITY_CREDENTIALS, SECURITY_PRINCIPAL, SECURITY_PROTOCOL, STATE_FACTORIES, URL_PKG_PREFIXES |
| Constructor Summary | |
|---|---|
|
DirContextAdapter()
Default constructor. |
|
DirContextAdapter(Attributes attrs,
Name dn)
Create a new adapter from the supplied attributes and dn. |
|
DirContextAdapter(Attributes attrs,
Name dn,
Name base)
Create a new adapter from the supplied attributes, dn, and base. |
|
DirContextAdapter(Attributes attrs,
Name dn,
Name base,
String referralUrl)
Create a new adapter from the supplied attributes, dn, base, and referral url. |
protected |
DirContextAdapter(DirContextAdapter master)
Constructor for cloning an existing adapter. |
|
DirContextAdapter(Name dn)
Create a new adapter from the supplied dn. |
|
DirContextAdapter(String dnString)
Create a new DirContextAdapter from the supplied DN String. |
| Method Summary | |
|---|---|
void |
addAttributeValue(String name,
Object value)
Add a value to the Attribute with the specified name. |
void |
addAttributeValue(String name,
Object value,
boolean addIfDuplicateExists)
Add a value to the Attribute with the specified name. |
Object |
addToEnvironment(String propName,
Object propVal)
|
boolean |
attributeExists(String name)
Check if an Object attribute exists, regardless of whether it has a value or not. |
void |
bind(Name name,
Object obj)
|
void |
bind(Name name,
Object obj,
Attributes attrs)
|
void |
bind(String name,
Object obj)
|
void |
bind(String name,
Object obj,
Attributes attrs)
|
void |
close()
|
Name |
composeName(Name name,
Name prefix)
|
String |
composeName(String name,
String prefix)
|
Context |
createSubcontext(Name name)
|
DirContext |
createSubcontext(Name name,
Attributes attrs)
|
Context |
createSubcontext(String name)
|
DirContext |
createSubcontext(String name,
Attributes attrs)
|
void |
destroySubcontext(Name name)
|
void |
destroySubcontext(String name)
|
boolean |
equals(Object obj)
|
protected boolean |
exists(Attribute attr)
Checks if an entry has a specific attribute. |
protected boolean |
exists(String attrId)
Checks if the attribute exists in this entry, either it was read or it has been added and update() has been called. |
Attributes |
getAttributes()
Get all attributes. |
Attributes |
getAttributes(Name name)
|
Attributes |
getAttributes(Name name,
String[] attrIds)
|
Attributes |
getAttributes(String name)
|
Attributes |
getAttributes(String name,
String[] attrIds)
|
SortedSet |
getAttributeSortedStringSet(String name)
Get all String values of the attribute as a SortedSet. |
Name |
getDn()
Returns the DN relative to the base path. |
Hashtable |
getEnvironment()
|
ModificationItem[] |
getModificationItems()
Creates an array of which attributes have been changed, added or removed since the initialization of this object. |
String |
getNameInNamespace()
|
NameParser |
getNameParser(Name name)
|
NameParser |
getNameParser(String name)
|
String[] |
getNamesOfModifiedAttributes()
Creates a String array of the names of the attributes which have been changed. |
Object |
getObjectAttribute(String name)
Get the value of an Object attribute. |
Object[] |
getObjectAttributes(String name)
Get all values of an Object attribute. |
String |
getReferralUrl()
If this instance results from a referral, this method returns the url of the referred server. |
DirContext |
getSchema(Name name)
|
DirContext |
getSchema(String name)
|
DirContext |
getSchemaClassDefinition(Name name)
|
DirContext |
getSchemaClassDefinition(String name)
|
String |
getStringAttribute(String name)
Get the value of a String attribute. |
String[] |
getStringAttributes(String name)
Get all values of a String attribute. |
int |
hashCode()
|
boolean |
isReferral()
Checks whether this instance results from a referral. |
boolean |
isUpdateMode()
Gets the update mode. |
NamingEnumeration |
list(Name name)
|
NamingEnumeration |
list(String name)
|
NamingEnumeration |
listBindings(Name name)
|
NamingEnumeration |
listBindings(String name)
|
Object |
lookup(Name name)
|
Object |
lookup(String name)
|
Object |
lookupLink(Name name)
|
Object |
lookupLink(String name)
|
void |
modifyAttributes(Name name,
int modOp,
Attributes attrs)
|
void |
modifyAttributes(Name name,
ModificationItem[] mods)
|
void |
modifyAttributes(String name,
int modOp,
Attributes attrs)
|
void |
modifyAttributes(String name,
ModificationItem[] mods)
|
void |
rebind(Name name,
Object obj)
|
void |
rebind(Name name,
Object obj,
Attributes attrs)
|
void |
rebind(String name,
Object obj)
|
void |
rebind(String name,
Object obj,
Attributes attrs)
|
void |
removeAttributeValue(String name,
Object value)
Remove a value from the Attribute with the specified name. |
Object |
removeFromEnvironment(String propName)
|
void |
rename(Name oldName,
Name newName)
|
void |
rename(String oldName,
String newName)
|
NamingEnumeration |
search(Name name,
Attributes matchingAttributes)
|
NamingEnumeration |
search(Name name,
Attributes matchingAttributes,
String[] attributesToReturn)
|
NamingEnumeration |
search(Name name,
String filterExpr,
Object[] filterArgs,
SearchControls cons)
|
NamingEnumeration |
search(Name name,
String filter,
SearchControls cons)
|
NamingEnumeration |
search(String name,
Attributes matchingAttributes)
|
NamingEnumeration |
search(String name,
Attributes matchingAttributes,
String[] attributesToReturn)
|
NamingEnumeration |
search(String name,
String filterExpr,
Object[] filterArgs,
SearchControls cons)
|
NamingEnumeration |
search(String name,
String filter,
SearchControls cons)
|
void |
setAttribute(Attribute attribute)
Set the supplied attribute. |
void |
setAttributeValue(String name,
Object value)
Set the with the name name to the value. |
void |
setAttributeValues(String name,
Object[] values)
Sets a multivalue attribute, disregarding the order of the values. |
void |
setAttributeValues(String name,
Object[] values,
boolean orderMatters)
Sets a multivalue attribute. |
void |
setDn(Name dn)
Set the dn of this entry. |
void |
setUpdateMode(boolean mode)
Sets the update mode. |
String |
toString()
|
void |
unbind(Name name)
|
void |
unbind(String name)
|
void |
update()
Update the attributes.This will mean that the getters ( getStringAttribute methods) will return the updated values,
and the modifications will be forgotten (i.e. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DirContextAdapter()
public DirContextAdapter(String dnString)
dnString - the DN string. Must be syntactically correct, or an
exception will be thrown.public DirContextAdapter(Name dn)
dn - the dn.
public DirContextAdapter(Attributes attrs,
Name dn)
attrs - the attributes.dn - the dn.
public DirContextAdapter(Attributes attrs,
Name dn,
Name base)
attrs - the attributes.dn - the dn.base - the base name.
public DirContextAdapter(Attributes attrs,
Name dn,
Name base,
String referralUrl)
attrs - the attributes.dn - the dn.base - the base.referralUrl - the referral url (if this instance results from a
referral).protected DirContextAdapter(DirContextAdapter master)
master - The adapter to be copied.| Method Detail |
|---|
public void setUpdateMode(boolean mode)
false for a
new entry and true for an existing entry that is being
updated.
mode - Update mode.public boolean isUpdateMode()
DirContextOperationsAttributeModificationsAware.getModificationItems(). The update
mode should be true for a new entry and true
for an existing entry that is being updated.
isUpdateMode in interface DirContextOperationspublic String[] getNamesOfModifiedAttributes()
DirContextOperations
getNamesOfModifiedAttributes in interface DirContextOperationspublic ModificationItem[] getModificationItems()
AttributeModificationsAware
getModificationItems in interface AttributeModificationsAwareprotected final boolean exists(Attribute attr)
attr - the attribute to check.
protected final boolean exists(String attrId)
attrId - id of the attribute to check.
public String getStringAttribute(String name)
DirContextOperationsnull will be returned.
getStringAttribute in interface DirContextOperationsname - name of the attribute.
null if
the attribute doesn't exist or if it exists but with no value.public Object getObjectAttribute(String name)
DirContextOperationsnull will be returned.
getObjectAttribute in interface DirContextOperationsname - name of the attribute.
null if the attribute doesn't exist or if it exists but with
no value.public boolean attributeExists(String name)
DirContextOperations
attributeExists in interface DirContextOperationsname - name of the attribute
true if the attribute exists, false
otherwise
public void setAttributeValue(String name,
Object value)
DirContextOperationsname to the value.
setAttributeValue in interface DirContextOperationsname - name of the attribute.value - value to set the attribute to.
public void addAttributeValue(String name,
Object value)
DirContextOperations
addAttributeValue in interface DirContextOperationsname - the name of the Attribute to which the specified value should
be added.value - the Attribute value to add.
public void addAttributeValue(String name,
Object value,
boolean addIfDuplicateExists)
DirContextOperationsaddIfDuplicateExists
parameter controls the handling of duplicates. It false,
this method makes sure that the there will be no duplicates of an added
value - it the value exists it will not be added again.
addAttributeValue in interface DirContextOperationsname - the name of the Attribute to which the specified value should
be added.value - the Attribute value to add.addIfDuplicateExists - true will add the value
regardless of whether there is an identical value already, allowing for
duplicate attribute values; false will not add the value if
it already exists.
public void removeAttributeValue(String name,
Object value)
DirContextOperations
removeAttributeValue in interface DirContextOperationsname - the name of the Attribute from which the specified value
should be removed.value - the value to remove.
public void setAttributeValues(String name,
Object[] values)
DirContextOperations
setAttributeValues in interface DirContextOperationsname - The id of the attribute.values - Attribute values.
public void setAttributeValues(String name,
Object[] values,
boolean orderMatters)
DirContextOperations
setAttributeValues in interface DirContextOperationsname - The id of the attribute.values - Attribute values.orderMatters - If true, it will be changed even if data
was just reordered.public void update()
DirContextOperationsgetStringAttribute methods) will return the updated values,
and the modifications will be forgotten (i.e.
AttributeModificationsAware.getModificationItems() will return an
empty array.
update in interface DirContextOperationspublic String[] getStringAttributes(String name)
DirContextOperations
getStringAttributes in interface DirContextOperationsname - name of the attribute.
null
otherwise.public Object[] getObjectAttributes(String name)
DirContextOperations
getObjectAttributes in interface DirContextOperationsname - name of the attribute.
null otherwise.public SortedSet getAttributeSortedStringSet(String name)
DirContextOperationsSortedSet.
getAttributeSortedStringSet in interface DirContextOperationsname - name of the attribute.
SortedSet containing all values of the attribute,
or null if the attribute does not exist.public void setAttribute(Attribute attribute)
attribute - the attribute to set.public Attributes getAttributes()
getAttributes in interface DirContextOperations
public Attributes getAttributes(Name name)
throws NamingException
getAttributes in interface DirContextNamingExceptionDirContext.getAttributes(Name)
public Attributes getAttributes(String name)
throws NamingException
getAttributes in interface DirContextNamingExceptionDirContext.getAttributes(String)
public Attributes getAttributes(Name name,
String[] attrIds)
throws NamingException
getAttributes in interface DirContextNamingExceptionDirContext.getAttributes(Name, String[])
public Attributes getAttributes(String name,
String[] attrIds)
throws NamingException
getAttributes in interface DirContextNamingExceptionDirContext.getAttributes(String, String[])
public void modifyAttributes(Name name,
int modOp,
Attributes attrs)
throws NamingException
modifyAttributes in interface DirContextNamingExceptionDirContext.modifyAttributes(javax.naming.Name,
int, javax.naming.directory.Attributes)
public void modifyAttributes(String name,
int modOp,
Attributes attrs)
throws NamingException
modifyAttributes in interface DirContextNamingExceptionDirContext.modifyAttributes(String, int,
Attributes)
public void modifyAttributes(Name name,
ModificationItem[] mods)
throws NamingException
modifyAttributes in interface DirContextNamingExceptionDirContext.modifyAttributes(Name,
ModificationItem[])
public void modifyAttributes(String name,
ModificationItem[] mods)
throws NamingException
modifyAttributes in interface DirContextNamingExceptionDirContext.modifyAttributes(String,
ModificationItem[])
public void bind(Name name,
Object obj,
Attributes attrs)
throws NamingException
bind in interface DirContextNamingExceptionDirContext.bind(Name, Object, Attributes)
public void bind(String name,
Object obj,
Attributes attrs)
throws NamingException
bind in interface DirContextNamingExceptionDirContext.bind(String, Object, Attributes)
public void rebind(Name name,
Object obj,
Attributes attrs)
throws NamingException
rebind in interface DirContextNamingExceptionDirContext.rebind(Name, Object, Attributes)
public void rebind(String name,
Object obj,
Attributes attrs)
throws NamingException
rebind in interface DirContextNamingExceptionDirContext.rebind(String, Object, Attributes)
public DirContext createSubcontext(Name name,
Attributes attrs)
throws NamingException
createSubcontext in interface DirContextNamingExceptionDirContext.createSubcontext(Name, Attributes)
public DirContext createSubcontext(String name,
Attributes attrs)
throws NamingException
createSubcontext in interface DirContextNamingExceptionDirContext.createSubcontext(String,
Attributes)
public DirContext getSchema(Name name)
throws NamingException
getSchema in interface DirContextNamingExceptionDirContext.getSchema(Name)
public DirContext getSchema(String name)
throws NamingException
getSchema in interface DirContextNamingExceptionDirContext.getSchema(String)
public DirContext getSchemaClassDefinition(Name name)
throws NamingException
getSchemaClassDefinition in interface DirContextNamingExceptionDirContext.getSchemaClassDefinition(Name)
public DirContext getSchemaClassDefinition(String name)
throws NamingException
getSchemaClassDefinition in interface DirContextNamingExceptionDirContext.getSchemaClassDefinition(String)
public NamingEnumeration search(Name name,
Attributes matchingAttributes,
String[] attributesToReturn)
throws NamingException
search in interface DirContextNamingExceptionDirContext.search(Name, Attributes, String[])
public NamingEnumeration search(String name,
Attributes matchingAttributes,
String[] attributesToReturn)
throws NamingException
search in interface DirContextNamingExceptionDirContext.search(String, Attributes,
String[])
public NamingEnumeration search(Name name,
Attributes matchingAttributes)
throws NamingException
search in interface DirContextNamingExceptionDirContext.search(Name, Attributes)
public NamingEnumeration search(String name,
Attributes matchingAttributes)
throws NamingException
search in interface DirContextNamingExceptionDirContext.search(String, Attributes)
public NamingEnumeration search(Name name,
String filter,
SearchControls cons)
throws NamingException
search in interface DirContextNamingExceptionDirContext.search(Name, String,
SearchControls)
public NamingEnumeration search(String name,
String filter,
SearchControls cons)
throws NamingException
search in interface DirContextNamingExceptionDirContext.search(String, String,
SearchControls)
public NamingEnumeration search(Name name,
String filterExpr,
Object[] filterArgs,
SearchControls cons)
throws NamingException
search in interface DirContextNamingExceptionDirContext.search(Name, String, Object[],
SearchControls)
public NamingEnumeration search(String name,
String filterExpr,
Object[] filterArgs,
SearchControls cons)
throws NamingException
search in interface DirContextNamingExceptionDirContext.search(String, String, Object[],
SearchControls)
public Object lookup(Name name)
throws NamingException
lookup in interface ContextNamingExceptionContext.lookup(Name)
public Object lookup(String name)
throws NamingException
lookup in interface ContextNamingExceptionContext.lookup(String)
public void bind(Name name,
Object obj)
throws NamingException
bind in interface ContextNamingExceptionContext.bind(Name, Object)
public void bind(String name,
Object obj)
throws NamingException
bind in interface ContextNamingExceptionContext.bind(String, Object)
public void rebind(Name name,
Object obj)
throws NamingException
rebind in interface ContextNamingExceptionContext.rebind(Name, Object)
public void rebind(String name,
Object obj)
throws NamingException
rebind in interface ContextNamingExceptionContext.rebind(String, Object)
public void unbind(Name name)
throws NamingException
unbind in interface ContextNamingExceptionContext.unbind(Name)
public void unbind(String name)
throws NamingException
unbind in interface ContextNamingExceptionContext.unbind(String)
public void rename(Name oldName,
Name newName)
throws NamingException
rename in interface ContextNamingExceptionContext.rename(Name, Name)
public void rename(String oldName,
String newName)
throws NamingException
rename in interface ContextNamingExceptionContext.rename(String, String)
public NamingEnumeration list(Name name)
throws NamingException
list in interface ContextNamingExceptionContext.list(Name)
public NamingEnumeration list(String name)
throws NamingException
list in interface ContextNamingExceptionContext.list(String)
public NamingEnumeration listBindings(Name name)
throws NamingException
listBindings in interface ContextNamingExceptionContext.listBindings(Name)
public NamingEnumeration listBindings(String name)
throws NamingException
listBindings in interface ContextNamingExceptionContext.listBindings(String)
public void destroySubcontext(Name name)
throws NamingException
destroySubcontext in interface ContextNamingExceptionContext.destroySubcontext(Name)
public void destroySubcontext(String name)
throws NamingException
destroySubcontext in interface ContextNamingExceptionContext.destroySubcontext(String)
public Context createSubcontext(Name name)
throws NamingException
createSubcontext in interface ContextNamingExceptionContext.createSubcontext(Name)
public Context createSubcontext(String name)
throws NamingException
createSubcontext in interface ContextNamingExceptionContext.createSubcontext(String)
public Object lookupLink(Name name)
throws NamingException
lookupLink in interface ContextNamingExceptionContext.lookupLink(Name)
public Object lookupLink(String name)
throws NamingException
lookupLink in interface ContextNamingExceptionContext.lookupLink(String)
public NameParser getNameParser(Name name)
throws NamingException
getNameParser in interface ContextNamingExceptionContext.getNameParser(Name)
public NameParser getNameParser(String name)
throws NamingException
getNameParser in interface ContextNamingExceptionContext.getNameParser(String)
public Name composeName(Name name,
Name prefix)
throws NamingException
composeName in interface ContextNamingExceptionContext.composeName(Name, Name)
public String composeName(String name,
String prefix)
throws NamingException
composeName in interface ContextNamingExceptionContext.composeName(String, String)
public Object addToEnvironment(String propName,
Object propVal)
throws NamingException
addToEnvironment in interface ContextNamingExceptionContext.addToEnvironment(String, Object)
public Object removeFromEnvironment(String propName)
throws NamingException
removeFromEnvironment in interface ContextNamingExceptionContext.removeFromEnvironment(String)
public Hashtable getEnvironment()
throws NamingException
getEnvironment in interface ContextNamingExceptionContext.getEnvironment()
public void close()
throws NamingException
close in interface ContextNamingExceptionContext.close()public String getNameInNamespace()
getNameInNamespace in interface ContextgetNameInNamespace in interface DirContextOperationsContext.getNameInNamespace()public Name getDn()
DirContextOperations
getDn in interface DirContextOperationsgetNameInNamespace()public final void setDn(Name dn)
DirContextOperations
setDn in interface DirContextOperationsdn - the dn.public boolean equals(Object obj)
equals in class ObjectObject.equals(java.lang.Object)public int hashCode()
hashCode in class ObjectObject.hashCode()public String toString()
toString in class ObjectObject.toString()public String getReferralUrl()
DirContextOperations
getReferralUrl in interface DirContextOperationsldap://localhost:389, or the empty string if this is not a
referral.public boolean isReferral()
DirContextOperations
isReferral in interface DirContextOperationstrue if this instance results from a referral,
false otherwise.
|
Spring LDAP Framework | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||