From 38a09766f048f113461a3b95005aa5ef2e28be05 Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Tue, 8 Dec 2009 20:24:07 +0000 Subject: [PATCH] Updated heavyduty sample to work with current trunk --- .gitignore | 6 ++ sandbox/heavyduty/pom.xml | 68 ++++++++++++------- ...avyDutyAuthenticationProcessingFilter.java | 7 +- .../security/ui/HeavyDutyEntryPoint.java | 4 +- .../src/main/java/sample/TestVoter.java | 6 +- .../webapp/WEB-INF/appContext-security.xml | 54 +++++++-------- sandbox/heavyduty/src/main/webapp/context.jsp | 8 +-- sandbox/heavyduty/src/main/webapp/login.jsp | 26 ++----- 8 files changed, 95 insertions(+), 84 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..fd9252ddbf --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +target/ +.classpath +.project +.settings/ +build/ +*.log \ No newline at end of file diff --git a/sandbox/heavyduty/pom.xml b/sandbox/heavyduty/pom.xml index 72e74b6e36..cb7d538857 100755 --- a/sandbox/heavyduty/pom.xml +++ b/sandbox/heavyduty/pom.xml @@ -21,7 +21,17 @@ spring-security-config ${spring.security.version} + + org.springframework.security + spring-security-taglibs + ${spring.security.version} + + + org.springframework + spring-context-support + ${spring.version} + org.springframework spring-web @@ -43,12 +53,9 @@ spring-orm ${spring.version} + @@ -182,7 +204,7 @@ - 3.0.0.CI-SNAPSHOT + 3.0.0.RC3 3.0.0.CI-SNAPSHOT diff --git a/sandbox/heavyduty/src/main/java/heavyduty/security/ui/HeavyDutyAuthenticationProcessingFilter.java b/sandbox/heavyduty/src/main/java/heavyduty/security/ui/HeavyDutyAuthenticationProcessingFilter.java index 4e7be0180c..c548242fd6 100755 --- a/sandbox/heavyduty/src/main/java/heavyduty/security/ui/HeavyDutyAuthenticationProcessingFilter.java +++ b/sandbox/heavyduty/src/main/java/heavyduty/security/ui/HeavyDutyAuthenticationProcessingFilter.java @@ -1,11 +1,8 @@ package heavyduty.security.ui; -import org.springframework.security.web.authentication.AuthenticationProcessingFilter; - -public class HeavyDutyAuthenticationProcessingFilter extends AuthenticationProcessingFilter { - - +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; +public class HeavyDutyAuthenticationProcessingFilter extends UsernamePasswordAuthenticationFilter { } diff --git a/sandbox/heavyduty/src/main/java/heavyduty/security/ui/HeavyDutyEntryPoint.java b/sandbox/heavyduty/src/main/java/heavyduty/security/ui/HeavyDutyEntryPoint.java index af40c3ea20..b2c76ea568 100755 --- a/sandbox/heavyduty/src/main/java/heavyduty/security/ui/HeavyDutyEntryPoint.java +++ b/sandbox/heavyduty/src/main/java/heavyduty/security/ui/HeavyDutyEntryPoint.java @@ -1,8 +1,8 @@ package heavyduty.security.ui; -import org.springframework.security.web.authentication.AuthenticationProcessingFilterEntryPoint; +import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint; -public class HeavyDutyEntryPoint extends AuthenticationProcessingFilterEntryPoint { +public class HeavyDutyEntryPoint extends LoginUrlAuthenticationEntryPoint { diff --git a/sandbox/heavyduty/src/main/java/sample/TestVoter.java b/sandbox/heavyduty/src/main/java/sample/TestVoter.java index 557dfc2fdd..31d20c2330 100644 --- a/sandbox/heavyduty/src/main/java/sample/TestVoter.java +++ b/sandbox/heavyduty/src/main/java/sample/TestVoter.java @@ -1,10 +1,10 @@ package sample; -import java.util.List; +import java.util.Collection; import org.aopalliance.intercept.MethodInvocation; import org.springframework.security.access.ConfigAttribute; -import org.springframework.security.access.vote.AccessDecisionVoter; +import org.springframework.security.access.AccessDecisionVoter; import org.springframework.security.core.Authentication; public class TestVoter implements AccessDecisionVoter { @@ -17,7 +17,7 @@ public class TestVoter implements AccessDecisionVoter { return MethodInvocation.class.isAssignableFrom(clazz); } - public int vote(Authentication authentication, Object object, List config) { + public int vote(Authentication authentication, Object object, Collection config) { MethodInvocation mi = (MethodInvocation) object; mi.getMethod().getParameterAnnotations(); diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-security.xml b/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-security.xml index 4a85ec7f05..511109a9ab 100755 --- a/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-security.xml +++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-security.xml @@ -11,10 +11,10 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd - http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd - http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.2.xsd"> + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd + http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"> @@ -48,7 +48,7 @@ --> - + @@ -56,12 +56,13 @@ - - + + + + + - - @@ -71,14 +72,10 @@ - - - --> - + + - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -126,5 +125,4 @@ - diff --git a/sandbox/heavyduty/src/main/webapp/context.jsp b/sandbox/heavyduty/src/main/webapp/context.jsp index bcd5c6fe0f..f758538a4b 100644 --- a/sandbox/heavyduty/src/main/webapp/context.jsp +++ b/sandbox/heavyduty/src/main/webapp/context.jsp @@ -1,6 +1,6 @@ <%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%> -<%@page import="org.springframework.security.providers.ldap.LdapAuthenticationProvider"%> -<%@page import="org.springframework.security.providers.ProviderManager"%> +<%@page import="org.springframework.security.ldap.authentication.LdapAuthenticationProvider"%> +<%@page import="org.springframework.security.authentication.ProviderManager"%> @@ -19,11 +19,11 @@ Providers:
<%= ((ProviderManager)WebApplicationContextUtils.getRequiredWebApplicationContext( - session.getServletContext()).getBean("_authenticationManager")).getProviders() %> + session.getServletContext()).getBean("org.springframework.security.authenticationManager")).getProviders() %>

Home

- \ No newline at end of file + diff --git a/sandbox/heavyduty/src/main/webapp/login.jsp b/sandbox/heavyduty/src/main/webapp/login.jsp index d752d3975e..8a7abb57e1 100755 --- a/sandbox/heavyduty/src/main/webapp/login.jsp +++ b/sandbox/heavyduty/src/main/webapp/login.jsp @@ -1,9 +1,7 @@ <%@ taglib prefix='c' uri='http://java.sun.com/jstl/core_rt' %> -<%@ page import="org.springframework.security.ui.AbstractProcessingFilter" %> -<%@ page import="org.springframework.security.ui.webapp.AuthenticationProcessingFilter" %> -<%@ page import="org.springframework.security.AuthenticationException" %> - - +<%@ page import="org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter" %> +<%@ page import="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter" %> +<%@ page import="org.springframework.security.core.AuthenticationException" %> @@ -13,35 +11,25 @@

CUSTOM SPRING SECURITY LOGIN

-

Valid users: -

-

username rod, password koala -
username dianne, password emu -
username scott, password wombat -
username peter, password opal -

- <%-- this form-login-page form is also used as the form-error-page to ask for a login again. --%> - <% if (session.getAttribute(AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY) != null) { %> + <% if (session.getAttribute(AbstractAuthenticationProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY) != null) { %> - Your login attempt was not successful, try again.

- Reason: <%= ((AuthenticationException) session.getAttribute(AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY)).getMessage() %> + Your login attempt was not successful, try again.

+ Reason: <%= ((AuthenticationException) session.getAttribute(AbstractAuthenticationProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY)).getMessage() %>
<% } %>

- +
User:value='<%= session.getAttribute(AuthenticationProcessingFilter.SPRING_SECURITY_LAST_USERNAME_KEY) %>'<% } %>>
User:value='<%= session.getAttribute(UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY) %>'<% } %>>
Password:
Don't ask for my password for two weeks
-
-