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 2005/05/03 19:36:28 UTC

svn commit: r167943 - in /directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn: AbstractAuthenticator.java LdapPrincipal.java

Author: akarasulu
Date: Tue May  3 10:36:27 2005
New Revision: 167943

URL: http://svn.apache.org/viewcvs?rev=167943&view=rev
Log:
Endi had a great recommendation to add a proectected method to create the 
LdapPrincipal rather than making its constructor public and exposing the
ability to create it to the world.

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/AbstractAuthenticator.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/LdapPrincipal.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/AbstractAuthenticator.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/AbstractAuthenticator.java?rev=167943&r1=167942&r2=167943&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/AbstractAuthenticator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/AbstractAuthenticator.java Tue May  3 10:36:27 2005
@@ -18,6 +18,7 @@
 
 
 import org.apache.ldap.server.jndi.ServerContext;
+import org.apache.ldap.common.name.LdapName;
 
 import javax.naming.NamingException;
 import java.util.Enumeration;
@@ -33,9 +34,11 @@
 
     /** authenticator config */
     public AuthenticatorConfig authenticatorConfig;
+
     /** authenticator type */
     public String authenticatorType;
 
+
     /**
      * Create a new AuthenticationService.
      *
@@ -55,6 +58,7 @@
         return authenticatorConfig.getAuthenticatorContext();
     }
 
+
     /**
      * Returns this authenticator's type.
      */
@@ -63,6 +67,7 @@
         return authenticatorType;
     }
 
+
     /**
      * Return this authenticator's AuthenticatorConfig object.
      */
@@ -71,8 +76,10 @@
         return authenticatorConfig;
     }
 
+
     /**
-     * Called by the server to indicate to an authenticator that the authenticator is being placed into service.
+     * Called by the server to indicate to an authenticator that the authenticator
+     * is being placed into service.
      */
     public void init( AuthenticatorConfig authenticatorConfig ) throws NamingException
     {
@@ -81,18 +88,22 @@
         init();
     }
 
+
     /**
-     * A convenience method which can be overridden so that there's no need to call super.init( authenticatorConfig ).
+     * 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.
      */
@@ -101,6 +112,7 @@
         return authenticatorConfig.getAuthenticatorName();
     }
 
+
     /**
      * Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist.
      */
@@ -109,6 +121,7 @@
         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.
      */
@@ -116,5 +129,22 @@
     {
         return authenticatorConfig.getInitParameterNames();
     }
+
+
+    /**
+     * Allows a means to create an LDAP principal without exposing LdapPrincipal creation
+     * to the rest of the world.
+     *
+     * @param dn the distinguished name of the X.500 principal
+     * @return the principal for the dn
+     * @throws NamingException if there is a problem parsing the dn
+     */
+    protected LdapPrincipal createLdapPrincipal( String dn ) throws NamingException
+    {
+        LdapName principalDn = new LdapName( dn );
+
+        return new LdapPrincipal( principalDn );
+    }
+
 
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/LdapPrincipal.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/LdapPrincipal.java?rev=167943&r1=167942&r2=167943&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/LdapPrincipal.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/authn/LdapPrincipal.java Tue May  3 10:36:27 2005
@@ -31,7 +31,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class LdapPrincipal implements Principal, Serializable
+public final class LdapPrincipal implements Principal, Serializable
 {
     private static final long serialVersionUID = 3906650782395676720L;