import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.Name;
-import javax.naming.NameAlreadyBoundException;
import javax.naming.NameClassPair;
import javax.naming.NameNotFoundException;
import javax.naming.NameParser;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
-import javax.naming.NotContextException;
-import javax.naming.OperationNotSupportedException;
-import javax.naming.directory.AttributeModificationException;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
-import javax.naming.directory.InvalidAttributesException;
-import javax.naming.directory.InvalidSearchControlsException;
-import javax.naming.directory.InvalidSearchFilterException;
import javax.naming.directory.ModificationItem;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
}
- /**
- * Builds a clone of this proxy dir context, wrapping the given directory
- * context, and sharing the same cache.
- */
- // TODO: Refactor using the proxy field
- /*
- protected ProxyDirContext(ProxyDirContext proxyDirContext,
- DirContext dirContext, String vPath) {
- this.env = proxyDirContext.env;
- this.dirContext = dirContext;
- this.vPath = vPath;
- this.cache = proxyDirContext.cache;
- this.cacheMaxSize = proxyDirContext.cacheMaxSize;
- this.cacheSize = proxyDirContext.cacheSize;
- this.cacheTTL = proxyDirContext.cacheTTL;
- this.cacheObjectMaxSize = proxyDirContext.cacheObjectMaxSize;
- this.notFoundCache = proxyDirContext.notFoundCache;
- this.hostName = proxyDirContext.hostName;
- this.contextName = proxyDirContext.contextName;
- }
- */
-
-
// ----------------------------------------------------- Instance Variables
* @return the object bound to name
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public Object lookup(Name name)
throws NamingException {
CacheEntry entry = cacheLookup(name.toString());
* @return the object bound to name
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public Object lookup(String name)
throws NamingException {
CacheEntry entry = cacheLookup(name);
*
* @param name the name to bind; may not be empty
* @param obj the object to bind; possibly null
- * @exception NameAlreadyBoundException if name is already bound
- * @exception InvalidAttributesException if object did not supply all
- * mandatory attributes
+ * @exception javax.naming.NameAlreadyBoundException if name is already
+ * bound
+ * @exception javax.naming.directory.InvalidAttributesException if object
+ * did not supply all mandatory attributes
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public void bind(Name name, Object obj)
throws NamingException {
dirContext.bind(parseName(name), obj);
*
* @param name the name to bind; may not be empty
* @param obj the object to bind; possibly null
- * @exception NameAlreadyBoundException if name is already bound
- * @exception InvalidAttributesException if object did not supply all
- * mandatory attributes
+ * @exception javax.naming.NameAlreadyBoundException if name is already
+ * bound
+ * @exception javax.naming.directory.InvalidAttributesException if object
+ * did not supply all mandatory attributes
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public void bind(String name, Object obj)
throws NamingException {
dirContext.bind(parseName(name), obj);
*
* @param name the name to bind; may not be empty
* @param obj the object to bind; possibly null
- * @exception InvalidAttributesException if object did not supply all
- * mandatory attributes
+ * @exception javax.naming.directory.InvalidAttributesException if object
+ * did not supply all mandatory attributes
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public void rebind(Name name, Object obj)
throws NamingException {
dirContext.rebind(parseName(name), obj);
*
* @param name the name to bind; may not be empty
* @param obj the object to bind; possibly null
- * @exception InvalidAttributesException if object did not supply all
- * mandatory attributes
+ * @exception javax.naming.directory.InvalidAttributesException if object
+ * did not supply all mandatory attributes
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public void rebind(String name, Object obj)
throws NamingException {
dirContext.rebind(parseName(name), obj);
* exist
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public void unbind(Name name)
throws NamingException {
dirContext.unbind(parseName(name));
* exist
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public void unbind(String name)
throws NamingException {
dirContext.unbind(parseName(name));
*
* @param oldName the name of the existing binding; may not be empty
* @param newName the name of the new binding; may not be empty
- * @exception NameAlreadyBoundException if newName is already bound
+ * @exception javax.naming.NameAlreadyBoundException if name is already
+ * bound
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public void rename(Name oldName, Name newName)
throws NamingException {
dirContext.rename(parseName(oldName), parseName(newName));
*
* @param oldName the name of the existing binding; may not be empty
* @param newName the name of the new binding; may not be empty
- * @exception NameAlreadyBoundException if newName is already bound
+ * @exception javax.naming.NameAlreadyBoundException if name is already
+ * bound
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public void rename(String oldName, String newName)
throws NamingException {
dirContext.rename(parseName(oldName), parseName(newName));
* this context. Each element of the enumeration is of type NameClassPair.
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public NamingEnumeration<NameClassPair> list(Name name)
throws NamingException {
return dirContext.list(parseName(name));
* this context. Each element of the enumeration is of type NameClassPair.
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public NamingEnumeration<NameClassPair> list(String name)
throws NamingException {
return dirContext.list(parseName(name));
* Each element of the enumeration is of type Binding.
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public NamingEnumeration<Binding> listBindings(Name name)
throws NamingException {
return dirContext.listBindings(parseName(name));
* Each element of the enumeration is of type Binding.
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public NamingEnumeration<Binding> listBindings(String name)
throws NamingException {
return dirContext.listBindings(parseName(name));
* @param name the name of the context to be destroyed; may not be empty
* @exception NameNotFoundException if an intermediate context does not
* exist
- * @exception NotContextException if the name is bound but does not name
- * a context, or does not name a context of the appropriate type
+ * @exception javax.naming.NotContextException if the name is bound but does
+ * not name a context, or does not name a context of the appropriate type
*/
+ @Override
public void destroySubcontext(Name name)
throws NamingException {
dirContext.destroySubcontext(parseName(name));
* @param name the name of the context to be destroyed; may not be empty
* @exception NameNotFoundException if an intermediate context does not
* exist
- * @exception NotContextException if the name is bound but does not name
- * a context, or does not name a context of the appropriate type
+ * @exception javax.naming.NotContextException if the name is bound but does
+ * not name a context, or does not name a context of the appropriate type
*/
+ @Override
public void destroySubcontext(String name)
throws NamingException {
dirContext.destroySubcontext(parseName(name));
*
* @param name the name of the context to create; may not be empty
* @return the newly created context
- * @exception NameAlreadyBoundException if name is already bound
- * @exception InvalidAttributesException if creation of the subcontext
- * requires specification of mandatory attributes
+ * @exception javax.naming.NameAlreadyBoundException if name is already
+ * bound
+ * @exception javax.naming.directory.InvalidAttributesException if creation
+ * of the sub-context requires specification of mandatory attributes
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public Context createSubcontext(Name name)
throws NamingException {
Context context = dirContext.createSubcontext(parseName(name));
*
* @param name the name of the context to create; may not be empty
* @return the newly created context
- * @exception NameAlreadyBoundException if name is already bound
- * @exception InvalidAttributesException if creation of the subcontext
- * requires specification of mandatory attributes
+ * @exception javax.naming.NameAlreadyBoundException if name is already
+ * bound
+ * @exception javax.naming.directory.InvalidAttributesException if creation
+ * of the sub-context requires specification of mandatory attributes
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public Context createSubcontext(String name)
throws NamingException {
Context context = dirContext.createSubcontext(parseName(name));
* (if any).
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public Object lookupLink(Name name)
throws NamingException {
return dirContext.lookupLink(parseName(name));
* (if any).
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public Object lookupLink(String name)
throws NamingException {
return dirContext.lookupLink(parseName(name));
* components
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public NameParser getNameParser(Name name)
throws NamingException {
return dirContext.getNameParser(parseName(name));
* components
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public NameParser getNameParser(String name)
throws NamingException {
return dirContext.getNameParser(parseName(name));
* @return the composition of prefix and name
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public Name composeName(Name name, Name prefix)
throws NamingException {
- prefix = (Name) prefix.clone();
- return prefix.addAll(name);
+ Name prefixClone = (Name) prefix.clone();
+ return prefixClone.addAll(name);
}
* @return the composition of prefix and name
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public String composeName(String name, String prefix)
throws NamingException {
return prefix + "/" + name;
* @param propVal the value of the property to add; may not be null
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public Object addToEnvironment(String propName, Object propVal)
throws NamingException {
return dirContext.addToEnvironment(propName, propVal);
* may not be null
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public Object removeFromEnvironment(String propName)
throws NamingException {
return dirContext.removeFromEnvironment(propName);
* @return the environment of this context; never null
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public Hashtable<?,?> getEnvironment()
throws NamingException {
return dirContext.getEnvironment();
*
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public void close()
throws NamingException {
dirContext.close();
* OperationNotSupportedException is thrown.
*
* @return this context's name in its own namespace; never null
- * @exception OperationNotSupportedException if the naming system does
- * not have the notion of a full name
+ * @exception javax.naming.OperationNotSupportedException if the naming
+ * system does not have the notion of a full name
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public String getNameInNamespace()
throws NamingException {
return dirContext.getNameInNamespace();
* @param name the name of the object from which to retrieve attributes
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public Attributes getAttributes(Name name)
throws NamingException {
CacheEntry entry = cacheLookup(name.toString());
* @param name the name of the object from which to retrieve attributes
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public Attributes getAttributes(String name)
throws NamingException {
CacheEntry entry = cacheLookup(name);
* indicates that none should be retrieved
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public Attributes getAttributes(Name name, String[] attrIds)
throws NamingException {
Attributes attributes =
* indicates that none should be retrieved
* @exception NamingException if a naming exception is encountered
*/
- public Attributes getAttributes(String name, String[] attrIds)
+ @Override
+ public Attributes getAttributes(String name, String[] attrIds)
throws NamingException {
Attributes attributes =
dirContext.getAttributes(parseName(name), attrIds);
* REPLACE_ATTRIBUTE, REMOVE_ATTRIBUTE
* @param attrs the attributes to be used for the modification; may not
* be null
- * @exception AttributeModificationException if the modification cannot be
- * completed successfully
+ * @exception javax.naming.directory.AttributeModificationException if the
+ * modification cannot be completed successfully
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public void modifyAttributes(Name name, int mod_op, Attributes attrs)
throws NamingException {
dirContext.modifyAttributes(parseName(name), mod_op, attrs);
* REPLACE_ATTRIBUTE, REMOVE_ATTRIBUTE
* @param attrs the attributes to be used for the modification; may not
* be null
- * @exception AttributeModificationException if the modification cannot be
- * completed successfully
+ * @exception javax.naming.directory.AttributeModificationException if the
+ * modification cannot be completed successfully
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public void modifyAttributes(String name, int mod_op, Attributes attrs)
throws NamingException {
dirContext.modifyAttributes(parseName(name), mod_op, attrs);
* @param name the name of the object whose attributes will be updated
* @param mods an ordered sequence of modifications to be performed; may
* not be null
- * @exception AttributeModificationException if the modification cannot be
- * completed successfully
+ * @exception javax.naming.directory.AttributeModificationException if the
+ * modification cannot be completed successfully
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public void modifyAttributes(Name name, ModificationItem[] mods)
throws NamingException {
dirContext.modifyAttributes(parseName(name), mods);
* @param name the name of the object whose attributes will be updated
* @param mods an ordered sequence of modifications to be performed; may
* not be null
- * @exception AttributeModificationException if the modification cannot be
- * completed successfully
+ * @exception javax.naming.directory.AttributeModificationException if the
+ * modification cannot be completed successfully
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public void modifyAttributes(String name, ModificationItem[] mods)
throws NamingException {
dirContext.modifyAttributes(parseName(name), mods);
* @param name the name to bind; may not be empty
* @param obj the object to bind; possibly null
* @param attrs the attributes to associate with the binding
- * @exception NameAlreadyBoundException if name is already bound
- * @exception InvalidAttributesException if some "mandatory" attributes
- * of the binding are not supplied
+ * @exception javax.naming.NameAlreadyBoundException if name is already
+ * bound
+ * @exception javax.naming.directory.InvalidAttributesException if some
+ * "mandatory" attributes of the binding are not supplied
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public void bind(Name name, Object obj, Attributes attrs)
throws NamingException {
dirContext.bind(parseName(name), obj, attrs);
* @param name the name to bind; may not be empty
* @param obj the object to bind; possibly null
* @param attrs the attributes to associate with the binding
- * @exception NameAlreadyBoundException if name is already bound
- * @exception InvalidAttributesException if some "mandatory" attributes
- * of the binding are not supplied
+ * @exception javax.naming.NameAlreadyBoundException if name is already
+ * bound
+ * @exception javax.naming.directory.InvalidAttributesException if some
+ * "mandatory" attributes of the binding are not supplied
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public void bind(String name, Object obj, Attributes attrs)
throws NamingException {
dirContext.bind(parseName(name), obj, attrs);
* @param name the name to bind; may not be empty
* @param obj the object to bind; possibly null
* @param attrs the attributes to associate with the binding
- * @exception InvalidAttributesException if some "mandatory" attributes
- * of the binding are not supplied
+ * @exception javax.naming.directory.InvalidAttributesException if some
+ * "mandatory" attributes of the binding are not supplied
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public void rebind(Name name, Object obj, Attributes attrs)
throws NamingException {
dirContext.rebind(parseName(name), obj, attrs);
* @param name the name to bind; may not be empty
* @param obj the object to bind; possibly null
* @param attrs the attributes to associate with the binding
- * @exception InvalidAttributesException if some "mandatory" attributes
- * of the binding are not supplied
+ * @exception javax.naming.directory.InvalidAttributesException if some
+ * "mandatory" attributes of the binding are not supplied
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public void rebind(String name, Object obj, Attributes attrs)
throws NamingException {
dirContext.rebind(parseName(name), obj, attrs);
* @param name the name of the context to create; may not be empty
* @param attrs the attributes to associate with the newly created context
* @return the newly created context
- * @exception NameAlreadyBoundException if the name is already bound
- * @exception InvalidAttributesException if attrs does not contain all
- * the mandatory attributes required for creation
+ * @exception javax.naming.NameAlreadyBoundException if name is already
+ * bound
+ * @exception javax.naming.directory.InvalidAttributesException if attrs
+ * does not contain all the mandatory attributes required for creation
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public DirContext createSubcontext(Name name, Attributes attrs)
throws NamingException {
DirContext context =
* @param name the name of the context to create; may not be empty
* @param attrs the attributes to associate with the newly created context
* @return the newly created context
- * @exception NameAlreadyBoundException if the name is already bound
- * @exception InvalidAttributesException if attrs does not contain all
- * the mandatory attributes required for creation
+ * @exception javax.naming.NameAlreadyBoundException if name is already
+ * bound
+ * @exception javax.naming.directory.InvalidAttributesException if attrs
+ * does not contain all the mandatory attributes required for creation
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public DirContext createSubcontext(String name, Attributes attrs)
throws NamingException {
DirContext context =
*
* @param name the name of the object whose schema is to be retrieved
* @return the schema associated with the context; never null
- * @exception OperationNotSupportedException if schema not supported
+ * @exception javax.naming.OperationNotSupportedException if schema not
+ * supported
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public DirContext getSchema(Name name)
throws NamingException {
return dirContext.getSchema(parseName(name));
*
* @param name the name of the object whose schema is to be retrieved
* @return the schema associated with the context; never null
- * @exception OperationNotSupportedException if schema not supported
+ * @exception javax.naming.OperationNotSupportedException if schema not
+ * supported
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public DirContext getSchema(String name)
throws NamingException {
return dirContext.getSchema(parseName(name));
* be retrieved
* @return the DirContext containing the named object's class
* definitions; never null
- * @exception OperationNotSupportedException if schema not supported
+ * @exception javax.naming.OperationNotSupportedException if schema not
+ * supported
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public DirContext getSchemaClassDefinition(Name name)
throws NamingException {
return dirContext.getSchemaClassDefinition(parseName(name));
* be retrieved
* @return the DirContext containing the named object's class
* definitions; never null
- * @exception OperationNotSupportedException if schema not supported
+ * @exception javax.naming.OperationNotSupportedException if schema not
+ * supported
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public DirContext getSchemaClassDefinition(String name)
throws NamingException {
return dirContext.getSchemaClassDefinition(parseName(name));
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public NamingEnumeration<SearchResult> search(Name name,
Attributes matchingAttributes, String[] attributesToReturn)
throws NamingException {
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public NamingEnumeration<SearchResult> search(String name,
Attributes matchingAttributes, String[] attributesToReturn)
throws NamingException {
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public NamingEnumeration<SearchResult> search(Name name,
Attributes matchingAttributes) throws NamingException {
return dirContext.search(parseName(name), matchingAttributes);
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public NamingEnumeration<SearchResult> search(String name,
Attributes matchingAttributes) throws NamingException {
return dirContext.search(parseName(name), matchingAttributes);
* (new SearchControls())).
* @return an enumeration of SearchResults of the objects that satisfy
* the filter; never null
- * @exception InvalidSearchFilterException if the search filter specified
- * is not supported or understood by the underlying directory
- * @exception InvalidSearchControlsException if the search controls
- * contain invalid settings
+ * @exception javax.naming.directory.InvalidSearchFilterException if the
+ * search filter specified is not supported or understood by the underlying
+ * directory
+ * @exception javax.naming.directory.InvalidSearchControlsException if the
+ * search controls contain invalid settings
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public NamingEnumeration<SearchResult> search(Name name, String filter,
SearchControls cons)
throws NamingException {
* (new SearchControls())).
* @return an enumeration of SearchResults of the objects that satisfy
* the filter; never null
- * @exception InvalidSearchFilterException if the search filter
- * specified is not supported or understood by the underlying directory
- * @exception InvalidSearchControlsException if the search controls
- * contain invalid settings
+ * @exception javax.naming.directory.InvalidSearchFilterException if the
+ * search filter specified is not supported or understood by the underlying
+ * directory
+ * @exception javax.naming.directory.InvalidSearchControlsException if the
+ * search controls contain invalid settings
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public NamingEnumeration<SearchResult> search(String name, String filter,
SearchControls cons)
throws NamingException {
* filter; never null
* @exception ArrayIndexOutOfBoundsException if filterExpr contains {i}
* expressions where i is outside the bounds of the array filterArgs
- * @exception InvalidSearchControlsException if cons contains invalid
- * settings
- * @exception InvalidSearchFilterException if filterExpr with filterArgs
- * represents an invalid search filter
+ * @exception javax.naming.directory.InvalidSearchControlsException if cons
+ * contains invalid settings
+ * @exception javax.naming.directory.InvalidSearchFilterException if
+ * filterExpr with filterArgs represents an invalid search filter
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public NamingEnumeration<SearchResult> search(Name name, String filterExpr,
Object[] filterArgs, SearchControls cons)
throws NamingException {
* filter; never null
* @exception ArrayIndexOutOfBoundsException if filterExpr contains {i}
* expressions where i is outside the bounds of the array filterArgs
- * @exception InvalidSearchControlsException if cons contains invalid
- * settings
- * @exception InvalidSearchFilterException if filterExpr with filterArgs
- * represents an invalid search filter
+ * @exception javax.naming.directory.InvalidSearchControlsException if cons
+ * contains invalid settings
+ * @exception javax.naming.directory.InvalidSearchFilterException if
+ * filterExpr with filterArgs represents an invalid search filter
* @exception NamingException if a naming exception is encountered
*/
+ @Override
public NamingEnumeration<SearchResult> search(String name,
String filterExpr, Object[] filterArgs, SearchControls cons)
throws NamingException {
*
* @return the parsed name
*/
- protected String parseName(String name)
- throws NamingException {
+ protected String parseName(String name) {
return name;
}
*
* @return the parsed name
*/
- protected Name parseName(Name name)
- throws NamingException {
+ protected Name parseName(Name name) {
return name;
}
/**
* Lookup in cache.
*/
- protected CacheEntry cacheLookup(String name) {
+ protected CacheEntry cacheLookup(String lookupName) {
if (cache == null)
return (null);
- if (name == null)
+ String name;
+ if (lookupName == null) {
name = "";
+ } else {
+ name = lookupName;
+ }
for (int i = 0; i < nonCacheable.length; i++) {
if (name.startsWith(nonCacheable[i])) {
return (null);