From f1c064b3b9213d8f183a61415758f5e0f262fdb5 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Sun, 3 Apr 2011 21:41:26 -0500 Subject: [PATCH] SEC-965: Updated CAS Sample application for proxy authentication * Configured for proxy authentication * Cleaned up the jsps * Changed the cas sample context root to cas-sample so the CAS Server's JSESSIONID cookie doesn't remove the cas samples --- samples/cas/Readme.txt | 2 +- samples/cas/cas.gradle | 2 +- samples/cas/src/main/webapp/403.jsp | 8 + .../WEB-INF/applicationContext-security.xml | 202 +++++++++--------- samples/cas/src/main/webapp/WEB-INF/web.xml | 40 ++-- samples/cas/src/main/webapp/cas-logout.jsp | 2 +- samples/cas/src/main/webapp/casfailed.jsp | 10 +- 7 files changed, 145 insertions(+), 121 deletions(-) create mode 100644 samples/cas/src/main/webapp/403.jsp diff --git a/samples/cas/Readme.txt b/samples/cas/Readme.txt index 1e2a19a1e1..cfa67e6ad7 100644 --- a/samples/cas/Readme.txt +++ b/samples/cas/Readme.txt @@ -4,7 +4,7 @@ To run a CAS server and client application, just execute the command from the project root directory. You should then be able to point your browser at -https://localhost:8443/cas/ +https://localhost:8443/cas-sample/ to view the sample application. On attempting to access a secure page, you'll be redirected to the CAS server where you can log in with one of diff --git a/samples/cas/cas.gradle b/samples/cas/cas.gradle index fb86dbef5d..b0f171689a 100644 --- a/samples/cas/cas.gradle +++ b/samples/cas/cas.gradle @@ -31,7 +31,7 @@ dependencies { def keystore = "$rootDir/samples/certificates/server.jks" [jettyRun, jettyRunWar]*.configure { - contextPath = "/cas" + contextPath = "/cas-sample" def httpConnector = new org.mortbay.jetty.nio.SelectChannelConnector(); httpConnector.port = 8080 httpConnector.confidentialPort = 8443 diff --git a/samples/cas/src/main/webapp/403.jsp b/samples/cas/src/main/webapp/403.jsp new file mode 100644 index 0000000000..f893421dbd --- /dev/null +++ b/samples/cas/src/main/webapp/403.jsp @@ -0,0 +1,8 @@ + + +403 - Access Denied + + +

403 - Access Denied

+ + \ No newline at end of file diff --git a/samples/cas/src/main/webapp/WEB-INF/applicationContext-security.xml b/samples/cas/src/main/webapp/WEB-INF/applicationContext-security.xml index 268571bb40..78d58960cf 100644 --- a/samples/cas/src/main/webapp/WEB-INF/applicationContext-security.xml +++ b/samples/cas/src/main/webapp/WEB-INF/applicationContext-security.xml @@ -1,111 +1,109 @@ - - + xmlns:context="http://www.springframework.org/schema/context" + xmlns:util="http://www.springframework.org/schema/util" + xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - - - - - - - - + + + + + - + + + + + + + + + + + - - - + + + + + - - - - - - - + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + localhost:8443 + localhost:9443 + + diff --git a/samples/cas/src/main/webapp/WEB-INF/web.xml b/samples/cas/src/main/webapp/WEB-INF/web.xml index ee92a9e55d..3675fa76df 100644 --- a/samples/cas/src/main/webapp/WEB-INF/web.xml +++ b/samples/cas/src/main/webapp/WEB-INF/web.xml @@ -25,42 +25,52 @@ cas.root + - CAS Single Sign Out Filter - org.jasig.cas.client.session.SingleSignOutFilter + characterEncodingFilter + org.springframework.web.filter.CharacterEncodingFilter + + encoding + UTF-8 + - springSecurityFilterChain org.springframework.web.filter.DelegatingFilterProxy - CAS Single Sign Out Filter - /* + characterEncodingFilter + /* + + + springSecurityFilterChain + /* - - springSecurityFilterChain - /* - + + + org.jasig.cas.client.session.SingleSignOutHttpSessionListener + - - org.jasig.cas.client.session.SingleSignOutHttpSessionListener - - org.springframework.web.context.ContextLoaderListener 403 - /casfailed.jsp + /403.jsp - diff --git a/samples/cas/src/main/webapp/cas-logout.jsp b/samples/cas/src/main/webapp/cas-logout.jsp index 36f6d2b9c6..4098f94ae4 100644 --- a/samples/cas/src/main/webapp/cas-logout.jsp +++ b/samples/cas/src/main/webapp/cas-logout.jsp @@ -9,7 +9,7 @@

You have logged out of this application, but may still have an active single-sign on session with CAS.

-

Logout of CAS

+

Logout of CAS

\ No newline at end of file diff --git a/samples/cas/src/main/webapp/casfailed.jsp b/samples/cas/src/main/webapp/casfailed.jsp index 2a713fbc33..9eef42a18e 100644 --- a/samples/cas/src/main/webapp/casfailed.jsp +++ b/samples/cas/src/main/webapp/casfailed.jsp @@ -11,7 +11,15 @@ Your CAS credentials were rejected.

- Reason: <%= ((AuthenticationException) session.getAttribute(AbstractAuthenticationProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY)).getMessage() %> + Reason: +<% + Exception error = ((AuthenticationException) session.getAttribute(AbstractAuthenticationProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY)); + if(error != null) { +%> +<%= error.getMessage() %> +<% +} +%>