directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r414273 - in /directory/branches/apacheds/noback-experiment: protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ server-installers/
Date Wed, 14 Jun 2006 14:38:00 GMT
Author: akarasulu
Date: Wed Jun 14 07:37:59 2006
New Revision: 414273

URL: http://svn.apache.org/viewvc?rev=414273&view=rev
Log:
bypassing calls to backend in search and bind for noback-experiment

Modified:
    directory/branches/apacheds/noback-experiment/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java
    directory/branches/apacheds/noback-experiment/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java
    directory/branches/apacheds/noback-experiment/server-installers/pom.xml

Modified: directory/branches/apacheds/noback-experiment/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/noback-experiment/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java?rev=414273&r1=414272&r2=414273&view=diff
==============================================================================
--- directory/branches/apacheds/noback-experiment/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java
(original)
+++ directory/branches/apacheds/noback-experiment/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java
Wed Jun 14 07:37:59 2006
@@ -17,29 +17,12 @@
 package org.apache.directory.server.ldap.support;
 
 
-import java.util.Hashtable;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.ldap.InitialLdapContext;
-import javax.naming.ldap.LdapContext;
-import javax.naming.spi.InitialContextFactory;
-
-import org.apache.directory.server.ldap.SessionRegistry;
-import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.message.BindRequest;
-import org.apache.directory.shared.ldap.message.Control;
 import org.apache.directory.shared.ldap.message.LdapResult;
-import org.apache.directory.shared.ldap.message.ManageDsaITControl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 
 /**
  * A single reply handler for {@link org.apache.directory.shared.ldap.message.BindRequest}s.
@@ -48,98 +31,10 @@
  */
 public class BindHandler implements MessageHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( BindHandler.class );
-    private static final Control[] EMPTY = new Control[0];
-
-
     public void messageReceived( IoSession session, Object request )
     {
-        LdapContext ctx;
         BindRequest req = ( BindRequest ) request;
         LdapResult result = req.getResultResponse().getLdapResult();
-        Hashtable env = SessionRegistry.getSingleton().getEnvironment();
-
-        // if the bind request is not simple then we freak: no strong auth yet
-        if ( !req.isSimple() )
-        {
-            result.setResultCode( ResultCodeEnum.AUTHMETHODNOTSUPPORTED );
-            result.setErrorMessage( "Only simple binds currently supported" );
-            session.write( req.getResultResponse() );
-            return;
-        }
-
-        // clone the environment first then add the required security settings
-        byte[] creds = req.getCredentials();
-
-        Hashtable cloned = ( Hashtable ) env.clone();
-        cloned.put( Context.SECURITY_PRINCIPAL, req.getName() );
-        cloned.put( Context.SECURITY_CREDENTIALS, creds );
-        cloned.put( Context.SECURITY_AUTHENTICATION, "simple" );
-
-        if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
-        {
-            cloned.put( Context.REFERRAL, "ignore" );
-        }
-        else
-        {
-            cloned.put( Context.REFERRAL, "throw" );
-        }
-
-        try
-        {
-            if ( cloned.containsKey( "server.use.factory.instance" ) )
-            {
-                InitialContextFactory factory = ( InitialContextFactory ) cloned.get( "server.use.factory.instance"
);
-
-                if ( factory == null )
-                {
-                    throw new NullPointerException( "server.use.factory.instance was set
in env but was null" );
-                }
-
-                // Bind is a special case where we have to use the referral property to deal
-                ctx = ( LdapContext ) factory.getInitialContext( cloned );
-            }
-            else
-            {
-                Control[] connCtls = ( Control[] ) req.getControls().values().toArray( EMPTY
);
-                ctx = new InitialLdapContext( cloned, connCtls );
-            }
-        }
-        catch ( NamingException e )
-        {
-            ResultCodeEnum code;
-
-            if ( e instanceof LdapException )
-            {
-                code = ( ( LdapException ) e ).getResultCode();
-                result.setResultCode( code );
-            }
-            else
-            {
-                code = ResultCodeEnum.getBestEstimate( e, req.getType() );
-                result.setResultCode( code );
-            }
-
-            String msg = "Bind failed";
-            if ( log.isDebugEnabled() )
-            {
-                msg += ":\n" + ExceptionUtils.getStackTrace( e );
-                msg += "\n\nBindRequest = \n" + req.toString();
-            }
-
-            if ( ( e.getResolvedName() != null )
-                && ( ( code == ResultCodeEnum.NOSUCHOBJECT ) || ( code == ResultCodeEnum.ALIASPROBLEM
)
-                    || ( code == ResultCodeEnum.INVALIDDNSYNTAX ) || ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM
) ) )
-            {
-                result.setMatchedDn( (LdapDN)e.getResolvedName() );
-            }
-
-            result.setErrorMessage( msg );
-            session.write( req.getResultResponse() );
-            return;
-        }
-
-        SessionRegistry.getSingleton().setLdapContext( session, ctx );
         result.setResultCode( ResultCodeEnum.SUCCESS );
         session.write( req.getResultResponse() );
     }

