Skip to content

Instantly share code, notes, and snippets.

@trepidity
Created October 26, 2015 17:03
Show Gist options
  • Select an option

  • Save trepidity/656b15270e3514efdb35 to your computer and use it in GitHub Desktop.

Select an option

Save trepidity/656b15270e3514efdb35 to your computer and use it in GitHub Desktop.
Access Manager Troubleshooting Tool This sample web page is for troubleshooting purposes only
<%@ page
import="java.io.*"
import="java.util.*"
%>
<%
//Do not allow page to be cached
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
Enumeration enames;
Map map;
String title;
out.println("<html>\n");
out.println("<meta http-equiv='cache-control' content='no-cache'>");
out.println("<meta http-equiv='pragma' content='no-cache'>");
out.println("<meta http-equiv='content-type' content='text/html; charset=UTF-8'>");
out.println("<title>Access Manager Troubleshooting Tool</title>");
out.println("<body>\n");
out.println("<center><h1>Access Manager Identity Injection Troubleshooting tool</h1>\n");
out.println("<font color=red size=3>WARNING: This sample web page is for troubleshooting purposes only.<br> Make sure you remove this sample web page from your web server after troubleshooting.<br> Use at your own risk.</font></center><br>\n");
// Print general information about request
map = new TreeMap();
map.put("Request Method", request.getMethod());
map.put("Request URI", request.getRequestURI());
map.put("Sent from host", request.getRemoteAddr());
out.println(createTable(map, "Information about request"));
// Print the request headers
map = new TreeMap();
enames = request.getHeaderNames();
while (enames.hasMoreElements()) {
String name = (String) enames.nextElement();
String value = request.getHeader(name);
map.put(name, value);
}
out.println(createTable(map, "HTTP Headers from request"));
// Print the request parameters
map = new TreeMap();
java.util.Enumeration e = request.getParameterNames();
while (e.hasMoreElements()) {
String key = (String)e.nextElement();
String[] values = request.getParameterValues(key);
for(int i = 0; i < values.length; i++) {
map.put(key, values[i]);
}
}
out.println(createTable(map, "Query String Parameters from request"));
out.println("<body>\n</html>\n");
%>
<%-- Define a method to create an HTML table --%>
<%!
private static String createTable(Map map, String title)
{
StringBuffer sb = new StringBuffer();
// Generate the header lines
sb.append("<table cellpadding='3' cellspacing='1'>\n");
sb.append("\t<tr bgcolor='lightblue'>");
sb.append("<th colspan='2'>");
sb.append(title);
sb.append("</th>");
sb.append("</tr>\n");
// Generate the table rows
if(map.size() == 0)
sb.append("\t<tr bgcolor='lightgrey'><td><i>No Query Strings found</i></td></tr>\n");
else{
Iterator imap = map.entrySet().iterator();
while (imap.hasNext()) {
Map.Entry entry = (Map.Entry) imap.next();
String key = (String) entry.getKey();
String value = (String) entry.getValue();
sb.append("\t<tr bgcolor='lightgrey'>");
sb.append("<td><b>");
sb.append(key);
sb.append("</b></td>");
sb.append("<td>");
sb.append(value);
sb.append("</td>");
sb.append("</tr>\n");
}
}
// Generate the footer lines
sb.append("</table>\n<p></p>\n");
// Return the generated HTML
return sb.toString();
}
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment