directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r423126 - in /directory/branches/apacheds/optimization: core/src/main/java/org/apache/directory/server/core/ core/src/main/java/org/apache/directory/server/core/jndi/ core/src/test/java/org/apache/directory/server/core/authz/support/ core/s...
Date Tue, 18 Jul 2006 16:21:57 GMT
Author: akarasulu
Date: Tue Jul 18 09:21:50 2006
New Revision: 423126

URL: http://svn.apache.org/viewvc?rev=423126&view=rev
Log:
avoiding addition parse of bindDn

Added:
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/PropertyKeys.java
Modified:
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryServiceConfiguration.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/DirectoryService.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/AbstractContextFactory.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/LdapJndiProperties.java
    directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java
    directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java
    directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/SessionRegistry.java
    directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=423126&r1=423125&r2=423126&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
Tue Jul 18 09:21:50 2006
@@ -35,6 +35,7 @@
 import org.apache.directory.server.core.interceptor.InterceptorChain;
 import org.apache.directory.server.core.jndi.AbstractContextFactory;
 import org.apache.directory.server.core.jndi.DeadContext;
+import org.apache.directory.server.core.jndi.PropertyKeys;
 import org.apache.directory.server.core.jndi.ServerLdapContext;
 import org.apache.directory.server.core.partition.DefaultDirectoryPartitionNexus;
 import org.apache.directory.server.core.partition.DirectoryPartitionNexus;
@@ -119,12 +120,12 @@
 
     public Context getJndiContext( String rootDN ) throws NamingException
     {
-        return this.getJndiContext( null, null, "none", rootDN );
+        return this.getJndiContext( null, null, null, "none", rootDN );
     }
 
 
-    public synchronized Context getJndiContext( String principal, byte[] credential, String
authentication,
-        String rootDN ) throws NamingException
+    public synchronized Context getJndiContext( LdapDN principalDn, String principal, byte[]
credential, 
+        String authentication, String rootDN ) throws NamingException
     {
         checkSecuritySettings( principal, credential, authentication );
 
@@ -158,7 +159,11 @@
             rootDN = "";
         }
         environment.put( Context.PROVIDER_URL, rootDN );
-
+        
+        if ( principalDn != null )
+        {
+            environment.put( PropertyKeys.PARSED_BIND_DN, principalDn );
+        }
         return new ServerLdapContext( this, environment );
     }
 
@@ -682,7 +687,10 @@
         String principal = AbstractContextFactory.getPrincipal( env );
         byte[] credential = AbstractContextFactory.getCredential( env );
         String authentication = AbstractContextFactory.getAuthentication( env );
-        ServerLdapContext ctx = ( ServerLdapContext ) getJndiContext( principal, credential,
authentication, "" );
+        
+        LdapDN principalDn = ( LdapDN ) env.get( PropertyKeys.PARSED_BIND_DN );
+        ServerLdapContext ctx = ( ServerLdapContext ) 
+            getJndiContext( principalDn, principal, credential, authentication, "" );
 
         Iterator i = startupConfiguration.getTestEntries().iterator();
         while ( i.hasNext() )

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryServiceConfiguration.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryServiceConfiguration.java?rev=423126&r1=423125&r2=423126&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryServiceConfiguration.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryServiceConfiguration.java
Tue Jul 18 09:21:50 2006
@@ -26,6 +26,7 @@
 import org.apache.directory.server.core.interceptor.InterceptorChain;
 import org.apache.directory.server.core.partition.DirectoryPartitionNexus;
 import org.apache.directory.server.core.schema.GlobalRegistries;
+import org.apache.directory.shared.ldap.name.LdapDN;
 
 
 /**
@@ -105,9 +106,9 @@
     }
 
 
-    public Context getJndiContext( String principal, byte[] credential, String authentication,
String baseName )
-        throws NamingException
+    public Context getJndiContext( LdapDN principalDn, String principal, byte[] credential,

+        String authentication, String baseName ) throws NamingException
     {
-        return parent.getJndiContext( principal, credential, authentication, baseName );
+        return parent.getJndiContext( principalDn, principal, credential, authentication,
baseName );
     }
 }

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/DirectoryService.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/DirectoryService.java?rev=423126&r1=423125&r2=423126&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/DirectoryService.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/DirectoryService.java
Tue Jul 18 09:21:50 2006
@@ -30,6 +30,7 @@
 import org.apache.directory.server.core.configuration.Configuration;
 import org.apache.directory.server.core.jndi.AbstractContextFactory;
 import org.apache.directory.server.core.partition.DirectoryPartition;
+import org.apache.directory.shared.ldap.name.LdapDN;
 
 
 /**
@@ -134,6 +135,6 @@
      * @param authentication {@link Context#SECURITY_AUTHENTICATION} value
      * @throws NamingException if failed to create a context
      */
