org.apache.directory.server.ldap
Class LdapSession

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

public class LdapSession
extends java.lang.Object

An object representing an LdapSession. Any connection established with the LDAP server forms a session.

Version:
$Rev$, $Date$
Author:
Apache Directory Project

Constructor Summary
LdapSession(org.apache.mina.core.session.IoSession ioSession)
          Creates a new instance of LdapSession associated with the underlying connection (MINA IoSession) to the server.
 
Method Summary
 void abandonAllOutstandingRequests()
          Abandons all outstanding requests associated with this session.
 org.apache.directory.shared.ldap.message.internal.InternalAbandonableRequest abandonOutstandingRequest(int messageId)
          Abandons a specific request by messageId.
 void addPagedSearchContext(PagedSearchContext context)
          Add a new Paged Search context into the stored context.
 void clearSaslProperties()
          Clear all the Sasl values stored into the Map
 org.apache.directory.shared.ldap.message.BindStatus getBindStatus()
           
 CoreSession getCoreSession()
          Gets the logical core DirectoryService session associated with this LdapSession.
 java.lang.String getCurrentMechanism()
          Get the mechanism selected by a user during a SASL Bind negotiation.
 org.apache.mina.core.session.IoSession getIoSession()
          Gets the MINA IoSession associated with this LdapSession.
 LdapServer getLdapServer()
           
 java.util.Map<java.lang.Integer,org.apache.directory.shared.ldap.message.internal.InternalAbandonableRequest> getOutstandingRequests()
           
 PagedSearchContext getPagedSearchContext(int contextId)
          Get paged search context associated with an ID
 java.lang.Object getSaslProperty(java.lang.String property)
          Get a Sasl property's value
 boolean isAnonymous()
          Check if the session is authenticated.
 boolean isAuthenticated()
          Check if the session is authenticated.
 boolean isAuthPending()
          Check if the session is processing a BindRequest, either Simple or SASL
 boolean isSaslAuthPending()
          Check if the session is processing a SASL BindRequest
 boolean isSimpleAuthPending()
          Check if the session is processing a Simple BindRequest
 void putSaslProperty(java.lang.String property, java.lang.Object value)
          Add a Sasl property and value
 void registerOutstandingRequest(org.apache.directory.shared.ldap.message.internal.InternalAbandonableRequest request)
          Registers an outstanding request which can be abandoned later.
 PagedSearchContext removePagedSearchContext(long contextId)
          Remove a Paged Search context from the map storing all of them.
 void removeSaslProperty(java.lang.String property)
          Remove a property from the SaslProperty map
 void setAnonymous()
          Set the current BindStatus to Anonymous
 void setAuthenticated()
          Set the current BindStatus to authenticated
 void setCoreSession(CoreSession coreSession)
          Sets the logical core DirectoryService session.
 void setLdapServer(LdapServer ldapServer)
          Store a reference on the LdapServer intance
 void setSaslAuthPending()
          Set the current BindStatus to SASL authentication pending
 void setSimpleAuthPending()
          Set the current BindStatus to Simple authentication pending
 java.lang.String toString()
          The principal and remote address associated with this session.
 void unregisterOutstandingRequest(org.apache.directory.shared.ldap.message.internal.InternalAbandonableRequest request)
          Unregisters an outstanding request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LdapSession

public LdapSession(org.apache.mina.core.session.IoSession ioSession)
Creates a new instance of LdapSession associated with the underlying connection (MINA IoSession) to the server.

Parameters:
ioSession - the MINA session associated this LdapSession
Method Detail

isAuthenticated

public boolean isAuthenticated()
Check if the session is authenticated. There are two conditions for a session to be authenticated :
- the coreSession must not be null
- and the state should be Authenticated.

Returns:
true if the session is not anonymous

isAnonymous

public boolean isAnonymous()
Check if the session is authenticated. There are two conditions for a session to be authenticated :
- it has to exist
- and the session should not be anonymous.

Returns:
true if the session is not anonymous

isAuthPending

public boolean isAuthPending()
Check if the session is processing a BindRequest, either Simple or SASL

Returns:
true if the session is in AuthPending state

isSimpleAuthPending

