You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2008/12/17 12:19:18 UTC

svn commit: r727344 - in /directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap: LdapProtocolHandler.java LdapSession.java

Author: elecharny
Date: Wed Dec 17 03:19:17 2008
New Revision: 727344

URL: http://svn.apache.org/viewvc?rev=727344&view=rev
Log:
o Adding some missing Javadoc
o Adding some logs
o Added a toString() method

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolHandler.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolHandler.java?rev=727344&r1=727343&r2=727344&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolHandler.java Wed Dec 17 03:19:17 2008
@@ -79,13 +79,18 @@
     }
 
 
-    /*
-     * (non-Javadoc)LdapProtocolHandler
-     * @see org.apache.mina.common.IoHandlerAdapter#sessionClosed(org.apache.mina.common.IoSession)
+    /**
+     * This method is called when a session is closed. If we have some 
+     * cleanup to do, it's done there.
+     * 
+     * @param session the closing session
      */
     public void sessionClosed( IoSession session )
     {
+        // Get the associated LdapSession
         LdapSession ldapSession = ldapService.getLdapSessionManager().removeLdapSession( session );
+        
+        // Clean it up !
         cleanUpSession( ldapSession );
     }
 
@@ -104,8 +109,11 @@
             return;
         }
         
+        LOG.debug( "Cleaning the {} session", ldapSession );
+        
         if ( ldapSession != null )
         {
+            // Abandon all the requests
             ldapSession.abandonAllOutstandingRequests();
         }
         

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java?rev=727344&r1=727343&r2=727344&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java Wed Dec 17 03:19:17 2008
@@ -20,12 +20,14 @@
 package org.apache.directory.server.ldap;
 
 
+import java.net.SocketAddress;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.authn.LdapPrincipal;
 import org.apache.directory.shared.ldap.message.AbandonableRequest;
 import org.apache.directory.shared.ldap.message.BindStatus;
 import org.apache.mina.core.session.IoSession;
@@ -34,7 +36,7 @@
 
 
 /**
- * An object representing an LdapSession.  Any connection established with the
+ * An object representing an LdapSession. Any connection established with the
  * LDAP server forms a session.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -48,9 +50,10 @@
     /** A speedup for logs */
     private static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
-    
+    /** The list of requests we can abandon */
     private static final AbandonableRequest[] EMPTY_ABANDONABLES = new AbandonableRequest[0]; 
     
+    /** A lock to protect the abandonableRequests against concurrent access */
     private final String outstandingLock;
     
     /**
@@ -65,23 +68,21 @@
     /** A reference on the LdapService instance */
     private LdapService ldapService;
     
-    
+    /** A map of all the running requests */
     private Map<Integer, AbandonableRequest> outstandingRequests;
     
-    
     /** The current Bind status */
     private BindStatus bindStatus;
     
     /** The current mechanism used to authenticate the user */
     private String currentMechanism;
     
-    
     /**
      * A Map containing Objects used during the SASL negotiation
      */
     private Map<String, Object> saslProperties;
     
- 
+
     /**
      * Creates a new instance of LdapSession associated with the underlying
      * connection (MINA IoSession) to the server.
@@ -190,8 +191,10 @@
 
     /**
      * Abandons a specific request by messageId.
+     * 
+     * @param messageId The request ID to abandon
      */
-    public AbandonableRequest abandonOutstandingRequest( Integer messageId )
+    public AbandonableRequest abandonOutstandingRequest( int messageId )
     {
         AbandonableRequest request = null;
         
@@ -251,6 +254,9 @@
     }
     
     
+    /**
+     * @return A list of all the abandonable requests for this session. 
+     */
     public Map<Integer, AbandonableRequest> getOutstandingRequests()
     {
         synchronized( outstandingLock )
@@ -369,4 +375,43 @@
     {
         this.ldapService = ldapService;
     }
+    
+    
+    /**
+     * The principal and remote address associated with this session.
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        if ( coreSession == null )
+        {
+            return "LdapSession : No Ldap session ...";
+        }
+        
+        StringBuilder sb = new StringBuilder();
+        
+        LdapPrincipal principal = coreSession.getAuthenticatedPrincipal(); 
+        SocketAddress address = coreSession.getClientAddress();
+        
+        sb.append( "LdapSession : <" );
+        
+        if ( principal != null )
+        {
+            sb.append( principal.getName() );
+            sb.append( "," );
+        }
+        
+        if ( address != null )
+        {
+            sb.append( address );
+        }
+        else
+        {
+            sb.append( "..." );
+        }
+        
+        sb.append( ">" );
+        
+        return sb.toString();
+    }
 }