Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 30980 invoked from network); 30 Nov 2010 20:45:29 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 30 Nov 2010 20:45:29 -0000 Received: (qmail 14384 invoked by uid 500); 30 Nov 2010 20:45:29 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 14350 invoked by uid 500); 30 Nov 2010 20:45:29 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 14343 invoked by uid 99); 30 Nov 2010 20:45:29 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Nov 2010 20:45:29 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Nov 2010 20:45:25 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id F0F3D23889EB; Tue, 30 Nov 2010 20:43:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@directory.apache.org From: antoine@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101130204352.F0F3D23889EB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 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 authenticators = authenticationInterceptor - .getAuthenticators(); + Set authenticators = new HashSet(); + 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() ); + } + } }