-    public abstract Context getJndiContext( String principal, byte[] credential, String authentication,
String baseName )
-        throws NamingException;
+    public abstract Context getJndiContext( LdapDN principalDn, String principal, byte[]
credential, 
+        String authentication, String baseName ) throws NamingException;
 }

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/AbstractContextFactory.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/AbstractContextFactory.java?rev=423126&r1=423125&r2=423126&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/AbstractContextFactory.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/AbstractContextFactory.java
Tue Jul 18 09:21:50 2006
@@ -34,6 +34,7 @@
 import org.apache.directory.server.core.configuration.StartupConfiguration;
 import org.apache.directory.server.core.configuration.SyncConfiguration;
 import org.apache.directory.server.core.partition.DirectoryPartitionNexusProxy;
+import org.apache.directory.shared.ldap.name.LdapDN;
 
 
 /**
@@ -82,6 +83,16 @@
     {
         Configuration cfg = Configuration.toConfiguration( env );
         env = ( Hashtable ) env.clone();
+        
+        LdapDN principalDn = null;
+        if ( env.containsKey( Context.SECURITY_PRINCIPAL ) )
+        {
+            if ( env.get( Context.SECURITY_PRINCIPAL ) instanceof LdapDN )
+            {
+                principalDn = ( LdapDN ) env.get( Context.SECURITY_PRINCIPAL );
+            }
+        }
+        
         String principal = getPrincipal( env );
         byte[] credential = getCredential( env );
         String authentication = getAuthentication( env );
@@ -104,13 +115,14 @@
         }
         else if ( cfg instanceof AddPartitionConfiguration )
         {
-            new DirectoryPartitionNexusProxy( service.getJndiContext( principal, credential,
authentication, "" ),
+            new DirectoryPartitionNexusProxy( 
+                service.getJndiContext( principalDn, principal, credential, authentication,
"" ),
                 service ).addContextPartition( ( ( AddPartitionConfiguration ) cfg )
                 .getDirectoryPartitionConfiguration() );
         }
         else if ( cfg instanceof RemovePartitionConfiguration )
         {
-            Context ctx = service.getJndiContext( principal, credential, authentication,
"" );
+            Context ctx = service.getJndiContext( principalDn, principal, credential, authentication,
"" );
             DirectoryPartitionNexusProxy proxy = new DirectoryPartitionNexusProxy( ctx, service
);
             proxy.removeContextPartition( ( ( RemovePartitionConfiguration ) cfg ).getSuffix()
);
         }
@@ -119,7 +131,7 @@
             throw new NamingException( "Unknown configuration: " + cfg );
         }
 
-        return service.getJndiContext( principal, credential, authentication, providerUrl
);
+        return service.getJndiContext( principalDn, principal, credential, authentication,
providerUrl );
     }
 
 

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/LdapJndiProperties.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/LdapJndiProperties.java?rev=423126&r1=423125&r2=423126&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/LdapJndiProperties.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/LdapJndiProperties.java
Tue Jul 18 09:21:50 2006
@@ -190,25 +190,35 @@
         // Figure out and set the security principal bindDn and saslAuthId
         // -------------------------------------------------------------------
 
-        if ( principal == null )
+        if ( env.containsKey( PropertyKeys.PARSED_BIND_DN ) )
         {
-            throw new LdapConfigurationException( Context.SECURITY_PRINCIPAL + " cannot be
null." );
-        }
-
-        if ( !( principal instanceof String ) )
-        {
-            throw new LdapConfigurationException( "Don't know how to interpret " + principal.getClass()
-                + " objects for environment property " + Context.SECURITY_PRINCIPAL );
-        }
-
-        if ( ( ( String ) principal ).trim().equals( "" ) )
-        {
-            props.bindDn = LdapDN.EMPTY_LDAPDN;
+            props.bindDn = ( LdapDN ) env.get( PropertyKeys.PARSED_BIND_DN );
         }
         else
         {
-            props.bindDn = new LdapDN( ( String ) principal );
+            if ( principal == null )
+            {
+                throw new LdapConfigurationException( Context.SECURITY_PRINCIPAL + " cannot
be null." );
+            }
+    
+            if ( !( principal instanceof String ) )
+            {
+                throw new LdapConfigurationException( "Don't know how to interpret " + principal.getClass()
+                    + " objects for environment property " + Context.SECURITY_PRINCIPAL );
+            }
+    
+            if ( ( ( String ) principal ).trim().equals( "" ) )
+            {
+                props.bindDn = LdapDN.EMPTY_LDAPDN;
+            }
+            else
+            {
+                props.bindDn = new LdapDN( ( String ) principal );
+            }
         }
+        
+        
+        
 
         if ( env.get( SASL_AUTHID ) != null && props.level == AuthenticationLevel.STRONG
)
         {

Added: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/PropertyKeys.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/PropertyKeys.java?rev=423126&view=auto
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/PropertyKeys.java
(added)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/PropertyKeys.java
Tue Jul 18 09:21:50 2006
@@ -0,0 +1,29 @@
+/*
+ *   @(#) $Id$
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.core.jndi;
+
+/**
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface PropertyKeys
+{
+    public static final String PARSED_BIND_DN = "parsed.bind.dn";
+}

Modified: directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java?rev=423126&r1=423125&r2=423126&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java
(original)
+++ directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java
Tue Jul 18 09:21:50 2006
@@ -203,8 +203,8 @@
         }
 
 
-        public Context getJndiContext( String principal, byte[] credential, String authentication,
String baseName )
-            throws NamingException
+        public Context getJndiContext( LdapDN principalDn, String principal, byte[] credential,

+            String authentication, String baseName ) throws NamingException
         {
             return null; //To change body of implemented methods use File | Settings | File
Templates.
         }

Modified: directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java?rev=423126&r1=423125&r2=423126&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java
(original)
+++ directory/branches/apacheds/optimization/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java
Tue Jul 18 09:21:50 2006
@@ -474,8 +474,8 @@
         }
 
 
-        public Context getJndiContext( String principal, byte[] credential, String authentication,
String baseName )
-            throws NamingException
+        public Context getJndiContext( LdapDN principalDn, String principal, byte[] credential,

+            String authentication, String baseName ) throws NamingException
         {
             return null; //To change body of implemented methods use File | Settings | File
Templates.
         }

Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/SessionRegistry.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/SessionRegistry.java?rev=423126&r1=423125&r2=423126&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/SessionRegistry.java
(original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/SessionRegistry.java
Tue Jul 18 09:21:50 2006
@@ -118,7 +118,7 @@
      *
      * @return the registry environment
      */
