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 2011/06/09 23:35:35 UTC

svn commit: r1134094 - in /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn: AnonymousAuthenticator.java AuthenticationInterceptor.java DelegatingAuthenticator.java SimpleAuthenticator.java StrongAuthenticator.java

Author: elecharny
Date: Thu Jun  9 21:35:34 2011
New Revision: 1134094

URL: http://svn.apache.org/viewvc?rev=1134094&view=rev
Log:
o Injected the IoSession into the BindContext
o Injected the clientAddress and serverAddress into the LdapPrincipal
o Modified the LdapPrincipal.toString() method to print the client address and server address

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AnonymousAuthenticator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/DelegatingAuthenticator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/StrongAuthenticator.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AnonymousAuthenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AnonymousAuthenticator.java?rev=1134094&r1=1134093&r2=1134094&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AnonymousAuthenticator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AnonymousAuthenticator.java Thu Jun  9 21:35:34 2011
@@ -20,11 +20,14 @@
 package org.apache.directory.server.core.authn;
 
 
+import java.net.SocketAddress;
+
 import org.apache.directory.server.core.LdapPrincipal;
 import org.apache.directory.server.core.interceptor.context.BindOperationContext;
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.shared.ldap.model.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.model.exception.LdapNoPermissionException;
+import org.apache.mina.core.session.IoSession;
 
 
 /**
@@ -53,7 +56,19 @@ public class AnonymousAuthenticator exte
         // We only allow Anonymous binds if the service allows them
         if ( getDirectoryService().isAllowAnonymousAccess() )
         {
-            return getDirectoryService().getAdminSession().getAnonymousPrincipal();
+            LdapPrincipal principal = getDirectoryService().getAdminSession().getAnonymousPrincipal();
+            
+            IoSession session = bindContext.getIoSession();
+            
+            if ( session != null )
+            {
+                SocketAddress clientAddress = session.getRemoteAddress();
+                principal.setClientAddress( clientAddress );
+                SocketAddress serverAddress = session.getServiceAddress();
+                principal.setServerAddress( serverAddress );
+            }
+            
+            return principal;
         }
         else
         {

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java?rev=1134094&r1=1134093&r2=1134094&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java Thu Jun  9 21:35:34 2011
@@ -889,7 +889,7 @@ public class AuthenticationInterceptor e
             {
                 // perform the authentication
                 LdapPrincipal principal = authenticator.authenticate( bindContext );
-
+                
                 LdapPrincipal clonedPrincipal = ( LdapPrincipal ) ( principal.clone() );
 
                 // remove creds so there is no security risk

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/DelegatingAuthenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/DelegatingAuthenticator.java?rev=1134094&r1=1134093&r2=1134094&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/DelegatingAuthenticator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/DelegatingAuthenticator.java Thu Jun  9 21:35:34 2011
@@ -20,6 +20,8 @@
 package org.apache.directory.server.core.authn;
 
 
+import java.net.SocketAddress;
+
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapConnectionFactory;
 import org.apache.directory.server.core.LdapPrincipal;
@@ -31,6 +33,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.util.Strings;
+import org.apache.mina.core.session.IoSession;
 
 
 /**
@@ -144,6 +147,16 @@ public class DelegatingAuthenticator ext
             principal = new LdapPrincipal( getDirectoryService().getSchemaManager(), bindContext.getDn(), AuthenticationLevel.SIMPLE,
                 bindContext.getCredentials() );
             
+            IoSession session = bindContext.getIoSession();
+            
+            if ( session != null )
+            {
+                SocketAddress clientAddress = session.getRemoteAddress();
+                principal.setClientAddress( clientAddress );
+                SocketAddress serverAddress = session.getServiceAddress();
+                principal.setServerAddress( serverAddress );
+            }
+            
             return principal;
 
         }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java?rev=1134094&r1=1134093&r2=1134094&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java Thu Jun  9 21:35:34 2011
@@ -20,6 +20,7 @@
 package org.apache.directory.server.core.authn;
 
 
+import java.net.SocketAddress;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.util.Arrays;
@@ -61,6 +62,7 @@ import org.apache.directory.shared.util.
 import org.apache.directory.shared.util.StringConstants;
 import org.apache.directory.shared.util.Strings;
 import org.apache.directory.shared.util.UnixCrypt;
+import org.apache.mina.core.session.IoSession;
 
 
 /**
@@ -219,6 +221,16 @@ public class SimpleAuthenticator extends
 
         LdapPrincipal principal = getStoredPassword( bindContext );
 
+        IoSession session = bindContext.getIoSession();
+        
+        if ( session != null )
+        {
+            SocketAddress clientAddress = session.getRemoteAddress();
+            principal.setClientAddress( clientAddress );
+            SocketAddress serverAddress = session.getServiceAddress();
+            principal.setServerAddress( serverAddress );
+        }
+        
         // Get the stored password, either from cache or from backend
         byte[] storedPassword = principal.getUserPassword();
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/StrongAuthenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/StrongAuthenticator.java?rev=1134094&r1=1134093&r2=1134094&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/StrongAuthenticator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/StrongAuthenticator.java Thu Jun  9 21:35:34 2011
@@ -20,10 +20,13 @@
 package org.apache.directory.server.core.authn;
 
 
+import java.net.SocketAddress;
+
 import org.apache.directory.server.core.LdapPrincipal;
 import org.apache.directory.server.core.interceptor.context.BindOperationContext;
 import org.apache.directory.shared.ldap.model.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.model.exception.LdapAuthenticationException;
+import org.apache.mina.core.session.IoSession;
 
 
 /**
@@ -52,6 +55,18 @@ public class StrongAuthenticator extends
     public LdapPrincipal authenticate( BindOperationContext bindContext ) throws LdapAuthenticationException
     {
         // Possibly check if user account is disabled, other account checks.
-        return new LdapPrincipal( getDirectoryService().getSchemaManager(), bindContext.getDn(), AuthenticationLevel.STRONG );
+        LdapPrincipal principal = new LdapPrincipal( getDirectoryService().getSchemaManager(), bindContext.getDn(), AuthenticationLevel.STRONG );
+        
+        IoSession session = bindContext.getIoSession();
+        
+        if ( session != null )
+        {
+            SocketAddress clientAddress = session.getRemoteAddress();
+            principal.setClientAddress( clientAddress );
+            SocketAddress serverAddress = session.getServiceAddress();
+            principal.setServerAddress( serverAddress );
+        }
+        
+        return principal;
     }
 }