directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r587139 - in /directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind: AbstractSaslCallbackHandler.java CramMd5CallbackHandler.java DigestMd5CallbackHandler.java GssapiCallbackHandler.java
Date Mon, 22 Oct 2007 16:20:50 GMT
Author: elecharny
Date: Mon Oct 22 09:20:48 2007
New Revision: 587139

URL: http://svn.apache.org/viewvc?rev=587139&view=rev
Log:
Some cleanup in the code (reorganization, switching from log to LOG, using BindRequest instead
of Object)

Modified:
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/AbstractSaslCallbackHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/CramMd5CallbackHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/DigestMd5CallbackHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/GssapiCallbackHandler.java

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/AbstractSaslCallbackHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/AbstractSaslCallbackHandler.java?rev=587139&r1=587138&r2=587139&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/AbstractSaslCallbackHandler.java
(original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/AbstractSaslCallbackHandler.java
Mon Oct 22 09:20:48 2007
@@ -56,21 +56,28 @@
  */
 public abstract class AbstractSaslCallbackHandler implements CallbackHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( AbstractSaslCallbackHandler.class
);
+    /** The logger instance */
+    private static final Logger LOG = LoggerFactory.getLogger( AbstractSaslCallbackHandler.class
);
 
+    /** An empty control array */ 
     private static final MutableControl[] EMPTY = new MutableControl[0];
 
     private String username;
     private String realm;
+    protected final DirectoryService directoryService;
 
 
+    /**
+     * Creates a new instance of AbstractSaslCallbackHandler.
+     *
+     * @param directoryService
+     */
     protected AbstractSaslCallbackHandler( DirectoryService directoryService )
     {
         this.directoryService = directoryService;
     }
 
 
-
     /**
      * Implementors use this method to access the username resulting from a callback.
      * Callback default name will be username, eg 'hnelson', for CRAM-MD5 and DIGEST-MD5.
@@ -92,8 +99,6 @@
         return realm;
     }
 
-    protected final DirectoryService directoryService;
-
     /**
      * Implementors set the password based on a lookup, using the username and
      * realm as keys.
@@ -133,23 +138,23 @@
         {
             Callback callback = callbacks[i];
 
-            if ( log.isDebugEnabled() )
+            if ( LOG.isDebugEnabled() )
             {
-                log.debug( "Processing callback " + ( i + 1 ) + " of " + callbacks.length
+ ":  "
+                LOG.debug( "Processing callback " + ( i + 1 ) + " of " + callbacks.length
+ ":  "
                         + callback.getClass().toString() );
             }
 
             if ( callback instanceof NameCallback )
             {
                 NameCallback nameCB = ( NameCallback ) callback;
-                log.debug( "NameCallback default name:  {}", nameCB.getDefaultName() );
+                LOG.debug( "NameCallback default name:  {}", nameCB.getDefaultName() );
 
                 username = nameCB.getDefaultName();
             }
             else if ( callback instanceof RealmCallback )
             {
                 RealmCallback realmCB = ( RealmCallback ) callback;
-                log.debug( "RealmCallback default text:  {}", realmCB.getDefaultText() );
+                LOG.debug( "RealmCallback default text:  {}", realmCB.getDefaultText() );
 
                 realm = realmCB.getDefaultText();
             }
@@ -169,17 +174,17 @@
 
                 // hnelson (CRAM-MD5, DIGEST-MD5)
                 // hnelson@EXAMPLE.COM (GSSAPI)
-                log.debug( "AuthorizeCallback authnID:  {}", authorizeCB.getAuthenticationID()
);
+                LOG.debug( "AuthorizeCallback authnID:  {}", authorizeCB.getAuthenticationID()
);
 
                 // hnelson (CRAM-MD5, DIGEST-MD5)
                 // hnelson@EXAMPLE.COM (GSSAPI)
-                log.debug( "AuthorizeCallback authzID:  {}", authorizeCB.getAuthorizationID()
);
+                LOG.debug( "AuthorizeCallback authzID:  {}", authorizeCB.getAuthorizationID()
);
 
                 // null (CRAM-MD5, DIGEST-MD5, GSSAPI)
-                log.debug( "AuthorizeCallback authorizedID:  {}", authorizeCB.getAuthorizedID()
);
+                LOG.debug( "AuthorizeCallback authorizedID:  {}", authorizeCB.getAuthorizedID()
);
 
                 // false (CRAM-MD5, DIGEST-MD5, GSSAPI)
-                log.debug( "AuthorizeCallback isAuthorized:  {}", authorizeCB.isAuthorized()
);
+                LOG.debug( "AuthorizeCallback isAuthorized:  {}", authorizeCB.isAuthorized()
);
 
                 authorize( authorizeCB );
             }
@@ -192,20 +197,19 @@
      * duration of a session.
      * 
      * @param session The current session.
-     * @param message The current message.
+     * @param bindRequest The current BindRequest.
      * @param env An environment to be used to acquire an {@link LdapContext}.
      * @return An {@link LdapContext} for the client.
      */
-    protected LdapContext getContext( IoSession session, Object message, Hashtable<String,
Object> env )
+    protected LdapContext getContext( IoSession session, BindRequest bindRequest, Hashtable<String,
Object> env )
     {
-        BindRequest request = ( BindRequest ) message;
-        LdapResult result = request.getResultResponse().getLdapResult();
+        LdapResult result = bindRequest.getResultResponse().getLdapResult();
 
         LdapContext ctx = null;
 
         try
         {
-            MutableControl[] connCtls = request.getControls().values().toArray( EMPTY );
+            MutableControl[] connCtls = bindRequest.getControls().values().toArray( EMPTY
);
             env.put( DirectoryService.JNDI_KEY, directoryService );
             ctx = new InitialLdapContext( env, connCtls );
         }
@@ -220,16 +224,16 @@
             }
             else
             {
-                code = ResultCodeEnum.getBestEstimate( e, request.getType() );
+                code = ResultCodeEnum.getBestEstimate( e, bindRequest.getType() );
                 result.setResultCode( code );
             }
 
             String msg = "Bind failed: " + e.getMessage();
 
-            if ( log.isDebugEnabled() )
+            if ( LOG.isDebugEnabled() )
             {
                 msg += ":\n" + ExceptionUtils.getStackTrace( e );
-                msg += "\n\nBindRequest = \n" + request.toString();
+                msg += "\n\nBindRequest = \n" + bindRequest.toString();
             }
 
             if ( ( e.getResolvedName() != null )
@@ -240,7 +244,7 @@
             }
 
             result.setErrorMessage( msg );
-            session.write( request.getResultResponse() );
+            session.write( bindRequest.getResultResponse() );
             ctx = null;
         }
 

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/CramMd5CallbackHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/CramMd5CallbackHandler.java?rev=587139&r1=587138&r2=587139&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/CramMd5CallbackHandler.java
(original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/CramMd5CallbackHandler.java
Mon Oct 22 09:20:48 2007
@@ -21,6 +21,7 @@
 
 
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.shared.ldap.message.BindRequest;
 import org.apache.mina.common.IoSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -40,7 +41,7 @@
     private static final Logger LOG = LoggerFactory.getLogger( CramMd5CallbackHandler.class
);
 
     private IoSession session;
-    private Object message;
+    private BindRequest bindRequest;
 
     private String bindDn;
     private String userPassword;
@@ -53,11 +54,11 @@
      * @param message the bind message
      * @param directoryService the directory service core
      */
-    public CramMd5CallbackHandler( DirectoryService directoryService,  IoSession session,
Object message )
+    public CramMd5CallbackHandler( DirectoryService directoryService,  IoSession session,
BindRequest bindRequest )
     {
         super( directoryService );
         this.session = session;
-        this.message = message;
+        this.bindRequest = bindRequest;
     }
 
 
@@ -65,7 +66,7 @@
     {
         Hashtable<String, Object> env = getEnvironment( session );
 
-        LdapContext ctx = getContext( session, message, env );
+        LdapContext ctx = getContext( session, bindRequest, env );
 
         GetBindDn getDn = new GetBindDn( username );
 

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/DigestMd5CallbackHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/DigestMd5CallbackHandler.java?rev=587139&r1=587138&r2=587139&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/DigestMd5CallbackHandler.java
(original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/DigestMd5CallbackHandler.java
Mon Oct 22 09:20:48 2007
@@ -21,6 +21,7 @@
 
 
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.shared.ldap.message.BindRequest;
 import org.apache.mina.common.IoSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -40,7 +41,7 @@
     private static final Logger LOG = LoggerFactory.getLogger( DigestMd5CallbackHandler.class
);
 
     private IoSession session;
-    private Object message;
+    private BindRequest bindRequest;
 
     private String bindDn;
     private String userPassword;
@@ -53,11 +54,11 @@
      * @param message the message
      * @param directoryService the directory service core
      */
-    public DigestMd5CallbackHandler( DirectoryService directoryService, IoSession session,
Object message )
+    public DigestMd5CallbackHandler( DirectoryService directoryService, IoSession session,
BindRequest bindRequest )
     {
         super( directoryService );
         this.session = session;
-        this.message = message;
+        this.bindRequest = bindRequest;
     }
 
 
@@ -65,7 +66,7 @@
     {
         Hashtable<String, Object> env = getEnvironment( session );
 
-        LdapContext ctx = getContext( session, message, env );
+        LdapContext ctx = getContext( session, bindRequest, env );
 
         // TODO - Use realm with multi-realm support.
 

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/GssapiCallbackHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/GssapiCallbackHandler.java?rev=587139&r1=587138&r2=587139&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/GssapiCallbackHandler.java
(original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/GssapiCallbackHandler.java
Mon Oct 22 09:20:48 2007
@@ -23,6 +23,7 @@
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStoreEntry;
 import org.apache.directory.server.kerberos.shared.store.operations.GetPrincipal;
+import org.apache.directory.shared.ldap.message.BindRequest;
 import org.apache.mina.common.IoSession;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -43,7 +44,7 @@
     private static final Logger LOG = LoggerFactory.getLogger( GssapiCallbackHandler.class
);
 
     private IoSession session;
-    private Object message;
+    private BindRequest bindRequest;
 
 
     /**
@@ -53,11 +54,11 @@
      * @param message the bind message
      * @param directoryService the directory service core
      */
-    public GssapiCallbackHandler( DirectoryService directoryService, IoSession session, Object
message )
+    public GssapiCallbackHandler( DirectoryService directoryService, IoSession session, BindRequest
bindRequest )
     {
         super( directoryService );
         this.session = session;
-        this.message = message;
+        this.bindRequest = bindRequest;
     }
 
 
@@ -74,7 +75,7 @@
 
         Hashtable<String, Object> env = getEnvironment( session );
 
-        LdapContext ctx = getContext( session, message, env );
+        LdapContext ctx = getContext( session, bindRequest, env );
 
         String username = authorizeCB.getAuthorizationID();
 



Mime
View raw message