directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r190353 - in /directory/apacheds/branches/direve-158/core/src: main/java/org/apache/ldap/server/ main/java/org/apache/ldap/server/jndi/ test/org/apache/ldap/server/jndi/
Date Mon, 13 Jun 2005 05:33:10 GMT
Author: trustin
Date: Sun Jun 12 22:33:08 2005
New Revision: 190353

URL: http://svn.apache.org/viewcvs?rev=190353&view=rev
Log:
Fixed: Failing tests

Modified:
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/AbstractTestCase.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryContext.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryContext.java
    directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SyncTest.java

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/AbstractTestCase.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/AbstractTestCase.java?rev=190353&r1=190352&r2=190353&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/AbstractTestCase.java
(original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/AbstractTestCase.java
Sun Jun 12 22:33:08 2005
@@ -247,6 +247,7 @@
         Hashtable env = new Hashtable( cfg.toJndiEnvironment() );
         env.put( Context.SECURITY_PRINCIPAL, user );
         env.put( Context.SECURITY_CREDENTIALS, passwd );
+        env.put( Context.SECURITY_AUTHENTICATION, "simple" );
         return setSysRoot( env );
     }
 

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java?rev=190353&r1=190352&r2=190353&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java
(original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java
Sun Jun 12 22:33:08 2005
@@ -66,10 +66,50 @@
     {
         Configuration cfg = Configuration.toConfiguration( env );
         
-        String username = null;
-        String password = null;
-        String providerUrl = null;
+        String principal;
+        String credential;
+        String authentication;
+        String providerUrl;
 
+        // Remove properties that can be changed
+        Object value = env.remove( Context.SECURITY_PRINCIPAL );
+        if( value == null )
+        {
+            principal = null;
+        }
+        else
+        {
+            principal = value.toString();
+        }
+        
+        value = env.remove( Context.SECURITY_CREDENTIALS );
+        if( value == null )
+        {
+            credential = null;
+        }
+        else
+        {
+            credential = value.toString();
+        }
+        
+        value = env.remove( Context.SECURITY_AUTHENTICATION );
+        if( value == null )
+        {
+            authentication = "none";
+        }
+        else
+        {
+            authentication = value.toString();
+        }
+
+        value = env.remove( Context.PROVIDER_URL );
+        if( value == null )
+        {
+            value = "";
+        }
+        providerUrl = value.toString();
+
+        // Execute configuration
         if( cfg instanceof ShutdownConfiguration )
         {
             provider.shutdown();
@@ -80,27 +120,6 @@
         }
         else if( cfg instanceof StartupConfiguration )
         {
-            // fire up the backend subsystem if we need to
-            Object value = env.remove( Context.SECURITY_PRINCIPAL );
-            if( value == null )
-            {
-                value = "";
-            }
-            username = value.toString();
-            
-            value = env.remove( Context.SECURITY_CREDENTIALS );
-            if( value == null )
-            {
-                value = "";
-            }
-            password = value.toString();
-
-            value = env.remove( Context.PROVIDER_URL );
-            if( value == null )
-            {
-                value = "";
-            }
-            providerUrl = value.toString();
             ( ( DefaultContextFactoryContext ) provider ).startup( this, env );
         }
         else
@@ -108,7 +127,7 @@
             throw new NamingException( "Unknown configuration: " + cfg );
         }
         
-        return provider.getJndiContext( username, password, providerUrl );
+        return provider.getJndiContext( principal, credential, authentication, providerUrl
);
     }
     
     protected abstract void beforeStartup( ContextFactoryContext ctx ) throws NamingException;

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryContext.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryContext.java?rev=190353&r1=190352&r2=190353&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryContext.java
(original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/ContextFactoryContext.java
Sun Jun 12 22:33:08 2005
@@ -65,9 +65,8 @@
      */
     boolean isStarted();
     
-    Context getJndiContext() throws NamingException;
     Context getJndiContext( String rootDN ) throws NamingException;
-    Context getJndiContext( String username, String password, String rootDN ) throws NamingException;
+    Context getJndiContext( String principal, String credential, String authentication, String
rootDN ) throws NamingException;
 
     /**
      * Invokes {@link Invocation} to this context.

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryContext.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryContext.java?rev=190353&r1=190352&r2=190353&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryContext.java
(original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryContext.java
Sun Jun 12 22:33:08 2005
@@ -146,41 +146,35 @@
     // BackendSubsystem Interface Method Implemetations
     // ------------------------------------------------------------------------
 
-    public Context getJndiContext() throws NamingException
-    {
-        return this.getJndiContext( "" );
-    }
-
     public Context getJndiContext( String rootDN ) throws NamingException
     {
-        return this.getJndiContext( "", "", rootDN );
+        return this.getJndiContext( null, null, "none", rootDN );
     }
-    
-    public synchronized Context getJndiContext( String username, String password, String
rootDN ) throws NamingException
+
+    public synchronized Context getJndiContext( String principal, String credential, String
authentication, String rootDN ) throws NamingException
     {
+        checkSecuritySettings( principal, credential, authentication );
+        
         if ( !started )
         {
             return new DeadContext();
         }
         
-        if( username == null )
+        Hashtable environment = getEnvironment();
+        if( principal != null )
         {
-            username = "";
+            environment.put( Context.SECURITY_PRINCIPAL, principal );
         }
         
-        if( password == null )
+        if( credential != null )
         {
-            password = "";
+            environment.put( Context.SECURITY_CREDENTIALS, credential );
         }
         
         if( rootDN == null )
         {
             rootDN = "";
         }
-
-        Hashtable environment = getEnvironment();
-        environment.put( Context.SECURITY_PRINCIPAL, username );
-        environment.put( Context.SECURITY_CREDENTIALS, password );
         environment.put( Context.PROVIDER_URL, rootDN );
 
         return new ServerLdapContext( proxy, environment );
@@ -195,8 +189,6 @@
 
         StartupConfiguration cfg = ( StartupConfiguration ) Configuration.toConfiguration(
env );
 
-        checkSecuritySettings( env );
-
         if ( isAnonymous( env ) )
         {
             env.put( PRINCIPAL, "" );
@@ -325,63 +317,57 @@
      *
      * @throws javax.naming.NamingException if the security settings are not correctly configured.
      */
-    private void checkSecuritySettings( Hashtable env ) throws NamingException
+    private void checkSecuritySettings( String principal, String credential, String authentication
) throws NamingException
     {
-        if ( env.containsKey( TYPE ) && env.get( TYPE ) != null )
+        if( authentication == null )
         {
-            /*
-             * If bind is simple make sure we have the credentials and the
-             * principal name set within the environment, otherwise complain
-             */
-            if ( env.get( TYPE ).equals( "simple" ) )
-            {
-                if ( !env.containsKey( CREDS ) )
-                {
-                    throw new LdapConfigurationException( "missing required "
-                            + CREDS + " property for simple authentication" );
-                }
-
-                if ( !env.containsKey( PRINCIPAL ) )
-                {
-                    throw new LdapConfigurationException( "missing required "
-                            + PRINCIPAL + " property for simple authentication" );
-                }
-            }
-            /*
-             * If bind is none make sure credentials and the principal
-             * name are NOT set within the environment, otherwise complain
-             */
-            else if ( env.get( TYPE ).equals( "none" ) )
+            authentication = "";
+        }
+        
+        /*
+         * If bind is simple make sure we have the credentials and the
+         * principal name set within the environment, otherwise complain
+         */
+        if ( "simple".equalsIgnoreCase( authentication ) )
+        {
+            if ( credential == null )
             {
-                if ( env.containsKey( CREDS ) )
-                {
-                    throw new LdapConfigurationException( "ambiguous bind "
-                            + "settings encountered where bind is anonymous yet "
-                            + CREDS + " property is set" );
-                }
-                if ( env.containsKey( PRINCIPAL ) )
-                {
-                    throw new LdapConfigurationException( "ambiguous bind "
-                            + "settings encountered where bind is anonymous yet "
-                            + PRINCIPAL + " property is set" );
-                }
+                throw new LdapConfigurationException( "missing required "
+                        + CREDS + " property for simple authentication" );
             }
-            /*
-             * If bind is anything other than simple or none we need to
-             * complain because SASL is not a supported auth method yet
-             */
-            else
+
+            if ( principal == null )
             {
-                throw new LdapAuthenticationNotSupportedException( ResultCodeEnum.AUTHMETHODNOTSUPPORTED
);
+                throw new LdapConfigurationException( "missing required "
+                        + PRINCIPAL + " property for simple authentication" );
             }
         }
-        else if ( env.containsKey( CREDS ) )
+        /*
+         * If bind is none make sure credentials and the principal
+         * name are NOT set within the environment, otherwise complain
+         */
+        else if ( "none".equalsIgnoreCase( authentication ) )
         {
-            if ( !env.containsKey( PRINCIPAL ) )
+            if ( credential != null )
             {
-                throw new LdapConfigurationException( "credentials provided "
-                        + "without principal name property: " + PRINCIPAL );
+                throw new LdapConfigurationException( "ambiguous bind "
+                        + "settings encountered where bind is anonymous yet "
+                        + CREDS + " property is set" );
             }
+            if ( principal != null )
+            {
+                throw new LdapConfigurationException( "ambiguous bind "
+                        + "settings encountered where bind is anonymous yet "
+                        + PRINCIPAL + " property is set" );
+            }
+        }
+        else
+        {
+            /*
+             * If bind is anything other than simple or none we need to
+             * complain because SASL is not a supported auth method yet
+             */
+            throw new LdapAuthenticationNotSupportedException( "Unknown authentication type:
'" + authentication + "'", ResultCodeEnum.AUTHMETHODNOTSUPPORTED );
         }
     }
 

Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SyncTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SyncTest.java?rev=190353&r1=190352&r2=190353&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SyncTest.java
(original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/SyncTest.java
Sun Jun 12 22:33:08 2005
@@ -53,6 +53,7 @@
     public void testPostSyncLookup() throws Exception
     {
         sysRoot = setSysRoot( "uid=admin,ou=system", "secret", new SyncConfiguration() );
+        
         Attributes users = sysRoot.getAttributes( "ou=users" );
 
         // assert making sure the entry is ok



Mime
View raw message