From 865dd185fdcae277a35429ecfe2631d2d0a7da27 Mon Sep 17 00:00:00 2001 From: Mattias Arthursson Date: Thu, 23 Oct 2008 10:44:19 +0000 Subject: [PATCH] Updated changelog and removed acegi-support. --- acegi-support/pom.xml | 58 ------- .../AcegiAuthenticationSource.java | 87 ----------- .../AcegiAuthenticationSourceTest.java | 144 ------------------ core/changelog.txt | 89 ++++++++++- parent/pom.xml | 5 - pom.xml | 1 - 6 files changed, 87 insertions(+), 297 deletions(-) delete mode 100644 acegi-support/pom.xml delete mode 100644 acegi-support/src/main/java/org/springframework/ldap/authentication/AcegiAuthenticationSource.java delete mode 100644 acegi-support/src/test/java/org/springframework/ldap/authentication/AcegiAuthenticationSourceTest.java diff --git a/acegi-support/pom.xml b/acegi-support/pom.xml deleted file mode 100644 index a7f96135..00000000 --- a/acegi-support/pom.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - org.springframework.ldap - spring-ldap-parent - 1.3-SNAPSHOT - - 4.0.0 - spring-ldap-acegi-support - jar - Spring LDAP Acegi Support - - - - - maven-compiler-plugin - - 1.4 - 1.4 - - - - - - - - org.springframework.ldap - spring-ldap-core - - - commons-logging - commons-logging - - - org.acegisecurity - acegi-security - provided - - - junit - junit - test - - - easymock - easymock - test - - - org.springframework - spring-core - test - - - diff --git a/acegi-support/src/main/java/org/springframework/ldap/authentication/AcegiAuthenticationSource.java b/acegi-support/src/main/java/org/springframework/ldap/authentication/AcegiAuthenticationSource.java deleted file mode 100644 index 2a8fa91e..00000000 --- a/acegi-support/src/main/java/org/springframework/ldap/authentication/AcegiAuthenticationSource.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2005-2007 the original author or authors. - * - * Licensed 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.springframework.ldap.authentication; - -import org.acegisecurity.Authentication; -import org.acegisecurity.context.SecurityContextHolder; -import org.acegisecurity.providers.anonymous.AnonymousAuthenticationToken; -import org.acegisecurity.userdetails.ldap.LdapUserDetails; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.ldap.core.AuthenticationSource; - -/** - * An AuthenticationSource to retrieve authentication information stored in - * Acegi's SecurityContextHolder. Use Acegi's LdapAuthenticationProvider have a - * LdapUserDetails object placed in the authentication. - * - * @author Mattias Arthursson - * - */ -public class AcegiAuthenticationSource implements AuthenticationSource { - private static final Log log = LogFactory - .getLog(AcegiAuthenticationSource.class); - - /** - * Get the principals of the logged in user, in this case the distinguished - * name. - * - * @return the distinguished name of the logged in user. - */ - public String getPrincipal() { - Authentication authentication = SecurityContextHolder.getContext() - .getAuthentication(); - if (authentication != null) { - Object principal = authentication.getPrincipal(); - if (principal instanceof LdapUserDetails) { - LdapUserDetails details = (LdapUserDetails) principal; - return details.getDn(); - } else if (authentication instanceof AnonymousAuthenticationToken) { - if (log.isDebugEnabled()) { - log - .debug("Anonymous Authentication, returning empty String as Principal"); - } - return ""; - } else { - throw new IllegalArgumentException( - "The principal property of the authentication object -" - + "needs to be a LdapUserDetails."); - } - } else { - log.warn("No Authentication object set in SecurityContext - " - + "returning empty String as Principal"); - return ""; - } - } - - /* - * @see org.springframework.ldap.core.AuthenticationSource#getCredentials() - */ - public String getCredentials() { - Authentication authentication = SecurityContextHolder.getContext() - .getAuthentication(); - - if (authentication != null) { - return (String) authentication.getCredentials(); - } else { - log.warn("No Authentication object set in SecurityContext - " - + "returning empty String as Credentials"); - return ""; - } - } - -} diff --git a/acegi-support/src/test/java/org/springframework/ldap/authentication/AcegiAuthenticationSourceTest.java b/acegi-support/src/test/java/org/springframework/ldap/authentication/AcegiAuthenticationSourceTest.java deleted file mode 100644 index dd9d89d4..00000000 --- a/acegi-support/src/test/java/org/springframework/ldap/authentication/AcegiAuthenticationSourceTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright 2005-2007 the original author or authors. - * - * Licensed 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.springframework.ldap.authentication; - -import junit.framework.TestCase; - -import org.acegisecurity.Authentication; -import org.acegisecurity.GrantedAuthority; -import org.acegisecurity.context.SecurityContextHolder; -import org.acegisecurity.providers.anonymous.AnonymousAuthenticationToken; -import org.acegisecurity.userdetails.User; -import org.acegisecurity.userdetails.ldap.LdapUserDetails; -import org.easymock.MockControl; -import org.springframework.ldap.authentication.AcegiAuthenticationSource; - -public class AcegiAuthenticationSourceTest extends TestCase { - - private MockControl authenticationControl; - - private Authentication authenticationMock; - - private MockControl ldapUserDetailsControl; - - private LdapUserDetails ldapUserDetailsMock; - - private AcegiAuthenticationSource tested; - - protected void setUp() throws Exception { - super.setUp(); - - authenticationControl = MockControl.createControl(Authentication.class); - authenticationMock = (Authentication) authenticationControl.getMock(); - - ldapUserDetailsControl = MockControl - .createControl(LdapUserDetails.class); - ldapUserDetailsMock = (LdapUserDetails) ldapUserDetailsControl - .getMock(); - - tested = new AcegiAuthenticationSource(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - - authenticationControl = null; - authenticationMock = null; - - ldapUserDetailsControl = null; - ldapUserDetailsMock = null; - - tested = null; - } - - protected void replay() { - authenticationControl.replay(); - ldapUserDetailsControl.replay(); - } - - protected void verify() { - authenticationControl.verify(); - ldapUserDetailsControl.verify(); - } - - public void testGetPrincipalAndCredentials() { - authenticationControl.expectAndReturn( - authenticationMock.getPrincipal(), ldapUserDetailsMock); - authenticationControl.expectAndReturn(authenticationMock - .getCredentials(), "secret"); - - ldapUserDetailsControl.expectAndDefaultReturn(ldapUserDetailsMock - .getDn(), "cn=Manager"); - - SecurityContextHolder.getContext() - .setAuthentication(authenticationMock); - - replay(); - - String principal = tested.getPrincipal(); - String credentials = tested.getCredentials(); - - verify(); - - assertEquals("secret", credentials); - assertEquals("cn=Manager", principal); - } - - public void testGetPrincipalAndCredentials_nullAuthentication() { - SecurityContextHolder.getContext().setAuthentication(null); - - replay(); - - assertEquals("", tested.getPrincipal()); - assertEquals("", tested.getCredentials()); - verify(); - } - - public void testGetPrincipal_InvalidPrincipal() { - authenticationControl.expectAndReturn( - authenticationMock.getPrincipal(), new User("dummy", "dummy", - true, true, true, true, new GrantedAuthority[0])); - - SecurityContextHolder.getContext() - .setAuthentication(authenticationMock); - - replay(); - - try { - tested.getPrincipal(); - fail("IllegalArgumentException expected"); - } catch (IllegalArgumentException expected) { - assertTrue(true); - } - verify(); - } - - public void testGetPrincipalWithAnonymousAuthenticationToken() { - - SecurityContextHolder.getContext().setAuthentication( - new AnonymousAuthenticationToken("dummy", "dummy", - new GrantedAuthority[] { new DummyAuthoroty() })); - - assertEquals("", tested.getPrincipal()); - } - - private static class DummyAuthoroty implements GrantedAuthority { - public String getAuthority() { - return null; - } - } -} diff --git a/core/changelog.txt b/core/changelog.txt index 0fad7107..c1656c83 100644 --- a/core/changelog.txt +++ b/core/changelog.txt @@ -13,9 +13,93 @@ http://www.ietf.org/rfc/rfc2696.txt Changes in version 1.3 (XXX 2008) ------------------------------------------- +* TLS connections are now supported using the DefaultTlsDirContextAuthenticationStrategy + and ExternalTlsDirContextAuthenticationStrategy. (LDAP-8) + +* NameNotFound is no longer silently ignored in searches. It is possible + to use the old behavior by setting the ignoreNameNotFoundException property + to true in LdapTemplate. (LDAP-134) + +* Referrals can now be handled by setting the property 'Context.REFERRAL' + to 'follow' in the base context supplied to AbstractContextSource, provided + that name servers are set up properly. Any DirContextAdapter instances + resulting from referrals will provide the URL of the referred server in + getReferralUrl(). (LDAP-136, LDAP-9) + +* The hard dependency on LDAP Booster Pack has now been completely removed, + preventing NoClassDefFoundErrors when using Paged Results without that + library on the classpath. (LDAP-110, LDAP-118) + +* The dreaded problem with '\' in Distinguished Names is now resolved. + (LDAP-50, LDAP-109) + +* Added bind method that takes a DirContextOperations instance as parameter, + performing the bind using the DN and Attributes from the DirContextOperations + instance. (LDAP-140) + +* DistinguishedName now returns compactly formatted String representations + from toString, e.g.: + cn=John Doe,ou=Company,c=Sweden + rather than + cn=John Doe, ou=Company, c=Sweden + To keep using the old formatting (for backward compatibility) set the + system property org.springframework.ldap.core.spacedDnFormat to true. + (LDAP-138, LDAP-112, LDAP-91) + +* Now using Maven for building internally. (LDAP-80, LDAP-82, LDAP-95) + +* Added HardcodedFilter class and corresponding PropertyEditor FilterEditor, + to allow for easily working with pre-encoded search filters + e.g. in configuration files. (LDAP-28) + +* Added ContextSourceAndHibernateTransactionManager to enable integration + of client-side LDAP Transactions in a Hibernate environment. (LDAP-115) + +* Added append method to BinaryLogicalFilter allowing client code to use + and/or filters from the same code. (LDAP-116) + +* Introduced DirContextAuthenticationStrategy to AbstractContextSource + to enable more flexible context authentication strategies, e.g. + TLS and Proxy Auth. (LDAP-124) + +* Corrected reference doc claiming DataAccessException hierarchy. (LDAP-106) + +* Probably the most requested feature of all - a plain method for simple + authentication is now provided in the ContextSource interface. + (LDAP-39, LDAP-103) + +* The order of multi-valued attributes is now properly preserved by + DirContextAdapter#getModificationItems(). (LDAP-96) + +* ContextSourceTransactionManager now properly throws a + CannotCreateTransactionException if anything goes wrong in doBegin(). (LDAP-122) + +* It is now possible to set the criticality on PagedResultsControl. + (LDAP-126) + +* DirContextAdapter now has a getObjectAttributes method, as stated in + reference docs. (LDAP-137) + +* DirContextAdapter#getStringAttributes, getObjectAttributes, and + getAttributeSortedStringSet now all return null if the requested Attribute + is not present, and an empty result (array or set) if present but empty. + (LDAP-130) + +* SimpleLdapOperations/SimpleLdapTemplate now has mirrored methods that take + Name parameters. (LDAP-139) + +* Fixed documentation glitch regarding ContextSourceAndDataSourceTransactionManager. + (LDAP-99) + +* Added the possibility to configure the search scope on DefaultDirContextValidator. + Changed the default to OBJECT_SCOPE. (LDAP-121) + +* Fixed DistinguishedName parsing error; \r is now allowed in Distinguished Names, + complying with LDAP v3 DN RFC. (LDAP-97) + * Moved SingleContextSource from an obscure inner class to a top-level class. This class doesn't close the DirContext, but reuses the same. - Useful for scenarios like Paged Results. + Useful for scenarios like Paged Results. (LDAP-114) * Removed deprecated method setUserName() in AbstractContextSource. @@ -32,7 +116,8 @@ Changes in version 1.3 (XXX 2008) * Made changes required for paged results to work when using Spring LDAP connection pool with a single connection. (LDAP-114) -* Upgraded Acegi to 1.0.6. +* Removed AcegiAuthenticationSource - use SpringSecurityAuthenticationSource + (included with Spring Security) instead. * Upgraded commons-lang to 2.3. diff --git a/parent/pom.xml b/parent/pom.xml index 9c8a08ee..681b47cb 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -182,11 +182,6 @@ spring-ldap-test ${project.version} - - org.springframework.ldap - spring-ldap-acegi-support - ${project.version} - org.springframework.ldap spring-ldap-samples-utils diff --git a/pom.xml b/pom.xml index 4eaad6ae..3fbb7654 100644 --- a/pom.xml +++ b/pom.xml @@ -112,7 +112,6 @@ parent core core-tiger - acegi-support test-support test