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: 927404 $
Author:
Apache Directory Project

Field Summary
protected  javax.naming.ldap.Control[] connectControls
          Connection level controls associated with the session
static java.lang.String DELETE_OLD_RDN_PROP
          property key used for deleting the old RDN on a rename
protected static javax.naming.ldap.Control[] EMPTY_CONTROLS
          Empty array of controls for use in dealing with them
protected  javax.naming.ldap.Control[] requestControls
          The request controls to set on operations before performing them
protected  javax.naming.ldap.Control[] responseControls
          The response controls to set after performing operations
 
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
  ServerContext(DirectoryService service, CoreSession session, javax.naming.Name name)
           
protected ServerContext(DirectoryService service, java.util.Hashtable<java.lang.String,java.lang.Object> env)
          Must be called by all subclasses to initialize the nexus proxy and the environment settings to be used by this Context implementation.
  ServerContext(DirectoryService service, LdapPrincipal principal, javax.naming.Name name)
          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  void doAddOperation(org.apache.directory.shared.ldap.name.DN target, org.apache.directory.shared.ldap.entry.ServerEntry entry)
          Used to encapsulate [de]marshalling of controls before and after add operations.
protected  BindOperationContext doBindOperation(org.apache.directory.shared.ldap.name.DN bindDn, byte[] credentials, java.lang.String saslMechanism, java.lang.String saslAuthId)
          Used to encapsulate [de]marshalling of controls before and after bind operations.
protected  void doDeleteOperation(org.apache.directory.shared.ldap.name.DN target)
          Used to encapsulate [de]marshalling of controls before and after delete operations.
protected  org.apache.directory.shared.ldap.entry.ServerEntry doGetRootDSEOperation(org.apache.directory.shared.ldap.name.DN target)
           
protected  EntryFilteringCursor doListOperation(org.apache.directory.shared.ldap.name.DN target)
          Used to encapsulate [de]marshalling of controls before and after list operations.
protected  org.apache.directory.shared.ldap.entry.ServerEntry doLookupOperation(org.apache.directory.shared.ldap.name.DN target)
          Used to encapsulate [de]marshalling of controls before and after lookup operations.
protected  org.apache.directory.shared.ldap.entry.ServerEntry doLookupOperation(org.apache.directory.shared.ldap.name.DN target, java.lang.String[] attrIds)
          Used to encapsulate [de]marshalling of controls before and after lookup operations.
protected  void doModifyOperation(org.apache.directory.shared.ldap.name.DN dn, java.util.List<org.apache.directory.shared.ldap.entry.Modification> modifications)
          Used to encapsulate [de]marshalling of controls before and after modify operations.
protected  void doMove(org.apache.directory.shared.ldap.name.DN oldDn, org.apache.directory.shared.ldap.name.DN target)
          Used to encapsulate [de]marshalling of controls before and after moveAndRename operations.
protected  void doMoveAndRenameOperation(org.apache.directory.shared.ldap.name.DN oldDn, org.apache.directory.shared.ldap.name.DN parent, org.apache.directory.shared.ldap.name.RDN newRdn, boolean delOldDn)
          Used to encapsulate [de]marshalling of controls before and after moveAndRename operations.
protected  void doRename(org.apache.directory.shared.ldap.name.DN oldDn, org.apache.directory.shared.ldap.name.RDN newRdn, boolean delOldRdn)
          Used to encapsulate [de]marshalling of controls before and after rename operations.
protected  EntryFilteringCursor doSearchOperation(org.apache.directory.shared.ldap.name.DN dn, org.apache.directory.shared.ldap.message.AliasDerefMode aliasDerefMode, org.apache.directory.shared.ldap.filter.ExprNode filter, javax.naming.directory.SearchControls searchControls)
          Used to encapsulate [de]marshalling of controls before and after list operations.
 DirectoryService getDirectoryService()
           
protected  org.apache.directory.shared.ldap.name.DN getDn()
          Gets the distinguished name of the entry associated with this Context.
 java.util.Hashtable<java.lang.String,java.lang.Object> getEnvironment()
           
protected  java.util.Map<javax.naming.event.NamingListener,DirectoryListener> 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.
abstract  ServerContext getRootContext()
          Gets a handle on the root context of the DIT.
 DirectoryService getService()
          Gets the DirectoryService associated with this context.
 CoreSession getSession()
           
protected  void injectReferralControl(OperationContext opCtx)
          Set the referral handling flag into the operation context using the JNDI value stored into the environment.
 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)
           
 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

EMPTY_CONTROLS

protected static final javax.naming.ldap.Control[] EMPTY_CONTROLS
Empty array of controls for use in dealing with them


requestControls

protected javax.naming.ldap.Control[] requestControls
The request controls to set on operations before performing them


responseControls

protected javax.naming.ldap.Control[] responseControls
The response controls to set after performing operations


connectControls

protected javax.naming.ldap.Control[] connectControls
Connection level controls associated with the session

Constructor Detail

ServerContext

protected ServerContext(DirectoryService service,
                        java.util.Hashtable<java.lang.String,java.lang.Object> env)
                 throws java.lang.Exception
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.
java.lang.Exception

ServerContext

