directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r159239 - in directory/apacheds/trunk: ./ core/src/main/java/org/apache/ldap/server/auth/ core/src/main/java/org/apache/ldap/server/jndi/ xdocs/users/
Date Mon, 28 Mar 2005 14:42:13 GMT
Author: akarasulu
Date: Mon Mar 28 06:42:10 2005
New Revision: 159239

URL: http://svn.apache.org/viewcvs?view=rev&rev=159239
Log:
changes ...

 o looks like without an artifactId for the parent project several things go
   crazy such as the multiproject:deploy option so I just added one
 o applied Endi's authenticator2.patch the JIRA issue URL is below: this closes
   the issue once and for all

http://issues.apache.org/jira/browse/DIREVE-147


Added:
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/GenericAuthenticatorConfig.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/GenericAuthenticatorContext.java
Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AbstractAuthenticator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AnonymousAuthenticator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/Authenticator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AuthenticatorConfig.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AuthenticatorContext.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/SimpleAuthenticator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/Authenticator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AuthenticatorConfigBuilder.java
    directory/apacheds/trunk/project.xml
    directory/apacheds/trunk/xdocs/users/authentication.xml

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AbstractAuthenticator.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AbstractAuthenticator.java?view=diff&r1=159238&r2=159239
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AbstractAuthenticator.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AbstractAuthenticator.java
Mon Mar 28 06:42:10 2005
@@ -17,7 +17,10 @@
 package org.apache.ldap.server.auth;
 
 
+import org.apache.ldap.server.jndi.ServerContext;
+
 import javax.naming.NamingException;
+import java.util.Enumeration;
 
 
 /**
@@ -25,15 +28,13 @@
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public abstract class AbstractAuthenticator implements Authenticator
+public abstract class AbstractAuthenticator implements Authenticator, AuthenticatorConfig
 {
 
     /** authenticator config */
     public AuthenticatorConfig authenticatorConfig;
-    /** authenticator context */
-    public AuthenticatorContext authenticatorContext;
     /** authenticator type */
-    public String type;
+    public String authenticatorType;
 
     /**
      * Create a new Authenticator.
@@ -42,28 +43,78 @@
      */
     public AbstractAuthenticator( String type )
     {
-        this.type = type;
+        this.authenticatorType = type;
     }
 
 
+    /**
+     * Returns a reference to the AuthenticatorContext in which this authenticator is running.
+     */
     public AuthenticatorContext getAuthenticatorContext()
     {
-        return authenticatorContext;
+        return authenticatorConfig.getAuthenticatorContext();
     }
 
-
-    public String getType()
+    /**
+     * Returns this authenticator's type.
+     */
+    public String getAuthenticatorType()
     {
-        return type;
+        return authenticatorType;
     }
 
+    /**
+     * Return this authenticator's AuthenticatorConfig object.
+     */
+    public AuthenticatorConfig getAuthenticatorConfig()
+    {
+        return authenticatorConfig;
+    }
 
+    /**
+     * Called by the server to indicate to an authenticator that the authenticator is being
placed into service.
+     */
     public void init( AuthenticatorConfig authenticatorConfig ) throws NamingException
     {
         this.authenticatorConfig = authenticatorConfig;
 
-        this.authenticatorContext = authenticatorConfig.getAuthenticatorContext();
-
         init();
     }
