Updated heavy-duty sample to be able to build it.

This commit is contained in:
Luke Taylor 2009-04-28 06:42:57 +00:00
parent 929b6bb1a0
commit f38c0eb675
13 changed files with 268 additions and 275 deletions

View File

@ -8,24 +8,20 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId> <artifactId>spring-security-web</artifactId>
<version>${spring.security.version}</version> <version>${spring.security.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId> <artifactId>spring-security-ldap</artifactId>
<version>${spring.security.version}</version> <version>${spring.security.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework.security</groupId>
<artifactId>org.springframework.core</artifactId> <artifactId>spring-security-config</artifactId>
<version>${spring.version}</version> <version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.context</artifactId>
<version>${spring.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>org.springframework.web</artifactId> <artifactId>org.springframework.web</artifactId>
@ -44,15 +40,28 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId> <artifactId>org.springframework.orm</artifactId>
<version>${spring.version}</version> <version>${spring.version}</version>
</dependency> </dependency>
<!--
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>org.springframework.aop</artifactId> <artifactId>org.springframework.aop</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
<version>${spring.version}</version> <version>${spring.version}</version>
</dependency> </dependency>
-->
<dependency> <dependency>
<groupId>org.freemarker</groupId> <groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId> <artifactId>freemarker</artifactId>
@ -74,20 +83,9 @@
<dependency> <dependency>
<groupId>net.sf.ehcache</groupId> <groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId> <artifactId>ehcache</artifactId>
<version>1.3.0</version> <version>1.4.1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<optional>true</optional>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.5.4</version>
</dependency>
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId> <artifactId>servlet-api</artifactId>
@ -184,7 +182,7 @@
</plugins> </plugins>
</build> </build>
<properties> <properties>
<spring.version>2.5.6</spring.version> <spring.version>3.0.0.M2</spring.version>
<spring.security.version>3.0.0.CI-SNAPSHOT</spring.security.version> <spring.security.version>3.0.0.CI-SNAPSHOT</spring.security.version>
</properties> </properties>

View File

@ -5,7 +5,7 @@ import java.util.Map;
public class BankDaoStub implements BankDao { public class BankDaoStub implements BankDao {
private long id = 0; private long id = 0;
private Map accounts = new HashMap(); private Map<Long, Account> accounts = new HashMap<Long, Account>();
public void createOrUpdateAccount(Account account) { public void createOrUpdateAccount(Account account) {
if (account.getId() == -1) { if (account.getId() == -1) {

View File

@ -1,6 +1,6 @@
package bigbank; package bigbank;
import org.springframework.security.annotation.Secured; import org.springframework.security.access.annotation.Secured;
public interface BankService { public interface BankService {

View File

@ -1,6 +1,6 @@
package heavyduty.security.ui; package heavyduty.security.ui;
import org.springframework.security.ui.webapp.AuthenticationProcessingFilter; import org.springframework.security.web.authentication.AuthenticationProcessingFilter;
public class HeavyDutyAuthenticationProcessingFilter extends AuthenticationProcessingFilter { public class HeavyDutyAuthenticationProcessingFilter extends AuthenticationProcessingFilter {

View File

@ -1,6 +1,6 @@
package heavyduty.security.ui; package heavyduty.security.ui;
import org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint; import org.springframework.security.web.authentication.AuthenticationProcessingFilterEntryPoint;
public class HeavyDutyEntryPoint extends AuthenticationProcessingFilterEntryPoint { public class HeavyDutyEntryPoint extends AuthenticationProcessingFilterEntryPoint {

View File

@ -41,7 +41,7 @@ public class TestMultiActionController extends MultiActionController {
} }
private ModelAndView createView(String name) { private ModelAndView createView(String name) {
Map model = new HashMap(); Map<String, String> model = new HashMap<String, String>();
model.put("nextAction", name); model.put("nextAction", name);
return new ModelAndView(VIEW_NAME, model); return new ModelAndView(VIEW_NAME, model);
} }

View File

@ -1,12 +1,11 @@
package sample; package sample;
import java.lang.annotation.Annotation;
import java.util.List; import java.util.List;
import org.aopalliance.intercept.MethodInvocation; import org.aopalliance.intercept.MethodInvocation;
import org.springframework.security.Authentication; import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.ConfigAttribute; import org.springframework.security.access.vote.AccessDecisionVoter;
import org.springframework.security.vote.AccessDecisionVoter; import org.springframework.security.core.Authentication;
public class TestVoter implements AccessDecisionVoter { public class TestVoter implements AccessDecisionVoter {
@ -14,14 +13,14 @@ public class TestVoter implements AccessDecisionVoter {
return true; return true;
} }
public boolean supports(Class clazz) { public boolean supports(Class<?> clazz) {
return MethodInvocation.class.isAssignableFrom(clazz); return MethodInvocation.class.isAssignableFrom(clazz);
} }
public int vote(Authentication authentication, Object object, List<ConfigAttribute> config) { public int vote(Authentication authentication, Object object, List<ConfigAttribute> config) {
MethodInvocation mi = (MethodInvocation) object; MethodInvocation mi = (MethodInvocation) object;
Annotation[][] annotations = mi.getMethod().getParameterAnnotations(); mi.getMethod().getParameterAnnotations();
return ACCESS_GRANTED; return ACCESS_GRANTED;

View File

@ -39,7 +39,6 @@ public class GenericDAOImpl<T extends Serializable, PK extends Serializable>
* data id * data id
* @return data * @return data
*/ */
@SuppressWarnings("unchecked")
public T read(PK id) { public T read(PK id) {
if (id == null) { if (id == null) {
throw new IllegalArgumentException("Id cannot be null or empty"); throw new IllegalArgumentException("Id cannot be null or empty");
@ -106,7 +105,6 @@ public class GenericDAOImpl<T extends Serializable, PK extends Serializable>
* @return the merged data * @return the merged data
* @see sido.common.dao.GenericDAO#merge(T) * @see sido.common.dao.GenericDAO#merge(T)
*/ */
@SuppressWarnings("unchecked")
public T merge(T detachedInstance) { public T merge(T detachedInstance) {
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("merging instance of " LOG.debug("merging instance of "

View File

@ -1,7 +1,7 @@
package sample.service; package sample.service;
import org.springframework.security.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UserDetailsService;
public interface UserService extends UserDetailsService { public interface UserService extends UserDetailsService {

View File

@ -6,13 +6,11 @@ package sample.service.impl;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.AuthenticationException; import org.springframework.security.core.AuthenticationException;
import org.springframework.security.GrantedAuthority; import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.GrantedAuthorityImpl; import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.userdetails.UserDetails; import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import sample.dao.UserDAO; import sample.dao.UserDAO;
@ -39,9 +37,9 @@ public class UserServiceImpl implements UserService {
try { try {
User user = userDAO.findByUsername(username); User user = userDAO.findByUsername(username);
return new org.springframework.security.userdetails.User(user return new org.springframework.security.core.userdetails.User(user
.getUsername(), user.getPassword(), true, true, true, true, .getUsername(), user.getPassword(), true, true, true, true,
new GrantedAuthority[] { new GrantedAuthorityImpl("ROLE_USER") }); AuthorityUtils.createAuthorityList("ROLE_USER"));
} catch (Exception e) { } catch (Exception e) {
LOG.error(e.getMessage(), e); LOG.error(e.getMessage(), e);
throw new UsernameNotFoundException("No matching account", e); throw new UsernameNotFoundException("No matching account", e);
@ -51,9 +49,9 @@ public class UserServiceImpl implements UserService {
public UserDetails register(String username, String password) { public UserDetails register(String username, String password) {
User user = new User(username, password); User user = new User(username, password);
userDAO.persist(user); userDAO.persist(user);
return new org.springframework.security.userdetails.User(user return new org.springframework.security.core.userdetails.User(user
.getUsername(), user.getPassword(), true, true, true, true, .getUsername(), user.getPassword(), true, true, true, true,
new GrantedAuthority[] { new GrantedAuthorityImpl("ROLE_USER") }); AuthorityUtils.createAuthorityList("ROLE_USER"));
} }

View File

@ -26,7 +26,7 @@
<aop:aspectj-autoproxy/> <aop:aspectj-autoproxy/>
<b:bean id="methodAccessMgr" class="org.springframework.security.vote.AffirmativeBased"> <b:bean id="methodAccessMgr" class="org.springframework.security.access.vote.AffirmativeBased">
<b:property name="decisionVoters"> <b:property name="decisionVoters">
<b:list> <b:list>
<b:bean class="sample.TestVoter"/> <b:bean class="sample.TestVoter"/>
@ -62,7 +62,7 @@
<authentication-manager alias="authenticationManager" /> <authentication-manager alias="authenticationManager" />
<b:bean id='tokenRepo' class='org.springframework.security.ui.rememberme.InMemoryTokenRepositoryImpl'/> <b:bean id='tokenRepo' class='org.springframework.security.web.authentication.rememberme.InMemoryTokenRepositoryImpl'/>
<!-- Traditional Session Control Beans --> <!-- Traditional Session Control Beans -->
<!-- <!--
@ -75,7 +75,7 @@
<b:property name='sessionRegistry' ref='sessionRegistry'/> <b:property name='sessionRegistry' ref='sessionRegistry'/>
</b:bean> </b:bean>
--> -->
<b:bean id='sessionRegistry' class="org.springframework.security.concurrent.SessionRegistryImpl"/> <b:bean id='sessionRegistry' class="org.springframework.security.authentication.concurrent.SessionRegistryImpl"/>
<!-- <!--
<b:bean id="customAuthFilter" class="heavyduty.security.ui.HeavyDutyAuthenticationProcessingFilter"> <b:bean id="customAuthFilter" class="heavyduty.security.ui.HeavyDutyAuthenticationProcessingFilter">
<custom-filter position="AUTHENTICATION_PROCESSING_FILTER"/> <custom-filter position="AUTHENTICATION_PROCESSING_FILTER"/>

View File

@ -83,17 +83,17 @@
</property> </property>
</bean> </bean>
<bean id="accessDecisionManager" class="org.springframework.security.vote.AffirmativeBased"> <bean id="accessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased">
<property name="allowIfAllAbstainDecisions" value="false"/> <property name="allowIfAllAbstainDecisions" value="false"/>
<property name="decisionVoters"> <property name="decisionVoters">
<list> <list>
<bean class="org.springframework.security.vote.RoleVoter"/> <bean class="org.springframework.security.access.vote.RoleVoter"/>
<bean class="org.springframework.security.vote.AuthenticatedVoter"/> <bean class="org.springframework.security.access.vote.AuthenticatedVoter"/>
</list> </list>
</property> </property>
</bean> </bean>
<bean id="filterInvocationInterceptor" class="org.springframework.security.intercept.web.FilterSecurityInterceptor"> <bean id="filterInvocationInterceptor" class="org.springframework.security.web.intercept.FilterSecurityInterceptor">
<property name="authenticationManager" ref="authenticationManager"/> <property name="authenticationManager" ref="authenticationManager"/>
<property name="accessDecisionManager" ref="accessDecisionManager"/> <property name="accessDecisionManager" ref="accessDecisionManager"/>
<property name="objectDefinitionSource"> <property name="objectDefinitionSource">
@ -107,31 +107,31 @@
</property> </property>
</bean> </bean>
<bean id="rememberMeServices" class="org.springframework.security.ui.rememberme.TokenBasedRememberMeServices"> <bean id="rememberMeServices" class="org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices">
<property name="userDetailsService" ref="userDetailsService"/> <property name="userDetailsService" ref="userDetailsService"/>
<property name="key" value="changeThis"/> <property name="key" value="changeThis"/>
</bean> </bean>
<bean id="authenticationManager" class="org.springframework.security.providers.ProviderManager"> <bean id="authenticationManager" class="org.springframework.security.authentication.ProviderManager">
<property name="providers"> <property name="providers">
<list> <list>
<ref local="daoAuthenticationProvider"/> <ref local="daoAuthenticationProvider"/>
<bean class="org.springframework.security.providers.anonymous.AnonymousAuthenticationProvider"> <bean class="org.springframework.security.authentication.AnonymousAuthenticationProvider">
<property name="key" value="changeThis"/> <property name="key" value="changeThis"/>
</bean> </bean>
<bean class="org.springframework.security.providers.rememberme.RememberMeAuthenticationProvider"> <bean class="org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationProvider">
<property name="key" value="changeThis"/> <property name="key" value="changeThis"/>
</bean> </bean>
</list> </list>
</property> </property>
</bean> </bean>
<bean id="daoAuthenticationProvider" class="org.springframework.security.providers.dao.DaoAuthenticationProvider"> <bean id="daoAuthenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
<property name="userDetailsService" ref="userDetailsService"/> <property name="userDetailsService" ref="userDetailsService"/>
</bean> </bean>
<!-- UserDetailsService is the most commonly frequently Acegi Security interface implemented by end users --> <!-- UserDetailsService is the most commonly frequently Acegi Security interface implemented by end users -->
<bean id="userDetailsService" class="org.springframework.security.userdetails.memory.InMemoryDaoImpl"> <bean id="userDetailsService" class="org.springframework.security.core.userdetails.memory.InMemoryDaoImpl">
<property name="userProperties"> <property name="userProperties">
<bean class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location" value="/WEB-INF/users.properties"/> <property name="location" value="/WEB-INF/users.properties"/>
@ -140,21 +140,21 @@
</bean> </bean>
<!-- This bean is optional; it isn't used by any other bean as it only listens and logs --> <!-- This bean is optional; it isn't used by any other bean as it only listens and logs -->
<bean id="loggerListener" class="org.springframework.security.event.authentication.LoggerListener"/> <bean id="loggerListener" class="org.springframework.security.authentication.event.LoggerListener"/>
<bean id="daacc" class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"/> <bean id="daacc" class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"/>
<bean id="attributes" class="org.springframework.security.annotation.SecurityAnnotationAttributes"/> <bean id="attributes" class="org.springframework.security.access.annotation.SecurityAnnotationAttributes"/>
<bean id="objectDefinitionSource" class="org.springframework.security.intercept.method.MethodDefinitionAttributes"> <bean id="securityMetadataSource" class="org.springframework.security.access.intercept.method.MethodDefinitionAttributes">
<property name="attributes"><ref local="attributes"/></property> <property name="attributes"><ref local="attributes"/></property>
</bean> </bean>
<bean id="securityInterceptor" class="org.springframework.security.intercept.method.aopalliance.MethodSecurityInterceptor"> <bean id="securityInterceptor" class="org.springframework.security.intercept.method.aopalliance.MethodSecurityInterceptor">
<property name="authenticationManager"><ref local="authenticationManager"/></property> <property name="authenticationManager"><ref local="authenticationManager"/></property>
<property name="accessDecisionManager"><ref local="accessDecisionManager"/></property> <property name="accessDecisionManager"><ref local="accessDecisionManager"/></property>
<property name="objectDefinitionSource"> <property name="securityMetadataSource">
<ref local="objectDefinitionSource"/> <ref local="securityMetadataSource"/>
</property> </property>
</bean> </bean>

View File

@ -62,7 +62,7 @@
- context. Optional unless concurrent session control is being used. - context. Optional unless concurrent session control is being used.
--> -->
<listener> <listener>
<listener-class>org.springframework.security.ui.session.HttpSessionEventPublisher</listener-class> <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener> </listener>
<!-- <!--