directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r664463 - in /directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap: ./ handlers/ handlers/bind/
Date Sun, 08 Jun 2008 07:27:28 GMT
Author: akarasulu
Date: Sun Jun  8 00:27:28 2008
New Revision: 664463

URL: http://svn.apache.org/viewvc?rev=664463&view=rev
Log:
fixed extended handler and other handler issues but many problems remain with search, sasl
and extended operation handlers

Added:
    directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewExtendedHandler.java
    directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewUnbindHandler.java
      - copied, changed from r664456, directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/DefaultUnbindHandler.java
Removed:
    directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/DefaultExtendedHandler.java
    directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/DefaultUnbindHandler.java
    directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/ExtendedHandler.java
    directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/UnbindHandler.java
Modified:
    directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/ExtendedOperationHandler.java
    directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/LdapServer.java
    directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewSearchHandler.java
    directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/CramMd5CallbackHandler.java
    directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/CramMd5MechanismHandler.java

Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/ExtendedOperationHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/ExtendedOperationHandler.java?rev=664463&r1=664462&r2=664463&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/ExtendedOperationHandler.java
(original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/ExtendedOperationHandler.java
Sun Jun  8 00:27:28 2008
@@ -65,9 +65,9 @@
 
 
     /**
-     * Sets the LDAP provider for this extendedOperation handler.
+     * Sets the LDAP server for this extendedOperation handler.
      * 
-     * @param provider the ldap protocol provider 
+     * @param ldapServer the ldap protocol server
      */
-    void setLdapProvider( LdapServer provider );
+    void setLdapServer( LdapServer ldapServer );
 }

Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/LdapServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/LdapServer.java?rev=664463&r1=664462&r2=664463&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/LdapServer.java
(original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/LdapServer.java
Sun Jun  8 00:27:28 2008
@@ -33,27 +33,17 @@
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.partition.PartitionNexus;
 import org.apache.directory.server.core.security.CoreKeyStoreSpi;
-import org.apache.directory.server.newldap.handlers.CompareHandler;
-import org.apache.directory.server.newldap.handlers.DefaultCompareHandler;
-import org.apache.directory.server.newldap.handlers.DefaultDeleteHandler;
-import org.apache.directory.server.newldap.handlers.DefaultExtendedHandler;
-import org.apache.directory.server.newldap.handlers.DefaultModifyDnHandler;
-import org.apache.directory.server.newldap.handlers.DefaultModifyHandler;
-import org.apache.directory.server.newldap.handlers.DefaultSearchHandler;
-import org.apache.directory.server.newldap.handlers.DefaultUnbindHandler;
-import org.apache.directory.server.newldap.handlers.DeleteHandler;
-import org.apache.directory.server.newldap.handlers.ExtendedHandler;
+import org.apache.directory.server.newldap.handlers.NewExtendedHandler;
+import org.apache.directory.server.newldap.handlers.NewModifyHandler;
+import org.apache.directory.server.newldap.handlers.NewSearchHandler;
+import org.apache.directory.server.newldap.handlers.NewUnbindHandler;
 import org.apache.directory.server.newldap.handlers.LdapRequestHandler;
-import org.apache.directory.server.newldap.handlers.ModifyDnHandler;
-import org.apache.directory.server.newldap.handlers.ModifyHandler;
 import org.apache.directory.server.newldap.handlers.NewAbandonHandler;
 import org.apache.directory.server.newldap.handlers.NewAddHandler;
 import org.apache.directory.server.newldap.handlers.NewBindHandler;
 import org.apache.directory.server.newldap.handlers.NewCompareHandler;
 import org.apache.directory.server.newldap.handlers.NewDeleteHandler;
 import org.apache.directory.server.newldap.handlers.NewModifyDnHandler;
-import org.apache.directory.server.newldap.handlers.SearchHandler;
-import org.apache.directory.server.newldap.handlers.UnbindHandler;
 import org.apache.directory.server.newldap.handlers.bind.*;
 import org.apache.directory.server.newldap.handlers.ssl.LdapsInitializer;
 import org.apache.directory.server.protocol.shared.DirectoryBackedService;
@@ -191,11 +181,11 @@
     private LdapRequestHandler<BindRequest> bindHandler;
     private LdapRequestHandler<CompareRequest> compareHandler;
     private LdapRequestHandler<DeleteRequest> deleteHandler;
-    private ExtendedHandler extendedHandler;
-    private ModifyHandler modifyHandler;
+    private LdapRequestHandler<ExtendedRequest> extendedHandler;
+    private LdapRequestHandler<ModifyRequest> modifyHandler;
     private LdapRequestHandler<ModifyDnRequest> modifyDnHandler;
-    private SearchHandler searchHandler;
-    private UnbindHandler unbindHandler;
+    private LdapRequestHandler<SearchRequest> searchHandler;
+    private LdapRequestHandler<UnbindRequest> unbindHandler;
 
 
     /** the underlying provider codec factory */
@@ -270,12 +260,12 @@
         
         if ( getExtendedHandler() == null )
         {
-            setExtendedHandler( new DefaultExtendedHandler() );
+            setExtendedHandler( new NewExtendedHandler() );
         }
         
         if ( getModifyHandler() == null )
         {
-            setModifyHandler( new DefaultModifyHandler() );
+            setModifyHandler( new NewModifyHandler() );
         }
         
         if ( getModifyDnHandler() == null )
@@ -285,12 +275,12 @@
         
         if ( getSearchHandler() == null )
         {
-            setSearchHandler( new DefaultSearchHandler() );
+            setSearchHandler( new NewSearchHandler() );
         }
         
         if ( getUnbindHandler() == null )
         {
-            setUnbindHandler( new DefaultUnbindHandler() );
+            setUnbindHandler( new NewUnbindHandler() );
         }
     }
 
