Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
castest2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Steve Ryan
castest2
Commits
d3487ab9
Commit
d3487ab9
authored
5 years ago
by
Steve Ryan
Browse files
Options
Downloads
Patches
Plain Diff
Added pulling the username, re-added validation filters/SSOlogout
parent
663937fd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
castest2/WebContent/WEB-INF/web.xml
+21
-21
21 additions, 21 deletions
castest2/WebContent/WEB-INF/web.xml
castest2/src/castest2/servlet/FileCounter.java
+14
-4
14 additions, 4 deletions
castest2/src/castest2/servlet/FileCounter.java
with
35 additions
and
25 deletions
castest2/WebContent/WEB-INF/web.xml
+
21
−
21
View file @
d3487ab9
<?xml version="1.0" encoding="UTF-8"?>
<?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"
>
<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-list>
<welcome-file>
index.html
</welcome-file>
<welcome-file>
index.html
</welcome-file>
<welcome-file>
index.htm
</welcome-file>
<welcome-file>
index.htm
</welcome-file>
...
@@ -9,10 +12,15 @@
...
@@ -9,10 +12,15 @@
<welcome-file>
default.htm
</welcome-file>
<welcome-file>
default.htm
</welcome-file>
<welcome-file>
default.jsp
</welcome-file>
<welcome-file>
default.jsp
</welcome-file>
</welcome-file-list>
</welcome-file-list>
<context-param>
<param-name>
serverName
</param-name>
<param-value>
http://localhost:8080
</param-value>
</context-param>
<!-- Start CAS configuration -->
<!-- Start CAS configuration -->
<!-- https://secure.identity.ucsb.edu/inside/doku.php/sso_java -->
<!-- https://secure.identity.ucsb.edu/inside/doku.php/sso_java -->
<!-- CAS Single Sign Out Filter
<!-- CAS Single Sign Out Filter
-->
<filter>
<filter>
<filter-name>
CAS Single Sign Out Filter
</filter-name>
<filter-name>
CAS Single Sign Out Filter
</filter-name>
<filter-class>
org.jasig.cas.client.session.SingleSignOutFilter
</filter-class>
<filter-class>
org.jasig.cas.client.session.SingleSignOutFilter
</filter-class>
...
@@ -20,7 +28,7 @@
...
@@ -20,7 +28,7 @@
<param-name>
casServerUrlPrefix
</param-name>
<param-name>
casServerUrlPrefix
</param-name>
<param-value>
https://shib.idm.umd.edu/shibboleth-idp/profile/cas
</param-value>
<param-value>
https://shib.idm.umd.edu/shibboleth-idp/profile/cas
</param-value>
</init-param>
</init-param>
</filter>
-->
</filter>
<!-- CAS Authentication Filter -->
<!-- CAS Authentication Filter -->
<filter>
<filter>
<filter-name>
CAS Authentication Filter
</filter-name>
<filter-name>
CAS Authentication Filter
</filter-name>
...
@@ -29,22 +37,14 @@
...
@@ -29,22 +37,14 @@
<param-name>
casServerLoginUrl
</param-name>
<param-name>
casServerLoginUrl
</param-name>
<param-value>
https://login.umd.edu/cas/login
</param-value>
<param-value>
https://login.umd.edu/cas/login
</param-value>
</init-param>
</init-param>
<init-param>
<param-name>
serverName
</param-name>
<param-value>
http://localhost:8080/
</param-value>
</init-param>
</filter>
</filter>
<!-- CAS Validation Filter
<!-- CAS Validation Filter
-->
<filter>
<filter>
<filter-name>
CAS Validation Filter
</filter-name>
<filter-name>
CAS Validation Filter
</filter-name>
<filter-class>org.jasig.cas.client.validation.Cas20
Service
TicketValidat
o
r</filter-class>
<filter-class>
org.jasig.cas.client.validation.Cas20
ProxyReceiving
TicketValidat
ionFilte
r
</filter-class>
<init-param>
<init-param>
<param-name>
casServerUrlPrefix
</param-name>
<param-name>
casServerUrlPrefix
</param-name>
<param-value>https://shib.idm.umd.edu/shibboleth-idp/profile/cas</param-value>
<param-value>
https://login.umd.edu/cas
</param-value>
</init-param>
<init-param>
<param-name>serverName</param-name>
<param-value>http://localhost:8080/castest2</param-value>
</init-param>
</init-param>
<init-param>
<init-param>
<param-name>
redirectAfterValidation
</param-name>
<param-name>
redirectAfterValidation
</param-name>
...
@@ -54,33 +54,33 @@
...
@@ -54,33 +54,33 @@
<param-name>
useSession
</param-name>
<param-name>
useSession
</param-name>
<param-value>
true
</param-value>
<param-value>
true
</param-value>
</init-param>
</init-param>
</filter>
-->
</filter>
<!-- CAS HttpServletRequest Wrapper Filter -->
<!-- CAS HttpServletRequest Wrapper Filter -->
<filter>
<filter>
<filter-name>
CAS HttpServletRequest Wrapper Filter
</filter-name>
<filter-name>
CAS HttpServletRequest Wrapper Filter
</filter-name>
<filter-class>
org.jasig.cas.client.util.HttpServletRequestWrapperFilter
</filter-class>
<filter-class>
org.jasig.cas.client.util.HttpServletRequestWrapperFilter
</filter-class>
</filter>
</filter>
<!-- order of CAS filter mappings is important
<!-- order of CAS filter mappings is important
-->
<filter-mapping>
<filter-mapping>
<filter-name>
CAS Single Sign Out Filter
</filter-name>
<filter-name>
CAS Single Sign Out Filter
</filter-name>
<url-pattern>
/*
</url-pattern>
<url-pattern>
/*
</url-pattern>
</filter-mapping>
-->
</filter-mapping>
<filter-mapping>
<filter-mapping>
<filter-name>
CAS Authentication Filter
</filter-name>
<filter-name>
CAS Authentication Filter
</filter-name>
<url-pattern>
/*
</url-pattern>
<url-pattern>
/*
</url-pattern>
</filter-mapping>
</filter-mapping>
<!--
<filter-mapping>
<filter-mapping>
<filter-name>
CAS Validation Filter
</filter-name>
<filter-name>
CAS Validation Filter
</filter-name>
<url-pattern>
/*
</url-pattern>
<url-pattern>
/*
</url-pattern>
</filter-mapping>
-->
</filter-mapping>
<filter-mapping>
<filter-mapping>
<filter-name>
CAS HttpServletRequest Wrapper Filter
</filter-name>
<filter-name>
CAS HttpServletRequest Wrapper Filter
</filter-name>
<url-pattern>
/*
</url-pattern>
<url-pattern>
/*
</url-pattern>
</filter-mapping>
</filter-mapping>
<!--
<listener>
<listener>
<listener-class>
org.jasig.cas.client.session.SingleSignOutHttpSessionListener
</listener-class>
<listener-class>
org.jasig.cas.client.session.SingleSignOutHttpSessionListener
</listener-class>
</listener>
-->
</listener>
<!-- End CAS configuration -->
<!-- End CAS configuration -->
</web-app>
</web-app>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
castest2/src/castest2/servlet/FileCounter.java
+
14
−
4
View file @
d3487ab9
...
@@ -8,6 +8,7 @@ import javax.servlet.http.HttpServlet;
...
@@ -8,6 +8,7 @@ import javax.servlet.http.HttpServlet;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
javax.servlet.http.HttpSession
;
import
org.jasig.cas.client.authentication.AttributePrincipal
;
import
castest2.FileDao
;
import
castest2.FileDao
;
...
@@ -29,16 +30,25 @@ public class FileCounter extends HttpServlet {
...
@@ -29,16 +30,25 @@ public class FileCounter extends HttpServlet {
HttpSession
session
=
request
.
getSession
(
true
);
HttpSession
session
=
request
.
getSession
(
true
);
// Set the session valid for 5 secs
// Set the session valid for 5 secs
session
.
setMaxInactiveInterval
(
5
);
session
.
setMaxInactiveInterval
(
5
);
response
.
setContentType
(
"text/html"
);
response
.
setContentType
(
"text/html"
);
PrintWriter
out
=
response
.
getWriter
();
PrintWriter
out
=
response
.
getWriter
();
if
(
session
.
isNew
())
{
if
(
session
.
isNew
())
{
count
++;
count
++;
}
}
out
.
println
(
"This site has been accessed "
+
count
+
" times."
);
//CAS returns principal in the request.
out
.
println
(
"<a href='https://login.umd.edu/cas/logout'> logout </a>"
);
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
@Override
public
void
init
()
throws
ServletException
{
public
void
init
()
throws
ServletException
{
dao
=
new
FileDao
();
dao
=
new
FileDao
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment