directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r1040768 - in /directory/apacheds/branches/antoine: core-annotations/src/main/java/org/apache/directory/server/core/annotations/ core-annotations/src/main/java/org/apache/directory/server/core/factory/ server-integ/src/test/java/org/apache/...
Date Tue, 30 Nov 2010 20:43:52 GMT
Author: antoine
Date: Tue Nov 30 20:43:52 2010
New Revision: 1040768

URL: http://svn.apache.org/viewvc?rev=1040768&view=rev
Log:
renamed additionalAuthenticators to just authenticators in CreateDS, also added another testcase

Modified:
    directory/apacheds/branches/antoine/core-annotations/src/main/java/org/apache/directory/server/core/annotations/CreateAuthenticator.java
    directory/apacheds/branches/antoine/core-annotations/src/main/java/org/apache/directory/server/core/annotations/CreateDS.java
    directory/apacheds/branches/antoine/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
    directory/apacheds/branches/antoine/server-integ/src/test/java/org/apache/directory/server/operations/bind/DelegatedAuthIT.java

Modified: directory/apacheds/branches/antoine/core-annotations/src/main/java/org/apache/directory/server/core/annotations/CreateAuthenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/antoine/core-annotations/src/main/java/org/apache/directory/server/core/annotations/CreateAuthenticator.java?rev=1040768&r1=1040767&r2=1040768&view=diff
==============================================================================
--- directory/apacheds/branches/antoine/core-annotations/src/main/java/org/apache/directory/server/core/annotations/CreateAuthenticator.java
(original)
+++ directory/apacheds/branches/antoine/core-annotations/src/main/java/org/apache/directory/server/core/annotations/CreateAuthenticator.java
Tue Nov 30 20:43:52 2010
@@ -45,8 +45,8 @@ public @interface CreateAuthenticator
     /** The authenticator implementation class */
     Class<? extends Authenticator> type() default AnonymousAuthenticator.class;
     /** Delegate host, use for testing DelegatingAuthenticator */
-    String delegateHost();
+    String delegateHost() default "localhost";
     /** Delegate port, use for testing DelegatingAuthenticator */
-    int delegatePort();
+    int delegatePort() default -1;
     
 }

Modified: directory/apacheds/branches/antoine/core-annotations/src/main/java/org/apache/directory/server/core/annotations/CreateDS.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/antoine/core-annotations/src/main/java/org/apache/directory/server/core/annotations/CreateDS.java?rev=1040768&r1=1040767&r2=1040768&view=diff
==============================================================================
--- directory/apacheds/branches/antoine/core-annotations/src/main/java/org/apache/directory/server/core/annotations/CreateDS.java
(original)
+++ directory/apacheds/branches/antoine/core-annotations/src/main/java/org/apache/directory/server/core/annotations/CreateDS.java
Tue Nov 30 20:43:52 2010
@@ -55,6 +55,6 @@ public @interface CreateDS
     /** additional interceptors */
     Class<?>[] additionalInterceptors() default {};
     
-    /** additional authenticators */
-    CreateAuthenticator[] additionalAuthenticators() default {};
+    /** authenticators, when empty the default authenticators are used, else this must contain
the complete list */
+    CreateAuthenticator[] authenticators() default {};
 }

Modified: directory/apacheds/branches/antoine/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/antoine/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java?rev=1040768&r1=1040767&r2=1040768&view=diff
==============================================================================
--- directory/apacheds/branches/antoine/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
(original)
+++ directory/apacheds/branches/antoine/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
Tue Nov 30 20:43:52 2010
@@ -23,6 +23,7 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.InputStream;
 import java.lang.reflect.Method;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -87,7 +88,7 @@ public class DSAnnotationProcessor
             interceptorList.add( ( Interceptor ) interceptorClass.newInstance() );
         }
 
-        if ( dsBuilder.additionalAuthenticators().length != 0 )
+        if ( dsBuilder.authenticators().length != 0 )
         {
             AuthenticationInterceptor authenticationInterceptor = null;
             for ( Interceptor interceptor : interceptorList )
@@ -103,10 +104,10 @@ public class DSAnnotationProcessor
                 throw new IllegalStateException(
                         "authentication interceptor not found" );
             }