@@ -407,9 +397,8 @@
 
         for ( ExtendedOperationHandler h : extendedOperationHandlers )
         {
-            extendedHandler.addHandler( h );
             LOG.info( "Added Extended Request Handler: " + h.getOid() );
-            h.setLdapProvider( this );
+            h.setLdapServer( this );
             nexus.registerSupportedExtensions( h.getExtensionOids() );
         }
 
@@ -480,8 +469,7 @@
     {
         if ( started )
         {
-            extendedHandler.addHandler( eoh );
-            eoh.setLdapProvider( this );
+            eoh.setLdapServer( this );
             PartitionNexus nexus = getDirectoryService().getPartitionNexus();
             nexus.registerSupportedExtensions( eoh.getExtensionOids() );
         }
@@ -501,27 +489,20 @@
      */
     public void removeExtendedOperationHandler( String oid )
     {
-        if ( started )
-        {
-            extendedHandler.removeHandler( oid );
+        // need to do something like this to make this work right
+        //            PartitionNexus nexus = getDirectoryService().getPartitionNexus();
+        //            nexus.unregisterSupportedExtensions( eoh.getExtensionOids() );
 
-            // need to do something like this to make this work right
-            //            PartitionNexus nexus = getDirectoryService().getPartitionNexus();
-            //            nexus.unregisterSupportedExtensions( eoh.getExtensionOids() );
-        }
-        else
+        ExtendedOperationHandler handler = null;
+        for ( ExtendedOperationHandler h : extendedOperationHandlers )
         {
-            ExtendedOperationHandler handler = null;
-            for ( ExtendedOperationHandler h : extendedOperationHandlers )
+            if ( h.getOid().equals( oid ) )
             {
-                if ( h.getOid().equals( oid ) )
-                {
-                    handler = h;
-                    break;
-                }
+                handler = h;
+                break;
             }
-            extendedOperationHandlers.remove( handler );
         }
+        extendedOperationHandlers.remove( handler );
     }
 
 
@@ -535,18 +516,11 @@
      */
     public ExtendedOperationHandler getExtendedOperationHandler( String oid )
     {
-        if ( started )
-        {
-            return extendedHandler.getHandler( oid );
-        }
-        else
+        for ( ExtendedOperationHandler h : extendedOperationHandlers )
         {
-            for ( ExtendedOperationHandler h : extendedOperationHandlers )
+            if ( h.getOid().equals( oid ) )
             {
-                if ( h.getOid().equals( oid ) )
-                {
-                    return h;
-                }
+                return h;
             }
         }
 
@@ -555,18 +529,6 @@
 
 
     /**
-     * Returns a {@link Map} of all registered OID-{@link ExtendedOperationHandler}
-     * pairs.
-     *
-     * @return map of all extended operation handlers
-     */
-    public Map<String,ExtendedOperationHandler> getExtendedOperationHandlerMap()
-    {
-        return extendedHandler.getHandlerMap();
-    }
-
-
-    /**
      * Returns <tt>true</tt> if LDAPS is enabled.
      *
      * @return True if LDAPS is enabled.
@@ -934,39 +896,37 @@
     }
 
 
-    public ExtendedHandler getExtendedHandler()
+    public LdapRequestHandler<ExtendedRequest> getExtendedHandler()
     {
         return extendedHandler;
     }
 
 
-    public void setExtendedHandler( ExtendedHandler extendedHandler )
+    public void setExtendedHandler( LdapRequestHandler<ExtendedRequest> extendedHandler
)
     {
         this.handler.removeMessageHandler( ExtendedRequest.class );
         this.extendedHandler = extendedHandler;
         this.extendedHandler.setLdapServer( this );
-        //noinspection unchecked
         this.handler.addMessageHandler( ExtendedRequest.class, this.extendedHandler );
     }
 
 
-    public ModifyHandler getModifyHandler()
+    public LdapRequestHandler<ModifyRequest> getModifyHandler()
     {
         return modifyHandler;
     }
 
 
-    public void setModifyHandler( ModifyHandler modifyHandler )
+    public void setModifyHandler( LdapRequestHandler<ModifyRequest> modifyHandler )
     {
         this.handler.removeMessageHandler( ModifyRequest.class );
         this.modifyHandler = modifyHandler;
-        this.modifyHandler.setProtocolProvider( this );
-        //noinspection unchecked
+        this.modifyHandler.setLdapServer( this );
         this.handler.addMessageHandler( ModifyRequest.class, this.modifyHandler );
     }
 
 
-    public ModifyDnHandler getModifyDnHandler()
+    public LdapRequestHandler<ModifyDnRequest> getModifyDnHandler()
     {
         return modifyDnHandler;
     }
@@ -981,34 +941,32 @@
     }
 
 
-    public SearchHandler getSearchHandler()
+    public LdapRequestHandler<SearchRequest> getSearchHandler()
     {
         return searchHandler;
     }
 
 
-    public void setSearchHandler( SearchHandler searchHandler )
+    public void setSearchHandler( LdapRequestHandler<SearchRequest> searchHandler )
     {
         this.handler.removeMessageHandler( SearchRequest.class );
         this.searchHandler = searchHandler;
-        this.searchHandler.setProtocolProvider( this );
-        //noinspection unchecked
+        this.searchHandler.setLdapServer( this );
         this.handler.addMessageHandler( SearchRequest.class, this.searchHandler );
     }
 
 
-    public UnbindHandler getUnbindHandler()
+    public LdapRequestHandler<UnbindRequest> getUnbindHandler()
     {
         return unbindHandler;
     }
 
 
-    public void setUnbindHandler( UnbindHandler unbindHandler )
+    public void setUnbindHandler( LdapRequestHandler<UnbindRequest> unbindHandler )
     {
         this.handler.removeMessageHandler( UnbindRequest.class );
         this.unbindHandler = unbindHandler;
-        this.unbindHandler.setProtocolProvider( this );
-        //noinspection unchecked
+        this.unbindHandler.setLdapServer( this );
         this.handler.addMessageHandler( UnbindRequest.class, this.unbindHandler );
     }
 
@@ -1084,6 +1042,18 @@
             ldapSession.abandonAllOutstandingRequests();
         }
         
+        if ( ! session.isClosing() || session.isConnected() )
+        {
+            try
+            {
+                session.close();
+            }
+            catch ( Throwable t )
+            {
+                LOG.warn( "Failed to close IoSession for LdapSession." );
+            }
+        }
+        
         return ldapSession;
     }
     

Added: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewExtendedHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewExtendedHandler.java?rev=664463&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewExtendedHandler.java
(added)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewExtendedHandler.java
Sun Jun  8 00:27:28 2008
@@ -0,0 +1,71 @@
+    /*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.newldap.handlers;
+
+
+import org.apache.directory.server.newldap.ExtendedOperationHandler;
+import org.apache.directory.server.newldap.LdapSession;
+import org.apache.directory.shared.ldap.message.ExtendedRequest;
+import org.apache.directory.shared.ldap.message.ExtendedResponse;
+import org.apache.directory.shared.ldap.message.LdapResult;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
+
+
+/**
+* A single reply handler for {@link ExtendedRequest}s.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 664302 $
+ */
+public class NewExtendedHandler extends LdapRequestHandler<ExtendedRequest>
+{
+    public void handle( LdapSession session, ExtendedRequest req ) throws Exception
+    {
+        ExtendedOperationHandler handler = getLdapServer().getExtendedOperationHandler( req.getOid()
);
+
+        if ( handler == null )
+        {
+            // As long as no extended operations are implemented, send appropriate
+            // error back to the client.
+            String msg = "Unrecognized extended operation EXTENSION_OID: " + req.getOid();
+            LdapResult result = req.getResultResponse().getLdapResult();
+            result.setResultCode( ResultCodeEnum.PROTOCOL_ERROR );
+            result.setErrorMessage( msg );
+            session.getIoSession().write( req.getResultResponse() );
+            return;
+        }
+        
+        try
+        {
+            handler.handleExtendedOperation( session, req );
+        }
+        catch ( Exception e )
+        {
+            LdapResult result = req.getResultResponse().getLdapResult();
+            result.setResultCode( ResultCodeEnum.OTHER );
+            result.setErrorMessage( "Extended operation handler for the specified EXTENSION_OID
(" + req.getOid()
+                + ") has failed to process your request:\n" + ExceptionUtils.getStackTrace(
e ) );
+            ExtendedResponse resp = ( ExtendedResponse ) req.getResultResponse();
+            resp.setResponse( new byte[0] );
+            session.getIoSession().write( req.getResultResponse() );
+        }
+    }
+}
\ No newline at end of file

Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewSearchHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewSearchHandler.java?rev=664463&r1=664462&r2=664463&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewSearchHandler.java
(original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewSearchHandler.java
Sun Jun  8 00:27:28 2008
@@ -69,7 +69,7 @@
  */
 public class NewSearchHandler extends LdapRequestHandler<SearchRequest>
 {
-    private static final Logger LOG = LoggerFactory.getLogger( SearchHandler.class );
+    private static final Logger LOG = LoggerFactory.getLogger( NewSearchHandler.class );
 
     
     /** Speedup for logs */

Copied: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewUnbindHandler.java
(from r664456, directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/DefaultUnbindHandler.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewUnbindHandler.java?p2=directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewUnbindHandler.java&p1=directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/DefaultUnbindHandler.java&r1=664456&r2=664463&rev=664463&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/DefaultUnbindHandler.java
(original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/NewUnbindHandler.java
Sun Jun  8 00:27:28 2008
@@ -20,15 +20,12 @@
 package org.apache.directory.server.newldap.handlers;
 
 
-import org.apache.directory.server.core.jndi.ServerLdapContext;
+import org.apache.directory.server.newldap.LdapSession;
 import org.apache.directory.shared.ldap.message.UnbindRequest;
-import org.apache.mina.common.IoSession;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.naming.NamingException;
-import javax.naming.ldap.LdapContext;
-
 
 /**
  * A no reply protocol handler implementation for LDAP {@link
@@ -37,31 +34,22 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class DefaultUnbindHandler extends UnbindHandler
+public class NewUnbindHandler extends LdapRequestHandler<UnbindRequest>
 {
-    private static final Logger LOG = LoggerFactory.getLogger( UnbindHandler.class );
+    private static final Logger LOG = LoggerFactory.getLogger( NewUnbindHandler.class );
 
 
-    public void unbindMessageReceived( IoSession session, UnbindRequest request ) throws
Exception
+    public void handle( LdapSession session, UnbindRequest request ) throws Exception
     {
         try
         {
-            LdapContext ctx = getSessionRegistry().getLdapContext( session, null, false );
-
-            if ( ctx != null )
-            {
-                if ( ctx instanceof ServerLdapContext && ( ( ServerLdapContext )
ctx ).getService().isStarted() )
-                {
-                    ( ( ServerLdapContext ) ctx ).ldapUnbind();
-                }
-                ctx.close();
-            }
-            getSessionRegistry().terminateSession( session );
-            getSessionRegistry().remove( session );
+            session.getCoreSession().unbind( request );
+            session.getIoSession().close();
+            ldapServer.removeLdapSession( session.getIoSession() );
         }
-        catch ( NamingException e )
+        catch ( Throwable t )
         {
-            LOG.error( "failed to unbind session properly", e );
+            LOG.error( "failed to unbind session properly", t );
         }
     }
 }
\ No newline at end of file

Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/CramMd5CallbackHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/CramMd5CallbackHandler.java?rev=664463&r1=664462&r2=664463&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/CramMd5CallbackHandler.java
(original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/CramMd5CallbackHandler.java
Sun Jun  8 00:27:28 2008
@@ -21,15 +21,14 @@
 
 
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.newldap.LdapSession;
 import org.apache.directory.shared.ldap.message.BindRequest;
-import org.apache.mina.common.IoSession;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.naming.Context;
-import javax.naming.ldap.LdapContext;
 import javax.security.sasl.AuthorizeCallback;
-import java.util.Hashtable;
 
 
 /**
@@ -40,8 +39,7 @@
 {
     private static final Logger LOG = LoggerFactory.getLogger( CramMd5CallbackHandler.class
);
 
-    private IoSession session;
-    private BindRequest bindRequest;
+    private LdapSession session;
 
     private String bindDn;
     private String userPassword;
@@ -54,24 +52,19 @@
      * @param bindRequest the bind message
      * @param directoryService the directory service core
      */
-    public CramMd5CallbackHandler( DirectoryService directoryService,  IoSession session,
BindRequest bindRequest )
+    public CramMd5CallbackHandler( DirectoryService directoryService,  LdapSession session,
BindRequest bindRequest )
     {
         super( directoryService );
         this.session = session;
-        this.bindRequest = bindRequest;
     }
 
 
     protected String lookupPassword( String username, String realm )
     {
-        Hashtable<String, Object> env = getEnvironment( session );
-
-        LdapContext ctx = getContext( session, bindRequest, env );
-
         GetBindDn getDn = new GetBindDn( username );
 
         // Don't actually want the entry, rather the hacked in dn.
-        getDn.execute( ctx, null );
+        getDn.execute( session, null );
         bindDn = getDn.getBindDn();
         userPassword = getDn.getUserPassword();
 
@@ -86,7 +79,7 @@
             LOG.debug( "Converted username " + getUsername() + " to DN " + bindDn + " with
password " + userPassword );
         }
 
-        session.setAttribute( Context.SECURITY_PRINCIPAL, bindDn );
+        session.getIoSession().setAttribute( Context.SECURITY_PRINCIPAL, bindDn );
 
         authorizeCB.setAuthorizedID( bindDn );
         authorizeCB.setAuthorized( true );

Modified: directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/CramMd5MechanismHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/CramMd5MechanismHandler.java?rev=664463&r1=664462&r2=664463&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/CramMd5MechanismHandler.java
(original)
+++ directory/apacheds/branches/bigbang/protocol-newldap/src/main/java/org/apache/directory/server/newldap/handlers/bind/CramMd5MechanismHandler.java
Sun Jun  8 00:27:28 2008
@@ -21,6 +21,7 @@
 
 
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.newldap.LdapSession;
 import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
 import org.apache.directory.shared.ldap.message.BindRequest;
 import org.apache.mina.common.IoSession;
@@ -50,17 +51,18 @@
     }
 
     
-    public SaslServer handleMechanism( IoSession session, BindRequest bindRequest ) throws
Exception
+    public SaslServer handleMechanism( LdapSession session, BindRequest bindRequest ) throws
Exception
     {
         SaslServer ss;
 
-        if ( session.containsAttribute( SASL_CONTEXT ) )
+        // TODO - don't use session properties anymore
+        if ( session.getIoSession().containsAttribute( SASL_CONTEXT ) )
         {
-            ss = ( SaslServer ) session.getAttribute( SASL_CONTEXT );
+            ss = ( SaslServer ) session.getIoSession().getAttribute( SASL_CONTEXT );
         }
         else
         {
-            String saslHost = ( String ) session.getAttribute( "saslHost" );
+            String saslHost = ( String ) session.getIoSession().getAttribute( "saslHost"
);
 
             /*
              * Sasl will throw an exception is Sasl.QOP properties are set.
@@ -71,7 +73,7 @@
             CallbackHandler callbackHandler = new CramMd5CallbackHandler( directoryService,
session, bindRequest );
 
             ss = Sasl.createSaslServer( SupportedSaslMechanisms.CRAM_MD5, "ldap", saslHost,
saslProps, callbackHandler );
-            session.setAttribute( SASL_CONTEXT, ss );
+            session.getIoSession().setAttribute( SASL_CONTEXT, ss );
         }
 
         return ss;



Mime
View raw message