Skip to content
Snippets Groups Projects
Commit d3487ab9 authored by Steve Ryan's avatar Steve Ryan
Browse files

Added pulling the username, re-added validation filters/SSOlogout

parent 663937fd
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>castest2</display-name>
<display-name>Sample CASified Application</display-name>
<description>
A sample application that demonstrates the CAS client.
</description>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
......@@ -9,10 +12,15 @@
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>serverName</param-name>
<param-value>http://localhost:8080</param-value>
</context-param>
<!-- Start CAS configuration -->
<!-- https://secure.identity.ucsb.edu/inside/doku.php/sso_java -->
<!-- CAS Single Sign Out Filter
<!-- CAS Single Sign Out Filter-->
<filter>
<filter-name>CAS Single Sign Out Filter</filter-name>
<filter-class>org.jasig.cas.client.session.SingleSignOutFilter</filter-class>
......@@ -20,7 +28,7 @@
<param-name>casServerUrlPrefix</param-name>
<param-value>https://shib.idm.umd.edu/shibboleth-idp/profile/cas</param-value>
</init-param>
</filter>-->
</filter>
<!-- CAS Authentication Filter -->
<filter>
<filter-name>CAS Authentication Filter</filter-name>
......@@ -29,22 +37,14 @@
<param-name>casServerLoginUrl</param-name>
<param-value>https://login.umd.edu/cas/login</param-value>
</init-param>
<init-param>
<param-name>serverName</param-name>
<param-value>http://localhost:8080/</param-value>
</init-param>
</filter>
<!-- CAS Validation Filter
<!-- CAS Validation Filter -->
<filter>
<filter-name>CAS Validation Filter</filter-name>
<filter-class>org.jasig.cas.client.validation.Cas20ServiceTicketValidator</filter-class>
<filter-class>org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter</filter-class>
<init-param>
<param-name>casServerUrlPrefix</param-name>
<param-value>https://shib.idm.umd.edu/shibboleth-idp/profile/cas</param-value>
</init-param>
<init-param>
<param-name>serverName</param-name>
<param-value>http://localhost:8080/castest2</param-value>
<param-value>https://login.umd.edu/cas</param-value>
</init-param>
<init-param>
<param-name>redirectAfterValidation</param-name>
......@@ -54,33 +54,33 @@
<param-name>useSession</param-name>
<param-value>true</param-value>
</init-param>
</filter> -->
</filter>
<!-- CAS HttpServletRequest Wrapper Filter -->
<filter>
<filter-name>CAS HttpServletRequest Wrapper Filter</filter-name>
<filter-class>org.jasig.cas.client.util.HttpServletRequestWrapperFilter</filter-class>
</filter>
<!-- order of CAS filter mappings is important
<!-- order of CAS filter mappings is important -->
<filter-mapping>
<filter-name>CAS Single Sign Out Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>-->
</filter-mapping>
<filter-mapping>
<filter-name>CAS Authentication Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--<filter-mapping>
<filter-mapping>
<filter-name>CAS Validation Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>-->
</filter-mapping>
<filter-mapping>
<filter-name>CAS HttpServletRequest Wrapper Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- <listener>
<listener>
<listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class>
</listener>-->
</listener>
<!-- End CAS configuration -->
</web-app>
\ No newline at end of file
......@@ -8,6 +8,7 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.jasig.cas.client.authentication.AttributePrincipal;
import castest2.FileDao;
......@@ -29,16 +30,25 @@ public class FileCounter extends HttpServlet {
HttpSession session = request.getSession(true);
// Set the session valid for 5 secs
session.setMaxInactiveInterval(5);
response.setContentType("text/html");
PrintWriter out = response.getWriter();
if (session.isNew()) {
count++;
}
out.println("This site has been accessed " + count + " times.");
out.println("<a href='https://login.umd.edu/cas/logout'> logout </a>");
//CAS returns principal in the request.
AttributePrincipal principal = (AttributePrincipal)request.getUserPrincipal();
if (principal != null) {
String uni = principal.getName();
out.println(uni);
} else {
out.println("Could not get username");
}
out.println("This site has been accessed " + count + " times.\n");
out.println("<a href='https://login.umd.edu/cas/logout'> logout\n </a>");
}
@Override
public void init() throws ServletException {
dao = new FileDao();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment