28 changed files with 20 additions and 440 deletions
@ -1,5 +0,0 @@
@@ -1,5 +0,0 @@
|
||||
target |
||||
.settings |
||||
.classpath |
||||
.project |
||||
.wtpmodules |
||||
@ -1,112 +0,0 @@
@@ -1,112 +0,0 @@
|
||||
<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"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<parent> |
||||
<groupId>org.springframework.security</groupId> |
||||
<artifactId>spring-security-cas</artifactId> |
||||
<version>2.0-SNAPSHOT</version> |
||||
</parent> |
||||
<artifactId>spring-security-cas-adapter</artifactId> |
||||
<name>Spring Security - CAS adapter</name> |
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.apache.maven.plugins</groupId> |
||||
<artifactId>maven-compiler-plugin</artifactId> |
||||
<version>2.0.2</version> |
||||
<configuration> |
||||
<source>1.5</source> |
||||
<target>1.5</target> |
||||
</configuration> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.jasig.cas</groupId> |
||||
<artifactId>cas-server-core</artifactId> |
||||
<version>3.2</version> |
||||
<exclusions> |
||||
<exclusion> |
||||
<groupId>org.jasig.service</groupId> |
||||
<artifactId>person-directory</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>jdom</groupId> |
||||
<artifactId>jdom</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>spring-orm</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>org.apache.santuario</groupId> |
||||
<artifactId>xmlsec</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>commons-codec</groupId> |
||||
<artifactId>commons-codec</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>commons-collections</groupId> |
||||
<artifactId>commons-collections</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>org.opensaml</groupId> |
||||
<artifactId>opensaml</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>javax.persistence</groupId> |
||||
<artifactId>persistence-api</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>javax.xml</groupId> |
||||
<artifactId>xmldsig</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>commons-lang</groupId> |
||||
<artifactId>commons-lang</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>spring-webmvc</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>net.sf.ehcache</groupId> |
||||
<artifactId>ehcache</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>spring-webflow</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>org.springframework.ldap</groupId> |
||||
<artifactId>spring-ldap</artifactId> |
||||
</exclusion> |
||||
<exclusion> |
||||
<groupId>org.springframework.ldap</groupId> |
||||
<artifactId>spring-ldap-tiger</artifactId> |
||||
</exclusion> |
||||
</exclusions> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>spring-mock</artifactId> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>spring-jdbc</artifactId> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
<repositories> |
||||
<repository> |
||||
<id>jasig-m2</id> |
||||
<name>jasig-m2</name> |
||||
<url>http://developer.ja-sig.org/maven2</url> |
||||
</repository> |
||||
|
||||
</repositories> |
||||
|
||||
</project> |
||||
@ -1,80 +0,0 @@
@@ -1,80 +0,0 @@
|
||||
/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited |
||||
* |
||||
* 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.security.adapters.cas3; |
||||
|
||||
import org.springframework.security.Authentication; |
||||
import org.springframework.security.AuthenticationManager; |
||||
|
||||
import org.springframework.security.providers.UsernamePasswordAuthenticationToken; |
||||
|
||||
import org.inspektr.common.ioc.annotation.NotNull; |
||||
import org.jasig.cas.authentication.handler.AuthenticationException; |
||||
import org.jasig.cas.authentication.handler.AuthenticationHandler; |
||||
import org.jasig.cas.authentication.handler.support.AbstractUsernamePasswordAuthenticationHandler; |
||||
import org.jasig.cas.authentication.principal.UsernamePasswordCredentials; |
||||
|
||||
/** |
||||
* <p>Provides JA-SIG CAS 3 authentication by delegating to the Spring Security <code>AuthenticationManager</code>.</p> |
||||
* <p>This class would be configured in the <code>webapp/WEB-INF/deployerConfigContext.xml</code> file in the CAS |
||||
* distribution.</p> |
||||
* |
||||
* @author Scott Battaglia |
||||
* @version $Id:CasAuthenticationHandler.java 2151 2007-09-22 11:54:13Z luke_t $ |
||||
* |
||||
* @see AuthenticationHandler |
||||
* @see AuthenticationManager |
||||
*/ |
||||
public final class CasAuthenticationHandler extends AbstractUsernamePasswordAuthenticationHandler { |
||||
//~ Instance fields ================================================================================================
|
||||
|
||||
@NotNull |
||||
private AuthenticationManager authenticationManager; |
||||
|
||||
protected boolean authenticateUsernamePasswordInternal(final UsernamePasswordCredentials credentials) |
||||
throws AuthenticationException { |
||||
final Authentication authenticationRequest = new UsernamePasswordAuthenticationToken(credentials.getUsername(), |
||||
credentials.getPassword()); |
||||
|
||||
if (log.isDebugEnabled()) { |
||||
log.debug("Attempting to authenticate for user: " + credentials.getUsername()); |
||||
} |
||||
|
||||
try { |
||||
this.authenticationManager.authenticate(authenticationRequest); |
||||
} catch (final org.springframework.security.AuthenticationException e) { |
||||
if (log.isDebugEnabled()) { |
||||
log.debug("Authentication request for " + credentials.getUsername() + " failed: " + e.toString(), e); |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
|
||||
if (log.isDebugEnabled()) { |
||||
log.debug("Authentication request for " + credentials.getUsername() + " successful."); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* Method to set the Spring Security <code>AuthenticationManager</code> to delegate to. |
||||
* |
||||
* @param authenticationManager the Spring Security AuthenticationManager that knows how to authenticate users. |
||||
*/ |
||||
public void setAuthenticationManager(final AuthenticationManager authenticationManager) { |
||||
this.authenticationManager = authenticationManager; |
||||
} |
||||
} |
||||
@ -1,56 +0,0 @@
@@ -1,56 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> |
||||
<!-- |
||||
* Copyright 2004 Acegi Technology Pty Limited |
||||
* |
||||
* 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. |
||||
* |
||||
* Demonstration of the applicationContext.xml that should be copied into |
||||
* JA-SIG CAS's webapp/WEB-INF/deployerConfigContext.xml |
||||
* The example CAS AuthenticationHandler should be placed within CAS's |
||||
* AuthenticationManager's authenticationHandler list property. |
||||
* |
||||
* The Spring Security-specific beans can just be placed in the context file. |
||||
* |
||||
* $Id:applicationContext.xml 2151 2007-09-22 11:54:13Z luke_t $ |
||||
--> |
||||
<beans> |
||||
|
||||
<!-- Data access object which stores authentication information --> |
||||
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl"> |
||||
<property name="userMap"> |
||||
<value> |
||||
rod=koala,ROLES_IGNORED_BY_CAS |
||||
dianne=emu,ROLES_IGNORED_BY_CAS |
||||
scott=wombat,ROLES_IGNORED_BY_CAS |
||||
peter=opal,disabled,ROLES_IGNORED_BY_CAS |
||||
</value> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="daoAuthenticationProvider" class="org.springframework.security.providers.dao.DaoAuthenticationProvider"> |
||||
<property name="userDetailsService"><ref bean="inMemoryDaoImpl"/></property> |
||||
</bean> |
||||
|
||||
<bean id="authenticationManager" class="org.springframework.security.providers.ProviderManager"> |
||||
<property name="providers"> |
||||
<list> |
||||
<ref bean="daoAuthenticationProvider"/> |
||||
</list> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="casAuthenticationHandler" class="org.springframework.security.adapters.cas3.CasAuthenticationHandler"> |
||||
<property name="authenticationManager" ref="authenticationManager" /> |
||||
</bean> |
||||
</beans> |
||||
@ -1,11 +0,0 @@
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?> |
||||
|
||||
<project name="Spring Security CAS Adapter"> |
||||
<body> |
||||
<menu ref="parent"/> |
||||
<menu ref="reports"/> |
||||
</body> |
||||
|
||||
</project> |
||||
|
||||
|
||||
@ -1,85 +0,0 @@
@@ -1,85 +0,0 @@
|
||||
/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited |
||||
* |
||||
* 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.security.adapters.cas3; |
||||
|
||||
import org.springframework.security.AuthenticationManager; |
||||
|
||||
import org.jasig.cas.authentication.handler.AuthenticationException; |
||||
import org.jasig.cas.authentication.principal.UsernamePasswordCredentials; |
||||
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests; |
||||
|
||||
|
||||
/** |
||||
* Tests {@link CasAuthenticationHandler} |
||||
* |
||||
* @author Scott Battaglia |
||||
* @version $Id:CasAuthenticationHandlerTests.java 2151 2007-09-22 11:54:13Z luke_t $ |
||||
*/ |
||||
public class CasAuthenticationHandlerTests extends AbstractDependencyInjectionSpringContextTests { |
||||
//~ Instance fields ================================================================================================
|
||||
|
||||
private AuthenticationManager authenticationManager; |
||||
private CasAuthenticationHandler casAuthenticationHandler; |
||||
|
||||
//~ Methods ========================================================================================================
|
||||
|
||||
protected String[] getConfigLocations() { |
||||
return new String[] {"/org/springframework/security/adapters/cas3/applicationContext-valid.xml"}; |
||||
} |
||||
|
||||
private UsernamePasswordCredentials getCredentialsFor(final String username, final String password) { |
||||
final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(); |
||||
credentials.setUsername(username); |
||||
credentials.setPassword(password); |
||||
|
||||
return credentials; |
||||
} |
||||
|
||||
protected void onSetUp() throws Exception { |
||||
this.casAuthenticationHandler = new CasAuthenticationHandler(); |
||||
this.casAuthenticationHandler.setAuthenticationManager(authenticationManager); |
||||
} |
||||
|
||||
public void setAuthenticationManager(final AuthenticationManager authenticationManager) { |
||||
this.authenticationManager = authenticationManager; |
||||
} |
||||
|
||||
public void testGracefullyHandlesInvalidInput() { |
||||
try { |
||||
assertFalse(this.casAuthenticationHandler.authenticate(getCredentialsFor("", ""))); |
||||
assertFalse(this.casAuthenticationHandler.authenticate(getCredentialsFor(null, null))); |
||||
} catch (final AuthenticationException e) { |
||||
fail("AuthenticationException not expected."); |
||||
} |
||||
} |
||||
|
||||
public void testInvalidUsernamePasswordCombination() { |
||||
try { |
||||
assertFalse(this.casAuthenticationHandler.authenticate(getCredentialsFor("scott", "scott"))); |
||||
} catch (final AuthenticationException e) { |
||||
fail("AuthenticationException not expected."); |
||||
} |
||||
} |
||||
|
||||
public void testValidUsernamePasswordCombination() { |
||||
try { |
||||
assertTrue(this.casAuthenticationHandler.authenticate(getCredentialsFor("scott", "wombat"))); |
||||
} catch (final AuthenticationException e) { |
||||
fail("AuthenticationException not expected."); |
||||
} |
||||
} |
||||
} |
||||
@ -1,45 +0,0 @@
@@ -1,45 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> |
||||
<!-- |
||||
* Copyright 2004 Acegi Technology Pty Limited |
||||
* |
||||
* 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. |
||||
* |
||||
* $Id$ |
||||
--> |
||||
|
||||
<beans> |
||||
|
||||
<bean id="inMemoryDaoImpl" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl"> |
||||
<property name="userMap"> |
||||
<value> |
||||
rod=koala,ROLE_TELLER,ROLE_SUPERVISOR |
||||
dianne=emu,ROLE_TELLER |
||||
scott=wombat,ROLE_TELLER |
||||
peter=opal,disabled,ROLE_TELLER |
||||
</value> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="daoAuthenticationProvider" class="org.springframework.security.providers.dao.DaoAuthenticationProvider"> |
||||
<property name="userDetailsService"><ref bean="inMemoryDaoImpl"/></property> |
||||
</bean> |
||||
|
||||
<bean id="authenticationManager" class="org.springframework.security.providers.ProviderManager"> |
||||
<property name="providers"> |
||||
<list> |
||||
<ref bean="daoAuthenticationProvider"/> |
||||
</list> |
||||
</property> |
||||
</bean> |
||||
</beans> |
||||
@ -1,40 +0,0 @@
@@ -1,40 +0,0 @@
|
||||
<?xml version="1.0"?> |
||||
<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> |
||||
<artifactId>spring-security-cas</artifactId> |
||||
<groupId>org.springframework.security</groupId> |
||||
<version>2.0-SNAPSHOT</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<groupId>org.springframework.security</groupId> |
||||
<artifactId>spring-security-cas-client</artifactId> |
||||
<name>Spring Security - CAS client integration</name> |
||||
<version>2.0-SNAPSHOT</version> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.springframework.security</groupId> |
||||
<artifactId>spring-security-core</artifactId> |
||||
<version>${project.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>javax.servlet</groupId> |
||||
<artifactId>servlet-api</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework</groupId> |
||||
<artifactId>spring-mock</artifactId> |
||||
<optional>true</optional> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.jasig.cas</groupId> |
||||
<artifactId>cas-client-core</artifactId> |
||||
<version>3.1.1</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>net.sf.ehcache</groupId> |
||||
<artifactId>ehcache</artifactId> |
||||
<optional>true</optional> |
||||
</dependency> |
||||
</dependencies> |
||||
</project> |
||||
Loading…
Reference in new issue