Modified: directory/branches/apacheds/noback-experiment/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/noback-experiment/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java?rev=414273&r1=414272&r2=414273&view=diff
==============================================================================
--- directory/branches/apacheds/noback-experiment/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java
(original)
+++ directory/branches/apacheds/noback-experiment/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java
Wed Jun 14 07:37:59 2006
@@ -22,9 +22,12 @@
 import java.util.Iterator;
 
 import javax.naming.Context;
+import javax.naming.InvalidNameException;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.ReferralException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
 import javax.naming.directory.SearchControls;
 import javax.naming.ldap.LdapContext;
 
@@ -46,6 +49,8 @@
 import org.apache.directory.shared.ldap.message.ScopeEnum;
 import org.apache.directory.shared.ldap.message.SearchRequest;
 import org.apache.directory.shared.ldap.message.SearchResponseDone;
+import org.apache.directory.shared.ldap.message.SearchResponseEntry;
+import org.apache.directory.shared.ldap.message.SearchResponseEntryImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.ArrayUtils;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
@@ -66,8 +71,15 @@
 {
     private static final Logger log = LoggerFactory.getLogger( SearchHandler.class );
     private static final String DEREFALIASES_KEY = "java.naming.ldap.derefAliases";
+    private Attributes entry;
+    private LdapDN entryDn;
 
-
+    public SearchHandler()
+    {
+        entry = new BasicAttributes( "objectClass", "top", true );
+        entryDn = new LdapDN();
+    }
+    
     /**
      * Builds the JNDI search controls for a SearchRequest.
      *  
@@ -113,6 +125,20 @@
      */
     public void messageReceived( IoSession session, Object request )
     {
+        SearchResponseEntry respEntry;
+        respEntry = new SearchResponseEntryImpl( ( ( SearchRequest) request ).getMessageId()
);
+        respEntry.setAttributes( entry );
+        respEntry.setObjectName( entryDn );
+        session.write( respEntry );
+        
+        SearchResponseDone respDone = ( SearchResponseDone ) ( ( SearchRequest) request ).getResultResponse();
+        respDone.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
+        session.write( respDone );
+        
+        if ( true ) return;
+        
+        // ================================================
+        
     	if ( log.isDebugEnabled() )
     	{
     		log.debug( "Message received : " + request.toString() );

Modified: directory/branches/apacheds/noback-experiment/server-installers/pom.xml
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/noback-experiment/server-installers/pom.xml?rev=414273&r1=414272&r2=414273&view=diff
==============================================================================
--- directory/branches/apacheds/noback-experiment/server-installers/pom.xml (original)
+++ directory/branches/apacheds/noback-experiment/server-installers/pom.xml Wed Jun 14 07:37:59
2006
@@ -128,11 +128,13 @@
               <installationBundleId>Binaries</installationBundleId>
             </packagedFile>
           </packagedFiles>
+<!--
           <svnBaseUrl>
             http://svn.apache.org/repos/asf/directory/branches/apacheds/1.0
           </svnBaseUrl>
           <packageSources>true</packageSources>
           <packageDocs>true</packageDocs>
+-->
           <applicationClass>
             org.apache.ldap.server.Service
           </applicationClass>



Mime
View raw message