directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r190710 - in /directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi: AbstractContextFactory.java ContextFactoryContext.java DefaultContextFactoryContext.java
Date Wed, 15 Jun 2005 05:51:17 GMT
Author: trustin
Date: Tue Jun 14 22:51:14 2005
New Revision: 190710

URL: http://svn.apache.org/viewcvs?rev=190710&view=rev
Log:
Fixed: Bind failure via networking layer

I changed the type of credential to byte[], and performed proper conversion between strings
and byte[].

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryContext.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryContext.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java?rev=190710&r1=190709&r2=190710&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java
Tue Jun 14 22:51:14 2005
@@ -24,6 +24,7 @@
 import javax.naming.spi.InitialContextFactory;
 
 import org.apache.ldap.server.configuration.Configuration;
+import org.apache.ldap.server.configuration.ConfigurationException;
 import org.apache.ldap.server.configuration.ShutdownConfiguration;
 import org.apache.ldap.server.configuration.StartupConfiguration;
 import org.apache.ldap.server.configuration.SyncConfiguration;
@@ -65,36 +66,51 @@
     public final synchronized Context getInitialContext( Hashtable env ) throws NamingException
     {
         Configuration cfg = Configuration.toConfiguration( env );
-        
-        String principal;
-        String credential;
-        String authentication;
-        String providerUrl;
-
         env = ( Hashtable ) env.clone();
+        
+        String principal = extractPrincipal( env );
+        byte[] credential = extractCredential( env );
+        String authentication = extractAuthentication( env );
+        String providerUrl = extractProviderUrl( env );
 
-        // Remove properties that can be changed
-        Object value = env.remove( Context.SECURITY_PRINCIPAL );
-        if( value == null )
+        // Execute configuration
+        if( cfg instanceof ShutdownConfiguration )
         {
-            principal = null;
+            provider.shutdown();
         }
-        else
+        else if( cfg instanceof SyncConfiguration )
         {
-            principal = value.toString();
+            provider.sync();
         }
-        
-        value = env.remove( Context.SECURITY_CREDENTIALS );
-        if( value == null )
+        else if( cfg instanceof StartupConfiguration )
         {
-            credential = null;
+            ( ( DefaultContextFactoryContext ) provider ).startup( this, env );
         }
         else
         {
-            credential = value.toString();
+            throw new NamingException( "Unknown configuration: " + cfg );
         }
         
-        value = env.remove( Context.SECURITY_AUTHENTICATION );
+        return provider.getJndiContext( principal, credential, authentication, providerUrl
);
+    }
+
+    private String extractProviderUrl( Hashtable env )
+    {
+        String providerUrl;
+        Object value;
+        value = env.remove( Context.PROVIDER_URL );
+        if( value == null )
+        {
+            value = "";
+        }
+        providerUrl = value.toString();
+        return providerUrl;
+    }
+
+    private String extractAuthentication( Hashtable env )
+    {
+        String authentication;
+        Object value = env.remove( Context.SECURITY_AUTHENTICATION );
         if( value == null )
         {
             authentication = "none";
@@ -103,33 +119,45 @@
         {
             authentication = value.toString();
         }
+        return authentication;
+    }
 
-        value = env.remove( Context.PROVIDER_URL );
+    private byte[] extractCredential( Hashtable env )
+    {
+        byte[] credential;
+        Object value = env.remove( Context.SECURITY_CREDENTIALS );
         if( value == null )
         {
-            value = "";
+            credential = null;
         }
-        providerUrl = value.toString();
-
-        // Execute configuration
-        if( cfg instanceof ShutdownConfiguration )
+        else if( value instanceof String )
         {
-            provider.shutdown();
+            credential = ( ( String ) value ).getBytes();
         }
-        else if( cfg instanceof SyncConfiguration )
+        else if( value instanceof byte[] )
         {
-            provider.sync();
+            credential = ( byte[] ) value;
         }
-        else if( cfg instanceof StartupConfiguration )
+        else
         {
-            ( ( DefaultContextFactoryContext ) provider ).startup( this, env );
+            throw new ConfigurationException( "Can't convert '" + Context.SECURITY_CREDENTIALS
+ "' to byte[]." );
+        }
+        return credential;
+    }
+
+    private String extractPrincipal( Hashtable env )
+    {
+        String principal;
+        Object value = env.remove( Context.SECURITY_PRINCIPAL );
+        if( value == null )
+        {
+            principal = null;
         }
         else
         {
-            throw new NamingException( "Unknown configuration: " + cfg );
+            principal = value.toString();
         }
-        
-        return provider.getJndiContext( principal, credential, authentication, providerUrl
);
+        return principal;
     }
     
     protected abstract void beforeStartup( ContextFactoryContext ctx ) throws NamingException;

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryContext.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryContext.java?rev=190710&r1=190709&r2=190710&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryContext.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryContext.java
Tue Jun 14 22:51:14 2005
@@ -66,7 +66,7 @@
     boolean isStarted();
     
     Context getJndiContext( String rootDN ) throws NamingException;
-    Context getJndiContext( String principal, String credential, String authentication, String
rootDN ) throws NamingException;
+    Context getJndiContext( String principal, byte[] credential, String authentication, String
rootDN ) throws NamingException;
 
     /**
      * Invokes {@link Invocation} to this context.

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryContext.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryContext.java?rev=190710&r1=190709&r2=190710&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryContext.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryContext.java
Tue Jun 14 22:51:14 2005
@@ -136,7 +136,7 @@
         return this.getJndiContext( null, null, "none", rootDN );
     }
 
-    public synchronized Context getJndiContext( String principal, String credential, String
authentication, String rootDN ) throws NamingException
+    public synchronized Context getJndiContext( String principal, byte[] credential, String
authentication, String rootDN ) throws NamingException
     {
         checkSecuritySettings( principal, credential, authentication );
         
@@ -295,7 +295,7 @@
      *
      * @throws javax.naming.NamingException if the security settings are not correctly configured.
      */
-    private void checkSecuritySettings( String principal, String credential, String authentication
) throws NamingException
+    private void checkSecuritySettings( String principal, byte[] credential, String authentication
) throws NamingException
     {
         if( authentication == null )
         {



Mime
View raw message