You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2007/07/14 07:35:42 UTC
svn commit: r556225 - in
/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core:
authn/ configuration/
Author: akarasulu
Date: Fri Jul 13 22:35:40 2007
New Revision: 556225
URL: http://svn.apache.org/viewvc?view=rev&rev=556225
Log:
cleaning up functional object dependencies in other core configuration beans
Modified:
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/AuthenticatorConfiguration.java
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/MutableAuthenticatorConfiguration.java
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/PartitionConfiguration.java
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java?view=diff&rev=556225&r1=556224&r2=556225
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java Fri Jul 13 22:35:40 2007
@@ -52,6 +52,7 @@
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;
@@ -130,6 +131,52 @@
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
@@ -137,17 +184,18 @@
*/
private void register( AuthenticatorConfiguration cfg ) throws NamingException
{
- cfg.getAuthenticator().init( factoryCfg, cfg );
+ Authenticator authenticator = instantiateAuthenticator( cfg );
+ authenticator.init( factoryCfg, cfg );
- Collection<Authenticator> authenticatorList = getAuthenticators( cfg.getAuthenticator().getAuthenticatorType() );
+ Collection<Authenticator> authenticatorList = getAuthenticators( authenticator.getAuthenticatorType() );
if ( authenticatorList == null )
{
authenticatorList = new ArrayList<Authenticator>();
- authenticators.put( cfg.getAuthenticator().getAuthenticatorType(), authenticatorList );
+ authenticators.put( authenticator.getAuthenticatorType(), authenticatorList );
}
- authenticatorList.add( cfg.getAuthenticator() );
+ authenticatorList.add( authenticator );
}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/AuthenticatorConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/AuthenticatorConfiguration.java?view=diff&rev=556225&r1=556224&r2=556225
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/AuthenticatorConfiguration.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/AuthenticatorConfiguration.java Fri Jul 13 22:35:40 2007
@@ -32,7 +32,7 @@
public class AuthenticatorConfiguration
{
private String name;
- private Authenticator authenticator;
+ private String authenticatorClassName;
/**
@@ -44,20 +44,21 @@
/**
- * Returns the {@link Authenticator} this configuration is configuring.
+ * Returns the fully qualified class name for the Authenticator implementation
+ * class.
*/
- public Authenticator getAuthenticator()
+ public String getAuthenticatorClassName()
{
- return authenticator;
+ return authenticatorClassName;
}
/**
* Sets the {@link Authenticator} to configure.
*/
- protected void setAuthenticator( Authenticator authenticator )
+ protected void setAuthenticatorClassName( String authenticatorClassName )
{
- this.authenticator = authenticator;
+ this.authenticatorClassName = authenticatorClassName;
}
/**
@@ -66,9 +67,9 @@
* @param name The authenticator name
* @param authenticator The authenticator to register
*/
- protected void setAuthenticator( String name, Authenticator authenticator )
+ protected void setAuthenticatorClassName( String name, String authenticatorClassName )
{
- this.authenticator = authenticator;
+ this.authenticatorClassName = authenticatorClassName;
this.name = name;
}
@@ -104,9 +105,9 @@
throw new ConfigurationException( "Name is not specified." );
}
- if ( authenticator == null )
+ if ( authenticatorClassName == null )
{
- throw new ConfigurationException( "Authenticator is not specified." );
+ throw new ConfigurationException( "Authenticator class name is not specified." );
}
}
}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/MutableAuthenticatorConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/MutableAuthenticatorConfiguration.java?view=diff&rev=556225&r1=556224&r2=556225
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/MutableAuthenticatorConfiguration.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/MutableAuthenticatorConfiguration.java Fri Jul 13 22:35:40 2007
@@ -20,9 +20,6 @@
package org.apache.directory.server.core.configuration;
-import org.apache.directory.server.core.authn.Authenticator;
-
-
/**
* A mutable version of {@link AuthenticatorConfiguration}.
*
@@ -31,7 +28,6 @@
*/
public class MutableAuthenticatorConfiguration extends AuthenticatorConfiguration
{
-
/**
* Creates a new instance.
*/
@@ -39,27 +35,30 @@
{
}
+
/**
* Create and register an authenticator with its name
*
* @param name The authenticator name
* @param authenticator The authenticator to register
*/
- public MutableAuthenticatorConfiguration( String name, Authenticator authenticator )
+ public MutableAuthenticatorConfiguration( String name, String authenticatorClassName )
{
- super.setAuthenticator( name, authenticator );
+ super.setAuthenticatorClassName( name, authenticatorClassName );
}
+
/**
* Register an authenticator
*
* @param authenticator The authenticator to register
*/
- public void setAuthenticator( Authenticator authenticator )
+ public void setAuthenticatorClassName( String authenticatorClassName )
{
- super.setAuthenticator( authenticator );
+ super.setAuthenticatorClassName( authenticatorClassName );
}
+
public void setName( String name )
{
super.setName( name );
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/PartitionConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/PartitionConfiguration.java?view=diff&rev=556225&r1=556224&r2=556225
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/PartitionConfiguration.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/PartitionConfiguration.java Fri Jul 13 22:35:40 2007
@@ -27,7 +27,6 @@
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
-import org.apache.directory.server.schema.registries.MatchingRuleRegistry;
import org.apache.directory.shared.ldap.exception.LdapConfigurationException;
import org.apache.directory.shared.ldap.message.AttributesImpl;
import org.apache.directory.shared.ldap.name.LdapDN;
@@ -153,15 +152,6 @@
public String getSuffix()
{
return suffix;
- }
-
-
- /**
- * Returns the normalized suffix of the {@link Partition}.
- */
- public Name getNormalizedSuffix( MatchingRuleRegistry matchingRuleRegistry ) throws NamingException
- {
- return getNormalizedSuffix( matchingRuleRegistry.lookup( "distinguishedNameMatch" ).getNormalizer() );
}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java?view=diff&rev=556225&r1=556224&r2=556225
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java Fri Jul 13 22:35:40 2007
@@ -29,9 +29,6 @@
import javax.naming.directory.Attributes;
-import org.apache.directory.server.core.authn.AnonymousAuthenticator;
-import org.apache.directory.server.core.authn.SimpleAuthenticator;
-import org.apache.directory.server.core.authn.StrongAuthenticator;
import org.apache.directory.shared.ldap.ldif.Entry;
import org.slf4j.Logger;
@@ -46,6 +43,13 @@
*/
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 normalizationService name */
public static final String NORMALIZATION_SERVICE_NAME = "normalizationService";
/** The fully qualified class name for the normalization service */
@@ -145,15 +149,15 @@
private void setDefaultAuthenticatorConfigurations()
{
Set<AuthenticatorConfiguration> set = new HashSet<AuthenticatorConfiguration>();
-
+
// Anonymous
- set.add( new MutableAuthenticatorConfiguration( "Anonymous", new AnonymousAuthenticator() ) );
+ set.add( new MutableAuthenticatorConfiguration( "Anonymous", ANONYMOUS_AUTHENTICATOR ) );
// Simple
- set.add( new MutableAuthenticatorConfiguration( "Simple", new SimpleAuthenticator() ) );
+ set.add( new MutableAuthenticatorConfiguration( "Simple", SIMPLE_AUTHENTICATOR ) );
// Strong
- set.add( new MutableAuthenticatorConfiguration( "Strong", new StrongAuthenticator() ) );
+ set.add( new MutableAuthenticatorConfiguration( "Strong", STRONG_AUTHENTICATOR ) );
setAuthenticatorConfigurations( set );
}