Updated changelog and removed acegi-support.
This commit is contained in:
@@ -1,58 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
<artifactId>spring-ldap-parent</artifactId>
|
||||
<version>1.3-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>spring-ldap-acegi-support</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Spring LDAP Acegi Support</name>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.4</source>
|
||||
<target>1.4</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
<artifactId>spring-ldap-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.acegisecurity</groupId>
|
||||
<artifactId>acegi-security</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>easymock</groupId>
|
||||
<artifactId>easymock</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -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 "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -182,11 +182,6 @@
|
||||
<artifactId>spring-ldap-test</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
<artifactId>spring-ldap-acegi-support</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
<artifactId>spring-ldap-samples-utils</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user