From c184d2d8c513b6fe548300f395e784a63ee7c5ab Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Wed, 23 Apr 2008 13:11:26 +0000 Subject: [PATCH] Added 'heavyduty' sample to sandbox for testing --- sandbox/heavyduty/certificates/Readme.txt | 10 ++ sandbox/heavyduty/certificates/ca.pem | 22 +++ sandbox/heavyduty/certificates/dianne.p12 | Bin 0 -> 1768 bytes sandbox/heavyduty/certificates/rod.p12 | Bin 0 -> 1784 bytes sandbox/heavyduty/certificates/scott.p12 | Bin 0 -> 1768 bytes sandbox/heavyduty/certificates/server.jks | Bin 0 -> 3488 bytes sandbox/heavyduty/pom.xml | 166 ++++++++++++++++++ .../src/main/java/bigbank/Account.java | 51 ++++++ .../src/main/java/bigbank/BankDao.java | 7 + .../src/main/java/bigbank/BankDaoStub.java | 32 ++++ .../src/main/java/bigbank/BankService.java | 15 ++ .../main/java/bigbank/BankServiceImpl.java | 40 +++++ .../src/main/java/bigbank/SeedData.java | 21 +++ .../main/java/bigbank/web/ListAccounts.java | 34 ++++ .../main/java/bigbank/web/PostAccounts.java | 39 ++++ ...avyDutyAuthenticationProcessingFilter.java | 11 ++ .../security/ui/HeavyDutyEntryPoint.java | 9 + .../src/main/java/sample/dao/GenericDAO.java | 46 +++++ .../src/main/java/sample/dao/UserDAO.java | 13 ++ .../java/sample/dao/impl/GenericDAOImpl.java | 126 +++++++++++++ .../java/sample/dao/impl/UserDAOImpl.java | 27 +++ .../src/main/java/sample/domain/User.java | 106 +++++++++++ .../main/java/sample/service/UserService.java | 16 ++ .../sample/service/impl/UserServiceImpl.java | 68 +++++++ .../resources/applicationContext-business.xml | 24 +++ .../src/main/webapp/META-INF/MANIFEST.MF | 2 + .../main/webapp/WEB-INF/appContext-misc.xml | 51 ++++++ .../webapp/WEB-INF/appContext-persistence.xml | 59 +++++++ .../webapp/WEB-INF/appContext-security.xml | 82 +++++++++ .../applicationContext-acegi-security.xml | 161 +++++++++++++++++ .../src/main/webapp/WEB-INF/bank-servlet.xml | 20 +++ .../WEB-INF/classes/META-INF/persistence.xml | 24 +++ .../webapp/WEB-INF/classes/jdbc.properties | 8 + .../webapp/WEB-INF/classes/log4j.properties | 18 ++ .../main/webapp/WEB-INF/classes/users.ldif | 60 +++++++ .../main/webapp/WEB-INF/jsp/listAccounts.jsp | 27 +++ .../heavyduty/src/main/webapp/WEB-INF/web.xml | 81 +++++++++ sandbox/heavyduty/src/main/webapp/index.jsp | 18 ++ sandbox/heavyduty/src/main/webapp/login.jsp | 47 +++++ .../src/main/webapp/secure/extreme/index.jsp | 15 ++ .../src/main/webapp/secure/index.jsp | 36 ++++ 41 files changed, 1592 insertions(+) create mode 100755 sandbox/heavyduty/certificates/Readme.txt create mode 100755 sandbox/heavyduty/certificates/ca.pem create mode 100755 sandbox/heavyduty/certificates/dianne.p12 create mode 100755 sandbox/heavyduty/certificates/rod.p12 create mode 100755 sandbox/heavyduty/certificates/scott.p12 create mode 100755 sandbox/heavyduty/certificates/server.jks create mode 100755 sandbox/heavyduty/pom.xml create mode 100755 sandbox/heavyduty/src/main/java/bigbank/Account.java create mode 100755 sandbox/heavyduty/src/main/java/bigbank/BankDao.java create mode 100755 sandbox/heavyduty/src/main/java/bigbank/BankDaoStub.java create mode 100755 sandbox/heavyduty/src/main/java/bigbank/BankService.java create mode 100755 sandbox/heavyduty/src/main/java/bigbank/BankServiceImpl.java create mode 100755 sandbox/heavyduty/src/main/java/bigbank/SeedData.java create mode 100755 sandbox/heavyduty/src/main/java/bigbank/web/ListAccounts.java create mode 100755 sandbox/heavyduty/src/main/java/bigbank/web/PostAccounts.java create mode 100755 sandbox/heavyduty/src/main/java/heavyduty/security/ui/HeavyDutyAuthenticationProcessingFilter.java create mode 100755 sandbox/heavyduty/src/main/java/heavyduty/security/ui/HeavyDutyEntryPoint.java create mode 100755 sandbox/heavyduty/src/main/java/sample/dao/GenericDAO.java create mode 100755 sandbox/heavyduty/src/main/java/sample/dao/UserDAO.java create mode 100755 sandbox/heavyduty/src/main/java/sample/dao/impl/GenericDAOImpl.java create mode 100755 sandbox/heavyduty/src/main/java/sample/dao/impl/UserDAOImpl.java create mode 100755 sandbox/heavyduty/src/main/java/sample/domain/User.java create mode 100755 sandbox/heavyduty/src/main/java/sample/service/UserService.java create mode 100755 sandbox/heavyduty/src/main/java/sample/service/impl/UserServiceImpl.java create mode 100755 sandbox/heavyduty/src/main/resources/applicationContext-business.xml create mode 100755 sandbox/heavyduty/src/main/webapp/META-INF/MANIFEST.MF create mode 100755 sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-misc.xml create mode 100755 sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-persistence.xml create mode 100755 sandbox/heavyduty/src/main/webapp/WEB-INF/appContext-security.xml create mode 100755 sandbox/heavyduty/src/main/webapp/WEB-INF/applicationContext-acegi-security.xml create mode 100755 sandbox/heavyduty/src/main/webapp/WEB-INF/bank-servlet.xml create mode 100755 sandbox/heavyduty/src/main/webapp/WEB-INF/classes/META-INF/persistence.xml create mode 100755 sandbox/heavyduty/src/main/webapp/WEB-INF/classes/jdbc.properties create mode 100755 sandbox/heavyduty/src/main/webapp/WEB-INF/classes/log4j.properties create mode 100755 sandbox/heavyduty/src/main/webapp/WEB-INF/classes/users.ldif create mode 100755 sandbox/heavyduty/src/main/webapp/WEB-INF/jsp/listAccounts.jsp create mode 100755 sandbox/heavyduty/src/main/webapp/WEB-INF/web.xml create mode 100755 sandbox/heavyduty/src/main/webapp/index.jsp create mode 100755 sandbox/heavyduty/src/main/webapp/login.jsp create mode 100755 sandbox/heavyduty/src/main/webapp/secure/extreme/index.jsp create mode 100755 sandbox/heavyduty/src/main/webapp/secure/index.jsp diff --git a/sandbox/heavyduty/certificates/Readme.txt b/sandbox/heavyduty/certificates/Readme.txt new file mode 100755 index 0000000000..64b415cf83 --- /dev/null +++ b/sandbox/heavyduty/certificates/Readme.txt @@ -0,0 +1,10 @@ +This directory contains certificates and keys for use with SSL in the sample applications. Certificates are issued by +our "Spring Security Test CA" certificate authority. + +ca.pem - the certificate authority's certificate. +server.jks - Java keystore containing the server certificate and privatekey. It Also contains the certificate authority + file and this is used as both keystore and truststore for they jetty server when running the samples with + the maven jetty plugin ("mvn jetty:run"). + +rod.p12, dianne.p12, scott.p12 are all certificate/key combinations for client authentication and can be installed in +your browser if you want to try out support for X.509 authentication. \ No newline at end of file diff --git a/sandbox/heavyduty/certificates/ca.pem b/sandbox/heavyduty/certificates/ca.pem new file mode 100755 index 0000000000..a5b52ca9d7 --- /dev/null +++ b/sandbox/heavyduty/certificates/ca.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDojCCAoqgAwIBAgIEMKX1dzANBgkqhkiG9w0BAQUFADCBiTELMAkGA1UEBhMC +R0IxETAPBgNVBAgTCFNjb3RsYW5kMRAwDgYDVQQHEwdHbGFzZ293MRkwFwYDVQQK +ExBTcHJpbmcgRnJhbWV3b3JrMRgwFgYDVQQLEw9TcHJpbmcgU2VjdXJpdHkxIDAe +BgNVBAMTF1NwcmluZyBTZWN1cml0eSBUZXN0IENBMB4XDTA4MDEyNTExMTIyMVoX +DTE4MDIyNTAwMDAwMFowgYkxCzAJBgNVBAYTAkdCMREwDwYDVQQIEwhTY290bGFu +ZDEQMA4GA1UEBxMHR2xhc2dvdzEZMBcGA1UEChMQU3ByaW5nIEZyYW1ld29yazEY +MBYGA1UECxMPU3ByaW5nIFNlY3VyaXR5MSAwHgYDVQQDExdTcHJpbmcgU2VjdXJp +dHkgVGVzdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALzl/wEe +snYrwqaGZuB8hmwACtptazh1+eXCfd66FkioxlLF7yTnjCC7DT+vmMgSuThIEIsN +xlxLpEgyU3bU8GIuR8wyYIyvuSMcptdFJLV7NKYuRycxpDuqimTM7Br0nfNgKVEv +1QwguGWr6YN3aZ68/xe/D5xyPhakKu++7VFXIXw9f0+nqojdrFTqQ6l9GAVRgfX6 +h4JOaV1VFx83y2pnFj0iFneVxRcvXyWnyXlcOvJDIyVuyS/hYxb+E5rtBvp5XQ0o +5CP4OMwCZGx/jEqlL8oO7BwEgu9aEBxKvoIKJmHDTHgWIxgawTrKabmong4utnMI +yNrhsI77bmh2U7UCAwEAAaMQMA4wDAYDVR0PBAUDAwcGADANBgkqhkiG9w0BAQUF +AAOCAQEAuD8W9Ukkfyi0y65mwguFVAqBC3RSTMRXcjbLQV4rMDM/Q9kjA6acY4Ta +WgxGTwNCydqaqwDVsmn+6Je8Lp2xm9KLDLypVdNopGs+Mlfo55dhwqymXkQw1oJI +CPhR3nBmGEnSWW0UY9bPlpxRF2D5GDVwpuxDtXvWa4baPwRRI9MxwPWHA3ITl+fc +s9QVKy+pRAnuP9MSIp755cJ1CODOn2ElNCqnxxsZmcWcmI3LkHAwTmegl3PVvhrk +MKMEA/neshh/M/hWGNTFt77Hoa7pU9dv5RCWFvZPqsUgPrwGrmUvcmSDir3lSWQm +SuSED2LKVo+BFqwWS+jp49AR9b8B/Q== +-----END CERTIFICATE----- diff --git a/sandbox/heavyduty/certificates/dianne.p12 b/sandbox/heavyduty/certificates/dianne.p12 new file mode 100755 index 0000000000000000000000000000000000000000..6e5ba218db795c356e8c0aa5df637950e500f0d0 GIT binary patch literal 1768 zcmV5p{H z@KGyZKM(YpXP|$!v=Z`&r_}of`Hb?dr|>EbzZ4AhI-Nr;UQ?jW$?E5B6&9x`m`5+x zek#|fKrRTLbQ*oAytH6XaiRoX#gXQ?<=~KhZ5>Ag*ytt`O5QApHH8t-nA=6|e4=*fKBLsjiY`aqwZ99UdyRcme`|(LamO0j1KRDNa5r_WH!UNrozVe$oMe*=n}Y#T-2Ql` zHrX1ab=Y|UDd zBW`LABJuJ%A-}^jpUv}td4d_BIBru*DA4Q9JG-^UJ9`&`lWBDq`569@ERD6Fpim4z z&Dr(QE_a4~qS8?md%GDQD;cS(OqPr>8xV7-Y7a`Z!52-3mDHX}$op?LWXED^^samlV-=MOuNbUPg-t9P5Mq@ zQ(vaiSG~FTD_sie|1^6y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w1($T`FMK^WIA0E6-Ibk7ftz43C-`B&E{yD2?`0T zQEXfKGg$y0eS;giVVT{@C;)^XrH)BHOc+5lxc?5O!}$ zlKck=be#ttIhf<64I^+n6Eq)$g>Bn}RX{?)b5g%e+QY2@_Kb?JqmKV+>OP%YGByf9 z(NSP7R#I#WAB%3N!;L6L57LEM1I1|VT6J$^pV@_yM2%33RnRTLCa+(ba3WwO6>g;4 z1VowM!(_>Ybrov|&JkP9W3}&c&U8XaNY>$c&d!3x-K;SJp4NFa&lWE3r2 zRY&>|Pc%LPYZM#F_{W-ECA%_3n*asGOy{QYiV`K*%6y~0(IkuVc{@8yw25y0I1dZp zNMQLOJ6X9(VqW%5LJ8~}bC+<{;U>Y4aS^^onQEX`E)LeTOdC`iwYp)&jAHe`O`?jm zQP74kvy8Q>sQOeYY-3{Xpn5M98QpNJ<;{tzB$l+92uBqbW&@%^N*5x#z&%KFMiYzS z51z3d;%f|LzHAClqV9B^-}cqq<#e-z#`5f6G}b70bg3p0@EJNA2x%BD`$-ul#xTOP z-W+%j7-*-t@p(0-{o+*M0sO5IAD^BF-vq7dF#&>vd!A`6ahmFYHObXCjtW6;m^JJg z&pWU`?~Z~g5~og{5sD2fi?_(wh5L9@RO-Qo3a=j&h|G0dHy^# zKdl2rJ=d>EghhIf^1m|%7oV{#uQc`}6%Whxo)tlWQt)xpD3SYR*3=Ha2nMX)FgY+GFbM_)D-Ht!8U+9Z6h0=3+$Ga8{-?Rpwy}ec8W~cY aA_Ne)6!9W(f=}drPhM~u0`Xu10te84%1hP& literal 0 HcmV?d00001 diff --git a/sandbox/heavyduty/certificates/scott.p12 b/sandbox/heavyduty/certificates/scott.p12 new file mode 100755 index 0000000000000000000000000000000000000000..f0a6357e730752bd6b2f05658ec8a1a85ade6de9 GIT binary patch literal 1768 zcmV@jf7w>$2!v?*0s;rnfPw}%uQ6CU(Nz)C_gUU@R@`pK{nk{#voCp;uha`md~4O@7hBjyQh3eo z2Dr>lsCwI_;J6Q9#e*Q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g b?AvPdx$6p(dMtTH;2V + 4.0.0 + org.springframework.security + spring-security-heavyduty + Spring Security - Heavy Duty Sample + war + 2.0.0 + + + org.springframework.security + spring-security-core + ${spring.security.version} + + + org.springframework.security + spring-security-core-tiger + ${spring.security.version} + + + org.springframework.security + spring-security-taglibs + ${spring.security.version} + + + org.springframework + spring-core + ${spring.version} + + + org.springframework + spring-context + ${spring.version} + + + org.springframework + spring-web + ${spring.version} + + + org.springframework + spring-webmvc + ${spring.version} + + + org.springframework + spring-jdbc + runtime + ${spring.version} + + + org.springframework + spring-orm + ${spring.version} + + + org.springframework + spring-aop + runtime + ${spring.version} + + + hsqldb + hsqldb + 1.8.0.7 + compile + + + org.hibernate + hibernate-entitymanager + 3.3.2.GA + compile + + + net.sf.ehcache + ehcache + 1.3.0 + compile + + + org.aspectj + aspectjweaver + true + 1.5.4 + + + org.aspectj + aspectjrt + 1.5.4 + + + javax.servlet + servlet-api + provided + 2.4 + + + javax.servlet + jstl + runtime + 1.1.2 + + + taglibs + standard + runtime + 1.1.2 + + + log4j + log4j + runtime + 1.2.14 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + org.apache.maven.plugins + maven-eclipse-plugin + 2.5.1 + + true + 2.0 + + + + org.mortbay.jetty + maven-jetty-plugin + 6.1.7 + + /tutorial + + + 8080 + 8443 + + + 8443 + certificates/server.jks + password + password + certificates/server.jks + password + true + false + + + + + + + + 2.5.3 + 2.0.1-SNAPSHOT + + + \ No newline at end of file diff --git a/sandbox/heavyduty/src/main/java/bigbank/Account.java b/sandbox/heavyduty/src/main/java/bigbank/Account.java new file mode 100755 index 0000000000..1fdc1044e5 --- /dev/null +++ b/sandbox/heavyduty/src/main/java/bigbank/Account.java @@ -0,0 +1,51 @@ +package bigbank; + +/** + * Note this class does not represent best practice, as we are failing to + * encapsulate business logic (methods) and state in the domain object. + * Nevertheless, this demo is intended to reflect what people usually do, + * as opposed to what they ideally would be doing. + * + * @author Ben Alex + * @version $Id$ + */ +public class Account { + private long id = -1; + private String holder; + private double balance; + + public Account(String holder) { + super(); + this.holder = holder; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getHolder() { + return holder; + } + + public void setHolder(String holder) { + this.holder = holder; + } + + public double getBalance() { + return balance; + } + + public void setBalance(double balance) { + this.balance = balance; + } + + public String toString() { + return "Account[id=" + id + ",balance=" + balance +",holder=" + holder + "]"; + } + + +} diff --git a/sandbox/heavyduty/src/main/java/bigbank/BankDao.java b/sandbox/heavyduty/src/main/java/bigbank/BankDao.java new file mode 100755 index 0000000000..67806a7e76 --- /dev/null +++ b/sandbox/heavyduty/src/main/java/bigbank/BankDao.java @@ -0,0 +1,7 @@ +package bigbank; + +public interface BankDao { + public Account readAccount(Long id); + public void createOrUpdateAccount(Account account); + public Account[] findAccounts(); +} diff --git a/sandbox/heavyduty/src/main/java/bigbank/BankDaoStub.java b/sandbox/heavyduty/src/main/java/bigbank/BankDaoStub.java new file mode 100755 index 0000000000..de46d38af9 --- /dev/null +++ b/sandbox/heavyduty/src/main/java/bigbank/BankDaoStub.java @@ -0,0 +1,32 @@ +package bigbank; + +import java.util.HashMap; +import java.util.Map; + +public class BankDaoStub implements BankDao { + private long id = 0; + private Map accounts = new HashMap(); + + public void createOrUpdateAccount(Account account) { + if (account.getId() == -1) { + id++; + account.setId(id); + } + accounts.put(new Long(account.getId()), account); + System.out.println("SAVE: " + account); + } + + public Account[] findAccounts() { + Account[] a = (Account[]) accounts.values().toArray(new Account[] {}); + System.out.println("Returning " + a.length + " account(s):"); + for (int i = 0; i < a.length; i++) { + System.out.println(" > " + a[i]); + } + return a; + } + + public Account readAccount(Long id) { + return (Account) accounts.get(id); + } + +} diff --git a/sandbox/heavyduty/src/main/java/bigbank/BankService.java b/sandbox/heavyduty/src/main/java/bigbank/BankService.java new file mode 100755 index 0000000000..90c21ccde5 --- /dev/null +++ b/sandbox/heavyduty/src/main/java/bigbank/BankService.java @@ -0,0 +1,15 @@ +package bigbank; + +import org.springframework.security.annotation.Secured; + +public interface BankService { + + @Secured("IS_AUTHENTICATED_ANONYMOUSLY") + public Account readAccount(Long id); + + @Secured("IS_AUTHENTICATED_ANONYMOUSLY") + public Account[] findAccounts(); + + @Secured("ROLE_TELLER") + public Account post(Account account, double amount); +} diff --git a/sandbox/heavyduty/src/main/java/bigbank/BankServiceImpl.java b/sandbox/heavyduty/src/main/java/bigbank/BankServiceImpl.java new file mode 100755 index 0000000000..e461e132d0 --- /dev/null +++ b/sandbox/heavyduty/src/main/java/bigbank/BankServiceImpl.java @@ -0,0 +1,40 @@ +package bigbank; + +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.util.Assert; + +public class BankServiceImpl implements BankService { + private BankDao bankDao; + + // Not used unless you declare a + @Pointcut("execution(* bigbank.BankServiceImpl.*(..))") + public void myPointcut() {} + + public BankServiceImpl(BankDao bankDao) { + Assert.notNull(bankDao); + this.bankDao = bankDao; + } + + public Account[] findAccounts() { + return this.bankDao.findAccounts(); + } + + public Account post(Account account, double amount) { + Assert.notNull(account); + Assert.notNull(account.getId()); + + // We read account bank from DAO so it reflects the latest balance + Account a = bankDao.readAccount(account.getId()); + if (account == null) { + throw new IllegalArgumentException("Couldn't find requested account"); + } + + a.setBalance(a.getBalance() + amount); + bankDao.createOrUpdateAccount(a); + return a; + } + + public Account readAccount(Long id) { + return bankDao.readAccount(id); + } +} diff --git a/sandbox/heavyduty/src/main/java/bigbank/SeedData.java b/sandbox/heavyduty/src/main/java/bigbank/SeedData.java new file mode 100755 index 0000000000..5bf0774448 --- /dev/null +++ b/sandbox/heavyduty/src/main/java/bigbank/SeedData.java @@ -0,0 +1,21 @@ +package bigbank; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.util.Assert; + +public class SeedData implements InitializingBean{ + private BankDao bankDao; + + public void afterPropertiesSet() throws Exception { + Assert.notNull(bankDao); + bankDao.createOrUpdateAccount(new Account("rod")); + bankDao.createOrUpdateAccount(new Account("dianne")); + bankDao.createOrUpdateAccount(new Account("scott")); + bankDao.createOrUpdateAccount(new Account("peter")); + } + + public void setBankDao(BankDao bankDao) { + this.bankDao = bankDao; + } + +} diff --git a/sandbox/heavyduty/src/main/java/bigbank/web/ListAccounts.java b/sandbox/heavyduty/src/main/java/bigbank/web/ListAccounts.java new file mode 100755 index 0000000000..d0ea3ed67b --- /dev/null +++ b/sandbox/heavyduty/src/main/java/bigbank/web/ListAccounts.java @@ -0,0 +1,34 @@ +package bigbank.web; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.AuthenticationCredentialsNotFoundException; +import org.springframework.util.Assert; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.mvc.Controller; + +import bigbank.BankService; + +public class ListAccounts implements Controller { + + private BankService bankService; + + public ListAccounts(BankService bankService) { + Assert.notNull(bankService); + this.bankService = bankService; + } + + public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { + // Security check (this is unnecessary if Spring Security is performing the authorization) +// if (request.getUserPrincipal() == null) { +// throw new AuthenticationCredentialsNotFoundException("You must login to view the account list (Spring Security message)"); // only for Spring Security managed authentication +// } + + // Actual business logic + ModelAndView mav = new ModelAndView("listAccounts"); + mav.addObject("accounts", bankService.findAccounts()); + return mav; + } + +} diff --git a/sandbox/heavyduty/src/main/java/bigbank/web/PostAccounts.java b/sandbox/heavyduty/src/main/java/bigbank/web/PostAccounts.java new file mode 100755 index 0000000000..e5967b52e3 --- /dev/null +++ b/sandbox/heavyduty/src/main/java/bigbank/web/PostAccounts.java @@ -0,0 +1,39 @@ +package bigbank.web; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.AccessDeniedException; +import org.springframework.util.Assert; +import org.springframework.web.bind.ServletRequestUtils; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.mvc.Controller; + +import bigbank.Account; +import bigbank.BankService; + +public class PostAccounts implements Controller { + + private BankService bankService; + + public PostAccounts(BankService bankService) { + Assert.notNull(bankService); + this.bankService = bankService; + } + + public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { + // Security check (this is unnecessary if Spring Security is performing the authorization) +// if (!request.isUserInRole("ROLE_TELLER")) { +// throw new AccessDeniedException("You must be a teller to post transactions (Spring Security message)"); // only for Spring Security managed authentication +// } + + // Actual business logic + Long id = ServletRequestUtils.getRequiredLongParameter(request, "id"); + Double amount = ServletRequestUtils.getRequiredDoubleParameter(request, "amount"); + Account a = bankService.readAccount(id); + bankService.post(a, amount); + + return new ModelAndView("redirect:listAccounts.html"); + } + +} diff --git a/sandbox/heavyduty/src/main/java/heavyduty/security/ui/HeavyDutyAuthenticationProcessingFilter.java b/sandbox/heavyduty/src/main/java/heavyduty/security/ui/HeavyDutyAuthenticationProcessingFilter.java new file mode 100755 index 0000000000..a456c7fad9 --- /dev/null +++ b/sandbox/heavyduty/src/main/java/heavyduty/security/ui/HeavyDutyAuthenticationProcessingFilter.java @@ -0,0 +1,11 @@ +package heavyduty.security.ui; + +import org.springframework.security.ui.webapp.AuthenticationProcessingFilter; + +public class HeavyDutyAuthenticationProcessingFilter extends AuthenticationProcessingFilter { + + + + + +} diff --git a/sandbox/heavyduty/src/main/java/heavyduty/security/ui/HeavyDutyEntryPoint.java b/sandbox/heavyduty/src/main/java/heavyduty/security/ui/HeavyDutyEntryPoint.java new file mode 100755 index 0000000000..3ee843792c --- /dev/null +++ b/sandbox/heavyduty/src/main/java/heavyduty/security/ui/HeavyDutyEntryPoint.java @@ -0,0 +1,9 @@ +package heavyduty.security.ui; + +import org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint; + +public class HeavyDutyEntryPoint extends AuthenticationProcessingFilterEntryPoint { + + + +} diff --git a/sandbox/heavyduty/src/main/java/sample/dao/GenericDAO.java b/sandbox/heavyduty/src/main/java/sample/dao/GenericDAO.java new file mode 100755 index 0000000000..4272790621 --- /dev/null +++ b/sandbox/heavyduty/src/main/java/sample/dao/GenericDAO.java @@ -0,0 +1,46 @@ +package sample.dao; + +import java.io.Serializable; + + +/** + * The Interface GenericDAO. + */ +public interface GenericDAO +{ + /** + * persist + * @param transientInstance objet to persist + */ + void persist(T transientInstance); + + + /** + * refresh + * @param instance objet to refresh + */ + void refresh(T instance); + + + /** + * delete + * @param persistentInstance objet to delete + */ + void delete(T persistentInstance); + + + /** + * merge + * @param detachedInstance objet to merge + * @return merged object + */ + T merge(T detachedInstance); + + + /** + * read + * @param id of object to read + * @return read object + */ + T read(PK id); +} \ No newline at end of file diff --git a/sandbox/heavyduty/src/main/java/sample/dao/UserDAO.java b/sandbox/heavyduty/src/main/java/sample/dao/UserDAO.java new file mode 100755 index 0000000000..5017a149f3 --- /dev/null +++ b/sandbox/heavyduty/src/main/java/sample/dao/UserDAO.java @@ -0,0 +1,13 @@ + +package sample.dao; + +import sample.domain.User; + + +/** + * The Interface PatientDAO. + */ +public interface UserDAO extends GenericDAO { + + public User findByUsername(String username); +} diff --git a/sandbox/heavyduty/src/main/java/sample/dao/impl/GenericDAOImpl.java b/sandbox/heavyduty/src/main/java/sample/dao/impl/GenericDAOImpl.java new file mode 100755 index 0000000000..4fffeb7ef3 --- /dev/null +++ b/sandbox/heavyduty/src/main/java/sample/dao/impl/GenericDAOImpl.java @@ -0,0 +1,126 @@ +package sample.dao.impl; + +import java.io.Serializable; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import sample.dao.GenericDAO; + + +public class GenericDAOImpl + implements GenericDAO { + /** type */ + private Class type; + + /** the logger */ + private static final Log LOG = LogFactory.getLog(GenericDAOImpl.class); + + @PersistenceContext + private EntityManager entityManager; + + /** + * Minimal constructor + * + * @param t + * type POJO hibernate + */ + public GenericDAOImpl(Class t) { + this.type = t; + } + + /** + * read data + * + * @param id + * data id + * @return data + */ + @SuppressWarnings("unchecked") + public T read(PK id) { + if (id == null) { + throw new IllegalArgumentException("Id cannot be null or empty"); + } + + // find() au lieu de getReference() pour forcer l'initialisation de + // l'objet, sinon on ne recupère + // qu'un proxy non-initialisé ! + return entityManager.find(type, id); + + } + + /** + * persist data + * + * @param transientInstance + * data to persist + * @see sido.common.dao.GenericDAO#persist(T) + */ + public void persist(T transientInstance) { + if (LOG.isDebugEnabled()) { + LOG.debug("Persisting instance of " + + transientInstance.getClass().getSimpleName()); + } + entityManager.persist(transientInstance); + } + + /** + * + * attach clean + * + * @param instance + * data to attach + * @see sido.common.dao.GenericDAO#refresh(T) + */ + public void refresh(T instance) { + if (LOG.isDebugEnabled()) { + LOG.debug("refreshing instance of " + + instance.getClass().getSimpleName()); + } + entityManager.refresh(instance); + } + + /** + * delete + * + * @param persistentInstance + * data to delete + * @see sido.common.dao.GenericDAO#delete(T) + */ + public void delete(T persistentInstance) { + if (LOG.isDebugEnabled()) { + LOG.debug("deleting instance of " + + persistentInstance.getClass().getSimpleName()); + } + entityManager.remove(persistentInstance); + } + + /** + * merge + * + * @param detachedInstance + * data to merge + * @return the merged data + * @see sido.common.dao.GenericDAO#merge(T) + */ + @SuppressWarnings("unchecked") + public T merge(T detachedInstance) { + if (LOG.isDebugEnabled()) { + LOG.debug("merging instance of " + + detachedInstance.getClass().getSimpleName()); + } + return entityManager.merge(detachedInstance); + } + + /** + * @return the entityManager + */ + public EntityManager getEntityManager() { + return entityManager; + } + + +} \ No newline at end of file diff --git a/sandbox/heavyduty/src/main/java/sample/dao/impl/UserDAOImpl.java b/sandbox/heavyduty/src/main/java/sample/dao/impl/UserDAOImpl.java new file mode 100755 index 0000000000..0712ab455f --- /dev/null +++ b/sandbox/heavyduty/src/main/java/sample/dao/impl/UserDAOImpl.java @@ -0,0 +1,27 @@ +package sample.dao.impl; + +import org.springframework.stereotype.Repository; + +import sample.domain.User; + +/** + * UserDAOImpl + */ +@Repository +public class UserDAOImpl extends GenericDAOImpl 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() %> +
+ <% } %> + +

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

+ + + + + + + + + + + + + + +
TagValue
<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