1<%-- 2 Licensed to the Apache Software Foundation (ASF) under one or more 3 contributor license agreements. See the NOTICE file distributed with 4 this work for additional information regarding copyright ownership. 5 The ASF licenses this file to You under the Apache License, Version 2.0 6 (the "License"); you may not use this file except in compliance with 7 the License. You may obtain a copy of the License at 8 9 http://www.apache.org/licenses/LICENSE-2.0 10 11 Unless required by applicable law or agreed to in writing, software 12 distributed under the License is distributed on an "AS IS" BASIS, 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 See the License for the specific language governing permissions and 15 limitations under the License. 16--%> 17<%@ page import="java.util.Enumeration" %> 18<% 19 if (request.getParameter("logoff") != null) { 20 session.invalidate(); 21 response.sendRedirect("index.jsp"); 22 return; 23 } 24%> 25<html> 26<head> 27<title>Protected Page for Examples</title> 28</head> 29<body bgcolor="white"> 30 31You are logged in as remote user 32<b><%= util.HTMLFilter.filter(request.getRemoteUser()) %></b> 33in session <b><%= session.getId() %></b><br><br> 34 35<% 36 if (request.getUserPrincipal() != null) { 37%> 38 Your user principal name is 39 <b><%= util.HTMLFilter.filter(request.getUserPrincipal().getName()) %></b> 40 <br><br> 41<% 42 } else { 43%> 44 No user principal could be identified.<br><br> 45<% 46 } 47%> 48 49<% 50 String role = request.getParameter("role"); 51 if (role == null) 52 role = ""; 53 if (role.length() > 0) { 54 if (request.isUserInRole(role)) { 55%> 56 You have been granted role 57 <b><%= util.HTMLFilter.filter(role) %></b><br><br> 58<% 59 } else { 60%> 61 You have <i>not</i> been granted role 62 <b><%= util.HTMLFilter.filter(role) %></b><br><br> 63<% 64 } 65 } 66%> 67 68To check whether your user name has been granted a particular role, 69enter it here: 70<form method="GET" action='<%= response.encodeURL("index.jsp") %>'> 71<input type="text" name="role" value="<%= util.HTMLFilter.filter(role) %>"> 72<input type="submit" > 73</form> 74<br><br> 75 76To add some data to the authenticated session, enter it here: 77<form method="GET" action='<%= response.encodeURL("index.jsp") %>'> 78<input type="text" name="dataName"> 79<input type="text" name="dataValue"> 80<input type="submit" > 81</form> 82<br><br> 83 84<% 85 String dataName = request.getParameter("dataName"); 86 if (dataName != null) { 87 session.setAttribute(dataName, request.getParameter("dataValue")); 88 } 89%> 90<p>The authenticated session contains the following attributes:</p> 91<table> 92<tr><th>Name</th><th>Value</th></tr> 93<% 94 Enumeration<String> names = session.getAttributeNames(); 95 while (names.hasMoreElements()) { 96 String name = names.nextElement(); 97%> 98<tr><td><%= name %></td><td><%= session.getAttribute(name) %></td> 99<% 100 } 101%> 102</table> 103<br><br> 104 105If you have configured this application for form-based authentication, you can 106log off by clicking 107<a href='<%= response.encodeURL("index.jsp?logoff=true") %>'>here</a>. 108This should cause you to be returned to the login page after the redirect 109that is performed. 110 111</body> 112</html> 113