Debug.jsp revision 76ad7ecb4e4f3ca5bc014a996cebf0942b7c09c9
1707N/A<%--
1707N/A DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1707N/A
1707N/A Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
1707N/A
1707N/A The contents of this file are subject to the terms
1707N/A of the Common Development and Distribution License
1707N/A (the License). You may not use this file except in
1707N/A compliance with the License.
1707N/A
1707N/A You can obtain a copy of the License at
1707N/A https://opensso.dev.java.net/public/CDDLv1.0.html or
1707N/A opensso/legal/CDDLv1.0.txt
1707N/A See the License for the specific language governing
1707N/A permission and limitations under the License.
1707N/A
1707N/A When distributing Covered Code, include this CDDL
1707N/A Header Notice in each file and include the License file
1707N/A at opensso/legal/CDDLv1.0.txt.
1707N/A If applicable, add the following below the CDDL Header,
1707N/A with the fields enclosed by brackets [] replaced by
1707N/A your own identifying information:
1707N/A "Portions Copyrighted [year] [name of copyright owner]"
1707N/A
1707N/A $Id: Debug.jsp,v 1.15 2009/01/28 05:35:06 ww203982 Exp $
5072N/A
1707N/A--%>
1707N/A
1920N/A<%--
1707N/A Portions Copyrighted 2010-2013 ForgeRock Inc
3824N/A--%>
3824N/A
3824N/A<%@ page pageEncoding="UTF-8" %>
3824N/A<%@ page
3824N/A import="
3824N/A com.iplanet.sso.SSOException,
3842N/A com.iplanet.sso.SSOToken,
3842N/A com.iplanet.sso.SSOTokenManager,
3824N/A com.iplanet.am.util.SystemProperties,
3842N/A com.sun.identity.common.DNUtils,
1707N/A com.sun.identity.idm.AMIdentity,
2976N/A com.sun.identity.idm.IdRepoException,
2650N/A com.sun.identity.idm.IdType,
2976N/A com.sun.identity.idm.IdUtils,
2976N/A com.sun.identity.shared.debug.Debug,
3824N/A com.sun.identity.shared.encode.Hash,
2976N/A java.text.MessageFormat,
1707N/A java.util.ArrayList,
2549N/A java.util.Enumeration,
2549N/A java.util.Collections,
2549N/A java.util.HashMap,
2549N/A java.util.HashSet,
3824N/A java.util.Iterator,
2549N/A java.util.List,
2549N/A java.util.Map,
2549N/A java.util.MissingResourceException,
2549N/A java.util.ResourceBundle,
2976N/A java.util.Set,
1777N/A java.util.StringTokenizer,
1777N/A com.sun.identity.shared.ldap.util.DN,
1777N/A org.owasp.esapi.ESAPI"
5072N/A%>
1707N/A
1707N/A<%
1777N/A String category = request.getParameter("category");
1777N/A String instance = request.getParameter("instance");
1777N/A String level = request.getParameter("level");
1777N/A if (!ESAPI.validator().isValidInput("category", category, "HTTPParameterValue", 512, true)
1707N/A || !ESAPI.validator().isValidInput("instance", instance, "HTTPParameterValue", 512, true)
|| !ESAPI.validator().isValidInput("level", level, "HTTPParameterValue", 512, true)) {
//Invalid values received, let's null them out and ignore them.
category = null;
instance = null;
level = null;
}
boolean performAction = Boolean.valueOf(request.getParameter("do")).
booleanValue();
ResourceBundle resourceBundle = ResourceBundle.getBundle("debug", request.getLocale());
ResourceBundle rbFiles = ResourceBundle.getBundle("debugfiles");
Map categories = new HashMap();
String adminUserDN = "";
List<String> instances = new ArrayList<String>();
AMIdentity adminUserId = null;
String formToken = null;
try {
SSOTokenManager sMgr = SSOTokenManager.getInstance();
SSOToken ssoToken = sMgr.createSSOToken(request);
// This will give you the 'amAdmin' user dn
String adminUser = SystemProperties.get(
"com.sun.identity.authentication.super.user");
if (adminUser != null) {
adminUserDN = DNUtils.normalizeDN(adminUser);
// This will give you the 'amAdmin' Identity
adminUserId = new AMIdentity(ssoToken, adminUser,
IdType.USER, "/", null);
}
// This will be your incoming user/token.
AMIdentity user = new AMIdentity(ssoToken);
if ((!adminUserDN.equals(DNUtils.normalizeDN(
ssoToken.getPrincipal().getName()))) &&
(!user.equals(adminUserId))) {
out.println(resourceBundle.getString("message-no-privileges"));
return;
}
formToken = Hash.hash(ssoToken.getTokenID().toString());
// Make a copy to prevent ConcurrentModificationException
List<Debug> temp = new ArrayList<Debug>(Debug.getInstances());
for (Debug debug : temp) {
instances.add(debug.getName());
}
Collections.sort(instances);
for (Enumeration e = rbFiles.getKeys();
e.hasMoreElements();
) {
String key = (String)e.nextElement();
String val = rbFiles.getString(key);
List lst = (List) categories.get(val);
if (lst == null) {
lst = new ArrayList();
}
lst.add(key);
categories.put(val, lst);
}
} catch (SSOException e) {
response.sendRedirect("UI/Login?goto=../Debug.jsp");
return;
} catch (MissingResourceException e) {
out.println(e.getMessage());
return;
}
if (performAction) {
String receivedToken = request.getParameter("formToken");
if (!formToken.equals(receivedToken)) {
out.println("Invalid form token provided!");
return;
}
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>OpenAM</title>
<link rel="stylesheet" type="text/css" href="com_sun_web_ui/css/css_ns6up.css" />
<link rel="shortcut icon" href="com_sun_web_ui/images/favicon/favicon.ico" type="image/x-icon" />
</head>
<body class="DefBdy">
<div class="SkpMedGry1"><a href="#SkipAnchor3860"><img src="com_sun_web_ui/images/other/dot.gif" alt="Jump to End of Masthead" border="0" height="1" width="1" /></a></div><div class="MstDiv">
<table class="MstTblBot" title="" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="MstTdTtl">
<div class="MstDivTtl"><img name="AMConfig.configurator.ProdName" src="com_sun_web_ui/images/PrimaryProductName.png" alt="OpenAM" border="0" /></div>
</td>
</tr>
</table>
</div>
<table class="SkpMedGry1" border="0" cellpadding="5" cellspacing="0" width="100%"><tr><td><img src="com_sun_web_ui/images/other/dot.gif" alt="Jump to End of Masthead" border="0" height="1" width="1" /></a></td></tr></table>
<table border="0" cellpadding="10" cellspacing="0" width="100%"><tr><td></td></tr></table>
<table cellpadding=5>
<tr>
<td>
<%
if ((instance == null || instance.length() == 0) && (category == null || category.length() == 0)
|| level == null || level.length() == 0
) {
%>
<form name="frm" action="Debug.jsp" method="POST">
<table>
<tr>
<td>
<%
out.println(resourceBundle.getString("label-category"));
%>
:</td>
<td>
<select name="category">
<%
for (Iterator i = categories.keySet().iterator(); i.hasNext(); ) {
String key = (String)i.next();
out.println("<option>" + key + "</option>");
}
%>
</select>
</td>
<td>&nbsp;&nbsp;</td>
<td>
<%
out.println(resourceBundle.getString("label-level"));
%>
:</td>
<td>
<select name="level">
<%
out.println("<option value=\"1\">" +
resourceBundle.getString("label-level-error") + "</option>");
out.println("<option value=\"2\">" +
resourceBundle.getString("label-level-warning") + "</option>");
out.println("<option value=\"3\">" +
resourceBundle.getString("label-level-message") + "</option>");
%>
</select>
</td>
<td><input type="submit" value="Submit" class="Btn1" onclick="this.form.submit();" onmouseover="javascript: this.className='Btn1Hov'" onmouseout="javascript: this.className='Btn1'" onblur="javascript: javascript: this.className='Btn1'" onfocus="javascript: this.className='Btn1Hov'" />
</td>
</tr>
</table>
</form>
<form name="frm" action="Debug.jsp" method="POST">
<table>
<tr>
<td>
<%
out.println(resourceBundle.getString("label-instance"));
%>
:</td>
<td>
<select name="instance">
<%
for (String inst : instances) {
out.println("<option>" + inst + "</option>");
}
%>
</select>
</td>
<td>&nbsp;&nbsp;</td>
<td>
<%
out.println(resourceBundle.getString("label-level"));
%>
:</td>
<td>
<select name="level">
<%
out.println("<option value=\"1\">" +
resourceBundle.getString("label-level-error") + "</option>");
out.println("<option value=\"2\">" +
resourceBundle.getString("label-level-warning") + "</option>");
out.println("<option value=\"3\">" +
resourceBundle.getString("label-level-message") + "</option>");
%>
</select>
</td>
<td><input type="submit" value="Submit" class="Btn1" onclick="this.form.submit();" onmouseover="javascript: this.className='Btn1Hov'" onmouseout="javascript: this.className='Btn1'" onblur="javascript: javascript: this.className='Btn1'" onfocus="javascript: this.className='Btn1Hov'" />
</td>
</tr>
</table>
</form>
<p>&nbsp;</p>
<table border=1 cellpadding=5 cellspacing=0>
<tr>
<th>
<%
out.println(resourceBundle.getString("label-category"));
%>
</th>
<th>
<%
out.println(resourceBundle.getString("label-filenames"));
%>
</th>
</tr>
<%
for (Iterator i = categories.keySet().iterator(); i.hasNext(); ) {
String key = (String)i.next();
out.println("<tr><td valign=top><b>" + key + "</b></td>");
List values = (List)categories.get(key);
out.println("<td>");
String msg = "message-category-"+key;
try {
msg = resourceBundle.getString("message-category-"+key);
} catch (Exception ex) {}
out.println("<b>"+msg+"</b><br>");
out.print("<span class=\"HlpFldTxt\">");
for (Iterator j = values.iterator(); j.hasNext(); ) {
out.println((String)j.next() + " " );
}
out.print("</span>");
out.println("</td></tr>");
}
%>
</table>
<%
} else {
if (category != null) {
out.println(resourceBundle.getString("label-category") + " = " + category);
} else {
out.println("Instance" + " = " + instance);
}
out.println("<br />");
String strLevel = "message";
if (level.equals("1")) {
strLevel = "error";
} else if (level.equals("2")) {
strLevel = "warning";
}
out.println(resourceBundle.getString("label-level") + " = " + strLevel);
out.println("<br />");
int levelint = Integer.parseInt(level);
if (category != null) {
Object[] param = {strLevel};
out.println(MessageFormat.format(
resourceBundle.getString("message-setting-level-on-modules"), param));
out.println("<br />");
List values = (List)categories.get(category);
out.println("<ul>");
for (Iterator i = values.iterator(); i.hasNext(); ) {
String mname = (String)i.next();
out.println( "<li>" + mname + "</li>" );
if (performAction) {
Debug debug = Debug.getInstance(mname);
debug.setDebug(levelint);
}
}
out.println("</ul>");
} else {
Object[] param = {strLevel, instance};
out.println(MessageFormat.format(
resourceBundle.getString("message-setting-level-on-instance"), param));
if (performAction) {
Debug.getInstance(instance).setDebug(levelint);
}
}
String backURL = "Debug.jsp";
if (!performAction) {
out.println("<form name='frm' method='POST' action='Debug.jsp'>");
if (category != null) {
out.println("<input name='category' type='hidden' value='" + category + "' />");
} else {
out.println("<input name='instance' type='hidden' value='" + instance + "' />");
}
out.println("<input name='level' type='hidden' value='" + levelint + "' />");
out.println("<input name='do' type='hidden' value='true' />");
out.println("<input type='hidden' name='formToken' value='" + formToken + "' />");
out.println("<table border=0>");
out.println("<tr><td>");
out.println("<input type=\"button\" name=\"do\" value=\"" + resourceBundle.getString("button-confirm") + "\" class=\"Btn1\" onclick=\"this.form.submit();\" onmouseover=\"javascript: this.className='Btn1Hov'\" onmouseout=\"javascript: this.className='Btn1'\" onblur=\"javascript: javascript: this.className='Btn1'\" onfocus=\"javascript: this.className='Btn1Hov'\" /></form>");
out.println("</td><td>");
out.println("<input type=\"button\" name=\"back\" value=\"" + resourceBundle.getString("button-back") + "\" class=\"Btn1\" onclick=\"var elements=this.form.elements;for (var i=0;i<elements.length;i++){if(elements[i].type && elements[i].type==='hidden'){elements[i].value=''}};this.form.submit();\" onmouseover=\"javascript: this.className='Btn1Hov'\" onmouseout=\"javascript: this.className='Btn1'\" onblur=\"javascript: this.className='Btn1'\" onfocus=\"javascript: this.className='Btn1Hov'\" />");
out.println("</td></tr></table>");
out.println("</form>");
} else {
Object[] params = {backURL};
out.println("<p>");
out.println(MessageFormat.format(
resourceBundle.getString("message-succeed"), params));
}
}
%>
</td></tr>
</table>
</body>
</html>