directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r580637 - in /directory/apacheds/branches/bigbang: core/src/main/java/org/apache/directory/server/core/authn/ core/src/main/java/org/apache/directory/server/core/configuration/ server-jndi/src/main/java/org/apache/directory/server/configura...
Date Sat, 29 Sep 2007 20:17:12 GMT
Author: djencks
Date: Sat Sep 29 13:17:11 2007
New Revision: 580637

URL: http://svn.apache.org/viewvc?rev=580637&view=rev
Log:
DIRSERVER-1074 remove AuthenticatorConfiguration

Removed:
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/AuthenticatorConfiguration.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/MutableAuthenticatorConfiguration.java
Modified:
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AbstractAuthenticator.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/Authenticator.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/MutableStartupConfiguration.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java
    directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/MutableServerStartupConfiguration.java

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AbstractAuthenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AbstractAuthenticator.java?rev=580637&r1=580636&r2=580637&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AbstractAuthenticator.java
(original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AbstractAuthenticator.java
Sat Sep 29 13:17:11 2007
@@ -24,7 +24,6 @@
 import javax.naming.spi.InitialContextFactory;
 
 import org.apache.directory.server.core.DirectoryServiceConfiguration;
-import org.apache.directory.server.core.configuration.AuthenticatorConfiguration;
 import org.apache.directory.server.core.jndi.ServerContext;
 import org.apache.directory.shared.ldap.aci.AuthenticationLevel;
 import org.apache.directory.shared.ldap.name.LdapDN;
@@ -39,7 +38,6 @@
 public abstract class AbstractAuthenticator implements Authenticator
 {
     private DirectoryServiceConfiguration factoryCfg;
-    private AuthenticatorConfiguration cfg;
 
     /** authenticator type */
     private String authenticatorType;
@@ -65,16 +63,6 @@
         return factoryCfg;
     }
 
-
-    /**
-     * Returns the configuration of this authenticator.
-     */
-    public AuthenticatorConfiguration getConfiguration()
-    {
-        return cfg;
-    }
-
-
     public String getAuthenticatorType()
     {
         return authenticatorType;
@@ -86,11 +74,10 @@
      * <tt>configuration</tt>, and calls {@link #doInit()} method.
      * Please put your initialization code into {@link #doInit()}.
      */
-    public final void init( DirectoryServiceConfiguration factoryCfg, AuthenticatorConfiguration
cfg )
+    public final void init( DirectoryServiceConfiguration factoryCfg )
         throws NamingException
     {
         this.factoryCfg = factoryCfg;
-        this.cfg = cfg;
         doInit();
     }
 
@@ -117,7 +104,6 @@
         finally
         {
             this.factoryCfg = null;
-            this.cfg = null;
         }
     }
 

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java?rev=580637&r1=580636&r2=580637&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java
(original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java
Sat Sep 29 13:17:11 2007
@@ -36,7 +36,6 @@
 import javax.naming.directory.SearchResult;
 
 import org.apache.directory.server.core.DirectoryServiceConfiguration;
-import org.apache.directory.server.core.configuration.AuthenticatorConfiguration;
 import org.apache.directory.server.core.interceptor.BaseInterceptor;
 import org.apache.directory.server.core.interceptor.Interceptor;
 import org.apache.directory.server.core.interceptor.NextInterceptor;
@@ -59,7 +58,6 @@
 import org.apache.directory.server.core.jndi.LdapJndiProperties;
 import org.apache.directory.server.core.jndi.ServerContext;
 import org.apache.directory.shared.ldap.exception.LdapAuthenticationException;
-import org.apache.directory.shared.ldap.exception.LdapConfigurationException;
 import org.apache.directory.shared.ldap.message.MessageTypeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
@@ -103,11 +101,11 @@
         this.factoryCfg = factoryCfg;
 
         // Register all authenticators
-        for ( AuthenticatorConfiguration config:factoryCfg.getStartupConfiguration().getAuthenticatorConfigurations()
)
+        for ( Authenticator authenticator:factoryCfg.getStartupConfiguration().getAuthenticators()
)
         {
             try
             {
-                this.register( config );
+                register( authenticator );
             }
             catch ( Exception e )
             {
@@ -140,61 +138,13 @@
         authenticators.clear();
     }
 
-    
-    private Authenticator instantiateAuthenticator( AuthenticatorConfiguration cfg ) throws
NamingException
-    {
-        if ( cfg == null )
-        {
-            throw new IllegalStateException( "Cannot get instance of authenticator without
a proper " +
-                    "configuration." );
-        }
-        
-        Class<?> authenticatorClass;
-        try
-        {
-            authenticatorClass = Class.forName( cfg.getAuthenticatorClassName() );
-        }
-        catch ( ClassNotFoundException e )
-        {
-            String msg = "Could not load authenticator implementation class '" 
-                + cfg.getAuthenticatorClassName() + "' for authenticator with name " + cfg.getName();
-            log.error( msg );
-            throw new LdapConfigurationException( msg, e );
-        }
-        
-        Authenticator authenticator = null;
-        try
-        {
-            authenticator = ( Authenticator ) authenticatorClass.newInstance();
-        }
-        catch ( InstantiationException e )
-        {
-            String msg = "No default constructor in authenticator implementation class '"

-                + cfg.getAuthenticatorClassName() + "' for authenticator with name " + cfg.getName();
-            log.error( msg );
-            throw new LdapConfigurationException( msg, e );
-        }
-        catch ( IllegalAccessException e )
-        {
-            String msg = "Default constructor for authenticator implementation class '" 
-                + cfg.getAuthenticatorClassName() + "' for authenticator with name " 
-                + cfg.getName() + " is not publicly accessible.";
-            log.error( msg );
-            throw new LdapConfigurationException( msg, e );
-        }
-        
-        return authenticator;
-    }
-    
-
     /**
      * Initializes the specified {@link Authenticator} and registers it to
      * this service.
      */
-    private void register( AuthenticatorConfiguration cfg ) throws NamingException
+    private void register( Authenticator authenticator ) throws NamingException
     {
-        Authenticator authenticator = instantiateAuthenticator( cfg );
-        authenticator.init( factoryCfg, cfg );
+        authenticator.init( factoryCfg );
 
         Collection<Authenticator> authenticatorList = getAuthenticators( authenticator.getAuthenticatorType()
);
         

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/Authenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/Authenticator.java?rev=580637&r1=580636&r2=580637&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/Authenticator.java
(original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/Authenticator.java
Sat Sep 29 13:17:11 2007
@@ -24,7 +24,6 @@
 import javax.naming.NamingException;
 
 import org.apache.directory.server.core.DirectoryServiceConfiguration;
-import org.apache.directory.server.core.configuration.AuthenticatorConfiguration;
 import org.apache.directory.server.core.jndi.ServerContext;
 import org.apache.directory.server.core.partition.PartitionNexus;
 import org.apache.directory.shared.ldap.name.LdapDN;
@@ -59,7 +58,7 @@
      * Called by {@link AuthenticationService} to indicate that this
      * authenticator is being placed into service.
      */
-    public void init( DirectoryServiceConfiguration factoryCfg, AuthenticatorConfiguration
cfg ) throws NamingException;
+    public void init( DirectoryServiceConfiguration factoryCfg ) throws NamingException;
 
 
     /**

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/MutableStartupConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/MutableStartupConfiguration.java?rev=580637&r1=580636&r2=580637&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/MutableStartupConfiguration.java
(original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/MutableStartupConfiguration.java
Sat Sep 29 13:17:11 2007
@@ -24,7 +24,7 @@
 import java.util.List;
 import java.util.Set;
 
-import org.apache.directory.shared.ldap.ldif.Entry;
+import org.apache.directory.server.core.authn.Authenticator;
 
 
 /**
@@ -80,9 +80,9 @@
      *
      * @param authenticators
      */
-    public void setAuthenticatorConfigurations( Set<AuthenticatorConfiguration> authenticators
)
+    public void setAuthenticators( Set<Authenticator> authenticators )
     {
-        super.setAuthenticatorConfigurations( authenticators );
+        super.setAuthenticators( authenticators );
     }
 
     /**

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java?rev=580637&r1=580636&r2=580637&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java
(original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java
Sat Sep 29 13:17:11 2007
@@ -20,7 +20,20 @@
 package org.apache.directory.server.core.configuration;
 
 
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.naming.directory.Attributes;
+
+import org.apache.directory.server.core.authn.AnonymousAuthenticator;
 import org.apache.directory.server.core.authn.AuthenticationService;
+import org.apache.directory.server.core.authn.Authenticator;
+import org.apache.directory.server.core.authn.SimpleAuthenticator;
+import org.apache.directory.server.core.authn.StrongAuthenticator;
 import org.apache.directory.server.core.authz.AuthorizationService;
 import org.apache.directory.server.core.authz.DefaultAuthorizationService;
 import org.apache.directory.server.core.collective.CollectiveAttributeService;
@@ -37,10 +50,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.naming.directory.Attributes;
-import java.io.File;
-import java.util.*;
-
 
 /**
  * A {@link Configuration} that starts up ApacheDS.
@@ -52,12 +61,6 @@
  */
 public class StartupConfiguration extends Configuration
 {
-    /** fully qualified class name of the string authenticator implementation */
-    private static final String STRONG_AUTHENTICATOR = "org.apache.directory.server.core.authn.StrongAuthenticator";
-    /** fully qualified class name of the simple authenticator implementation */
-    private static final String SIMPLE_AUTHENTICATOR = "org.apache.directory.server.core.authn.SimpleAuthenticator";
-    /** fully qualified class name of the anonymous authenticator implementation */
-    private static final String ANONYMOUS_AUTHENTICATOR = "org.apache.directory.server.core.authn.AnonymousAuthenticator";
 
     /** The logger for this class */
     private static final Logger log = LoggerFactory.getLogger( StartupConfiguration.class
);
@@ -77,7 +80,7 @@
     private int maxThreads = MAX_THREADS_DEFAULT; // set to default value
     private int maxSizeLimit = MAX_SIZE_LIMIT_DEFAULT; // set to default value
     private int maxTimeLimit = MAX_TIME_LIMIT_DEFAULT; // set to default value (milliseconds)
-    private Set authenticatorConfigurations; // Set<AuthenticatorConfiguration>
+    private Set<Authenticator> authenticators;
     private List<Interceptor> interceptors;
     private PartitionConfiguration systemPartitionConfiguration;
     private Set<? extends PartitionConfiguration> partitionConfigurations =
@@ -90,7 +93,7 @@
      */
     public StartupConfiguration()
     {
-        setDefaultAuthenticatorConfigurations();
+        setDefaultAuthenticators();
         setDefaultInterceptorConfigurations();
     }
 
@@ -101,26 +104,26 @@
      */
     public StartupConfiguration(String instanceId)
     {
-        setDefaultAuthenticatorConfigurations();
+        setDefaultAuthenticators();
         setDefaultInterceptorConfigurations();
         setInstanceId( instanceId );
     }
 
 
-    private void setDefaultAuthenticatorConfigurations()
+    private void setDefaultAuthenticators()
     {
-        Set<AuthenticatorConfiguration> set = new HashSet<AuthenticatorConfiguration>();
+        Set<Authenticator> set = new HashSet<Authenticator>();
 
         // Anonymous
-        set.add( new MutableAuthenticatorConfiguration( "Anonymous", ANONYMOUS_AUTHENTICATOR
) );
+        set.add( new AnonymousAuthenticator() );
 
         // Simple
-        set.add( new MutableAuthenticatorConfiguration( "Simple", SIMPLE_AUTHENTICATOR )
);
+        set.add( new SimpleAuthenticator() );
 
         // Strong
-        set.add( new MutableAuthenticatorConfiguration( "Strong", STRONG_AUTHENTICATOR )
);
+        set.add( new StrongAuthenticator() );
 
-        setAuthenticatorConfigurations( set );
+        setAuthenticators( set );
     }
 
 
@@ -159,45 +162,24 @@
 
 
     /**
-     * Returns {@link AuthenticatorConfiguration}s to use for authenticating clients.
+     * Returns {@link Authenticator}s to use for authenticating clients.
      */
     @SuppressWarnings("unchecked")
-    public Set<AuthenticatorConfiguration> getAuthenticatorConfigurations()
+    public Set<Authenticator> getAuthenticators()
     {
-        Set<AuthenticatorConfiguration> cloned =
-            new HashSet<AuthenticatorConfiguration>( authenticatorConfigurations.size()
);
-        cloned.addAll( authenticatorConfigurations );
-        return cloned;
+        return new HashSet<Authenticator>( authenticators );
     }
 
 
     /**
-     * Sets {@link AuthenticatorConfiguration}s to use for authenticating clients.
+     * Sets {@link Authenticator}s to use for authenticating clients.
      */
-    protected void setAuthenticatorConfigurations( Set<AuthenticatorConfiguration>
authenticatorConfigurations )
+    protected void setAuthenticators( Set<Authenticator> authenticators )
     {
-        Set<String> names = new HashSet<String>();
-
-        // Loop through all the configurations to check if we do not have duplicated authenticators.
-        for ( AuthenticatorConfiguration cfg:authenticatorConfigurations )
-        {
-            cfg.validate();
-
-            String name = cfg.getName();
-
-            if ( names.contains( name ) )
-            {
-                // TODO Not sure that it worth to throw an excpetion here. We could simply
ditch the
-                // duplicated authenticator, trace a warning and that's it.
-                log.error( "The authenticator nammed '{}' has already been registred.", name
);
-                throw new ConfigurationException( "Duplicate authenticator name: " + name
);
-            }
-
-            names.add( name );
-        }
-
-        // The set has been checked, so we can now register it
-        this.authenticatorConfigurations = authenticatorConfigurations;
+        //At one time there was a check for duplicate names.  I think it is more appropriate
to
+        // implement equals correctly on Authenticator instances and the fact we have a Set
will do
+        // the work for us.
+        this.authenticators = authenticators;
     }
 
 

Modified: directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/MutableServerStartupConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/MutableServerStartupConfiguration.java?rev=580637&r1=580636&r2=580637&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/MutableServerStartupConfiguration.java
(original)
+++ directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/MutableServerStartupConfiguration.java
Sat Sep 29 13:17:11 2007
@@ -26,8 +26,8 @@
 
 import org.apache.directory.server.changepw.ChangePasswordConfiguration;
 import org.apache.directory.server.core.configuration.PartitionConfiguration;
-import org.apache.directory.server.core.configuration.AuthenticatorConfiguration;
 import org.apache.directory.server.core.interceptor.Interceptor;
+import org.apache.directory.server.core.authn.Authenticator;
 import org.apache.directory.server.dns.DnsConfiguration;
 import org.apache.directory.server.kerberos.kdc.KdcConfiguration;
 import org.apache.directory.server.ldap.LdapConfiguration;
@@ -120,11 +120,11 @@
     /**
      * @org.apache.xbean.Property nestedType="org.apache.directory.server.core.configuration.AuthenticatorConfiguration"
      *
-     * @param authenticatorConfigurations
+     * @param authenticators
      */
-    public void setAuthenticatorConfigurations( Set<AuthenticatorConfiguration> authenticatorConfigurations
)
+    public void setAuthenticators( Set<Authenticator> authenticators )
     {
-        super.setAuthenticatorConfigurations( authenticatorConfigurations );
+        super.setAuthenticators( authenticators );
     }
 
     /**



Mime
View raw message