-            Set<Authenticator> authenticators = authenticationInterceptor
-                    .getAuthenticators();
+            Set<Authenticator> authenticators = new HashSet<Authenticator>();
+
             for ( CreateAuthenticator createAuthenticator : dsBuilder
-                    .additionalAuthenticators() )
+                    .authenticators() )
             {
                 Authenticator auth = createAuthenticator.type().newInstance();
                 if ( auth instanceof DelegatingAuthenticator )

Modified: directory/apacheds/branches/antoine/server-integ/src/test/java/org/apache/directory/server/operations/bind/DelegatedAuthIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/antoine/server-integ/src/test/java/org/apache/directory/server/operations/bind/DelegatedAuthIT.java?rev=1040768&r1=1040767&r2=1040768&view=diff
==============================================================================
--- directory/apacheds/branches/antoine/server-integ/src/test/java/org/apache/directory/server/operations/bind/DelegatedAuthIT.java
(original)
+++ directory/apacheds/branches/antoine/server-integ/src/test/java/org/apache/directory/server/operations/bind/DelegatedAuthIT.java
Tue Nov 30 20:43:52 2010
@@ -31,7 +31,10 @@ import org.apache.directory.server.annot
 import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.annotations.CreateAuthenticator;
 import org.apache.directory.server.core.annotations.CreateDS;
+import org.apache.directory.server.core.authn.AnonymousAuthenticator;
 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.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.shared.ldap.message.BindResponse;
@@ -75,7 +78,7 @@ public class DelegatedAuthIT extends Abs
     @CreateDS(
         allowAnonAccess = true,
         name = "DelegatedAuthIT-method",
-        additionalAuthenticators =
+        authenticators =
             {
             @CreateAuthenticator(
                 type = DelegatingAuthenticator.class,
@@ -121,5 +124,95 @@ public class DelegatedAuthIT extends Abs
             System.out.println( "exception happened" + exc.getMessage() );
         }
     }
+    /**
+     * Test with bindDn which is not even found under any namingContext of the
+     * server.
+     * 
+     * @throws Exception 
+     */
+    @CreateDS(
+        allowAnonAccess = true,
+        name = "DelegatedAuthIT-MultipleAuthenticators-method",
+        authenticators =
+            {
+            @CreateAuthenticator(type = AnonymousAuthenticator.class),
+            @CreateAuthenticator(type = SimpleAuthenticator.class),
+            @CreateAuthenticator(
+                type = DelegatingAuthenticator.class,
+                delegateHost = "localhost",
+                delegatePort = 10200),
+            @CreateAuthenticator(type = StrongAuthenticator.class)})
+@ApplyLdifs(
+    {
+        // Entry # 1
+        "dn: uid=emmanuel,ou=users,ou=system",
+        "objectClass: uidObject",
+        "objectClass: person",
+        "objectClass: top",
+        "uid: emmanuel",
+        "cn: Emmanuel Lecharny",
+        "sn: Lecharny",
+        "userPassword: sesame" })
+    @CreateLdapServer(
+        transports =
+    {
+        @CreateTransport(protocol = "LDAP")
+    })
+    @Test
+    public void testMultipleAuthenticators() throws Exception
+    {
+        assertTrue( service.isStarted() );
+        assertEquals( "DelegatedAuthIT-MultipleAuthenticators-method", service.getInstanceId()
);
+        LdapConnection ldapConnection = LdapConnectionFactory.getNetworkConnection( "localhost",
ldapServer.getPort() );
+        BindResponse bindResponse = ldapConnection.bind( "uid=emmanuel,ou=users,ou=system",
"sesame" );
+        if ( bindResponse.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS )
+        {
+            fail( "this authentication should have been successful through local simple authenticator,
got result code : "
+                + bindResponse.getLdapResult().getResultCode() );
+        }
+        ldapConnection.unBind();
+        bindResponse = ldapConnection.bind( "uid=emmanuel,ou=users,ou=system", "crypto" );
+        if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+        {
+            fail( "this authentication should fail due to wrong password, got result code
: "
+                + bindResponse.getLdapResult().getResultCode() );
+        }
+        ldapConnection.unBind();
+        bindResponse = ldapConnection.bind();
+        if ( bindResponse.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS )
+        {
+            fail( "this authentication should have been successful through local anonymous
authenticator, got result code : "
+                + bindResponse.getLdapResult().getResultCode() );
+        }
+        ldapConnection.unBind();
+        bindResponse = ldapConnection.bind( "uid=antoine,ou=users,ou=system", "secret" );
+        if ( bindResponse.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS )
+        {
+            fail( "this authentication should have been successful, got result code : "
+                + bindResponse.getLdapResult().getResultCode() );
+        }
+        ldapConnection.unBind();
+        bindResponse = ldapConnection.bind( "uid=antoine,ou=users,ou=system", "sesame" );
+        if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+        {
+            fail( "this authentication should have failed due to wrong password, got result
code : "
+                + bindResponse.getLdapResult().getResultCode() );
+        }
+        ldapConnection.unBind();
+        try
+        {
+            bindResponse = ldapConnection.bind( "uid=ivanhoe,ou=users,ou=system", "secret"
);
+            if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+            {
+                fail( "this authentication should fail, user does not exist, got result code
: "
+                    + bindResponse.getLdapResult().getResultCode() );
+            }
+            ldapConnection.unBind();
+        }
+        catch ( Exception exc )
+        {
+            System.out.println( "exception happened" + exc.getMessage() );
+        }
+    }
 
 }



Mime
View raw message