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 2013/05/22 17:10:10 UTC

svn commit: r1485239 - in /directory/apacheds/trunk: core-shared/src/main/java/org/apache/directory/server/core/shared/DefaultCoreSession.java protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/BindRequestHandler.java

Author: elecharny
Date: Wed May 22 15:10:10 2013
New Revision: 1485239

URL: http://svn.apache.org/r1485239
Log:
o Injected the IoSession into the CoreSession, when we do have an IoSession
o Implemented the CoreSession.getClientAddress()/getServcieAddress() methods.

This fixes DIRSERVER-1489

Modified:
    directory/apacheds/trunk/core-shared/src/main/java/org/apache/directory/server/core/shared/DefaultCoreSession.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/BindRequestHandler.java

Modified: directory/apacheds/trunk/core-shared/src/main/java/org/apache/directory/server/core/shared/DefaultCoreSession.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-shared/src/main/java/org/apache/directory/server/core/shared/DefaultCoreSession.java?rev=1485239&r1=1485238&r2=1485239&view=diff
==============================================================================
--- directory/apacheds/trunk/core-shared/src/main/java/org/apache/directory/server/core/shared/DefaultCoreSession.java (original)
+++ directory/apacheds/trunk/core-shared/src/main/java/org/apache/directory/server/core/shared/DefaultCoreSession.java Wed May 22 15:10:10 2013
@@ -76,6 +76,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.api.interceptor.context.SearchOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.UnbindOperationContext;
 import org.apache.directory.server.i18n.I18n;
+import org.apache.mina.core.session.IoSession;
 
 
 /**
@@ -103,6 +104,9 @@ public class DefaultCoreSession implemen
     /** A reference to the ObjectClass AT */
     protected AttributeType OBJECT_CLASS_AT;
 
+    /** The associated IoSession */
+    private IoSession ioSession;
+
 
     /**
      * Creates a new instance of a DefaultCoreSession
@@ -129,6 +133,17 @@ public class DefaultCoreSession implemen
 
 
     /**
+     * Stores the IoSession into the CoreSession. This is only useful when the server is not embedded.
+     * 
+     * @param ioSession The IoSession for this CoreSession
+     */
+    public void setIoSession( IoSession ioSession )
+    {
+        this.ioSession = ioSession;
+    }
+
+
+    /**
      * Set the ignoreRefferal flag for the current operationContext.
      *
      * @param opContext The current operationContext
@@ -368,13 +383,19 @@ public class DefaultCoreSession implemen
     }
 
 
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.CoreSession#getClientAddress()
+    /**
+     * {@inheritDoc}
      */
     public SocketAddress getClientAddress()
     {
-        // TODO Auto-generated method stub
-        return null;
+        if ( ioSession != null )
+        {
+            return ioSession.getRemoteAddress();
+        }
+        else
+        {
+            return null;
+        }
     }
 
 
@@ -421,13 +442,19 @@ public class DefaultCoreSession implemen
     }
 
 
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.CoreSession#getServiceAddress()
+    /**
+     * {@inheritDoc}
      */
     public SocketAddress getServiceAddress()
     {
-        // TODO Auto-generated method stub
-        return null;
+        if ( ioSession != null )
+        {
+            return ioSession.getServiceAddress();
+        }
+        else
+        {
+            return null;
+        }
     }
 
 

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/BindRequestHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/BindRequestHandler.java?rev=1485239&r1=1485238&r2=1485239&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/BindRequestHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/BindRequestHandler.java Wed May 22 15:10:10 2013
@@ -45,6 +45,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.api.OperationEnum;
 import org.apache.directory.server.core.api.entry.ClonedServerEntry;
 import org.apache.directory.server.core.api.interceptor.context.BindOperationContext;
+import org.apache.directory.server.core.shared.DefaultCoreSession;
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.server.ldap.LdapProtocolUtils;
 import org.apache.directory.server.ldap.LdapSession;
@@ -178,7 +179,11 @@ public class BindRequestHandler extends 
             directoryService.getOperationManager().bind( bindContext );
 
             // As a result, store the created session in the Core Session
-            ldapSession.setCoreSession( bindContext.getSession() );
+            CoreSession coreSession = bindContext.getSession();
+            ldapSession.setCoreSession( coreSession );
+
+            // Store the IoSession in the coreSession
+            ( ( DefaultCoreSession ) coreSession ).setIoSession( bindContext.getIoSession() );
 
             // And set the current state accordingly
             if ( !ldapSession.getCoreSession().isAnonymous() )
@@ -330,6 +335,9 @@ public class BindRequestHandler extends 
 
                     // Set the user session into the ldap session 
                     ldapSession.setCoreSession( userSession );
+
+                    // Store the IoSession in the coreSession
+                    ( ( DefaultCoreSession ) userSession ).setIoSession( ldapSession.getIoSession() );
                 }
 
                 // Mark the user as authenticated