-}
\ No newline at end of file
+
+    /**
+     * A convenience method which can be overridden so that there's no need to call super.init(
authenticatorConfig ).
+     */
+    public void init() throws NamingException
+    {
+    }
+
+    /**
+     * Perform the authentication operation and return the authorization id if successfull.
+     */
+    public abstract LdapPrincipal authenticate( ServerContext ctx ) throws NamingException;
+
+    /**
+     * Returns the name of this authenticator instance.
+     */
+    public String getAuthenticatorName()
+    {
+        return authenticatorConfig.getAuthenticatorName();
+    }
+
+    /**
+     * Returns a String containing the value of the named initialization parameter, or null
if the parameter does not exist.
+     */
+    public String getInitParameter( String name )
+    {
+        return authenticatorConfig.getInitParameter( name );
+    }
+
+    /**
+     * Returns the names of the servlet's initialization parameters as an Enumeration of
String objects, or an empty Enumeration if the servlet has no initialization parameters.
+     */
+    public Enumeration getInitParameterNames()
+    {
+        return authenticatorConfig.getInitParameterNames();
+    }
+
+}

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AnonymousAuthenticator.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AnonymousAuthenticator.java?view=diff&r1=159238&r2=159239
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AnonymousAuthenticator.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AnonymousAuthenticator.java
Mon Mar 28 06:42:10 2005
@@ -22,7 +22,7 @@
 import javax.naming.NamingException;
 
 /**
- * Endi can you please javadoc this code.
+ * A default implentation of an Authenticator for handling anonymous connections.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -34,11 +34,10 @@
     }
 
 
-    public void init() throws NamingException
-    {
-    }
-
-
+    /**
+     * This will be called when the authentication is set to "none" on the client.
+     * If server is not configured to allow anonymous connections, it throws an exception.
+     */
     public LdapPrincipal authenticate( ServerContext ctx ) throws NamingException
     {
         if ( getAuthenticatorContext().getAllowAnonymous() )

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/Authenticator.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/Authenticator.java?view=diff&r1=159238&r2=159239
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/Authenticator.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/Authenticator.java
Mon Mar 28 06:42:10 2005
@@ -23,16 +23,22 @@
 
 
 /**
- * Endi when you have a chance please document this class with the proper javadocs.
+ * Defines methods that all Authenticators must implement.
  *
+ * <p>An Authenticator is a program that performs client authentication based on the
authentication
+ * method/type that the client specifies in the JNDI properties.
+ *
+ * <p>To implement this interface, you can write an authenticator that extends org.apache.ldap.server.auth.AbstractAuthenticator.
+ *
+ * @see AbstractAuthenticator
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
 public interface Authenticator
 {
-    AuthenticatorContext getAuthenticatorContext();
+    public AuthenticatorConfig getAuthenticatorConfig();
 
-    String getType();
+    public String getAuthenticatorType();
 
     /**
      * Called by the authenticator container to indicate that the authenticator is being
placed into service.
@@ -40,12 +46,7 @@
      * @param authenticatorConfig
      * @throws NamingException
      */
-    void init( AuthenticatorConfig authenticatorConfig ) throws NamingException;
-
-    /**
-     * A convenience method which can be overridden so that there's no need to call super.init(
authenticatorConfig ).
-     */
-    void init() throws NamingException;
+    public void init( AuthenticatorConfig authenticatorConfig ) throws NamingException;
 
     /**
      * Perform the authentication operation and return the authorization id if successfull.
@@ -54,5 +55,5 @@
      * @return the authorization id
      * @throws NamingException
      */
-    LdapPrincipal authenticate( ServerContext ctx ) throws NamingException;
+    public LdapPrincipal authenticate( ServerContext ctx ) throws NamingException;
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AuthenticatorConfig.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AuthenticatorConfig.java?view=diff&r1=159238&r2=159239
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AuthenticatorConfig.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AuthenticatorConfig.java
Mon Mar 28 06:42:10 2005
@@ -17,68 +17,32 @@
 package org.apache.ldap.server.auth;
 
 import java.util.Enumeration;
-import java.util.Properties;
 
 /**
- * A configuration bean for Authenticators. 
+ * An authenticator configuration object used by the server to pass information to an authenticator
+ * during initialization.
  *
- * @todo Endi this class needs javadocs for the methods
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class AuthenticatorConfig {
+public interface AuthenticatorConfig {
 
-    private String authenticatorName;
-    private String authenticatorClass;
-    private AuthenticatorContext authenticatorContext;
-    private Properties properties = new Properties();
-
-    public String getAuthenticatorName()
-    {
-        return authenticatorName;
-    }
-
-    public void setAuthenticatorName( String authenticatorName )
-    {
-        this.authenticatorName = authenticatorName;
-    }
-
-    public String getAuthenticatorClass()
-    {
-        return authenticatorClass;
-    }
-
-    public void setAuthenticatorClass( String authenticatorClass )
-    {
-        this.authenticatorClass = authenticatorClass;
-    }
-
-    public Properties getProperties()
-    {
-        return properties;
-    }
-
-    public void setProperties( Properties properties )
-    {
-        this.properties = properties;
-    }
-
-    public String getInitParameter( String name )
-    {
-        return properties.getProperty( name );
-    }
-
-    public Enumeration getInitParameterNames()
-    {
-        return properties.keys();
-    }
-
-    public AuthenticatorContext getAuthenticatorContext()
-    {
-        return authenticatorContext;
-    }
-
-    public void setAuthenticatorContext( AuthenticatorContext authenticatorContext )
-    {
-        this.authenticatorContext = authenticatorContext;
-    }
+    /**
+     * Returns the name of this authenticator instance.
+     */
+    public String getAuthenticatorName();
+
+    /**
+     * Returns a String containing the value of the named initialization parameter, or null
if the parameter does not exist.
+     */
+    public String getInitParameter( String name );
+
+    /**
+     * Returns the names of the servlet's initialization parameters as an Enumeration of
String objects, or an empty Enumeration if the servlet has no initialization parameters.
+     */
+    public Enumeration getInitParameterNames();
+
+    /**
+     * Returns a reference to the AuthenticatorContext.
+     */
+    public AuthenticatorContext getAuthenticatorContext();
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AuthenticatorContext.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AuthenticatorContext.java?view=diff&r1=159238&r2=159239
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AuthenticatorContext.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/AuthenticatorContext.java
Mon Mar 28 06:42:10 2005
@@ -21,43 +21,23 @@
 
 
 /**
- * Base class for all Authenticators.
+ * Defines a set of methods that an authenticator uses to communicate with its container,
+ * for example, to get the partition nexus, or whether the server is configured to accept
+ * anonymous connection.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev: 124525 $
  */
-public class AuthenticatorContext
+public interface AuthenticatorContext
 {
 
-    /** the root nexus to all database partitions */
-    private PartitionNexus partitionNexus;
-    /** whether or not to allow anonymous users */
-    private boolean allowAnonymous = false;
-
     /**
-     * Create a new AuthenticatorContext.
+     * Returns a reference to the PartitionNexus.
      */
-    public AuthenticatorContext()
-    {
-    }
-
-    public PartitionNexus getPartitionNexus()
-    {
-        return partitionNexus;
-    }
-    public void setPartitionNexus( PartitionNexus rootNexus )
-    {
-        this.partitionNexus = rootNexus;
-    }
-
-    public boolean getAllowAnonymous()
-    {
-        return allowAnonymous;
-    }
-
-    public void setAllowAnonymous( boolean allowAnonymous )
-    {
-        this.allowAnonymous = allowAnonymous;
-    }
+    public PartitionNexus getPartitionNexus();
 
+    /**
+     * Returns the value of server.disable.anonymous JNDI Property.
+     */
+    public boolean getAllowAnonymous();
 }

Added: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/GenericAuthenticatorConfig.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/GenericAuthenticatorConfig.java?view=auto&rev=159239
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/GenericAuthenticatorConfig.java
(added)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/GenericAuthenticatorConfig.java
Mon Mar 28 06:42:10 2005
@@ -0,0 +1,83 @@
+/*
+ *   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.ldap.server.auth;
+
+import java.util.Enumeration;
+import java.util.Properties;
+
+/**
+ * Default implementation of AuthenticatorConfig.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class GenericAuthenticatorConfig implements AuthenticatorConfig {
+
+    private String authenticatorName;
+    private String authenticatorClass;
+    private AuthenticatorContext authenticatorContext;
+    private Properties properties = new Properties();
+
+    public String getAuthenticatorName()
+    {
+        return authenticatorName;
+    }
+
+    public void setAuthenticatorName( String authenticatorName )
+    {
+        this.authenticatorName = authenticatorName;
+    }
+
+    public String getAuthenticatorClass()
+    {
+        return authenticatorClass;
+    }
+
+    public void setAuthenticatorClass( String authenticatorClass )
+    {
+        this.authenticatorClass = authenticatorClass;
+    }
+
+    public Properties getProperties()
+    {
+        return properties;
+    }
+
+    public void setProperties( Properties properties )
+    {
+        this.properties = properties;
+    }
+
+    public String getInitParameter( String name )
+    {
+        return properties.getProperty( name );
+    }
+
+    public Enumeration getInitParameterNames()
+    {
+        return properties.keys();
+    }
+
+    public AuthenticatorContext getAuthenticatorContext()
+    {
+        return authenticatorContext;
+    }
+
+    public void setAuthenticatorContext( AuthenticatorContext authenticatorContext )
+    {
+        this.authenticatorContext = authenticatorContext;
+    }
+}

Added: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/GenericAuthenticatorContext.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/GenericAuthenticatorContext.java?view=auto&rev=159239
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/GenericAuthenticatorContext.java
(added)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/GenericAuthenticatorContext.java
Mon Mar 28 06:42:10 2005
@@ -0,0 +1,63 @@
+/*
+ *   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.ldap.server.auth;
+
+
+import org.apache.ldap.server.PartitionNexus;
+
+
+/**
+ * Default implementation of AuthenticatorContext.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 124525 $
+ */
+public class GenericAuthenticatorContext implements AuthenticatorContext
+{
+
+    /** the root nexus to all database partitions */
+    private PartitionNexus partitionNexus;
+    /** whether or not to allow anonymous users */
+    private boolean allowAnonymous = false;
+
+    /**
+     * Create a new AuthenticatorContext.
+     */
+    public GenericAuthenticatorContext()
+    {
+    }
+
+    public PartitionNexus getPartitionNexus()
+    {
+        return partitionNexus;
+    }
+    public void setPartitionNexus( PartitionNexus rootNexus )
+    {
+        this.partitionNexus = rootNexus;
+    }
+
+    public boolean getAllowAnonymous()
+    {
+        return allowAnonymous;
+    }
+
+    public void setAllowAnonymous( boolean allowAnonymous )
+    {
+        this.allowAnonymous = allowAnonymous;
+    }
+
+}
\ No newline at end of file

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/SimpleAuthenticator.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/SimpleAuthenticator.java?view=diff&r1=159238&r2=159239
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/SimpleAuthenticator.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/auth/SimpleAuthenticator.java
Mon Mar 28 06:42:10 2005
@@ -49,16 +49,6 @@
 
 
     /**
-     * Does nothing!
-     *
-     * @see Authenticator#init()
-     */
-    public void init() throws NamingException
-    {
-    }
-
-
-    /**
      * Uses the userPassword field of the user to authenticate.
      *
      * @see Authenticator#authenticate(org.apache.ldap.server.jndi.ServerContext)

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/Authenticator.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/Authenticator.java?view=diff&r1=159238&r2=159239
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/Authenticator.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/Authenticator.java
Mon Mar 28 06:42:10 2005
@@ -34,8 +34,8 @@
 import org.apache.ldap.common.util.StringTools;
 import org.apache.ldap.server.auth.AbstractAuthenticator;
 import org.apache.ldap.server.auth.AnonymousAuthenticator;
-import org.apache.ldap.server.auth.AuthenticatorConfig;
-import org.apache.ldap.server.auth.AuthenticatorContext;
+import org.apache.ldap.server.auth.GenericAuthenticatorConfig;
+import org.apache.ldap.server.auth.GenericAuthenticatorContext;
 import org.apache.ldap.server.auth.LdapPrincipal;
 import org.apache.ldap.server.auth.SimpleAuthenticator;
 import org.apache.ldap.server.jndi.invocation.Invocation;
@@ -79,14 +79,14 @@
         boolean allowAnonymous = !ctx.getEnvironment().containsKey( EnvKeys.DISABLE_ANONYMOUS
);
 
         // create authenticator context
-        AuthenticatorContext authenticatorContext = new AuthenticatorContext();
+        GenericAuthenticatorContext authenticatorContext = new GenericAuthenticatorContext();
         authenticatorContext.setPartitionNexus( ctx.getRootNexus() );
         authenticatorContext.setAllowAnonymous( allowAnonymous );
 
         try // initialize default authenticators
         {
             // create anonymous authenticator
-            AuthenticatorConfig authenticatorConfig = new AuthenticatorConfig();
+            GenericAuthenticatorConfig authenticatorConfig = new GenericAuthenticatorConfig();
             authenticatorConfig.setAuthenticatorName( "none" );
             authenticatorConfig.setAuthenticatorContext( authenticatorContext );
 
@@ -95,7 +95,7 @@
             this.register( authenticator );
 
             // create simple authenticator
-            authenticatorConfig = new AuthenticatorConfig();
+            authenticatorConfig = new GenericAuthenticatorConfig();
             authenticatorConfig.setAuthenticatorName( "simple" );
             authenticatorConfig.setAuthenticatorContext( authenticatorContext );
 
@@ -108,7 +108,7 @@
             throw new NamingException( e.getMessage() );
         }
 
-        AuthenticatorConfig[] configs = null;
+        GenericAuthenticatorConfig[] configs = null;
         configs = AuthenticatorConfigBuilder
                 .getAuthenticatorConfigs( new Hashtable( ctx.getEnvironment() ) );
 
@@ -150,11 +150,11 @@
      */
     public void register( org.apache.ldap.server.auth.Authenticator authenticator )
     {
-        Collection authenticatorList = getAuthenticators( authenticator.getType() );
+        Collection authenticatorList = getAuthenticators( authenticator.getAuthenticatorType()
);
         if ( authenticatorList == null )
         {
             authenticatorList = new ArrayList();
-            authenticators.put( authenticator.getType(), authenticatorList );
+            authenticators.put( authenticator.getAuthenticatorType(), authenticatorList );
         }
         authenticatorList.add( authenticator );
     }
@@ -170,7 +170,7 @@
      */
     public void unregister( org.apache.ldap.server.auth.Authenticator authenticator )
     {
-        Collection authenticatorList = getAuthenticators( authenticator.getType() );
+        Collection authenticatorList = getAuthenticators( authenticator.getAuthenticatorType()
);
         if ( authenticatorList == null )
         {
             return;

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AuthenticatorConfigBuilder.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AuthenticatorConfigBuilder.java?view=diff&r1=159238&r2=159239
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AuthenticatorConfigBuilder.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AuthenticatorConfigBuilder.java
Mon Mar 28 06:42:10 2005
@@ -24,7 +24,7 @@
 import javax.naming.NamingException;
 
 import org.apache.ldap.common.util.StringTools;
-import org.apache.ldap.server.auth.AuthenticatorConfig;
+import org.apache.ldap.server.auth.GenericAuthenticatorConfig;
 
 
 /**
@@ -36,7 +36,7 @@
 public class AuthenticatorConfigBuilder
 {
     /** keep this so we do not have create empty ones over and over again */
-    private final static AuthenticatorConfig[] EMPTY = new AuthenticatorConfig[0];
+    private final static GenericAuthenticatorConfig[] EMPTY = new GenericAuthenticatorConfig[0];
 
 
     /**
@@ -48,11 +48,11 @@
      * @return the extracted configuration object
      * @throws javax.naming.NamingException
      */
-    public static AuthenticatorConfig getAuthenticatorConfig( String authenticatorName, Hashtable
env )
+    public static GenericAuthenticatorConfig getAuthenticatorConfig( String authenticatorName,
Hashtable env )
             throws NamingException
     {
         final StringBuffer buf = new StringBuffer();
-        final AuthenticatorConfig config = new AuthenticatorConfig();
+        final GenericAuthenticatorConfig config = new GenericAuthenticatorConfig();
 
         // --------------------------------------------------------------------
         // set id for authenticator
@@ -107,7 +107,7 @@
      * @return all the extracted configuration objects configured
      * @throws javax.naming.NamingException
      */
-    public static AuthenticatorConfig[] getAuthenticatorConfigs( Hashtable env )
+    public static GenericAuthenticatorConfig[] getAuthenticatorConfigs( Hashtable env )
             throws NamingException
     {
         String idList = ( String ) env.get( EnvKeys.AUTHENTICATORS );
@@ -120,7 +120,7 @@
 
         idList = StringTools.deepTrim( idList );
         final String[] ids = idList.split( " " );
-        final AuthenticatorConfig[] configs = new AuthenticatorConfig[ids.length];
+        final GenericAuthenticatorConfig[] configs = new GenericAuthenticatorConfig[ids.length];
         for ( int ii = 0; ii < configs.length; ii++ )
         {
             configs[ii] = getAuthenticatorConfig( ids[ii], env );

Modified: directory/apacheds/trunk/project.xml
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/project.xml?view=diff&r1=159238&r2=159239
==============================================================================
--- directory/apacheds/trunk/project.xml (original)
+++ directory/apacheds/trunk/project.xml Mon Mar 28 06:42:10 2005
@@ -2,6 +2,7 @@
 
 <project>
     <groupId>directory</groupId>
+    <artifactId>directory</artifactId>
     <currentVersion>0.9-SNAPSHOT</currentVersion>
     <name>Apache Directory Project</name>
     <url>http://directory.apache.org</url>

Modified: directory/apacheds/trunk/xdocs/users/authentication.xml
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/xdocs/users/authentication.xml?view=diff&r1=159238&r2=159239
==============================================================================
--- directory/apacheds/trunk/xdocs/users/authentication.xml (original)
+++ directory/apacheds/trunk/xdocs/users/authentication.xml Mon Mar 28 06:42:10 2005
@@ -166,6 +166,90 @@
         </p>
       </subsection>
 
+      <subsection name="Custom Authenticator">
+        <p>
+          Authenticator SPI provides a way to implement your own authentication mechanism,
+          for instance simple mechanism using password encryption such as MD5 or SHA1, or
+          SASL mechanism. See the following example:
+        </p>
+
+        <source>
+import javax.naming.NamingException;
+
+import org.apache.ldap.server.auth.AbstractAuthenticator;
+import org.apache.ldap.server.auth.LdapPrincipal;
+import org.apache.ldap.server.jndi.ServerContext;
+import org.apache.ldap.common.exception.LdapNoPermissionException;
+import org.apache.ldap.common.name.LdapName;
+
+public class MyAuthenticator extends AbstractAuthenticator {
+
+    public MyAuthenticator( )
+    {
+        // create authenticator that will handle "simple" authentication mechanism
+        super( "simple" );
+    }
+
+    public void init() throws NamingException
+    {
+        ...
+    }
+
+    public LdapPrincipal authenticate( ServerContext ctx ) throws NamingException
+    {
+        ...
+
+        // return the authorization id
+        LdapName principalDn = new LdapName( dn );
+        return new LdapPrincipal( principalDn );
+    }
+}
+          </source>
+
+          <p>
+            The authenticator class has to extend the org.apache.ldap.server.auth.AbstractAuthenticator.
+            This class needs to have a no-argument constructor that calls the super()
+            constructor with parameter the authentication mechanism it is going to handle.
+            In the above example, MyAuthenticator class is going to handle the simple
+            authentication mechanism. To implement a SASL mechanism you need to call super()
+            with the name of the SASL mechanism, e.g. super( "DIGEST-MD5" ).
+          </p>
+
+          <p>
+            You can optionally implement the init() method to initialize your authenticator
class.
+            This will be called when the authenticator is loaded by ApacheDS during start-up.
+          </p>
+
+          <p>
+            When a client performs an authentication, ApacheDS will call the authenticate()
method.
+            You can get the client authentication info from the server context. After you
authenticate
+            the client, you need to return the authorization id. If the authentication fails,
you
+            should throw an LdapNoPermissionException.
+          </p>
+
+          <p>
+            When there are multiple authenticators registered with the same authentication
type,
+            ApacheDS will try to use them in the order it was registered. If one fails it
will use
+            the next one, until it finds one that successfully authenticates the client.
+          </p>
+
+          <p>
+            To tell ApacheDS to load your custom authenticators, you need to specify it in
the JNDI
+            Properties. You can also optionally specify the location of a .properties file
containing
+            the initialization parameters. See the following example:
+          </p>
+
+          <source>
+server.authenticators=myauthenticator yourauthenticator
+
+server.authenticator.class.myauthenticator=com.mycompany.MyAuthenticator
+server.authenticator.properties.myauthenticator=myauthenticator.properties
+
+server.authenticator.class.yourauthenticator=com.yourcompany.YourAuthenticator
+server.authenticator.properties.yourauthenticator=yourauthenticator.properties
+          </source>
+      </subsection>
+
     </section>
   </body>
 </document>



Mime
View raw message