org.apache.directory.server.core.jndi
Class ServerContext

java.lang.Object
  extended by org.apache.directory.server.core.jndi.ServerContext
All Implemented Interfaces:
javax.naming.Context, javax.naming.event.EventContext
Direct Known Subclasses:
ServerDirContext

public abstract class ServerContext
extends java.lang.Object
implements javax.naming.event.EventContext

A non-federated abstract Context implementation.

Version:
$Rev: 514793 $
Author:
Apache Directory Project

Field Summary
static java.lang.String DELETE_OLD_RDN_PROP
          property key used for deleting the old RDN on a rename
 
Fields inherited from interface javax.naming.event.EventContext
OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE
 
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
protected ServerContext(DirectoryService service, java.util.Hashtable env)
          Must be called by all subclasses to initialize the nexus proxy and the environment settings to be used by this Context implementation.
protected ServerContext(DirectoryService service, LdapPrincipal principal, javax.naming.Name dn)
          Must be called by all subclasses to initialize the nexus proxy and the environment settings to be used by this Context implementation.
 
Method Summary
 void addNamingListener(javax.naming.Name name, int scope, javax.naming.event.NamingListener namingListener)
           
 void addNamingListener(java.lang.String name, int scope, javax.naming.event.NamingListener namingListener)
           
 java.lang.Object addToEnvironment(java.lang.String propName, java.lang.Object propVal)
           
 void bind(javax.naming.Name name, java.lang.Object obj)
           
 void bind(java.lang.String name, java.lang.Object obj)
           
 void close()
           
 javax.naming.Name composeName(javax.naming.Name name, javax.naming.Name prefix)
           
 java.lang.String composeName(java.lang.String name, java.lang.String prefix)
           
 javax.naming.Context createSubcontext(javax.naming.Name name)
           
 javax.naming.Context createSubcontext(java.lang.String name)
           
 void destroySubcontext(javax.naming.Name name)
           
 void destroySubcontext(java.lang.String name)
           
protected  javax.naming.Name getDn()
          Gets the distinguished name of the entry associated with this Context.
 java.util.Hashtable getEnvironment()
           
protected  java.util.Set getListeners()
          Allows subclasses to register and unregister listeners.
 java.lang.String getNameInNamespace()
           
 javax.naming.NameParser getNameParser(javax.naming.Name name)
          Non-federated implementation presuming the name argument is not a composite name spanning multiple namespaces but a compound name in the same LDAP namespace.
 javax.naming.NameParser getNameParser(java.lang.String name)
          Non-federated implementation presuming the name argument is not a composite name spanning multiple namespaces but a compound name in the same LDAP namespace.
