-
Notifications
You must be signed in to change notification settings - Fork 409
Expand file tree
/
Copy pathacs.jsp
More file actions
131 lines (117 loc) · 4.21 KB
/
acs.jsp
File metadata and controls
131 lines (117 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<%@page import="com.onelogin.saml2.Auth"%>
<%@page import="com.onelogin.saml2.servlet.ServletUtils"%>
<%@page import="java.util.Collection"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Map"%>
<%@page import="org.apache.commons.lang3.StringUtils" %>
<%@page import="java.io.StringWriter"%>
<%@page import="java.io.PrintWriter"%>
<%@page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>A Java SAML Toolkit</title>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<h1>A Java SAML Toolkit</h1>
<!-- TODO Session support -->
<%
Auth auth;
try
{
auth = new Auth(request, response);
auth.processResponse();
}
catch (Exception e)
{
e.printStackTrace();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
String stackTrace = sw.toString().replace("\n", "<br/>");
out.println("<div class=\"alert alert-danger\" role=\"alert\">" + stackTrace + "</div>");
return;
}
if (!auth.isAuthenticated()) {
out.println("<div class=\"alert alert-danger\" role=\"alert\">Not authenticated</div>");
}
List<String> errors = auth.getErrors();
if (!errors.isEmpty()) {
out.println("<p>" + StringUtils.join(errors, ", ") + "</p>");
if (auth.isDebugActive()) {
String errorReason = auth.getLastErrorReason();
if (errorReason != null && !errorReason.isEmpty()) {
out.println("<p>" + auth.getLastErrorReason() + "</p>");
}
}
out.println("<a href=\"dologin.jsp\" class=\"btn btn-primary\">Login</a>");
} else {
Map<String, List<String>> attributes = auth.getAttributes();
String nameId = auth.getNameId();
String nameIdFormat = auth.getNameIdFormat();
String sessionIndex = auth.getSessionIndex();
String nameidNameQualifier = auth.getNameIdNameQualifier();
String nameidSPNameQualifier = auth.getNameIdSPNameQualifier();
session.setAttribute("attributes", attributes);
session.setAttribute("nameId", nameId);
session.setAttribute("nameIdFormat", nameIdFormat);
session.setAttribute("sessionIndex", sessionIndex);
session.setAttribute("nameidNameQualifier", nameidNameQualifier);
session.setAttribute("nameidSPNameQualifier", nameidSPNameQualifier);
String relayState = request.getParameter("RelayState");
if (relayState != null && !relayState.isEmpty() && !relayState.equals(ServletUtils.getSelfRoutedURLNoQuery(request)) &&
!relayState.contains("/dologin.jsp")) { // We don't want to be redirected to login.jsp neither
response.sendRedirect(request.getParameter("RelayState"));
} else {
if (attributes.isEmpty()) {
%>
<div class="alert alert-danger" role="alert">You don't have any attributes</div>
<%
}
else {
%>
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Values</th>
</tr>
</thead>
<tbody>
<%
Collection<String> keys = attributes.keySet();
for(String name :keys){
out.println("<tr><td>" + name + "</td><td>");
List<String> values = attributes.get(name);
for(String value :values) {
out.println("<li>" + value + "</li>");
}
out.println("</td></tr>");
}
%>
</tbody>
</table>
<%
}
%>
<a href="attrs.jsp" class="btn btn-primary">See user data stored at session</a>
<a href="dologout.jsp" class="btn btn-primary">Logout</a>
<%
}
}
%>
</div>
</body>
</html>