directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1104133 - in /directory/apacheds/trunk: server-config/src/main/java/org/apache/directory/server/config/beans/ server-config/src/main/resources/ service-builder/src/main/java/org/apache/directory/server/config/
Date Tue, 17 May 2011 11:05:13 GMT
Author: kayyagari
Date: Tue May 17 11:05:12 2011
New Revision: 1104133

URL: http://svn.apache.org/viewvc?rev=1104133&view=rev
Log:
o changed the way authenticators are created from the configuration based on the new authenticator
configuration options
o made createAuthenticator() throw ConfigurationException
o added a check for discarding the disabled authenticator configuration beans
o updated the config.ldif

Added:
    directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/AuthenticatorImplBean.java
Removed:
    directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/AnonymousAuthenticatorBean.java
    directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/SimpleAuthenticatorBean.java
    directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/StrongAuthenticatorBean.java
Modified:
    directory/apacheds/trunk/server-config/src/main/resources/config.ldif
    directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/ServiceBuilder.java

Added: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/AuthenticatorImplBean.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/AuthenticatorImplBean.java?rev=1104133&view=auto
==============================================================================
--- directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/AuthenticatorImplBean.java
(added)
+++ directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/AuthenticatorImplBean.java
Tue May 17 11:05:12 2011
@@ -0,0 +1,73 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you 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.directory.server.config.beans;
+
+
+import org.apache.directory.server.config.ConfigurationElement;
+
+
+/**
+ * Configuration bean of an authenticator implementation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AuthenticatorImplBean extends AuthenticatorBean
+{
+    /** the fully qualified class name of the authenticator implementation */
+    @ConfigurationElement(attributeType = "ads-authenticatorClass")
+    private String authenticatorClass;
+
+
+    /**
+     * Creates a new instance of AuthenticatorImplBean.
+     */
+    public AuthenticatorImplBean()
+    {
+    }
+
+
+    /**
+     * @return the authenticatorClass
+     */
+    public String getAuthenticatorClass()
+    {
+        return authenticatorClass;
+    }
+
+
+    /**
+     * @param authenticatorClass the authenticatorClass to set
+     */
+    public void setAuthenticatorClass( String authenticatorClass )
+    {
+        this.authenticatorClass = authenticatorClass;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString()
+    {
+        return "AuthenticatorImplBean [authenticatorClass=" + authenticatorClass + "]";
+    }
+}

Modified: directory/apacheds/trunk/server-config/src/main/resources/config.ldif
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/main/resources/config.ldif?rev=1104133&r1=1104132&r2=1104133&view=diff
==============================================================================
--- directory/apacheds/trunk/server-config/src/main/resources/config.ldif (original)
+++ directory/apacheds/trunk/server-config/src/main/resources/config.ldif Tue May 17 11:05:12
2011
@@ -93,21 +93,24 @@ ads-authenticatorid: anonymousauthentica
 objectclass: top
 objectclass: ads-base
 objectClass: ads-authenticator
-objectClass: ads-anonymousAuthenticator
+objectClass: ads-authenticatorImpl
+ads-authenticatorClass: org.apache.directory.server.core.authn.AnonymousAuthenticator
 
 dn: ads-authenticatorid=simpleauthenticator,ou=authenticators,ads-interceptorId=authenticationInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config
 ads-authenticatorid: simpleauthenticator
 objectclass: top
 objectclass: ads-base
 objectClass: ads-authenticator
-objectClass: ads-simpleAuthenticator
+objectClass: ads-authenticatorImpl
+ads-authenticatorClass: org.apache.directory.server.core.authn.SimpleAuthenticator
 
 dn: ads-authenticatorid=strongauthenticator,ou=authenticators,ads-interceptorId=authenticationInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config
 ads-authenticatorid: strongauthenticator
 objectclass: top
 objectclass: ads-base
 objectClass: ads-authenticator
-objectClass: ads-strongAuthenticator
+objectClass: ads-authenticatorImpl
+ads-authenticatorClass: org.apache.directory.server.core.authn.StrongAuthenticator
 
 dn: ou=passwordPolicies,ads-interceptorId=authenticationInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config
 objectClass: organizationalUnit

Modified: directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/ServiceBuilder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/ServiceBuilder.java?rev=1104133&r1=1104132&r2=1104133&view=diff
==============================================================================
--- directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/ServiceBuilder.java
(original)
+++ directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/ServiceBuilder.java
Tue May 17 11:05:12 2011
@@ -32,9 +32,9 @@ import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
 
