org.apache.directory.server.ldap
Class LdapSession

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

public class LdapSession
extends Object

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

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.api.ldap.model.message.AbandonableRequest 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
 void closeAllPagedSearches()
          Close all the pending cursors for all the pending PagedSearches
 org.apache.directory.api.ldap.model.message.BindStatus getBindStatus()
           
 org.apache.directory.server.core.api.CoreSession getCoreSession()
          Gets the logical core DirectoryService session associated with this LdapSession.
 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()
           
 Map<Integer,org.apache.directory.api.ldap.model.message.AbandonableRequest> getOutstandingRequests()
           
 PagedSearchContext getPagedSearchContext(int contextId)
          Get paged search context associated with an ID
 Object getSaslProperty(String property)
          Get a Sasl property's value
 org.apache.directory.server.core.api.SearchRequestContainer getSearchRequest(int messageId)
          Find the searchRequestContainer associated with a MessageID
 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(String property, Object value)
          Add a Sasl property and value
 void registerOutstandingRequest(org.apache.directory.api.ldap.model.message.AbandonableRequest request)
          Registers an outstanding request which can be abandoned later.
 void registerSearchRequest(org.apache.directory.api.ldap.model.message.SearchRequest searchRequest, org.apache.directory.api.ldap.model.cursor.Cursor<org.apache.directory.api.ldap.model.entry.Entry> cursor)
          Registers a new searchRequest
 PagedSearchContext removePagedSearchContext(int contextId)
          Remove a Paged Search context from the map storing all of them.
 void removeSaslProperty(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(org.apache.directory.server.core.api.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
 String toString()
          The principal and remote address associated with this session.
 void unregisterOutstandingRequest(org.apache.directory.api.ldap.model.message.AbandonableRequest request)
          Unregisters an outstanding request.
 void unregisterSearchRequest(org.apache.directory.api.ldap.model.message.SearchRequest searchRequest)
          Unregisters a completed search 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 org.apache.directory.server.core.api.CoreSession getCoreSession()
Gets the logical core DirectoryService session associated with this LdapSession.

Returns:
the logical core DirectoryService session

setCoreSession

public void setCoreSession(org.apache.directory.server.core.api.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.api.ldap.model.message.AbandonableRequest abandonOutstandingRequest(int messageId)
Abandons a specific request by messageId.

Parameters:
messageId - The request ID to abandon

registerOutstandingRequest

public void registerOutstandingRequest(org.apache.directory.api.ldap.model.message.AbandonableRequest 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.api.ldap.model.message.AbandonableRequest request)
Unregisters an outstanding request.

Parameters:
request - the request to unregister

getOutstandingRequests

public Map<Integer,org.apache.directory.api.ldap.model.message.AbandonableRequest> getOutstandingRequests()
Returns:
A list of all the abandonable requests for this session.

registerSearchRequest

public void registerSearchRequest(org.apache.directory.api.ldap.model.message.SearchRequest searchRequest,
                                  org.apache.directory.api.ldap.model.cursor.Cursor<org.apache.directory.api.ldap.model.entry.Entry> cursor)
Registers a new searchRequest

Parameters:
searchRequest - a new searchRequest

unregisterSearchRequest

public void unregisterSearchRequest(org.apache.directory.api.ldap.model.message.SearchRequest searchRequest)
Unregisters a completed search request.

Parameters:
searchRequest - the searchRequest to unregister

getSearchRequest

public org.apache.directory.server.core.api.SearchRequestContainer getSearchRequest(int messageId)
Find the searchRequestContainer associated with a MessageID

Parameters:
messageId - the SearchRequestContainer MessageID we are looking for

getBindStatus

public org.apache.directory.api.ldap.model.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 String getCurrentMechanism()
Get the mechanism selected by a user during a SASL Bind negotiation.

Returns:
The used mechanism, if any

putSaslProperty

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

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

getSaslProperty

public Object getSaslProperty(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(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 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:
Exception

removePagedSearchContext

public PagedSearchContext removePagedSearchContext(int 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

closeAllPagedSearches

public void closeAllPagedSearches()
                           throws Exception
Close all the pending cursors for all the pending PagedSearches

Throws:
Exception - If we've got an exception.

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 String toString()
The principal and remote address associated with this session.

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


Copyright © 2003-2013 The Apache Software Foundation. All Rights Reserved.