public ServerContext(DirectoryService service,
                     LdapPrincipal principal,
                     javax.naming.Name name)
              throws java.lang.Exception
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
service - the directory service core
Throws:
javax.naming.NamingException - if there is a problem creating the new context
java.lang.Exception

ServerContext

public ServerContext(DirectoryService service,
                     CoreSession session,
                     javax.naming.Name name)
              throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

injectReferralControl

protected void injectReferralControl(OperationContext opCtx)
Set the referral handling flag into the operation context using the JNDI value stored into the environment.


doAddOperation

protected void doAddOperation(org.apache.directory.shared.ldap.name.DN target,
                              org.apache.directory.shared.ldap.entry.ServerEntry entry)
                       throws java.lang.Exception
Used to encapsulate [de]marshalling of controls before and after add operations.

Parameters:
entry -
target -
Throws:
java.lang.Exception

doDeleteOperation

protected void doDeleteOperation(org.apache.directory.shared.ldap.name.DN target)
                          throws java.lang.Exception
Used to encapsulate [de]marshalling of controls before and after delete operations.

Parameters:
target -
Throws:
java.lang.Exception

doSearchOperation

protected EntryFilteringCursor doSearchOperation(org.apache.directory.shared.ldap.name.DN dn,
                                                 org.apache.directory.shared.ldap.message.AliasDerefMode aliasDerefMode,
                                                 org.apache.directory.shared.ldap.filter.ExprNode filter,
                                                 javax.naming.directory.SearchControls searchControls)
                                          throws java.lang.Exception
Used to encapsulate [de]marshalling of controls before and after list operations.

Parameters:
dn -
aliasDerefMode -
filter -
searchControls -
Returns:
NamingEnumeration
Throws:
java.lang.Exception

doListOperation

protected EntryFilteringCursor doListOperation(org.apache.directory.shared.ldap.name.DN target)
                                        throws java.lang.Exception
Used to encapsulate [de]marshalling of controls before and after list operations.

Throws:
java.lang.Exception

doGetRootDSEOperation

protected org.apache.directory.shared.ldap.entry.ServerEntry doGetRootDSEOperation(org.apache.directory.shared.ldap.name.DN target)
                                                                            throws java.lang.Exception
Throws:
java.lang.Exception

doLookupOperation

protected org.apache.directory.shared.ldap.entry.ServerEntry doLookupOperation(org.apache.directory.shared.ldap.name.DN target)
                                                                        throws java.lang.Exception
Used to encapsulate [de]marshalling of controls before and after lookup operations.

Throws:
java.lang.Exception

doLookupOperation

protected org.apache.directory.shared.ldap.entry.ServerEntry doLookupOperation(org.apache.directory.shared.ldap.name.DN target,
                                                                               java.lang.String[] attrIds)
                                                                        throws java.lang.Exception
Used to encapsulate [de]marshalling of controls before and after lookup operations.

Throws:
java.lang.Exception

doBindOperation

protected BindOperationContext doBindOperation(org.apache.directory.shared.ldap.name.DN bindDn,
                                               byte[] credentials,
                                               java.lang.String saslMechanism,
                                               java.lang.String saslAuthId)
                                        throws java.lang.Exception
Used to encapsulate [de]marshalling of controls before and after bind operations.

Throws:
java.lang.Exception

doMoveAndRenameOperation

protected void doMoveAndRenameOperation(org.apache.directory.shared.ldap.name.DN oldDn,
                                        org.apache.directory.shared.ldap.name.DN parent,
                                        org.apache.directory.shared.ldap.name.RDN newRdn,
                                        boolean delOldDn)
                                 throws java.lang.Exception
Used to encapsulate [de]marshalling of controls before and after moveAndRename operations.

Throws:
java.lang.Exception

doModifyOperation

protected void doModifyOperation(org.apache.directory.shared.ldap.name.DN dn,
                                 java.util.List<org.apache.directory.shared.ldap.entry.Modification> modifications)
                          throws java.lang.Exception
Used to encapsulate [de]marshalling of controls before and after modify operations.

Throws:
java.lang.Exception

doMove

protected void doMove(org.apache.directory.shared.ldap.name.DN oldDn,
                      org.apache.directory.shared.ldap.name.DN target)
               throws java.lang.Exception
Used to encapsulate [de]marshalling of controls before and after moveAndRename operations.

Throws:
java.lang.Exception

doRename

protected void doRename(org.apache.directory.shared.ldap.name.DN oldDn,
                        org.apache.directory.shared.ldap.name.RDN newRdn,
                        boolean delOldRdn)
                 throws java.lang.Exception
Used to encapsulate [de]marshalling of controls before and after rename operations.

Throws:
java.lang.Exception

getSession

public CoreSession getSession()

getDirectoryService

public DirectoryService getDirectoryService()

getRootContext

public abstract ServerContext getRootContext()
                                      throws javax.naming.NamingException
Gets a handle on the root context of the DIT. The RootDSE as the present user.

Returns:
the rootDSE context
Throws:
javax.naming.NamingException - if this fails

getService

public DirectoryService getService()
Gets the DirectoryService associated with this context.

Returns:
the directory service associated with this context

getDn

protected org.apache.directory.shared.ldap.name.DN 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<java.lang.String,java.lang.Object> 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.Map<javax.naming.event.NamingListener,DirectoryListener> getListeners()
Allows subclasses to register and unregister listeners.

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


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