org.apache.directory.server.ldap
Class SessionRegistry

java.lang.Object
  extended by org.apache.directory.server.ldap.SessionRegistry

public class SessionRegistry
extends java.lang.Object

A client session state based on JNDI contexts.

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

Method Summary
 void addOutstandingRequest(org.apache.mina.common.IoSession session, org.apache.directory.shared.ldap.message.Request req)
          Adds a request to the map of outstanding requests for a session.
 java.util.Hashtable getEnvironmentByCopy()
          Gets a cloned copy of the environment associated with this registry.
 javax.naming.ldap.LdapContext getLdapContext(org.apache.mina.common.IoSession session, javax.naming.ldap.Control[] connCtls, boolean allowAnonymous)
          Gets the InitialContext to the root of the system that was gotten for client.
 javax.naming.ldap.LdapContext getLdapContextOnRootDSEAccess(org.apache.mina.common.IoSession session, javax.naming.ldap.Control[] connCtls)
          Gets the InitialContext to the root of the system that was gotten for client ONLY to be used for RootDSE Search operations.
 org.apache.directory.shared.ldap.message.Request getOutstandingRequest(org.apache.mina.common.IoSession session, int abandonedId)
          Overload that does not require boxing of primitive messageId.
 org.apache.directory.shared.ldap.message.Request getOutstandingRequest(org.apache.mina.common.IoSession session, java.lang.Integer id)
          Gets an outstanding request by messageId for a session.
 java.util.Map getOutstandingRequests(org.apache.mina.common.IoSession session)
          Returns a shallow copied map of all outstanding requests for an IoSession.
 org.apache.mina.common.IoSession[] getSessions()
           
static SessionRegistry getSingleton()
          Gets the singleton instance for this SessionRegistry.
 void remove(org.apache.mina.common.IoSession session)
          Removes the state mapping a JNDI initial context for the client's key.
 org.apache.directory.shared.ldap.message.Request removeOutstandingRequest(org.apache.mina.common.IoSession session, int messageId)
          Overload that does not require boxing of primitive messageId.
 org.apache.directory.shared.ldap.message.Request removeOutstandingRequest(org.apache.mina.common.IoSession session, java.lang.Integer id)
          Removes an outstanding request from the session's outstanding request map.
 void setLdapContext(org.apache.mina.common.IoSession session, javax.naming.ldap.LdapContext ictx)
          Sets the initial context associated with a newly authenticated client.
 void terminateSession(org.apache.mina.common.IoSession session)
          Terminates the session by publishing a disconnect event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSingleton

public static SessionRegistry getSingleton()
Gets the singleton instance for this SessionRegistry. If the singleton does not exist one is created.

Returns:
the singleton SessionRegistry instance

getEnvironmentByCopy

public java.util.Hashtable getEnvironmentByCopy()
Gets a cloned copy of the environment associated with this registry.

Returns:
the registry environment

addOutstandingRequest

public void addOutstandingRequest(org.apache.mina.common.IoSession session,
                                  org.apache.directory.shared.ldap.message.Request req)
Adds a request to the map of outstanding requests for a session.

Parameters:
session - the session the request was issued on
req - the request to add

removeOutstandingRequest

public org.apache.directory.shared.ldap.message.Request removeOutstandingRequest(org.apache.mina.common.IoSession session,
                                                                                 int messageId)
Overload that does not require boxing of primitive messageId.

Parameters:
session - the session associated with the request
messageId - the id of the request
Returns:
the Request if it is removed or null if no such request was mapped as outstanding

removeOutstandingRequest

public org.apache.directory.shared.ldap.message.Request removeOutstandingRequest(org.apache.mina.common.IoSession session,
                                                                                 java.lang.Integer id)
Removes an outstanding request from the session's outstanding request map.

Parameters:
session - the session the request is removed from
id - the messageId of the request to remove
Returns:
the Request if it is removed or null if no such request was mapped as outstanding

getOutstandingRequests

public java.util.Map getOutstandingRequests(org.apache.mina.common.IoSession session)
Returns a shallow copied map of all outstanding requests for an IoSession.

Parameters:
session - the session to get outstanding requests for
Returns:
a map by message id as an Integer to Request objects

getOutstandingRequest

public org.apache.directory.shared.ldap.message.Request getOutstandingRequest(org.apache.mina.common.IoSession session,
                                                                              int abandonedId)
Overload that does not require boxing of primitive messageId.

Parameters:
session - the session associated with the request
messageId - the id of the request
Returns:
the request in session for id or null if request has completed

getOutstandingRequest

public org.apache.directory.shared.ldap.message.Request getOutstandingRequest(org.apache.mina.common.IoSession session,
                                                                              java.lang.Integer id)
Gets an outstanding request by messageId for a session.

Parameters:
session - the LDAP session
id - the message id of the request
Returns:
the request in session for id or null if request has completed

getSessions

public org.apache.mina.common.IoSession[] getSessions()

getLdapContext

public javax.naming.ldap.LdapContext getLdapContext(org.apache.mina.common.IoSession session,
                                                    javax.naming.ldap.Control[] connCtls,
                                                    boolean allowAnonymous)
                                             throws javax.naming.NamingException
Gets the InitialContext to the root of the system that was gotten for client. If the context is not present then there was no bind operation that set it. Hence this operation requesting the context is anonymous.

Parameters:
session - the client's key
connCtls - connection controls if any to use if creating anon context
allowAnonymous - true if anonymous requests will create anonymous InitialContext if one is not present for the operation
Returns:
the InitialContext or null
Throws:
javax.naming.NamingException

getLdapContextOnRootDSEAccess

public javax.naming.ldap.LdapContext getLdapContextOnRootDSEAccess(org.apache.mina.common.IoSession session,
                                                                   javax.naming.ldap.Control[] connCtls)
                                                            throws javax.naming.NamingException
Gets the InitialContext to the root of the system that was gotten for client ONLY to be used for RootDSE Search operations. This bypasses checks to only allow anonymous binds for this special case.

Parameters:
session - the client's key
connCtls - connection controls if any to use if creating anon context
Returns:
the InitialContext or null
Throws:
javax.naming.NamingException

setLdapContext

public void setLdapContext(org.apache.mina.common.IoSession session,
                           javax.naming.ldap.LdapContext ictx)
Sets the initial context associated with a newly authenticated client.

Parameters:
session - the client session
ictx - the initial context gotten

remove

public void remove(org.apache.mina.common.IoSession session)
Removes the state mapping a JNDI initial context for the client's key.

Parameters:
session - the client's key

terminateSession

public void terminateSession(org.apache.mina.common.IoSession session)
Terminates the session by publishing a disconnect event.

Parameters:
session - the client key of the client to disconnect


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