-    public Hashtable getEnvironment()
+    public Hashtable getEnvironmentByCopy()
     {
         return ( Hashtable ) env.clone();
     }

Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java?rev=423126&r1=423125&r2=423126&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java
(original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java
Tue Jul 18 09:21:50 2006
@@ -26,6 +26,7 @@
 import javax.naming.spi.InitialContextFactory;
 
 import org.apache.directory.server.core.configuration.StartupConfiguration;
+import org.apache.directory.server.core.jndi.PropertyKeys;
 import org.apache.directory.server.ldap.SessionRegistry;
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.message.BindRequest;
@@ -58,7 +59,7 @@
         LdapContext ctx;
         BindRequest req = ( BindRequest ) request;
         LdapResult result = req.getResultResponse().getLdapResult();
-        Hashtable env = SessionRegistry.getSingleton().getEnvironment();
+        Hashtable env = SessionRegistry.getSingleton().getEnvironmentByCopy();
 
         // if the bind request is not simple then we freak: no strong auth yet
         if ( !req.isSimple() )
@@ -71,26 +72,25 @@
 
         // 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" );
+        env.put( Context.SECURITY_PRINCIPAL, req.getName() );
+        env.put( Context.SECURITY_CREDENTIALS, creds );
+        env.put( Context.SECURITY_AUTHENTICATION, "simple" );
+        env.put( PropertyKeys.PARSED_BIND_DN, req.getName() );
 
         if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
         {
-            cloned.put( Context.REFERRAL, "ignore" );
+            env.put( Context.REFERRAL, "ignore" );
         }
         else
         {
-            cloned.put( Context.REFERRAL, "throw" );
+            env.put( Context.REFERRAL, "throw" );
         }
 
         try
         {
-            if ( cloned.containsKey( "server.use.factory.instance" ) )
+            if ( env.containsKey( "server.use.factory.instance" ) )
             {
-                InitialContextFactory factory = ( InitialContextFactory ) cloned.get( "server.use.factory.instance"
);
+                InitialContextFactory factory = ( InitialContextFactory ) env.get( "server.use.factory.instance"
);
 
                 if ( factory == null )
                 {
@@ -98,12 +98,12 @@
                 }
 
                 // Bind is a special case where we have to use the referral property to deal
-                ctx = ( LdapContext ) factory.getInitialContext( cloned );
+                ctx = ( LdapContext ) factory.getInitialContext( env );
             }
             else
             {
                 Control[] connCtls = ( Control[] ) req.getControls().values().toArray( EMPTY
);
-                ctx = new InitialLdapContext( cloned, connCtls );
+                ctx = new InitialLdapContext( env, connCtls );
             }
         }
         catch ( NamingException e )



Mime
View raw message