You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2015/04/22 08:32:13 UTC
svn commit: r1675262 - in /directory/apacheds/trunk/interceptors/authn/src:
main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
test/java/org/apache/directory/server/core/authn/AuthenticationInterceptorTest.java
Author: seelmann
Date: Wed Apr 22 06:32:13 2015
New Revision: 1675262
URL: http://svn.apache.org/r1675262
Log:
Register the authenticator always, also when another authenticator with same type already exists (DIRSERVER-2060)
Added:
directory/apacheds/trunk/interceptors/authn/src/test/java/org/apache/directory/server/core/authn/AuthenticationInterceptorTest.java
Modified:
directory/apacheds/trunk/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
Modified: directory/apacheds/trunk/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java?rev=1675262&r1=1675261&r2=1675262&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java (original)
+++ directory/apacheds/trunk/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java Wed Apr 22 06:32:13 2015
@@ -280,6 +280,7 @@ public class AuthenticationInterceptor e
private void register( Authenticator authenticator, DirectoryService directoryService ) throws LdapException
{
authenticator.init( directoryService );
+ authenticators.add( authenticator );
Collection<Authenticator> authenticatorList = getAuthenticators( authenticator.getAuthenticatorType() );
@@ -287,7 +288,6 @@ public class AuthenticationInterceptor e
{
authenticatorList = new ArrayList<Authenticator>();
authenticatorsMapByType.put( authenticator.getAuthenticatorType(), authenticatorList );
- authenticators.add( authenticator );
}
if ( !authenticatorList.contains( authenticator ) )
Added: directory/apacheds/trunk/interceptors/authn/src/test/java/org/apache/directory/server/core/authn/AuthenticationInterceptorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/authn/src/test/java/org/apache/directory/server/core/authn/AuthenticationInterceptorTest.java?rev=1675262&view=auto
==============================================================================
--- directory/apacheds/trunk/interceptors/authn/src/test/java/org/apache/directory/server/core/authn/AuthenticationInterceptorTest.java (added)
+++ directory/apacheds/trunk/interceptors/authn/src/test/java/org/apache/directory/server/core/authn/AuthenticationInterceptorTest.java Wed Apr 22 06:32:13 2015
@@ -0,0 +1,86 @@
+/*
+ * 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.core.authn;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Collections;
+
+import org.junit.Test;
+
+
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AuthenticationInterceptorTest
+{
+
+ @Test
+ public void testSetAuthenticatorsWithDefaultAuthenticators()
+ {
+ Authenticator[] authenticators = new Authenticator[]
+ { new AnonymousAuthenticator(), new SimpleAuthenticator(), new StrongAuthenticator() };
+
+ setAuthenticatorsAndAssertAllAreRegistered( authenticators );
+ }
+
+
+ @Test
+ public void testSetAuthenticatorsWithDelegatingAuthenticator()
+ {
+ Authenticator[] authenticators = new Authenticator[]
+ { new AnonymousAuthenticator(), new SimpleAuthenticator(), new StrongAuthenticator(),
+ new DelegatingAuthenticator() };
+
+ setAuthenticatorsAndAssertAllAreRegistered( authenticators );
+ }
+
+
+ @Test
+ public void testSetAuthenticatorsWithDelegatingAuthenticatorShuffled()
+ {
+ Authenticator[] authenticators = new Authenticator[]
+ { new AnonymousAuthenticator(), new SimpleAuthenticator(), new StrongAuthenticator(),
+ new DelegatingAuthenticator(), };
+
+ for ( int i = 0; i < 42; i++ )
+ {
+ Collections.shuffle( Arrays.asList( authenticators ) );
+
+ setAuthenticatorsAndAssertAllAreRegistered( authenticators );
+
+ }
+ }
+
+
+ private void setAuthenticatorsAndAssertAllAreRegistered( Authenticator[] authenticators )
+ {
+ AuthenticationInterceptor ai = new AuthenticationInterceptor();
+ ai.setAuthenticators( authenticators );
+
+ // assert all authenticators are registered
+ assertEquals( authenticators.length, ai.getAuthenticators().size() );
+ assertTrue( ai.getAuthenticators().containsAll( Arrays.asList( authenticators ) ) );
+ }
+
+}