public boolean isSimpleAuthPending()
Check if the session is processing a Simple BindRequest

Returns:
true if the session is in AuthPending state

isSaslAuthPending

public boolean isSaslAuthPending()
Check if the session is processing a SASL BindRequest

Returns:
true if the session is in AuthPending state

getIoSession

public org.apache.mina.core.session.IoSession getIoSession()
Gets the MINA IoSession associated with this LdapSession.

Returns:
the MINA IoSession

getCoreSession

public CoreSession getCoreSession()
Gets the logical core DirectoryService session associated with this LdapSession.

Returns:
the logical core DirectoryService session

setCoreSession

public void setCoreSession(CoreSession coreSession)
Sets the logical core DirectoryService session.

Parameters:
coreSession - the logical core DirectoryService session

abandonAllOutstandingRequests

public void abandonAllOutstandingRequests()
Abandons all outstanding requests associated with this session.


abandonOutstandingRequest

public org.apache.directory.shared.ldap.message.internal.InternalAbandonableRequest abandonOutstandingRequest(int messageId)
Abandons a specific request by messageId.

Parameters:
messageId - The request ID to abandon

registerOutstandingRequest

public void registerOutstandingRequest(org.apache.directory.shared.ldap.message.internal.InternalAbandonableRequest request)
Registers an outstanding request which can be abandoned later.

Parameters:
request - an outstanding request that can be abandoned

unregisterOutstandingRequest

public void unregisterOutstandingRequest(org.apache.directory.shared.ldap.message.internal.InternalAbandonableRequest request)
Unregisters an outstanding request.

Parameters:
request - the request to unregister

getOutstandingRequests

public java.util.Map<java.lang.Integer,org.apache.directory.shared.ldap.message.internal.InternalAbandonableRequest> getOutstandingRequests()
Returns:
A list of all the abandonable requests for this session.

getBindStatus

public org.apache.directory.shared.ldap.message.BindStatus getBindStatus()
Returns:
the current bind status for this session

setSimpleAuthPending

public void setSimpleAuthPending()
Set the current BindStatus to Simple authentication pending


setSaslAuthPending

public void setSaslAuthPending()
Set the current BindStatus to SASL authentication pending


setAnonymous

public void setAnonymous()
Set the current BindStatus to Anonymous


setAuthenticated

public void setAuthenticated()
Set the current BindStatus to authenticated


getCurrentMechanism

public java.lang.String getCurrentMechanism()
Get the mechanism selected by a user during a SASL Bind negotiation.

Returns:
The used mechanism, if any

putSaslProperty

public void putSaslProperty(java.lang.String property,
                            java.lang.Object value)
Add a Sasl property and value

Parameters:
property - the property to add
value - the value for this property

getSaslProperty

public java.lang.Object getSaslProperty(java.lang.String property)
Get a Sasl property's value

Parameters:
property - the property to get
Returns:
the associated value, or null if we don't have such a property

clearSaslProperties

public void clearSaslProperties()
Clear all the Sasl values stored into the Map


removeSaslProperty

public void removeSaslProperty(java.lang.String property)
Remove a property from the SaslProperty map

Parameters:
property - the property to remove

getLdapServer

public LdapServer getLdapServer()
Returns:
The LdapServer reference

setLdapServer

public void setLdapServer(LdapServer ldapServer)
Store a reference on the LdapServer intance

Parameters:
ldapServer - the LdapServer instance

addPagedSearchContext

public void addPagedSearchContext(PagedSearchContext context)
                           throws java.lang.Exception
Add a new Paged Search context into the stored context. If some context with the same id already exists, it will be closed and removed.

Parameters:
context - The context to add
Throws:
java.lang.Exception

removePagedSearchContext

public PagedSearchContext removePagedSearchContext(long contextId)
Remove a Paged Search context from the map storing all of them.

Parameters:
contextId - The context ID to remove
Returns:
The removed context if any found

getPagedSearchContext

public PagedSearchContext getPagedSearchContext(int contextId)
Get paged search context associated with an ID

Parameters:
contextId - The id for teh context we want to get
Returns:
The associated context, if any

toString

public java.lang.String toString()
The principal and remote address associated with this session.

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()


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