implements
+ sample.dao.UserDAO {
+
+ /**
+ * Required constructor
+ */
+ public UserDAOImpl() {
+ super(User.class);
+ }
+
+ public User findByUsername(String username) {
+ return (User) getEntityManager().createNamedQuery("User.findByUsername")
+ .setParameter("username", username).getSingleResult();
+ }
+
+
+}
diff --git a/sandbox/heavyduty/src/main/java/sample/domain/User.java b/sandbox/heavyduty/src/main/java/sample/domain/User.java
new file mode 100755
index 0000000000..7fc7bf6afa
--- /dev/null
+++ b/sandbox/heavyduty/src/main/java/sample/domain/User.java
@@ -0,0 +1,106 @@
+
+
+package sample.domain;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.NamedQuery;
+
+/**
+ * The Class Patient.
+ */
+@Entity
+@NamedQuery(name = "User.findByUsername", query = "from User where username= :username")
+public class User implements Serializable {
+
+ /** serialVersionUID */
+ private static final long serialVersionUID = 7073017148588882593L;
+
+ /** The id. */
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ private Long id;
+
+ /** The username. */
+ @Basic(optional = false)
+ private String username;
+
+ /** The username. */
+ @Basic(optional = false)
+ private String password;
+
+ /**
+ * Default constructor
+ */
+ public User() {
+ super();
+ }
+
+ /**
+ * @param username
+ * @param password
+ */
+ public User(String username, String password) {
+ super();
+ this.username = username;
+ this.password = password;
+ }
+
+ /**
+ * @return the id
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the username
+ */
+ public String getUsername() {
+ return username;
+ }
+
+ /**
+ * @param username the username to set
+ */
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ /**
+ * Full constructor
+ * @param username
+ */
+ public User(String username, String password, Date derniereConnexion,
+ String key) {
+ super();
+ this.username = username;
+ }
+
+ /**
+ * @return the password
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * @param password the password to set
+ */
+ public void setPassword(String password) {
+ this.password = password;
+ }
+}
diff --git a/sandbox/heavyduty/src/main/java/sample/service/UserService.java b/sandbox/heavyduty/src/main/java/sample/service/UserService.java
new file mode 100755
index 0000000000..7130c120ee
--- /dev/null
+++ b/sandbox/heavyduty/src/main/java/sample/service/UserService.java
@@ -0,0 +1,16 @@
+package sample.service;
+
+import org.springframework.security.userdetails.UserDetails;
+import org.springframework.security.userdetails.UserDetailsService;
+
+public interface UserService extends UserDetailsService {
+
+ /**
+ * Register a new User in database
+ * @param username
+ */
+ public UserDetails register(String username, String password);
+
+
+
+}
diff --git a/sandbox/heavyduty/src/main/java/sample/service/impl/UserServiceImpl.java b/sandbox/heavyduty/src/main/java/sample/service/impl/UserServiceImpl.java
new file mode 100755
index 0000000000..8730c6888e
--- /dev/null
+++ b/sandbox/heavyduty/src/main/java/sample/service/impl/UserServiceImpl.java
@@ -0,0 +1,68 @@
+/**
+ *
+ */
+package sample.service.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.AuthenticationException;
+import org.springframework.security.GrantedAuthority;
+import org.springframework.security.GrantedAuthorityImpl;
+import org.springframework.security.userdetails.UserDetails;
+import org.springframework.security.userdetails.UsernameNotFoundException;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import sample.dao.UserDAO;
+import sample.domain.User;
+import sample.service.UserService;
+
+/**
+ * @author A207119
+ *
+ */
+@Component
+@Transactional
+public class UserServiceImpl implements UserService {
+
+ /** The logger */
+ private static final Log LOG = LogFactory.getLog(UserServiceImpl.class);
+
+ /** The User DAO */
+ @Autowired
+ private UserDAO userDAO = null;
+
+ public UserDetails loadUserByUsername(String username)
+ throws AuthenticationException {
+ try {
+ User user = userDAO.findByUsername(username);
+
+ return new org.springframework.security.userdetails.User(user
+ .getUsername(), user.getPassword(), true, true, true, true,
+ new GrantedAuthority[] { new GrantedAuthorityImpl("ROLE_USER") });
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new UsernameNotFoundException("No matching account", e);
+ }
+ }
+
+ public UserDetails register(String username, String password) {
+ User user = new User(username, password);
+ userDAO.persist(user);
+ return new org.springframework.security.userdetails.User(user
+ .getUsername(), user.getPassword(), true, true, true, true,
+ new GrantedAuthority[] { new GrantedAuthorityImpl("ROLE_USER") });
+
+ }
+
+ /**
+ * @param userDAO
+ * the userDAO to set
+ */
+ public void setUserDAO(UserDAO userDAO) {
+ this.userDAO = userDAO;
+ }
+
+}
diff --git a/sandbox/heavyduty/src/main/resources/applicationContext-business.xml b/sandbox/heavyduty/src/main/resources/applicationContext-business.xml
new file mode 100755
index 0000000000..e1e21a97e4
--- /dev/null
+++ b/sandbox/heavyduty/src/main/resources/applicationContext-business.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sandbox/heavyduty/src/main/webapp/META-INF/MANIFEST.MF b/sandbox/heavyduty/src/main/webapp/META-INF/MANIFEST.MF
new file mode 100755
index 0000000000..58630c02ef
--- /dev/null
+++ b/sandbox/heavyduty/src/main/webapp/META-INF/MANIFEST.MF
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+
diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-misc.xml b/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-misc.xml
new file mode 100755
index 0000000000..67da7b4a52
--- /dev/null
+++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-misc.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ My Realm
+
+
+
+
+
\ No newline at end of file
diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-persistence.xml b/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-persistence.xml
new file mode 100755
index 0000000000..b1dd610e78
--- /dev/null
+++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-persistence.xml
@@ -0,0 +1,59 @@
+
+
+
+
+
+ classpath:jdbc.properties
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-security.xml b/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-security.xml
new file mode 100755
index 0000000000..055b910218
--- /dev/null
+++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-security.xml
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/applicationContext-acegi-security.xml b/sandbox/heavyduty/src/main/webapp/WEB-INF/applicationContext-acegi-security.xml
new file mode 100755
index 0000000000..edd0759a43
--- /dev/null
+++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/applicationContext-acegi-security.xml
@@ -0,0 +1,161 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ My Realm
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/bank-servlet.xml b/sandbox/heavyduty/src/main/webapp/WEB-INF/bank-servlet.xml
new file mode 100755
index 0000000000..a119417066
--- /dev/null
+++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/bank-servlet.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/META-INF/persistence.xml b/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/META-INF/persistence.xml
new file mode 100755
index 0000000000..20e12ff1bf
--- /dev/null
+++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/META-INF/persistence.xml
@@ -0,0 +1,24 @@
+
+
+
+ org.hibernate.ejb.HibernatePersistence
+ sample.domain.User
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/jdbc.properties b/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/jdbc.properties
new file mode 100755
index 0000000000..a88ac1e426
--- /dev/null
+++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/jdbc.properties
@@ -0,0 +1,8 @@
+jpa.dialect=org.hibernate.dialect.HSQLDialect
+jpa.generateDdl=true
+jpa.showSql=true
+
+jdbc.driver=org.hsqldb.jdbcDriver
+jdbc.url=jdbc:hsqldb:mem:.
+jdbc.username=sa
+jdbc.password=
\ No newline at end of file
diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/log4j.properties b/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/log4j.properties
new file mode 100755
index 0000000000..b2a7f64139
--- /dev/null
+++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/log4j.properties
@@ -0,0 +1,18 @@
+# Global logging configuration
+log4j.rootLogger=DEBUG, stdout
+
+log4j.logger.org.springframework.security=DEBUG, stdout
+
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.conversionPattern=[%p,%c{1},%L] - %m%n
+
+# Rolling log file output...
+#log4j.appender.fileout=org.apache.log4j.RollingFileAppender
+#log4j.appender.fileout.File=spring-security-tutorial.log
+#log4j.appender.fileout.File=${webapp.root}/WEB-INF/log4j.log
+#log4j.appender.fileout.MaxFileSize=1024KB
+#log4j.appender.fileout.MaxBackupIndex=1
+#log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
+#log4j.appender.fileout.layout.conversionPattern=%d{ABSOLUTE} %5p %c{1},%t:%L - %m%n
diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/users.ldif b/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/users.ldif
new file mode 100755
index 0000000000..0cf02e22ec
--- /dev/null
+++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/classes/users.ldif
@@ -0,0 +1,60 @@
+dn: ou=groups,dc=springframework,dc=org
+objectclass: top
+objectclass: organizationalUnit
+ou: groups
+
+dn: ou=people,dc=springframework,dc=org
+objectclass: top
+objectclass: organizationalUnit
+ou: people
+
+dn: uid=rod,ou=people,dc=springframework,dc=org
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+cn: Rod Johnson
+sn: Johnson
+uid: rod
+userPassword: koala
+
+dn: uid=dianne,ou=people,dc=springframework,dc=org
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+cn: Dianne Emu
+sn: Emu
+uid: dianne
+userPassword: emu
+
+dn: uid=scott,ou=people,dc=springframework,dc=org
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+cn: Scott
+sn: Wombat
+uid: scott
+userPassword: wombat
+
+dn: cn=user,ou=groups,dc=springframework,dc=org
+objectclass: top
+objectclass: groupOfNames
+cn: user
+member: uid=rod,ou=people,dc=springframework,dc=org
+member: uid=dianne,ou=people,dc=springframework,dc=org
+member: uid=scott,ou=people,dc=springframework,dc=org
+
+dn: cn=teller,ou=groups,dc=springframework,dc=org
+objectclass: top
+objectclass: groupOfNames
+cn: teller
+member: uid=rod,ou=people,dc=springframework,dc=org
+member: dianne=rod,ou=people,dc=springframework,dc=org
+
+dn: cn=supervisor,ou=groups,dc=springframework,dc=org
+objectclass: top
+objectclass: groupOfNames
+cn: supervisor
+member: uid=rod,ou=people,dc=springframework,dc=org
diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/jsp/listAccounts.jsp b/sandbox/heavyduty/src/main/webapp/WEB-INF/jsp/listAccounts.jsp
new file mode 100755
index 0000000000..548f43f3ba
--- /dev/null
+++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/jsp/listAccounts.jsp
@@ -0,0 +1,27 @@
+<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
+
+Accounts
+
+Home3
+
+
+
+
+
+
+ |
+
+
+ |
+
+
+ |
+
+ &amount=-20.00">-$20
+ &amount=-5.00">-$5
+ &amount=5.00">+$5
+ &amount=20.00">+$20
+ |
+
+
+
\ No newline at end of file
diff --git a/sandbox/heavyduty/src/main/webapp/WEB-INF/web.xml b/sandbox/heavyduty/src/main/webapp/WEB-INF/web.xml
new file mode 100755
index 0000000000..e745ff4d3c
--- /dev/null
+++ b/sandbox/heavyduty/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,81 @@
+
+
+
+
+
+ Spring Security Tutorial Application
+
+
+
+ contextConfigLocation
+
+ classpath:applicationContext-business.xml
+ /WEB-INF/appContext-persistence.xml
+ /WEB-INF/appContext-security.xml
+
+
+
+
+ log4jConfigLocation
+ /WEB-INF/classes/log4j.properties
+
+
+
+ springSecurityFilterChain
+ org.springframework.web.filter.DelegatingFilterProxy
+
+
+
+ springSecurityFilterChain
+ /*
+
+
+
+ org.springframework.web.util.Log4jConfigListener
+
+
+
+
+ org.springframework.web.context.ContextLoaderListener
+
+
+
+
+ org.springframework.security.ui.session.HttpSessionEventPublisher
+
+
+
+
+ bank
+ org.springframework.web.servlet.DispatcherServlet
+ 1
+
+
+
+ bank
+ *.html
+
+
+
+ index.jsp
+
+
+
diff --git a/sandbox/heavyduty/src/main/webapp/index.jsp b/sandbox/heavyduty/src/main/webapp/index.jsp
new file mode 100755
index 0000000000..edf1d00d0b
--- /dev/null
+++ b/sandbox/heavyduty/src/main/webapp/index.jsp
@@ -0,0 +1,18 @@
+<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
+
+
+Home Page
+
+Anyone can view this page.
+
+
+If you're logged in, you can list accounts.
+
+
+Your principal object is....: <%= request.getUserPrincipal() %>
+
+
+Secure page
+Extremely secure page
+
+
\ No newline at end of file
diff --git a/sandbox/heavyduty/src/main/webapp/login.jsp b/sandbox/heavyduty/src/main/webapp/login.jsp
new file mode 100755
index 0000000000..d752d3975e
--- /dev/null
+++ b/sandbox/heavyduty/src/main/webapp/login.jsp
@@ -0,0 +1,47 @@
+<%@ 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" %>
+
+
+
+
+
+ CUSTOM SPRING SECURITY LOGIN
+
+
+
+ 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) { %>
+
+ Your login attempt was not successful, try again.
+ Reason: <%= ((AuthenticationException) session.getAttribute(AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY)).getMessage() %>
+
+ <% } %>
+
+
+
+
+
diff --git a/sandbox/heavyduty/src/main/webapp/secure/extreme/index.jsp b/sandbox/heavyduty/src/main/webapp/secure/extreme/index.jsp
new file mode 100755
index 0000000000..93f7a17cfc
--- /dev/null
+++ b/sandbox/heavyduty/src/main/webapp/secure/extreme/index.jsp
@@ -0,0 +1,15 @@
+<%@ taglib prefix="authz" uri="http://www.springframework.org/security/tags" %>
+
+
+
+VERY Secure Page
+This is a protected page. You can only see me if you are a supervisor.
+
+
+ You have "ROLE_SUPERVISOR" (this text is surrounded by <authz:authorize> tags).
+
+
+Home
+
Logout
+
+
\ No newline at end of file
diff --git a/sandbox/heavyduty/src/main/webapp/secure/index.jsp b/sandbox/heavyduty/src/main/webapp/secure/index.jsp
new file mode 100755
index 0000000000..e44be8bcd7
--- /dev/null
+++ b/sandbox/heavyduty/src/main/webapp/secure/index.jsp
@@ -0,0 +1,36 @@
+<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
+
+
+
+Secure Page
+
+This is a protected page. You can get to me if you've been remembered,
+or if you've authenticated this session.
+
+
+
+ You are a supervisor! You can therefore see the extremely secure page.
+
+
+Properties obtained using <sec:authentication /> tag
+
+Tag | Value |
+
+<sec:authentication property='name' /> | |
+
+
+<sec:authentication property='principal.username' /> | |
+
+
+<sec:authentication property='principal.enabled' /> | |
+
+
+<sec:authentication property='principal.accountNonLocked' /> | |
+
+
+
+
+Home
+
Logout
+
+
\ No newline at end of file