protected  PartitionNexus getNexusProxy()
          Gets the RootNexus proxy.
 LdapPrincipal getPrincipal()
          Gets the principal of the authenticated user which also happens to own
 DirectoryService getService()
          Returns the DirectoryService which manages this context.
 javax.naming.NamingEnumeration list(javax.naming.Name name)
           
 javax.naming.NamingEnumeration list(java.lang.String name)
           
 javax.naming.NamingEnumeration listBindings(javax.naming.Name name)
           
 javax.naming.NamingEnumeration listBindings(java.lang.String name)
           
 java.lang.Object lookup(javax.naming.Name name)
           
 java.lang.Object lookup(java.lang.String name)
           
 java.lang.Object lookupLink(javax.naming.Name name)
           
 java.lang.Object lookupLink(java.lang.String name)
           
 void rebind(javax.naming.Name name, java.lang.Object obj)
           
 void rebind(java.lang.String name, java.lang.Object obj)
           
 java.lang.Object removeFromEnvironment(java.lang.String propName)
           
 void removeNamingListener(javax.naming.event.NamingListener namingListener)
           
 void rename(javax.naming.Name oldName, javax.naming.Name newName)
           
 void rename(java.lang.String oldName, java.lang.String newName)
           
 void setPrincipal(AuthenticationService.TrustedPrincipalWrapper wrapper)
          Sets the principal of the authenticated user which also happens to own.
 boolean targetMustExist()
           
 void unbind(javax.naming.Name name)
           
 void unbind(java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DELETE_OLD_RDN_PROP

public static final java.lang.String DELETE_OLD_RDN_PROP
property key used for deleting the old RDN on a rename

See Also:
Constant Field Values
Constructor Detail

ServerContext

protected ServerContext(DirectoryService service,
                        java.util.Hashtable env)
                 throws javax.naming.NamingException
Must be called by all subclasses to initialize the nexus proxy and the environment settings to be used by this Context implementation. This specific contstructor relies on the presence of the Context.PROVIDER_URL key and value to determine the distinguished name of the newly created context. It also checks to make sure the referenced name actually exists within the system. This constructor is used for all InitialContext requests.

Parameters:
service - the parent service that manages this context
env - the environment properties used by this context.
Throws:
javax.naming.NamingException - if the environment parameters are not set correctly.

ServerContext

protected ServerContext(DirectoryService service,
                        LdapPrincipal principal,
                        javax.naming.Name dn)
                 throws javax.naming.NamingException
Must be called by all subclasses to initialize the nexus proxy and the environment settings to be used by this Context implementation. This constructor is used to propagate new contexts from existing contexts.

Parameters:
principal - the directory user principal that is propagated
dn - the distinguished name of this context
Throws:
javax.naming.NamingException
Method Detail

getService

public DirectoryService getService()
Returns the DirectoryService which manages this context.


getPrincipal

public LdapPrincipal getPrincipal()
Gets the principal of the authenticated user which also happens to own


setPrincipal

public void setPrincipal(AuthenticationService.TrustedPrincipalWrapper wrapper)
Sets the principal of the authenticated user which also happens to own. This method can be invoked only once to keep this property safe. This method has been changed to be public but it can only be set by the AuthenticationService to prevent malicious code from changing the effective principal.


getNexusProxy

protected PartitionNexus getNexusProxy()
Gets the RootNexus proxy.

Returns:
the proxy to the backend nexus.

getDn

protected javax.naming.Name getDn()
Gets the distinguished name of the entry associated with this Context.

Returns:
the distinguished name of this Context's entry.

close

public void close()
           throws javax.naming.NamingException
Specified by:
close in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.close()

getNameInNamespace

public java.lang.String getNameInNamespace()
                                    throws javax.naming.NamingException
Specified by:
getNameInNamespace in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.getNameInNamespace()

getEnvironment

public java.util.Hashtable getEnvironment()
Specified by:
getEnvironment in interface javax.naming.Context
See Also:
Context.getEnvironment()

addToEnvironment

public java.lang.Object addToEnvironment(java.lang.String propName,
                                         java.lang.Object propVal)
                                  throws javax.naming.NamingException
Specified by:
addToEnvironment in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.addToEnvironment(java.lang.String, java.lang.Object)

removeFromEnvironment

public java.lang.Object removeFromEnvironment(java.lang.String propName)
                                       throws javax.naming.NamingException
Specified by:
removeFromEnvironment in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.removeFromEnvironment(java.lang.String)

createSubcontext

public javax.naming.Context createSubcontext(java.lang.String name)
                                      throws javax.naming.NamingException
Specified by:
createSubcontext in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.createSubcontext(java.lang.String)

createSubcontext

public javax.naming.Context createSubcontext(javax.naming.Name name)
                                      throws javax.naming.NamingException
Specified by:
createSubcontext in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.createSubcontext(javax.naming.Name)

destroySubcontext

public void destroySubcontext(java.lang.String name)
                       throws javax.naming.NamingException
Specified by:
destroySubcontext in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.destroySubcontext(java.lang.String)

destroySubcontext

public void destroySubcontext(javax.naming.Name name)
                       throws javax.naming.NamingException
Specified by:
destroySubcontext in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.destroySubcontext(javax.naming.Name)

bind

public void bind(java.lang.String name,
                 java.lang.Object obj)
          throws javax.naming.NamingException
Specified by:
bind in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.bind(java.lang.String, java.lang.Object)

bind

public void bind(javax.naming.Name name,
                 java.lang.Object obj)
          throws javax.naming.NamingException
Specified by:
bind in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.bind(javax.naming.Name, java.lang.Object)

rename

public void rename(java.lang.String oldName,
                   java.lang.String newName)
            throws javax.naming.NamingException
Specified by:
rename in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.rename(java.lang.String, java.lang.String)

rename

public void rename(javax.naming.Name oldName,
                   javax.naming.Name newName)
            throws javax.naming.NamingException
Specified by:
rename in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.rename(javax.naming.Name, javax.naming.Name)

rebind

public void rebind(java.lang.String name,
                   java.lang.Object obj)
            throws javax.naming.NamingException
Specified by:
rebind in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.rebind(java.lang.String, java.lang.Object)

rebind

public void rebind(javax.naming.Name name,
                   java.lang.Object obj)
            throws javax.naming.NamingException
Specified by:
rebind in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.rebind(javax.naming.Name, java.lang.Object)

unbind

public void unbind(java.lang.String name)
            throws javax.naming.NamingException
Specified by:
unbind in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.unbind(java.lang.String)

unbind

public void unbind(javax.naming.Name name)
            throws javax.naming.NamingException
Specified by:
unbind in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.unbind(javax.naming.Name)

lookup

public java.lang.Object lookup(java.lang.String name)
                        throws javax.naming.NamingException
Specified by:
lookup in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.lookup(java.lang.String)

lookup

public java.lang.Object lookup(javax.naming.Name name)
                        throws javax.naming.NamingException
Specified by:
lookup in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.lookup(javax.naming.Name)

lookupLink

public java.lang.Object lookupLink(java.lang.String name)
                            throws javax.naming.NamingException
Specified by:
lookupLink in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.lookupLink(java.lang.String)

lookupLink

public java.lang.Object lookupLink(javax.naming.Name name)
                            throws javax.naming.NamingException
Specified by:
lookupLink in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.lookupLink(javax.naming.Name)

getNameParser

public javax.naming.NameParser getNameParser(java.lang.String name)
                                      throws javax.naming.NamingException
Non-federated implementation presuming the name argument is not a composite name spanning multiple namespaces but a compound name in the same LDAP namespace. Hence the parser returned is always the same as calling this method with the empty String.

Specified by:
getNameParser in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.getNameParser(java.lang.String)

getNameParser

public javax.naming.NameParser getNameParser(javax.naming.Name name)
                                      throws javax.naming.NamingException
Non-federated implementation presuming the name argument is not a composite name spanning multiple namespaces but a compound name in the same LDAP namespace. Hence the parser returned is always the same as calling this method with the empty String Name.

Specified by:
getNameParser in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.getNameParser(javax.naming.Name)

list

public javax.naming.NamingEnumeration list(java.lang.String name)
                                    throws javax.naming.NamingException
Specified by:
list in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.list(java.lang.String)

list

public javax.naming.NamingEnumeration list(javax.naming.Name name)
                                    throws javax.naming.NamingException
Specified by:
list in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.list(javax.naming.Name)

listBindings

public javax.naming.NamingEnumeration listBindings(java.lang.String name)
                                            throws javax.naming.NamingException
Specified by:
listBindings in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.listBindings(java.lang.String)

listBindings

public javax.naming.NamingEnumeration listBindings(javax.naming.Name name)
                                            throws javax.naming.NamingException
Specified by:
listBindings in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.listBindings(javax.naming.Name)

composeName

public java.lang.String composeName(java.lang.String name,
                                    java.lang.String prefix)
                             throws javax.naming.NamingException
Specified by:
composeName in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.composeName(java.lang.String, java.lang.String)

composeName

public javax.naming.Name composeName(javax.naming.Name name,
                                     javax.naming.Name prefix)
                              throws javax.naming.NamingException
Specified by:
composeName in interface javax.naming.Context
Throws:
javax.naming.NamingException
See Also:
Context.composeName(javax.naming.Name, javax.naming.Name)

addNamingListener

public void addNamingListener(javax.naming.Name name,
                              int scope,
                              javax.naming.event.NamingListener namingListener)
                       throws javax.naming.NamingException
Specified by:
addNamingListener in interface javax.naming.event.EventContext
Throws:
javax.naming.NamingException

addNamingListener

public void addNamingListener(java.lang.String name,
                              int scope,
                              javax.naming.event.NamingListener namingListener)
                       throws javax.naming.NamingException
Specified by:
addNamingListener in interface javax.naming.event.EventContext
Throws:
javax.naming.NamingException

removeNamingListener

public void removeNamingListener(javax.naming.event.NamingListener namingListener)
                          throws javax.naming.NamingException
Specified by:
removeNamingListener in interface javax.naming.event.EventContext
Throws:
javax.naming.NamingException

targetMustExist

public boolean targetMustExist()
                        throws javax.naming.NamingException
Specified by:
targetMustExist in interface javax.naming.event.EventContext
Throws:
javax.naming.NamingException

getListeners

protected java.util.Set getListeners()
Allows subclasses to register and unregister listeners.

Returns:
the set of listeners used for tracking registered name listeners.


Copyright © 2003-2012 Apache Software Foundation. All Rights Reserved.