-import org.apache.directory.server.config.beans.AnonymousAuthenticatorBean;
 import org.apache.directory.server.config.beans.AuthenticationInterceptorBean;
 import org.apache.directory.server.config.beans.AuthenticatorBean;
+import org.apache.directory.server.config.beans.AuthenticatorImplBean;
 import org.apache.directory.server.config.beans.ChangeLogBean;
 import org.apache.directory.server.config.beans.DelegatingAuthenticatorBean;
 import org.apache.directory.server.config.beans.DirectoryServiceBean;
@@ -53,20 +53,15 @@ import org.apache.directory.server.confi
 import org.apache.directory.server.config.beans.PasswordPolicyBean;
 import org.apache.directory.server.config.beans.ReplConsumerBean;
 import org.apache.directory.server.config.beans.SaslMechHandlerBean;
-import org.apache.directory.server.config.beans.SimpleAuthenticatorBean;
-import org.apache.directory.server.config.beans.StrongAuthenticatorBean;
 import org.apache.directory.server.config.beans.TcpTransportBean;
 import org.apache.directory.server.config.beans.TransportBean;
 import org.apache.directory.server.config.beans.UdpTransportBean;
 import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.InstanceLayout;
-import org.apache.directory.server.core.authn.AnonymousAuthenticator;
 import org.apache.directory.server.core.authn.AuthenticationInterceptor;
 import org.apache.directory.server.core.authn.Authenticator;
 import org.apache.directory.server.core.authn.DelegatingAuthenticator;
-import org.apache.directory.server.core.authn.SimpleAuthenticator;
-import org.apache.directory.server.core.authn.StrongAuthenticator;
 import org.apache.directory.server.core.authn.ppolicy.PasswordPolicyConfiguration;
 import org.apache.directory.server.core.authn.ppolicy.PpolicyConfigContainer;
 import org.apache.directory.server.core.changelog.ChangeLog;
@@ -438,30 +433,39 @@ public class ServiceBuilder
      * Creates a Authenticator from the configuration
      * 
      * @param authenticatorBean The created instance of authenticator
-     * @return An instance of authenticator
+     * @return An instance of authenticator if the given authenticatorBean is not disabled
      */
-    public static Authenticator createAuthenticator( AuthenticatorBean authenticatorBean
)
+    public static Authenticator createAuthenticator( AuthenticatorBean authenticatorBean
) throws ConfigurationException
     {
-        Authenticator authenticator = null;
-        
-        if (authenticatorBean instanceof SimpleAuthenticatorBean)
-        {
-            authenticator = new SimpleAuthenticator();
-        }
-        else if (authenticatorBean instanceof AnonymousAuthenticatorBean)
-        {
-            authenticator = new AnonymousAuthenticator();
-        }
-        else if (authenticatorBean instanceof StrongAuthenticatorBean)
+        if ( authenticatorBean.isDisabled() )
         {
-            authenticator = new StrongAuthenticator();
+            return null;
         }
-        else if (authenticatorBean instanceof DelegatingAuthenticatorBean)
+        
+        Authenticator authenticator = null;
+        
+        if (authenticatorBean instanceof DelegatingAuthenticatorBean)
         {
             authenticator = new DelegatingAuthenticator();
             ((DelegatingAuthenticator)authenticator).setDelegateHost( ((DelegatingAuthenticatorBean)
authenticatorBean).getDelegateHost() );
             ((DelegatingAuthenticator)authenticator).setDelegatePort( ((DelegatingAuthenticatorBean)
authenticatorBean).getDelegatePort() );
         }
+        else if ( authenticatorBean instanceof AuthenticatorImplBean )
+        {
+            String fqcn = ( ( AuthenticatorImplBean ) authenticatorBean ).getAuthenticatorClass();
+            
+            try
+            {
+                Class authnImplClass = Class.forName( fqcn );
+                authenticator = ( Authenticator ) authnImplClass.newInstance();
+            }
+            catch( Exception e )
+            {
+                String errorMsg = "Failed to instantiate the configured authenticator " +
authenticatorBean.getAuthenticatorId();
+                LOG.warn( errorMsg );
+                throw new ConfigurationException( errorMsg, e );
+            }
+        }
         
         return authenticator;
     }
@@ -506,7 +510,7 @@ public class ServiceBuilder
      * @param transportBeans The array of Transport configuration
      * @return An arry of Transport instance
      */
-    public static Authenticator[] createAuthenticators( List<AuthenticatorBean> list
)
+    public static Authenticator[] createAuthenticators( List<AuthenticatorBean> list
) throws ConfigurationException
     {
         Authenticator[] authenticators = new Authenticator[ list.size() ];
         int i = 0;



Mime
View raw message