/*
* Sun Public License
*
* The contents of this file are subject to the Sun Public License Version
* 1.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is available at http://www.sun.com/
*
* The Original Code is the SLAMD Distributed Load Generation Engine.
* The Initial Developer of the Original Code is Neil A. Wilson.
* Portions created by Neil A. Wilson are Copyright (C) 2004-2010.
* Some preexisting portions Copyright (C) 2002-2006 Sun Microsystems, Inc.
* All Rights Reserved.
*
* Contributor(s): Neil A. Wilson
*/
package com.slamd.admin;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Properties;
import java.util.StringTokenizer;
import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.sleepycat.je.DatabaseException;
import netscape.ldap.LDAPException;
import com.slamd.common.Constants;
import com.slamd.db.SLAMDDB;
import com.slamd.parameter.BooleanParameter;
import com.slamd.parameter.IntegerParameter;
import com.slamd.parameter.InvalidValueException;
import com.slamd.parameter.MultiLineTextParameter;
import com.slamd.parameter.Parameter;
import com.slamd.parameter.ParameterList;
import com.slamd.parameter.PasswordParameter;
import com.slamd.parameter.StringParameter;
import com.slamd.report.ReportGenerator;
import com.slamd.server.ConfigSubscriber;
import static com.slamd.admin.AdminAccess.*;
import static com.slamd.admin.AdminServlet.*;
import static com.slamd.admin.AdminUI.*;
/**
* This class provides a set of methods for providing the interface to the
* SLAMD server configuration.
*/
public class AdminConfig
implements ConfigSubscriber
{
static AdminConfig ADMIN_CONFIG = new AdminConfig();
/**
* Creates a new instance of this class.
*/
private AdminConfig()
{
}
/**
* Retrieves the name that the servlet uses to subscribe to the configuration
* handler in order to be notified of configuration changes.
*
* @return The name that the servlet uses to subscribe to the configuration
* handler in order to be notified of configuration changes.
*/
public String getSubscriberName()
{
return CONFIG_SUBSCRIBER_NAME;
}
/**
* Retrieves the set of configuration parameters associated with this
* configuration subscriber.
*
* @return The set of configuration parameters associated with this
* configuration subscriber.
*/
public ParameterList getSubscriberParameters()
{
BooleanParameter alwaysShowAdvancedParameter =
new BooleanParameter(Constants.PARAM_ALWAYS_SHOW_ADVANCED_OPTIONS,
"Always Show Advanced Scheduling Options",
"Indicates whether the advanced scheduling " +
"options should always be displayed when " +
"scheduling a job.", alwaysShowAdvancedOptions);
BooleanParameter disableGraphsParameter =
new BooleanParameter(Constants.PARAM_DISABLE_GRAPHS,
"Disable Graphs",
"Indicates whether the graphing capabilities " +
"should be disabled. This may be useful if " +
"no X-Windows environment is available for " +
"use by the SLAMD server to generate the images.",
disableGraphs);
BooleanParameter graphInNewWindowParameter =
new BooleanParameter(Constants.PARAM_GRAPH_IN_NEW_WINDOW,
"Display Graphs in New Window",
"Indicates whether graphs generated by SLAMD " +
"should be displayed in a new window separate " +
"from other data", graphInNewWindow);
BooleanParameter disableUploadsParameter =
new BooleanParameter(Constants.PARAM_DISABLE_UPLOADS,
"Disable File Uploads",
"Indicates whether the SLAMD file upload " +
"capabilities should be disabled.",
disableUploads);
BooleanParameter hideOptimizingIterationsParameter =
new BooleanParameter(Constants.PARAM_HIDE_OPTIMIZING_ITERATIONS,
"Hide Optimizing Job Iterations",
"Indicates whether the individual iterations of " +
"an optimizing job should be hidden when " +
"viewing a list of completed jobs.",
hideOptimizingIterations);
BooleanParameter includeServerInTitleParameter =
new BooleanParameter(Constants.PARAM_INCLUDE_SERVER_IN_TITLE,
"Include Server Name in Page Title",
"Indicates whether the address of the SLAMD " +
"server should be included in the title of the " +
"generated HTML pages. This may be useful if " +
"you are using several SLAMD servers at the " +
"same time.", includeAddressInPageTitle);
BooleanParameter manageReadOnlyParameter =
new BooleanParameter(Constants.PARAM_MANAGE_READ_ONLY,
"Enable Management of Read-Only Options",
"Indicates whether the admin interface should " +
"display options for managing the SLAMD server " +
"that will only be applicable if the server is " +
"to be run in restricted read-only mode.",
enableReadOnlyManagement);
BooleanParameter populateStartTimeParameter =
new BooleanParameter(Constants.PARAM_POPULATE_START_TIME,
"Supply Default Start Time",
"Indicates whether a default start time (set " +
"to the current time) should be automatically " +
"specified when scheduling a new job for " +
"execution. Providing a default value may " +
"make it easier for someone to change the " +
"start time because it is easier to remember " +
"the format.", populateStartTime);
BooleanParameter showLoginIDParameter =
new BooleanParameter(Constants.PARAM_SHOW_LOGIN_ID,
"Show Login ID",
"Indicates whether to show the login ID of the " +
"currently authenticated user in the " +
"navigation bar on the side of the generated " +
"HTML pages. This will only appear if access " +
"control is enabled for the administrative " +
"interface.", showLoginID);
BooleanParameter showTimeParameter =
new BooleanParameter(Constants.PARAM_SHOW_TIME, "Show Time in Sidebar",
"Indicates whether the current date and time " +
"should be included in the navigation sidebar " +
"of pages that are generated.",
showTimeInSidebar);
IntegerParameter defaultGraphWidthParameter =
new IntegerParameter(Constants.PARAM_DEFAULT_GRAPH_WIDTH,
"Default Graph Width",
"The default width to use for graphs " +
"generated from statistical data", true,
defaultGraphWidth, true, 1, false, 0);
IntegerParameter defaultGraphHeightParameter =
new IntegerParameter(Constants.PARAM_DEFAULT_GRAPH_HEIGHT,
"Default Graph Height",
"The default height to use for graphs " +
"generated from statistical data", true,
defaultGraphHeight, true, 1, false, 0);
IntegerParameter defaultMonitorGraphHeightParameter =
new IntegerParameter(Constants.PARAM_DEFAULT_MONITOR_GRAPH_HEIGHT,
"Default Monitor Graph Height",
"The default height to use for graphs " +
"generated from system resource data", true,
defaultMonitorGraphHeight, true, 1, false, 0);
IntegerParameter maxUploadSizeParameter =
new IntegerParameter(Constants.PARAM_MAX_UPLOAD_SIZE,
"Maximum File Upload Size",
"The maximum size in bytes that will be " +
"allowed for an upload file. A value of " +
"-1 indicates that there should not be any " +
"limit imposed.", true, maxUploadSize, true, -1,
false, 0);
String[] generatorClasses = new String[reportGenerators.length];
for (int i=0; i < reportGenerators.length; i++)
{
generatorClasses[i] = reportGenerators[i].getClass().getName();
}
MultiLineTextParameter reportGeneratorsParameter =
new MultiLineTextParameter(Constants.PARAM_REPORT_GENERATOR_CLASSES,
"Report Generator Classes",
"The fully-qualified names of the Java " +
"classes that provide the ability to " +
"generate reports of SLAMD data. If " +
"multiple classes are to be used, they " +
"should be listed one per line.",
generatorClasses, false);
reportGeneratorsParameter.setVisibleColumns(80);
String headerStr =
configDB.getConfigParameter(Constants.PARAM_ADD_TO_HTML_HEADER);
String[] headerLines = stringToLineArray(headerStr);
MultiLineTextParameter headerLinesParameter =
new MultiLineTextParameter(Constants.PARAM_ADD_TO_HTML_HEADER,
"Lines to Add to HTML Header",
"The lines to add to the HTML header for " +
"generated pages.", headerLines, false);
headerLinesParameter.setVisibleRows(10);
headerLinesParameter.setVisibleColumns(80);
String styleStr = configDB.getConfigParameter(Constants.PARAM_STYLE_SHEET);
if ((styleStr == null) || (styleStr.length() == 0))
{
styleStr = Constants.STYLE_SHEET_DATA;
}
String[] styleLines = stringToLineArray(styleStr);
MultiLineTextParameter styleSheetParameter =
new MultiLineTextParameter(Constants.PARAM_STYLE_SHEET,
"HTML Style Sheet",
"The style sheet to be used for " +
"generated HTML pages.", styleLines, false);
styleSheetParameter.setVisibleRows(10);
styleSheetParameter.setVisibleColumns(80);
headerStr = configDB.getConfigParameter(Constants.PARAM_PAGE_HEADER);
if ((headerStr == null) || (headerStr.length() == 0))
{
headerStr = Constants.DEFAULT_PAGE_HEADER;
}
String[] pageHeaderLines = stringToLineArray(headerStr);
MultiLineTextParameter pageHeaderParameter =
new MultiLineTextParameter(Constants.PARAM_PAGE_HEADER,
"Page Header",
"The HTML to include at the top of " +
"generated pages.", pageHeaderLines, false);
pageHeaderParameter.setVisibleRows(10);
pageHeaderParameter.setVisibleColumns(80);
String footerStr = configDB.getConfigParameter(Constants.PARAM_PAGE_FOOTER);
if ((footerStr == null) || (footerStr.length() == 0))
{
footerStr = Constants.DEFAULT_PAGE_FOOTER;
}
String[] pageFooterLines = stringToLineArray(footerStr);
MultiLineTextParameter pageFooterParameter =
new MultiLineTextParameter(Constants.PARAM_PAGE_FOOTER,
"Page Footer",
"The HTML to include at the bottom of " +
"generated pages.", pageFooterLines, false);
pageFooterParameter.setVisibleRows(10);
pageFooterParameter.setVisibleColumns(80);
String mainPageStr =
configDB.getConfigParameter(Constants.PARAM_DEFAULT_HTML);
if ((mainPageStr == null) || (mainPageStr.length() == 0))
{
mainPageStr = Constants.DEFAULT_HTML;
}
String[] mainPageLines = stringToLineArray(mainPageStr);
MultiLineTextParameter mainPageParameter =
new MultiLineTextParameter(Constants.PARAM_DEFAULT_HTML,
"Main Page Contents",
"The HTML that should be included on the " +
"main page displayed when SLAMD is " +
"initially accessed.", mainPageLines,
false);
mainPageParameter.setVisibleRows(10);
mainPageParameter.setVisibleColumns(80);
Parameter[] params = new Parameter[]
{
populateStartTimeParameter,
alwaysShowAdvancedParameter,
showLoginIDParameter,
showTimeParameter,
disableGraphsParameter,
graphInNewWindowParameter,
defaultGraphWidthParameter,
defaultGraphHeightParameter,
defaultMonitorGraphHeightParameter,
includeServerInTitleParameter,
disableUploadsParameter,
maxUploadSizeParameter,
manageReadOnlyParameter,
hideOptimizingIterationsParameter,
reportGeneratorsParameter,
headerLinesParameter,
styleSheetParameter,
pageHeaderParameter,
pageFooterParameter,
mainPageParameter
};
return new ParameterList(params);
}
/**
* Read the servlet configuration information and instantiate the appropriate
* static instance variables. The location of the configuration file will be
* read from the initialization parameters, but all other configuration will
* be read from the specified file.
*
* @param config The servlet configuration information.
*
* @return <CODE>true</CODE> if the configuration information could be read,
* or <CODE>false</CODE> if it could not.
*
* @throws IOException If a problem occurs while reading the configuration
* file.
*/
static boolean readServletConfig(ServletConfig config)
throws IOException
{
// Set default values for a couple of key configuration parameters.
classPath = webInfBasePath + "/classes";
configDBDirectory = webInfBasePath + "/db";
// See if the admin interface should operate in read-only mode.
String readOnlyStr = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_READ_ONLY);
if ((readOnlyStr != null) && readOnlyStr.equals("1"))
{
readOnlyMode = true;
}
else
{
readOnlyMode = false;
}
// See if the admin interface should operate in restricted read-only mode.
String restrictStr =
config.getInitParameter(
Constants.SERVLET_INIT_PARAM_RESTRICTED_READ_ONLY);
if ((restrictStr != null) && restrictStr.equals("1"))
{
restrictedReadOnlyMode = true;
}
else
{
restrictedReadOnlyMode = false;
}
// See if the admin interface should allow users to search in read-only
// mode.
String searchStr = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_SEARCH_READ_ONLY);
if ((searchStr != null) && searchStr.equals("1"))
{
searchReadOnly = true;
}
else
{
searchReadOnly = false;
}
// See if the admin interface should attempt to hide sensitive information
// in read-only mode.
String hideStr = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_HIDE_SENSITIVE_INFO);
if ((hideStr != null) && hideStr.equals("1"))
{
hideSensitiveInformation = true;
}
else
{
hideSensitiveInformation = false;
}
// See if we should display the link to the status page at the top or bottom
// of the navigation sidebar
String statusStr = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_SHOW_STATUS_FIRST);
if ((statusStr != null) && statusStr.equals("1"))
{
showStatusFirstInSidebar = true;
}
else
{
showStatusFirstInSidebar = false;
}
// See if we have access to a config file. If so, then read it in.
configFile = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_CONFIG_FILE);
if ((configFile == null) || (configFile.length() == 0))
{
configFile = config.getServletContext().getRealPath(
Constants.DEFAULT_CONFIG_FILE_PATH);
}
if (! new File(configFile).exists())
{
unavailableReason = "The configuration file " + configFile +
" does not exist.";
return false;
}
configProperties = new Properties();
configProperties.load(new FileInputStream(configFile));
// See if the configuration has been edited.
String configuredStr = configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_CONFIGURED);
if ((configuredStr != null) && (configuredStr.length() > 0))
{
if (configuredStr.equalsIgnoreCase("false") ||
configuredStr.equalsIgnoreCase("no") ||
configuredStr.equalsIgnoreCase("0"))
{
unavailableReason = "The SLAMD configuration has not yet been " +
"initialized.";
configProperties.remove(Constants.SERVLET_INIT_PARAM_CONFIGURED);
return false;
}
}
// Get the location of the job class files.
classPath = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_JOB_CLASS_PATH);
if ((classPath == null) || (classPath.length() == 0))
{
classPath = configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_JOB_CLASS_PATH);
if ((classPath == null) || (classPath.length() == 0))
{
classPath = webInfBasePath + "/classes";
}
}
// Get the location of the configuration database files.
configDBDirectory = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_CONFIG_DB_DIRECTORY);
if ((configDBDirectory == null) || (configDBDirectory.length() == 0))
{
configDBDirectory =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_CONFIG_DB_DIRECTORY);
if ((configDBDirectory == null) || (configDBDirectory.length() == 0))
{
configDBDirectory = webInfBasePath + "/db";
}
}
// Determine whether access control should be enforced.
useAccessControl = false;
String aclStr = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_USE_ACCESS_CONTROL);
if ((aclStr == null) || (aclStr.length() == 0))
{
aclStr = configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_USE_ACCESS_CONTROL);
}
if ((aclStr != null) &&
(aclStr.equalsIgnoreCase("true") || aclStr.equalsIgnoreCase("yes") ||
aclStr.equalsIgnoreCase("on")))
{
useAccessControl = true;
}
// Only read access-related parameters if access control is enabled.
if (useAccessControl)
{
// Determine the address of the user directory.
userDirHost = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_USER_DIR_HOST);
if ((userDirHost == null) || (userDirHost.length() == 0))
{
userDirHost = configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_USER_DIR_HOST);
}
if ((userDirHost == null) || (userDirHost.length() == 0))
{
unavailableReason = "Access control is enabled, but the address of " +
"the user directory could not be determined.";
return false;
}
// Determine the port number for the user directory.
userDirPort = 389;
String portStr = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_USER_DIR_PORT);
if ((portStr == null) || (portStr.length() == 0))
{
portStr = configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_USER_DIR_PORT);
if ((portStr != null) && (portStr.length() > 0))
{
try
{
userDirPort = Integer.parseInt(portStr);
}
catch (NumberFormatException nfe)
{
unavailableReason = "Unable to interpret " + portStr +
" as the port number for the user " +
"directory.";
return false;
}
}
}
else
{
try
{
userDirPort = Integer.parseInt(portStr);
}
catch (NumberFormatException nfe)
{
unavailableReason = "Unable to interpret " + portStr +
" as the port number for the user " +
"directory.";
return false;
}
}
// Determine the bind DN for the user directory.
userDirBindDN = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_USER_DIR_BIND_DN);
if ((userDirBindDN == null) || (userDirBindDN.length() == 0))
{
userDirBindDN = configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_USER_DIR_BIND_DN);
}
if (userDirBindDN == null)
{
userDirBindDN = "";
}
// Determine the bind password for the user directory.
userDirBindPW = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_USER_DIR_BIND_PW);
if ((userDirBindPW == null) || (userDirBindPW.length() == 0))
{
userDirBindPW = configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_USER_DIR_BIND_PW);
}
if (userDirBindPW == null)
{
userDirBindPW = "";
}
// Determine the location of user accounts in the user directory.
userDirBase = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_USER_DIR_BASE);
if ((userDirBase == null) || (userDirBase.length() == 0))
{
userDirBase = configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_USER_DIR_BASE);
}
if ((userDirBase == null) || (userDirBase.length() == 0))
{
unavailableReason = "Access control is enabled, but the location of " +
"user account entries in the user directory " +
"could not be determined.";
return false;
}
// Determine the name of the attribute to use to find user entries.
userIDAttribute = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_USER_ID_ATTR);
if ((userIDAttribute == null) || (userIDAttribute.length() == 0))
{
userIDAttribute = configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_USER_ID_ATTR);
}
if ((userIDAttribute == null) || (userIDAttribute.length() == 0))
{
unavailableReason = "Access control is enabled, but the attribute to " +
"use to look up user entries could not be " +
"determined.";
return false;
}
// Determine whether the user directory should use SSL.
userDirUseSSL = false;
String sslStr =
config.getInitParameter(Constants.SERVLET_INIT_PARAM_USER_USE_SSL);
if ((sslStr == null) || (sslStr.length() == 0))
{
sslStr = configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_USER_USE_SSL);
}
if ((sslStr != null) &&
(sslStr.equalsIgnoreCase("true") || sslStr.equalsIgnoreCase("yes") ||
sslStr.equalsIgnoreCase("on")))
{
userDirUseSSL = true;
}
// Determine whether the SLAMD server should blindly trust any SSL
// certificate presented by the user directory.
userDirBlindTrust = true;
String trustStr = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_USER_BLIND_TRUST);
if ((trustStr == null) || (trustStr.length() == 0))
{
trustStr = configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_USER_BLIND_TRUST);
}
if ((trustStr != null) &&
(trustStr.equalsIgnoreCase("false") ||
trustStr.equalsIgnoreCase("no") || trustStr.equalsIgnoreCase("off")))
{
userDirBlindTrust = false;
}
// Determine the resource DN for full access.
resourceDNFullAccess = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_FULL);
if ((resourceDNFullAccess == null) ||
(resourceDNFullAccess.length() == 0))
{
resourceDNFullAccess = configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_ACCESS_FULL);
}
// Determine the resource DN for SLAMD start/stop access.
resourceDNRestartSLAMD =
config.getInitParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_RESTART_SLAMD);
if ((resourceDNRestartSLAMD == null) ||
(resourceDNRestartSLAMD.length() == 0))
{
resourceDNRestartSLAMD =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_ACCESS_RESTART_SLAMD);
}
// Determine the resource DN for access manager start/stop access.
resourceDNRestartACL =
config.getInitParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_RESTART_ACL);
if ((resourceDNRestartACL == null) ||
(resourceDNRestartACL.length() == 0))
{
resourceDNRestartACL =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_ACCESS_RESTART_ACL);
}
// Determine the resource DN for view servlet config access.
resourceDNViewServletConfig =
config.getInitParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_SERVLET_CONFIG);
if ((resourceDNViewServletConfig == null) ||
(resourceDNViewServletConfig.length() == 0))
{
resourceDNViewServletConfig =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_SERVLET_CONFIG);
}
// Determine the resource DN for edit servlet config access.
resourceDNEditServletConfig =
config.getInitParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_EDIT_SERVLET_CONFIG);
if ((resourceDNEditServletConfig == null) ||
(resourceDNEditServletConfig.length() == 0))
{
resourceDNEditServletConfig =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_ACCESS_EDIT_SERVLET_CONFIG);
}
// Determine the resource DN for view SLAMD config access.
resourceDNViewSLAMDConfig =
config.getInitParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_SLAMD_CONFIG);
if ((resourceDNViewSLAMDConfig == null) ||
(resourceDNViewSLAMDConfig.length() == 0))
{
resourceDNViewSLAMDConfig =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_SLAMD_CONFIG);
}
// Determine the resource DN for edit SLAMD config access.
resourceDNEditSLAMDConfig =
config.getInitParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_EDIT_SLAMD_CONFIG);
if ((resourceDNEditSLAMDConfig == null) ||
(resourceDNEditSLAMDConfig.length() == 0))
{
resourceDNEditSLAMDConfig =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_ACCESS_EDIT_SLAMD_CONFIG);
}
// Determine the resource DN for view status access.
resourceDNViewStatus =
config.getInitParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_STATUS);
if ((resourceDNViewStatus == null) ||
(resourceDNViewStatus.length() == 0))
{
resourceDNViewStatus =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_STATUS);
}
// Determine the resource DN for disconnect client access.
resourceDNDisconnectClient =
config.getInitParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_DISCONNECT_CLIENT);
if ((resourceDNDisconnectClient == null) ||
(resourceDNDisconnectClient.length() == 0))
{
resourceDNDisconnectClient =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_ACCESS_DISCONNECT_CLIENT);
}
// Determine the resource DN for view job access.
resourceDNViewJob = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_JOB);
if ((resourceDNViewJob == null) || (resourceDNViewJob.length() == 0))
{
resourceDNViewJob = configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_JOB);
}
// Determine the resource DN for export job access.
resourceDNExportJob =
config.getInitParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_EXPORT_JOB);
if ((resourceDNExportJob == null) || (resourceDNExportJob.length() == 0))
{
resourceDNExportJob =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_ACCESS_EXPORT_JOB);
}
// Determine the resource DN for schedule job access.
resourceDNScheduleJob =
config.getInitParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_SCHEDULE_JOB);
if ((resourceDNScheduleJob == null) ||
(resourceDNScheduleJob.length() == 0))
{
resourceDNScheduleJob =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_ACCESS_SCHEDULE_JOB);
}
// Determine the resource DN for cancel job access.
resourceDNCancelJob =
config.getInitParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_CANCEL_JOB);
if ((resourceDNCancelJob == null) || (resourceDNCancelJob.length() == 0))
{
resourceDNCancelJob =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_ACCESS_CANCEL_JOB);
}
// Determine the resource DN for delete job access.
resourceDNDeleteJob =
config.getInitParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_DELETE_JOB);
if ((resourceDNDeleteJob == null) || (resourceDNDeleteJob.length() == 0))
{
resourceDNDeleteJob =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_ACCESS_DELETE_JOB);
}
// Determine the resource DN for manage job folder access.
resourceDNManageJobFolders =
config.getInitParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_MANAGE_JOB_FOLDERS);
if ((resourceDNManageJobFolders == null) ||
(resourceDNManageJobFolders.length() == 0))
{
resourceDNManageJobFolders =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_ACCESS_MANAGE_JOB_FOLDERS);
}
// Determine the resource DN for view job class access.
resourceDNViewJobClass =
config.getInitParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_JOB_CLASS);
if ((resourceDNViewJobClass == null) ||
(resourceDNViewJobClass.length() == 0))
{
resourceDNViewJobClass =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_JOB_CLASS);
}
// Determine the resource DN for add job class access.
resourceDNAddJobClass =
config.getInitParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_ADD_JOB_CLASS);
if ((resourceDNAddJobClass == null) ||
(resourceDNAddJobClass.length() == 0))
{
resourceDNAddJobClass =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_ACCESS_ADD_JOB_CLASS);
}
// Determine the resource DN for delete job class access.
resourceDNDeleteJobClass =
config.getInitParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_DELETE_JOB_CLASS);
if ((resourceDNDeleteJobClass == null) ||
(resourceDNDeleteJobClass.length() == 0))
{
resourceDNDeleteJobClass =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_ACCESS_DELETE_JOB_CLASS);
}
}
// Determine the resource DN that specifies which clients may authenticate.
resourceDNAuthenticateClient =
config.getInitParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_AUTHENTICATE_CLIENT);
if ((resourceDNAuthenticateClient == null) ||
(resourceDNAuthenticateClient.length() == 0))
{
resourceDNAuthenticateClient =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_ACCESS_AUTHENTICATE_CLIENT);
}
// Get the location of the JSSE key store.
sslKeyStore = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_SSL_KEY_STORE);
if ((sslKeyStore == null) || (sslKeyStore.length() == 0))
{
sslKeyStore = configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_SSL_KEY_STORE);
}
// Get the password for the JSSE key store.
sslKeyStorePassword = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_SSL_KEY_PASSWORD);
if ((sslKeyStorePassword == null) || (sslKeyStorePassword.length() == 0))
{
sslKeyStorePassword =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_SSL_KEY_PASSWORD);
}
// Get the location of the JSSE trust store.
sslTrustStore = config.getInitParameter(
Constants.SERVLET_INIT_PARAM_SSL_TRUST_STORE);
if ((sslTrustStore == null) || (sslTrustStore.length() == 0))
{
sslTrustStore = configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_SSL_TRUST_STORE);
}
// Get the password for the JSSE key store.
sslTrustStorePassword =
config.getInitParameter(
Constants.SERVLET_INIT_PARAM_SSL_TRUST_PASSWORD);
if ((sslTrustStorePassword == null) ||
(sslTrustStorePassword.length() == 0))
{
sslTrustStorePassword =
configProperties.getProperty(
Constants.SERVLET_INIT_PARAM_SSL_TRUST_PASSWORD);
}
// If we have made it here, then we must have values for all of the required
// config parameters.
return true;
}
/**
* Generate the HTML content that may be used to allow the user to choose
* which SLAMD configuration information should be accessed.
*
* @param requestInfo The state information for this request.
*/
static void handleConfig(RequestInfo requestInfo)
{
logMessage(requestInfo, "In handleConfig()");
// The user must at least have permission to view the servlet configuration
// to see anything here.
if (! requestInfo.mayViewServletConfig)
{
logMessage(requestInfo, "No mayViewServletConfig permission granted");
generateAccessDeniedBody(requestInfo, "You do not have permission to " +
"view or edit the SLAMD configuration");
return;
}
// Get the buffer for the main HTML body.
StringBuilder htmlBody = requestInfo.htmlBody;
// Display the page header.
htmlBody.append("<SPAN CLASS=\"" + Constants.STYLE_MAIN_HEADER +
"\">SLAMD Configuration</SPAN>" + EOL);
htmlBody.append("<BR><BR>" + EOL);
htmlBody.append("Choose the type of configuration information to update." +
EOL);
htmlBody.append("<BR><BR>" + EOL);
// Display the startup configuration options.
htmlBody.append("<B>Startup Configuration</B>" + EOL);
htmlBody.append("<UL>" + EOL);
htmlBody.append(" <LI>" +
generateLink(requestInfo, Constants.SERVLET_SECTION_CONFIG,
Constants.SERVLET_SECTION_CONFIG_SERVLET,
"Servlet Configuration") + "</LI>" + EOL);
htmlBody.append(" <LI>" +
generateLink(requestInfo, Constants.SERVLET_SECTION_CONFIG,
Constants.SERVLET_SECTION_CONFIG_ACCESS,
"Access Control Configuration") + "</LI>" +
EOL);
htmlBody.append("</UL>" + EOL);
htmlBody.append("<BR>" + EOL);
// Display the configuration subscriber options.
if (slamdRunning)
{
ConfigSubscriber[] subscribers = configDB.getConfigSubscribers();
if ((subscribers != null) && (subscribers.length > 0))
{
htmlBody.append("<B>Startup Configuration</B>" + EOL);
htmlBody.append("<UL>" + EOL);
for (int i=0; i < subscribers.length; i++)
{
String safeName =
subscribers[i].getSubscriberName().toLowerCase().replace(' ',
'_');
htmlBody.append(" <LI>" +
generateLink(requestInfo, Constants.SERVLET_SECTION_CONFIG,
Constants.SERVLET_SECTION_CONFIG_SLAMD,
Constants.SERVLET_PARAM_CONFIG_SUBSCRIBER, safeName,
subscribers[i].getSubscriberName()) + "</LI>" +
EOL);
}
htmlBody.append("</UL>" + EOL);
}
}
}
/**
* Handle the various phases of viewing and updating the servlet configuration
* parameters, including displaying the current values, allowing the user to
* change the values, and performing all necessary access control
* verification.
*
* @param requestInfo The state information for this request.
*/
static void handleServletConfig(RequestInfo requestInfo)
{
logMessage(requestInfo, "In handleServletConfig()");
// Get key variables out of the request info.
HttpServletRequest request = requestInfo.request;
HttpServletResponse response = requestInfo.response;
StringBuilder htmlBody = requestInfo.htmlBody;
StringBuilder infoMessage = requestInfo.infoMessage;
// The user must at least have permission to view the servlet configuration
// to see anything here.
if (! requestInfo.mayViewServletConfig)
{
logMessage(requestInfo, "No mayViewServletConfig permission granted");
generateAccessDeniedBody(requestInfo, "You do not have permission to " +
"view or edit the SLAMD servlet configuration");
response.addHeader(Constants.RESPONSE_HEADER_ERROR_MESSAGE,
"You do not have permission to view or edit the " +
"SLAMD servlet configuration.");
return;
}
// See if the operation has been cancelled.
String cancelStr = request.getParameter(Constants.SERVLET_PARAM_CANCEL);
boolean cancelled = ((cancelStr != null) && (cancelStr.length() > 0));
// See if a parameter name has been specified. If so, then the intent must
// be to edit the configuration. If not, then we will just display the
// relevant parameter values.
String prefix = Constants.SERVLET_PARAM_JOB_PARAM_PREFIX;
String servletParamName =
request.getParameter(Constants.SERVLET_PARAM_CONFIG_PARAM_NAME);
String paramName = null;
if ((servletParamName != null) &&
(servletParamName.length() > prefix.length()))
{
paramName = servletParamName.substring(prefix.length());
}
Parameter p;
if ((! cancelled) && (paramName != null) && (paramName.length() > 0) &&
((p = getServletParameters().getParameter(paramName)) != null))
{
// If the user can't edit the servlet configuration, then tell them so.
if (! requestInfo.mayEditServletConfig)
{
logMessage(requestInfo, "No mayEditServletConfig permission granted");
generateAccessDeniedBody(requestInfo, "You do not have permission to " +
"edit the SLAMD servlet configuration");
response.addHeader(Constants.RESPONSE_HEADER_ERROR_MESSAGE,
"You do not have permission to edit the SLAMD " +
"servlet configuration.");
return;
}
else
{
// If a value has been specified, then see if it is valid. If so, then
// try to update the configuration. If not, tell the user why.
String confirmedStr =
request.getParameter(Constants.SERVLET_PARAM_CONFIRMED);
if ((confirmedStr != null) && (confirmedStr.length() > 0))
{
try
{
p.htmlInputFormToValue(
request.getParameterValues(
Constants.SERVLET_PARAM_JOB_PARAM_PREFIX + p.getName()));
configProperties.setProperty(paramName, p.getValueString());
String notifySubscribers =
request.getParameter(
Constants.SERVLET_PARAM_NOTIFY_SUBSCRIBERS);
boolean apply = ((notifySubscribers != null) &&
(notifySubscribers.length() > 0));
try
{
FileOutputStream fos = new FileOutputStream(configFile);
configProperties.store(fos, Constants.CONFIG_FILE_HEADER);
updateServletConfiguration(requestInfo, paramName,
p.getValueString(), apply);
htmlBody.append("<SPAN CLASS=\"" + Constants.STYLE_MAIN_HEADER +
"\">Update Successful</SPAN>" + EOL);
htmlBody.append("<BR><BR>" + EOL);
htmlBody.append("The configuration for " + p.getDisplayName() +
" has been updated." + EOL);
if (changeRequiresSLAMDRestart(paramName))
{
htmlBody.append("You must restart the SLAMD server for this " +
"change to take effect." + EOL);
}
if (changeRequiresAccessManagerRestart(paramName))
{
htmlBody.append("You must restart the access control manager " +
"for this change to take effect." + EOL);
}
}
catch (IOException ioe)
{
infoMessage.append("ERROR: " + ioe.getMessage() + "<BR>" + EOL);
htmlBody.append("<SPAN CLASS=\"" + Constants.STYLE_MAIN_HEADER +
"\">Update Failed</SPAN>" + EOL);
htmlBody.append("<BR><BR>" + EOL);
htmlBody.append("The update to the " + p.getDisplayName() +
" parameter failed because the configuration " +
"could not be saved." + EOL);
htmlBody.append("Please check the above error message for " +
"more information about the problem that " +
"occurred.");
htmlBody.append("Also make sure that the configuration file " +
configFile + " is writable by the user running " +
" the servlet engine (" +
System.getProperty("user.name") + ").");
response.addHeader(Constants.RESPONSE_HEADER_ERROR_MESSAGE,
"The update to the " + p.getDisplayName() +
" parameter failed because the " +
"configuration could not be saved: " + ioe);
}
htmlBody.append("<BR><BR>" + EOL);
String link = generateLink(requestInfo,
Constants.SERVLET_SECTION_CONFIG,
Constants.SERVLET_SECTION_CONFIG_SERVLET,
"initialization parameters " +
"configuration");
htmlBody.append("Return to the " + link + " page.");
}
catch (InvalidValueException ive)
{
// The value was invalid. Tell the user why and let them try
// again.
infoMessage.append(ive.getMessage() + "<BR>" + EOL);
generateServletConfigInputForm(requestInfo, p);
response.addHeader(Constants.RESPONSE_HEADER_ERROR_MESSAGE,
"The update to the " + p.getDisplayName() +
" parameter failed because the " +
"value provided was invalid: " + ive);
}
}
else
{
// No value was specified, so generate the form to let the user
// specify one.
generateServletConfigInputForm(requestInfo, p);
}
}
}
else
{
// No parameter name was specified, so just show them the set of
// available parameters.
htmlBody.append("<SPAN CLASS=\"" + Constants.STYLE_MAIN_HEADER +
"\">SLAMD Servlet Initialization Parameters</SPAN>" +
EOL);
htmlBody.append("<BR><BR>" + EOL);
htmlBody.append("This section allows you to configure the file-based " +
"configuration that is required to start the SLAMD " +
"server." + EOL);
htmlBody.append("<BR><BR>" + EOL + EOL);
htmlBody.append("<TABLE WIDTH=\"100%\" BORDER=\"0\" CELLPADDING=\"10\" " +
"CELLSPACING=\"0\">" + EOL);
Parameter[] servletParams = getServletParameters().getParameters();
for (int i=0; i < servletParams.length; i++)
{
if (i % 2 == 0)
{
htmlBody.append(" <TR CLASS=\"" +
Constants.STYLE_JOB_SUMMARY_LINE_A + "\">" + EOL);
}
else
{
htmlBody.append(" <TR CLASS=\"" +
Constants.STYLE_JOB_SUMMARY_LINE_B + "\">" + EOL);
}
if (requestInfo.mayEditServletConfig)
{
String link = generateLink(requestInfo,
Constants.SERVLET_SECTION_CONFIG,
Constants.SERVLET_SECTION_CONFIG_SERVLET,
Constants.SERVLET_PARAM_CONFIG_PARAM_NAME,
prefix + servletParams[i].getName(),
servletParams[i].getDisplayName());
htmlBody.append(" <TD>" + link + "</TD>" + EOL);
}
else
{
htmlBody.append(" <TD>" + servletParams[i].getDisplayName() +
"</TD>" + EOL);
}
String value;
if (servletParams[i].hasValue())
{
value = servletParams[i].getHTMLDisplayValue();
}
else
{
value = " ";
}
htmlBody.append(" <TD>" + value + "</TD>" + EOL);
}
htmlBody.append("</TABLE>" + EOL);
}
}
/**
* Handle the various phases of viewing and updating the access control
* configuration parameters, including displaying the current values, allowing
* the user to change the values, and performing all necessary access control
* verification.
*
* @param requestInfo The state information for this request.
*/
static void handleAccessControlConfig(RequestInfo requestInfo)
{
logMessage(requestInfo, "In handleAccessControlConfig()");
// The user must at least have permission to view the servlet configuration
// to see anything here.
if (! requestInfo.mayViewServletConfig)
{
logMessage(requestInfo, "No mayViewServletConfig permission granted");
generateAccessDeniedBody(requestInfo, "You do not have permission to " +
"view or edit the access control configuration");
return;
}
// Get the important information from the request info.
HttpServletRequest request = requestInfo.request;
StringBuilder htmlBody = requestInfo.htmlBody;
StringBuilder infoMessage = requestInfo.infoMessage;
// See if the operation has been cancelled.
String cancelStr = request.getParameter(Constants.SERVLET_PARAM_CANCEL);
boolean cancelled = ((cancelStr != null) && (cancelStr.length() > 0));
// See if a parameter name has been specified. If so, then the intent must
// be to edit the configuration. If not, then we will just display the
// relevant parameter values.
String prefix = Constants.SERVLET_PARAM_JOB_PARAM_PREFIX;
String servletParamName =
request.getParameter(Constants.SERVLET_PARAM_CONFIG_PARAM_NAME);
String paramName = null;
if ((servletParamName != null) &&
(servletParamName.length() > prefix.length()))
{
paramName = servletParamName.substring(prefix.length());
}
Parameter p;
if ((! cancelled) && (paramName != null) && (paramName.length() > 0) &&
((p = getAccessControlParameters().getParameter(paramName)) != null))
{
// If the user can't edit the ACL configuration, then tell them so.
if (! requestInfo.mayEditServletConfig)
{
logMessage(requestInfo, "No mayEditServletConfig permission granted");
generateAccessDeniedBody(requestInfo, "You do not have permission to " +
"edit the access control configuration");
}
else
{
// If a value has been specified, then see if it is valid. If so, then
// try to update the configuration. If not, tell the user why.
String confirmedStr =
request.getParameter(Constants.SERVLET_PARAM_CONFIRMED);
if ((confirmedStr != null) && (confirmedStr.length() > 0))
{
try
{
p.htmlInputFormToValue(
request.getParameterValues(
Constants.SERVLET_PARAM_JOB_PARAM_PREFIX + p.getName()));
configProperties.setProperty(paramName, p.getValueString());
String notifySubscribers =
request.getParameter(
Constants.SERVLET_PARAM_NOTIFY_SUBSCRIBERS);
boolean apply = ((notifySubscribers != null) &&
(notifySubscribers.length() > 0));
try
{
FileOutputStream fos = new FileOutputStream(configFile);
configProperties.store(fos, Constants.CONFIG_FILE_HEADER);
updateServletConfiguration(requestInfo, paramName,
p.getValueString(), apply);
htmlBody.append("<SPAN CLASS=\"" + Constants.STYLE_MAIN_HEADER +
"\">Update Successful</SPAN>" + EOL);
htmlBody.append("<BR><BR>" + EOL);
htmlBody.append("The configuration for " + p.getDisplayName() +
" has been updated." + EOL);
if (changeRequiresSLAMDRestart(paramName))
{
htmlBody.append("You must restart the SLAMD server for this " +
"change to take effect." + EOL);
}
if (changeRequiresAccessManagerRestart(paramName))
{
htmlBody.append("You must restart the access control manager " +
"for this change to take effect." + EOL);
}
}
catch (IOException ioe)
{
infoMessage.append("ERROR: " + ioe.getMessage() + "<BR>" + EOL);
htmlBody.append("<SPAN CLASS=\"" + Constants.STYLE_MAIN_HEADER +
"\">Update Failed</SPAN>" + EOL);
htmlBody.append("<BR><BR>" + EOL);
htmlBody.append("The update to the " + p.getDisplayName() +
" parameter failed because the configuration " +
"could not be saved." + EOL);
htmlBody.append("Please check the above error message for " +
"more information about the problem that " +
"occurred.");
htmlBody.append("Also make sure that the configuration file " +
configFile + " is writable by the user running " +
" the servlet engine (" +
System.getProperty("user.name") + ").");
}
htmlBody.append("<BR><BR>" + EOL);
String link = generateLink(requestInfo,
Constants.SERVLET_SECTION_CONFIG,
Constants.SERVLET_SECTION_CONFIG_ACCESS,
"access control configuration");
htmlBody.append("Return to the " + link + " page.");
}
catch (InvalidValueException ive)
{
// The value was invalid. Tell the user why and let them try
// again.
infoMessage.append(ive.getMessage() + "<BR>" + EOL);
generateServletConfigInputForm(requestInfo, p);
}
}
else
{
// No value was specified, so generate the form to let the user
// specify one.
generateServletConfigInputForm(requestInfo, p);
}
}
}
else
{
htmlBody.append("<SPAN CLASS=\"" + Constants.STYLE_MAIN_HEADER +
"\">Access Control Configuration</SPAN>" + EOL);
htmlBody.append("<BR><BR>" + EOL + EOL);
htmlBody.append("This section allows you to configure parameters " +
"related to access control within the administrative " +
"interface." + EOL);
htmlBody.append("Note that if any resource DN is not specified, then " +
"the associated function may be performed by any " +
"authenticated user. " + EOL);
htmlBody.append("<BR><BR>" + EOL + EOL);
htmlBody.append("<TABLE WIDTH=\"100%\" BORDER=\"0\" CELLPADDING=\"10\" " +
"CELLSPACING=\"0\">" + EOL);
Parameter[] aclParams = getAccessControlParameters().getParameters();
for (int i=0; i < aclParams.length; i++)
{
if (i % 2 == 0)
{
htmlBody.append(" <TR CLASS=\"" +
Constants.STYLE_JOB_SUMMARY_LINE_A + "\">" + EOL);
}
else
{
htmlBody.append(" <TR CLASS=\"" +
Constants.STYLE_JOB_SUMMARY_LINE_B + "\">" + EOL);
}
if (requestInfo.mayEditServletConfig)
{
String link = generateLink(requestInfo,
Constants.SERVLET_SECTION_CONFIG,
Constants.SERVLET_SECTION_CONFIG_ACCESS,
Constants.SERVLET_PARAM_CONFIG_PARAM_NAME,
Constants.SERVLET_PARAM_JOB_PARAM_PREFIX +
aclParams[i].getName(),
aclParams[i].getDisplayName());
htmlBody.append(" <TD>" + link + "</TD>" + EOL);
}
else
{
htmlBody.append(" <TD>" + aclParams[i].getDisplayName() +
"</TD>" + EOL);
}
String value;
if (aclParams[i].hasValue())
{
value = aclParams[i].getHTMLDisplayValue();
}
else
{
if (isResourceDNParameter(aclParams[i].getName()))
{
value = "Any Authenticated User";
}
else
{
value = " ";
}
}
htmlBody.append(" <TD>" + value + "</TD>" + EOL);
}
htmlBody.append("</TABLE>" + EOL);
}
}
/**
* Generates the HTML for a form that can be used to update the value of a
* servlet configuration parameter.
*
* @param requestInfo The state information for this request.
* @param param The configuration parameter for which to generate the
* input form.
*/
static void generateServletConfigInputForm(RequestInfo requestInfo,
Parameter param)
{
logMessage(requestInfo,
"In generateServletConfigInputForm(" + param.getName() + ')');
// Get the important state information.
String subsection = requestInfo.subsection;
String servletBaseURI = requestInfo.servletBaseURI;
StringBuilder htmlBody = requestInfo.htmlBody;
StringBuilder infoMessage = requestInfo.infoMessage;
htmlBody.append("<SPAN CLASS=\"" + Constants.STYLE_MAIN_HEADER +
"\">Edit " + param.getDisplayName() + "</SPAN>" + EOL);
htmlBody.append("<BR><BR>" + EOL);
htmlBody.append("Specify the value to use for the " +
param.getDisplayName() + " configuration parameter." + EOL);
htmlBody.append("<BR><BR>" + EOL + EOL);
htmlBody.append("<FORM CLASS=\"" + Constants.STYLE_MAIN_FORM +
"\" METHOD=\"POST\" ACTION=\"" + servletBaseURI + "\">" +
EOL);
htmlBody.append(generateHidden(Constants.SERVLET_PARAM_SECTION,
Constants.SERVLET_SECTION_CONFIG) + EOL);
htmlBody.append(generateHidden(Constants.SERVLET_PARAM_SUBSECTION,
subsection) + EOL);
htmlBody.append(generateHidden(Constants.SERVLET_PARAM_CONFIG_PARAM_NAME,
Constants.SERVLET_PARAM_JOB_PARAM_PREFIX+
param.getName()) + EOL);
htmlBody.append(generateHidden(Constants.SERVLET_PARAM_CONFIRMED, "1") +
EOL);
if (requestInfo.debugHTML)
{
htmlBody.append(generateHidden(Constants.SERVLET_PARAM_HTML_DEBUG, "1") +
EOL);
}
htmlBody.append(" <TABLE WIDTH=\"100%\" BORDER=\"0\" " +
"CELLPADDING=\"10\" CELLSPACING=\"0\">" + EOL);
htmlBody.append(" <TR>" + EOL);
htmlBody.append(" <TD>Description</TD>" + EOL);
htmlBody.append(" <TD>" + param.getDescription() + "</TD>" + EOL);
htmlBody.append(" </TR>" + EOL);
htmlBody.append(" <TR>" + EOL);
htmlBody.append(" <TD>" + param.getDisplayName() + "</TD>" + EOL);
htmlBody.append(" <TD>" +
param.getHTMLInputForm(Constants.SERVLET_PARAM_JOB_PARAM_PREFIX) +
"</TD>" + EOL);
htmlBody.append(" </TR>" + EOL);
if (changeRequiresSLAMDRestart(param.getName()))
{
if (changeRequiresAccessManagerRestart(param.getName()))
{
infoMessage.append("NOTE: Both the SLAMD server and the access " +
"control manager must be restarted for changes " +
"to this parameter to take effect.<BR>" + EOL);
}
else
{
infoMessage.append("NOTE: The SLAMD server must be restarted for " +
"changes to this parameter to take effect.<BR>" +
EOL);
}
}
else if (changeRequiresAccessManagerRestart(param.getName()))
{
infoMessage.append("NOTE: The access control manager must be " +
"restarted for changes to this parameter to take " +
"effect<BR>" + EOL);
}
else
{
htmlBody.append(" <TR>" + EOL);
htmlBody.append(" <TD>Apply Changes Immediately</TD>" + EOL);
htmlBody.append(" <TD><INPUT TYPE=\"CHECKBOX\" NAME=\"" +
Constants.SERVLET_PARAM_NOTIFY_SUBSCRIBERS + "\"></TD>" +
EOL);
htmlBody.append(" </TR>" + EOL);
}
htmlBody.append(" <TR>" + EOL);
htmlBody.append(" <TD> </TD>" + EOL);
htmlBody.append(" <TD>" + EOL);
htmlBody.append(" <INPUT TYPE=\"SUBMIT\" VALUE=\"Update\">" + EOL);
htmlBody.append(" " + EOL);
htmlBody.append(" <INPUT TYPE=\"SUBMIT\" NAME=\"" +
Constants.SERVLET_PARAM_CANCEL +
"\" VALUE=\"Cancel\">" + EOL);
htmlBody.append(" </TD>" + EOL);
htmlBody.append(" </TR>" + EOL);
htmlBody.append(" </TABLE>" + EOL);
htmlBody.append("</FORM>" + EOL);
}
/**
* Handle the various phases of viewing and updating the SLAMD server
* configuration parameters, including displaying the current values, allowing
# the user to change the values, and performing all necessary access control
* verification.
*
* @param requestInfo The state information for this request.
*/
static void handleSLAMDConfig(RequestInfo requestInfo)
{
logMessage(requestInfo, "In handleSLAMDConfig()");
// The user must at least have permission to view the server configuration
// to see anything here.
if (! requestInfo.mayViewSLAMDConfig)
{
logMessage(requestInfo, "No mayViewSLAMDConfig permission granted");
generateAccessDeniedBody(requestInfo, "You do not have permission to " +
"view or edit the SLAMD server configuration");
return;
}
// Get the important state variables from the request.
HttpServletRequest request = requestInfo.request;
StringBuilder htmlBody = requestInfo.htmlBody;
StringBuilder infoMessage = requestInfo.infoMessage;
// Determine the configuration subscriber. If it can't be determined, then
// display an error message.
String subscriberStr =
request.getParameter(Constants.SERVLET_PARAM_CONFIG_SUBSCRIBER);
ConfigSubscriber subscriber = null;
if ((subscriberStr == null) || (subscriberStr.length() == 0) ||
((subscriber = configDB.subscriberForSafeName(subscriberStr)) == null))
{
infoMessage.append("ERROR: Missing or unrecognized configuration " +
"subscriber name.<BR>" + EOL);
htmlBody.append("<SPAN CLASS=\"" + Constants.STYLE_MAIN_HEADER +
"\">Unknown Configuration Subscriber</SPAN>" + EOL);
htmlBody.append("<BR><BR>" + EOL);
htmlBody.append("Could not proceed with editing the SLAMD server " +
"configuration because the configuration subscriber " +
"could not be determined." + EOL);
return;
}
// See if the operation has been cancelled.
String cancelStr = request.getParameter(Constants.SERVLET_PARAM_CANCEL);
boolean cancelled = ((cancelStr != null) && (cancelStr.length() > 0));
// See if a parameter name has been specified. If so, then the intent must
// be to edit the configuration. If not, then we will just display the
// relevant parameter values.
String prefix = Constants.SERVLET_PARAM_JOB_PARAM_PREFIX;
String servletParamName =
request.getParameter(Constants.SERVLET_PARAM_CONFIG_PARAM_NAME);
String paramName = null;
if ((servletParamName != null) &&
(servletParamName.length() > prefix.length()))
{
paramName = servletParamName.substring(prefix.length());
}
Parameter p;
if ((! cancelled) && (paramName != null) && (paramName.length() > 0) &&
((p = subscriber.getSubscriberParameters().getParameter(paramName))
!= null))
{
// If the user can't edit the servlet configuration, then tell them so.
if (! requestInfo.mayEditSLAMDConfig)
{
logMessage(requestInfo, "No mayEditSLAMDConfig permission granted");
generateAccessDeniedBody(requestInfo, "You do not have permission to " +
"edit the " + subscriber.getSubscriberName() +
" configuration");
}
else
{
// If a value has been specified, then see if it is valid. If so, then
// try to update the configuration. If not, tell the user why.
String confirmedStr =
request.getParameter(Constants.SERVLET_PARAM_CONFIRMED);
if ((confirmedStr != null) && (confirmedStr.length() > 0))
{
try
{
p.htmlInputFormToValue(
request.getParameterValues(
Constants.SERVLET_PARAM_JOB_PARAM_PREFIX + p.getName()));
String notifySubscribersStr =
request.getParameter(
Constants.SERVLET_PARAM_NOTIFY_SUBSCRIBERS);
boolean notifySubscribers = ((notifySubscribersStr != null) &&
(notifySubscribersStr.length() > 0));
try
{
configDB.putConfigParameter(paramName, p.getValueString(),
notifySubscribers);
htmlBody.append("<SPAN CLASS=\"" + Constants.STYLE_MAIN_HEADER +
"\">Update Successful</SPAN>" + EOL);
htmlBody.append("<BR><BR>" + EOL);
htmlBody.append("The configuration for " + p.getDisplayName() +
" has been updated." + EOL);
}
catch (DatabaseException de)
{
infoMessage.append("ERROR: " + de.getMessage() + "<BR>" + EOL);
htmlBody.append("<SPAN CLASS=\"" + Constants.STYLE_MAIN_HEADER +
"\">Update Failed</SPAN>" + EOL);
htmlBody.append("<BR><BR>" + EOL);
htmlBody.append("The configuration for " + p.getDisplayName() +
" could not be updated." + EOL);
htmlBody.append("See the above error message for additional " +
"information." + EOL);
}
htmlBody.append("<BR><BR>" + EOL);
String link =
generateLink(requestInfo, Constants.SERVLET_SECTION_CONFIG,
Constants.SERVLET_SECTION_CONFIG_SLAMD,
Constants.SERVLET_PARAM_CONFIG_SUBSCRIBER,
subscriberStr,
subscriber.getSubscriberName() +
" configuration");
htmlBody.append("Return to the " + link + " page.");
}
catch (InvalidValueException ive)
{
// The value was invalid. Tell the user why and let them try
// again.
infoMessage.append(ive.getMessage() + "<BR>" + EOL);
generateServerConfigInputForm(requestInfo, subscriber, p);
}
}
else
{
// No value was specified, so generate the form to let the user
// specify one.
generateServerConfigInputForm(requestInfo, subscriber, p);
}
}
}
else
{
// No parameter name was specified, so just show them the set of
// available parameters.
htmlBody.append("<SPAN CLASS=\"" + Constants.STYLE_MAIN_HEADER +
"\">" + subscriber.getSubscriberName() +
" Configuration</SPAN>" + EOL);
htmlBody.append("<BR><BR>" + EOL);
htmlBody.append("This section allows you to view and/or edit the " +
"configuration for the " +
subscriber.getSubscriberName() + '.' + EOL);
htmlBody.append("<BR><BR>" + EOL + EOL);
htmlBody.append("<TABLE WIDTH=\"100%\" BORDER=\"0\" CELLSPACING=\"0\" " +
"CELLPADDING=\"10\">" + EOL);
Parameter[] subscriberParams =
subscriber.getSubscriberParameters().getParameters();
for (int i=0; i < subscriberParams.length; i++)
{
if (i % 2 == 0)
{
htmlBody.append(" <TR CLASS=\"" +
Constants.STYLE_JOB_SUMMARY_LINE_A + "\">" + EOL);
}
else
{
htmlBody.append(" <TR CLASS=\"" +
Constants.STYLE_JOB_SUMMARY_LINE_B + "\">" + EOL);
}
if (requestInfo.mayEditSLAMDConfig)
{
String link = generateLink(requestInfo,
Constants.SERVLET_SECTION_CONFIG,
Constants.SERVLET_SECTION_CONFIG_SLAMD,
Constants.SERVLET_PARAM_CONFIG_PARAM_NAME,
prefix + subscriberParams[i].getName(),
Constants.SERVLET_PARAM_CONFIG_SUBSCRIBER,
subscriberStr,
subscriberParams[i].getDisplayName());
htmlBody.append(" <TD>" + link + "</TD>" + EOL);
}
else
{
htmlBody.append(" <TD>" + subscriberParams[i].getDisplayName() +
"</TD>" + EOL);
}
String value;
if (subscriberParams[i].hasValue())
{
value = subscriberParams[i].getHTMLDisplayValue();
}
else
{
value = " ";
}
htmlBody.append(" <TD>" + value + "</TD>" + EOL);
}
htmlBody.append("</TABLE>" + EOL);
}
}
/**
* Generates the HTML for a form that can be used to update the value of a
* SLAMD server configuration parameter.
*
* @param requestInfo The state information for this request.
* @param subscriber The configuration subscriber with which the parameter
* is associated.
* @param param The configuration parameter for which to generate the
* input form.
*/
static void generateServerConfigInputForm(RequestInfo requestInfo,
ConfigSubscriber subscriber,
Parameter param)
{
logMessage(requestInfo, "In generateServerConfigInputForm(" +
subscriber.getSubscriberName() + ", " + param.getName() + ')');
// Get the important state information for the request.
String subsection = requestInfo.subsection;
String servletBaseURI = requestInfo.servletBaseURI;
StringBuilder htmlBody = requestInfo.htmlBody;
htmlBody.append("<SPAN CLASS=\"" + Constants.STYLE_MAIN_HEADER +
"\">Edit " + param.getDisplayName() + "</SPAN>" + EOL);
htmlBody.append("<BR><BR>" + EOL);
htmlBody.append("Specify the value to use for the " +
param.getDisplayName() + " configuration parameter." + EOL);
htmlBody.append("<BR><BR>" + EOL + EOL);
htmlBody.append("<FORM CLASS=\"" + Constants.STYLE_MAIN_FORM +
"\" METHOD=\"POST\" ACTION=\"" + servletBaseURI + "\">" +
EOL);
htmlBody.append(generateHidden(Constants.SERVLET_PARAM_SECTION,
Constants.SERVLET_SECTION_CONFIG) + EOL);
htmlBody.append(generateHidden(Constants.SERVLET_PARAM_SUBSECTION,
subsection) + EOL);
htmlBody.append(generateHidden(Constants.SERVLET_PARAM_CONFIG_SUBSCRIBER,
SLAMDDB.getSafeName(subscriber)));
htmlBody.append(generateHidden(Constants.SERVLET_PARAM_CONFIG_PARAM_NAME,
Constants.SERVLET_PARAM_JOB_PARAM_PREFIX+
param.getName()) + EOL);
htmlBody.append(generateHidden(Constants.SERVLET_PARAM_CONFIRMED, "1") +
EOL);
if (requestInfo.debugHTML)
{
htmlBody.append(generateHidden(Constants.SERVLET_PARAM_HTML_DEBUG, "1") +
EOL);
}
htmlBody.append(" <TABLE WIDTH=\"100%\" BORDER=\"0\" " +
"CELLSPACING=\"0\" CELLPADDING=\"10\">" + EOL);
htmlBody.append(" <TR>" + EOL);
htmlBody.append(" <TD>Description</TD>" + EOL);
htmlBody.append(" <TD>" + param.getDescription() + "</TD>" + EOL);
htmlBody.append(" </TR>" + EOL);
htmlBody.append(" <TR>" + EOL);
htmlBody.append(" <TD>" + param.getDisplayName() + "</TD>" + EOL);
htmlBody.append(" <TD>" +
param.getHTMLInputForm(Constants.SERVLET_PARAM_JOB_PARAM_PREFIX) +
"</TD>" + EOL);
htmlBody.append(" </TR>" + EOL);
htmlBody.append(" <TR>" + EOL);
htmlBody.append(" <TD>Apply Changes Immediately</TD>" + EOL);
htmlBody.append(" <TD><INPUT TYPE=\"CHECKBOX\" NAME=\"" +
Constants.SERVLET_PARAM_NOTIFY_SUBSCRIBERS + "\"></TD>" +
EOL);
htmlBody.append(" </TR>" + EOL);
htmlBody.append(" <TR>" + EOL);
htmlBody.append(" <TD> </TD>" + EOL);
htmlBody.append(" <TD>" + EOL);
htmlBody.append(" <INPUT TYPE=\"SUBMIT\" VALUE=\"Update\">" + EOL);
htmlBody.append(" " + EOL);
htmlBody.append(" <INPUT TYPE=\"SUBMIT\" NAME=\"" +
Constants.SERVLET_PARAM_CANCEL +
"\" VALUE=\"Cancel\">" + EOL);
htmlBody.append(" </TD>" + EOL);
htmlBody.append(" </TR>" + EOL);
htmlBody.append(" </TABLE>" + EOL);
htmlBody.append("</FORM>" + EOL);
}
/**
* Retrieves the set of configuration parameters used by the SLAMD servlet,
* excluding those parameters used for managing access control.
*
* @return The set of configuration parameters used by the SLAMD servlet.
*/
static ParameterList getServletParameters()
{
PasswordParameter sslKeyPWParameter =
new PasswordParameter(Constants.SERVLET_INIT_PARAM_SSL_KEY_PASSWORD,
"SSL Key Store Password",
"The password to use to access the JSSE key " +
"store.", false, sslKeyStorePassword);
PasswordParameter sslTrustPWParameter =
new PasswordParameter(Constants.SERVLET_INIT_PARAM_SSL_TRUST_PASSWORD,
"SSL Trust Store Password",
"The password to use to access the JSSE trust " +
"store.", false, sslTrustStorePassword);
StringParameter jobClassPathParameter =
new StringParameter(Constants.SERVLET_INIT_PARAM_JOB_CLASS_PATH,
"Job Class Path",
"The location on the filesystem in which the " +
"job class files are located.", true, classPath);
StringParameter sslKeyStoreParameter =
new StringParameter(Constants.SERVLET_INIT_PARAM_SSL_KEY_STORE,
"SSL Key Store Location",
"The location of the JSSE key store to use for " +
"SSL communication.", false, sslKeyStore);
StringParameter sslTrustStoreParameter =
new StringParameter(Constants.SERVLET_INIT_PARAM_SSL_TRUST_STORE,
"SSL Trust Store Location",
"The location of the JSSE trust store to use " +
"for SSL communication.", false, sslTrustStore);
Parameter[] params = new Parameter[]
{
jobClassPathParameter,
sslKeyStoreParameter,
sslKeyPWParameter,
sslTrustStoreParameter,
sslTrustPWParameter
};
return new ParameterList(params);
}
/**
* Retrieves the set of configuration parameters used by the SLAMD servlet for
* access control management.
*
* @return The set of configuration parameters used by the SLAMD servlet for
* access control management.
*/
static ParameterList getAccessControlParameters()
{
BooleanParameter useAccessControlParameter =
new BooleanParameter(Constants.SERVLET_INIT_PARAM_USE_ACCESS_CONTROL,
"Use Access Control",
"Require authentication to access the SLAMD " +
"administrative interface.", useAccessControl);
BooleanParameter userUseSSLParameter =
new BooleanParameter(Constants.SERVLET_INIT_PARAM_USER_USE_SSL,
"Use SSL for User Directory",
"Indicates whether to use SSL to communicate " +
"with the configuration directory.",
userDirUseSSL);
BooleanParameter userBlindTrustParameter =
new BooleanParameter(Constants.SERVLET_INIT_PARAM_USER_BLIND_TRUST,
"Blindly Trust any SSL Certificate",
"Indicates whether the SLAMD server should " +
"blindly trust any SSL certificate presented " +
"by the user directory.", userDirBlindTrust);
IntegerParameter userPortParameter =
new IntegerParameter(Constants.SERVLET_INIT_PARAM_USER_DIR_PORT,
"User Directory Port",
"The port number to use to connect to the " +
"user directory.", true, userDirPort, false, 1,
true, 65535);
PasswordParameter userBindPWParameter =
new PasswordParameter(Constants.SERVLET_INIT_PARAM_USER_DIR_BIND_PW,
"User Directory Bind Password",
"The password to use to bind to the " +
"user directory.", false, userDirBindPW);
StringParameter userHostParameter =
new StringParameter(Constants.SERVLET_INIT_PARAM_USER_DIR_HOST,
"User Directory Address",
"The DNS hostname or IP address to use to " +
"connect to the user directory.", true,
userDirHost);
StringParameter userBindDNParameter =
new StringParameter(Constants.SERVLET_INIT_PARAM_USER_DIR_BIND_DN,
"User Directory Bind DN",
"The DN of the account to use to bind to the " +
"user directory.", false, userDirBindDN);
StringParameter userBaseParameter =
new StringParameter(Constants.SERVLET_INIT_PARAM_USER_DIR_BASE,
"User Base DN",
"The location of user account information in " +
"the user directory.", true, userDirBase);
StringParameter userIDParameter =
new StringParameter(Constants.SERVLET_INIT_PARAM_USER_ID_ATTR,
"User ID Attribute",
"The name of the LDAP attribute used to " +
"find user accounts in the user directory.", true,
userIDAttribute);
StringParameter fullAccessDNParameter =
new StringParameter(Constants.SERVLET_INIT_PARAM_ACCESS_FULL,
"Full Access DN",
"The DN of the group or role that specifies the " +
"users that have access to all components in " +
"the admin interface.", false,
resourceDNFullAccess);
StringParameter manageFoldersDNParameter =
new StringParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_MANAGE_JOB_FOLDERS,
"Manage Job Folders DN", "The DN of the group or role that " +
"specifies the users that have the ability to create, " +
"delete, and manage real and virtual job folders.", false,
resourceDNManageJobFolders);
StringParameter restartSLAMDDNParameter =
new StringParameter(Constants.SERVLET_INIT_PARAM_ACCESS_RESTART_SLAMD,
"Start/Stop SLAMD DN",
"The DN of the group or role that specifies the " +
"users that have the ability to start and stop " +
"the SLAMD server.", false,
resourceDNRestartSLAMD);
StringParameter restartACLDNParameter =
new StringParameter(Constants.SERVLET_INIT_PARAM_ACCESS_RESTART_ACL,
"Start/Stop Access Manager DN",
"The DN of the group or role that specifies the " +
"users that have the ability to start and stop " +
"the access manager.", false,
resourceDNRestartACL);
StringParameter viewServletConfigDNParameter =
new StringParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_SERVLET_CONFIG,
"View Servlet Config DN",
"The DN of the group or role that specifies the users that " +
"have the ability to view SLAMD servlet config information.",
false, resourceDNViewServletConfig);
StringParameter editServletConfigDNParameter =
new StringParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_EDIT_SERVLET_CONFIG,
"Edit Servlet Config DN",
"The DN of the group or role that specifies the users that " +
"have the ability to edit SLAMD servlet config information.",
false, resourceDNEditServletConfig);
StringParameter viewSLAMDConfigDNParameter =
new StringParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_SLAMD_CONFIG,
"View SLAMD Config DN",
"The DN of the group or role that specifies the users that " +
"have the ability to view SLAMD server config information.",
false, resourceDNViewSLAMDConfig);
StringParameter editSLAMDConfigDNParameter =
new StringParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_EDIT_SLAMD_CONFIG,
"Edit SLAMD Config DN",
"The DN of the group or role that specifies the users that " +
"have the ability to edit SLAMD server config information.",
false, resourceDNEditServletConfig);
StringParameter viewStatusDNParameter =
new StringParameter(Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_STATUS,
"View SLAMD Status DN",
"The DN of the group or role that specifies the " +
"users that have the ability to view SLAMD " +
"server status information.", false,
resourceDNViewStatus);
StringParameter disconnectClientDNParameter =
new StringParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_DISCONNECT_CLIENT,
"Disconnect Client DN",
"The DN of the group or role that specifies the users that " +
"have the ability to disconnect clients.", false,
resourceDNDisconnectClient);
StringParameter viewJobDNParameter =
new StringParameter(Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_JOB,
"View Job Info DN",
"The DN of the group or role that specifies the " +
"users that have the ability to view job " +
"information.", false, resourceDNViewJob);
StringParameter exportJobDNParameter =
new StringParameter(Constants.SERVLET_INIT_PARAM_ACCESS_EXPORT_JOB,
"Export Job Info DN",
"The DN of the group or role that specifies the " +
"users that have the ability to export job " +
"information.", false, resourceDNExportJob);
StringParameter scheduleJobDNParameter =
new StringParameter(Constants.SERVLET_INIT_PARAM_ACCESS_SCHEDULE_JOB,
"Schedule New Jobs DN",
"The DN of the group or role that specifies the " +
"users that have the ability to schedule new " +
"jobs for execution.", false,
resourceDNScheduleJob);
StringParameter cancelJobDNParameter =
new StringParameter(Constants.SERVLET_INIT_PARAM_ACCESS_CANCEL_JOB,
"Cancel Jobs DN",
"The DN of the group or role that specifies the " +
"users that have the ability to cancel " +
"scheduled jobs.", false, resourceDNCancelJob);
StringParameter deleteJobDNParameter =
new StringParameter(Constants.SERVLET_INIT_PARAM_ACCESS_DELETE_JOB,
"Delete Jobs DN",
"The DN of the group or role that specifies the " +
"users that have the ability to delete " +
"information about jobs that have completed.",
false, resourceDNDeleteJob);
StringParameter viewJobClassDNParameter =
new StringParameter(Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_JOB_CLASS,
"View Job Classes DN",
"The DN of the group or role that specifies the " +
"users that have the ability to view " +
"information about the job classes that have " +
"been defined for use in the SLAMD server.", false,
resourceDNViewJobClass);
StringParameter addJobClassDNParameter =
new StringParameter(Constants.SERVLET_INIT_PARAM_ACCESS_ADD_JOB_CLASS,
"Add Job Classes DN",
"The DN of the group or role that specifies the " +
"users that have the ability to define new job " +
"classes for use in the SLAMD server.", false,
resourceDNAddJobClass);
StringParameter deleteJobClassDNParameter =
new StringParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_DELETE_JOB_CLASS,
"Delete Job Classes DN",
"The DN of the group or role that specifies the users that " +
"have the ability to delete job class definitions from the " +
"SLAMD server.", false, resourceDNDeleteJobClass);
StringParameter authClientDNParameter =
new StringParameter(
Constants.SERVLET_INIT_PARAM_ACCESS_AUTHENTICATE_CLIENT,
"Authenticate Clients DN",
"The DN of the group or role that specifies the users that " +
"have the ability to authenticate to the SLAMD server as a " +
"client.", false, resourceDNAuthenticateClient);
Parameter[] params = new Parameter[]
{
useAccessControlParameter,
userHostParameter,
userPortParameter,
userBindDNParameter,
userBindPWParameter,
userBaseParameter,
userUseSSLParameter,
userBlindTrustParameter,
userIDParameter,
fullAccessDNParameter,
restartSLAMDDNParameter,
restartACLDNParameter,
viewServletConfigDNParameter,
editServletConfigDNParameter,
viewSLAMDConfigDNParameter,
editSLAMDConfigDNParameter,
viewStatusDNParameter,
disconnectClientDNParameter,
viewJobDNParameter,
exportJobDNParameter,
scheduleJobDNParameter,
cancelJobDNParameter,
deleteJobDNParameter,
manageFoldersDNParameter,
viewJobClassDNParameter,
addJobClassDNParameter,
deleteJobClassDNParameter,
authClientDNParameter
};
return new ParameterList(params);
}
/**
* Re-reads all configuration information used by the SLAMD Web interface. In
* this case, the only options are related to the look and feel of the user
* interface.
*/
public void refreshSubscriberConfiguration()
{
// The only configuration we care about is the configuration that allows us
// to customize the UI
String param =
configDB.getConfigParameter(Constants.PARAM_POPULATE_START_TIME);
populateStartTime = (! ((param != null) &&
(param.equalsIgnoreCase("false") ||
param.equalsIgnoreCase("off") ||
param.equalsIgnoreCase("no"))));
param = configDB.getConfigParameter(
Constants.PARAM_ALWAYS_SHOW_ADVANCED_OPTIONS);
alwaysShowAdvancedOptions = ((param != null) &&
(param.equalsIgnoreCase("true") ||
param.equalsIgnoreCase("yes") ||
param.equalsIgnoreCase("on") ||
param.equalsIgnoreCase("1")));
param = configDB.getConfigParameter(Constants.PARAM_SHOW_LOGIN_ID);
showLoginID = (! ((param != null) &&
(param.equalsIgnoreCase("false") ||
param.equalsIgnoreCase("off") ||
param.equalsIgnoreCase("no"))));
param = configDB.getConfigParameter(Constants.PARAM_SHOW_TIME);
showTimeInSidebar = (! ((param != null) &&
(param.equalsIgnoreCase("false") ||
param.equalsIgnoreCase("off") ||
param.equalsIgnoreCase("no"))));
param = configDB.getConfigParameter(Constants.PARAM_DISABLE_GRAPHS);
disableGraphs = ((param != null) &&
(param.equalsIgnoreCase("true") ||
param.equalsIgnoreCase("on") ||
param.equalsIgnoreCase("yes")));
param = configDB.getConfigParameter(Constants.PARAM_GRAPH_IN_NEW_WINDOW);
graphInNewWindow = ((param != null) &&
(param.equalsIgnoreCase("true") ||
param.equalsIgnoreCase("on") ||
param.equalsIgnoreCase("yes")));
if (graphInNewWindow)
{
blankTarget = " TARGET=\"_BLANK\"";
}
else
{
blankTarget = "";
}
param = configDB.getConfigParameter(
Constants.PARAM_HIDE_OPTIMIZING_ITERATIONS);
hideOptimizingIterations = ((param != null) &&
(param.equalsIgnoreCase("true") ||
param.equalsIgnoreCase("on") ||
param.equalsIgnoreCase("yes")));
param = configDB.getConfigParameter(Constants.PARAM_DEFAULT_GRAPH_WIDTH);
if ((param != null) && (param.length() > 0))
{
try
{
defaultGraphWidth = Integer.parseInt(param);
}
catch (NumberFormatException nfe)
{
defaultGraphWidth = Constants.DEFAULT_GRAPH_WIDTH;
}
}
else
{
defaultGraphWidth = Constants.DEFAULT_GRAPH_WIDTH;
}
param = configDB.getConfigParameter(Constants.PARAM_DEFAULT_GRAPH_HEIGHT);
if ((param != null) && (param.length() > 0))
{
try
{
defaultGraphHeight = Integer.parseInt(param);
}
catch (NumberFormatException nfe)
{
defaultGraphHeight = Constants.DEFAULT_GRAPH_HEIGHT;
}
}
else
{
defaultGraphHeight = Constants.DEFAULT_GRAPH_HEIGHT;
}
param = configDB.getConfigParameter(
Constants.PARAM_DEFAULT_MONITOR_GRAPH_HEIGHT);
if ((param != null) && (param.length() > 0))
{
try
{
defaultMonitorGraphHeight = Integer.parseInt(param);
}
catch (NumberFormatException nfe)
{
defaultMonitorGraphHeight = Constants.DEFAULT_MONITOR_GRAPH_HEIGHT;
}
}
else
{
defaultMonitorGraphHeight = Constants.DEFAULT_MONITOR_GRAPH_HEIGHT;
}
param = configDB.getConfigParameter(Constants.PARAM_DISABLE_UPLOADS);
disableUploads = ((param != null) &&
(param.equalsIgnoreCase("true") ||
param.equalsIgnoreCase("on") ||
param.equalsIgnoreCase("yes")));
param = configDB.getConfigParameter(Constants.PARAM_MAX_UPLOAD_SIZE);
if ((param != null) && (param.length() > 0))
{
try
{
maxUploadSize = Integer.parseInt(param);
}
catch (NumberFormatException nfe)
{
maxUploadSize = Constants.DEFAULT_MAX_UPLOAD_SIZE;
}
}
else
{
maxUploadSize = Constants.DEFAULT_MAX_UPLOAD_SIZE;
}
param =
configDB.getConfigParameter(Constants.PARAM_INCLUDE_SERVER_IN_TITLE);
includeAddressInPageTitle = ((param != null) &&
(param.equalsIgnoreCase("true") ||
param.equalsIgnoreCase("on") ||
param.equalsIgnoreCase("yes")));
param = configDB.getConfigParameter(Constants.PARAM_MANAGE_READ_ONLY);
enableReadOnlyManagement = ((param != null) &&
(param.equalsIgnoreCase("true") ||
param.equalsIgnoreCase("on") ||
param.equalsIgnoreCase("yes")));
param =
configDB.getConfigParameter(Constants.PARAM_REPORT_GENERATOR_CLASSES);
if ((param == null) || (param.length() == 0))
{
reportGenerators = new ReportGenerator[0];
}
else
{
ArrayList<ReportGenerator> generatorList =
new ArrayList<ReportGenerator>();
StringTokenizer tokenizer = new StringTokenizer(param, " \t\r\n");
while (tokenizer.hasMoreTokens())
{
String className = tokenizer.nextToken();
try
{
Class<?> generatorClass = Constants.classForName(className);
ReportGenerator generator =
(ReportGenerator) generatorClass.newInstance();
generatorList.add(generator);
}
catch (Exception e)
{
slamdServer.logMessage(Constants.LOG_LEVEL_ANY,
"Unable to instantiate report generator \"" +
className + "\" -- " + e);
}
}
reportGenerators = new ReportGenerator[generatorList.size()];
generatorList.toArray(reportGenerators);
}
param = configDB.getConfigParameter(Constants.PARAM_ADD_TO_HTML_HEADER);
if ((param != null) && (param.length() > 0))
{
addedHeaderLines = param;
}
else
{
addedHeaderLines = "";
}
param = configDB.getConfigParameter(Constants.PARAM_STYLE_SHEET);
if ((param != null) && (param.length() > 0))
{
styleSheet = param;
}
else
{
styleSheet = Constants.STYLE_SHEET_DATA;
}
// Just set the header, footer, and default HTML to null and they will be
// read and parsed on the next request.
AdminUI.defaultHTML = null;
pageHeader = null;
pageFooter = null;
}
/**
* Re-reads all configuration information used by the SLAMD Web interface. In
* this case, the only options are related to the look and feel of the user
* interface.
*
* @param parameterName The name of the parameter to be re-read from the
* configuration.
*/
public void refreshSubscriberConfiguration(String parameterName)
{
String param = configDB.getConfigParameter(parameterName);
if (parameterName.equalsIgnoreCase(Constants.PARAM_POPULATE_START_TIME))
{
populateStartTime = (! ((param != null) &&
(param.equalsIgnoreCase("false") ||
param.equalsIgnoreCase("off") ||
param.equalsIgnoreCase("no"))));
}
else if (parameterName.equalsIgnoreCase(
Constants.PARAM_ALWAYS_SHOW_ADVANCED_OPTIONS))
{
alwaysShowAdvancedOptions = ((param != null) &&
(param.equalsIgnoreCase("true") ||
param.equalsIgnoreCase("yes") ||
param.equalsIgnoreCase("on") ||
param.equalsIgnoreCase("1")));
}
else if (parameterName.equalsIgnoreCase(Constants.PARAM_SHOW_LOGIN_ID))
{
showLoginID = (! ((param != null) &&
(param.equalsIgnoreCase("false") ||
param.equalsIgnoreCase("off") ||
param.equalsIgnoreCase("no"))));
}
else if (parameterName.equalsIgnoreCase(Constants.PARAM_SHOW_TIME))
{
showTimeInSidebar = (! ((param != null) &&
(param.equalsIgnoreCase("false") ||
param.equalsIgnoreCase("off") ||
param.equalsIgnoreCase("no"))));
}
else if (parameterName.equalsIgnoreCase(Constants.PARAM_DISABLE_GRAPHS))
{
disableGraphs = ((param != null) &&
(param.equalsIgnoreCase("true") ||
param.equalsIgnoreCase("on") ||
param.equalsIgnoreCase("yes")));
}
else if (parameterName.equalsIgnoreCase(
Constants.PARAM_GRAPH_IN_NEW_WINDOW))
{
graphInNewWindow = ((param != null) &&
(param.equalsIgnoreCase("true") ||
param.equalsIgnoreCase("on") ||
param.equalsIgnoreCase("yes")));
if (graphInNewWindow)
{
blankTarget = " TARGET=\"_BLANK\"";
}
else
{
blankTarget = "";
}
}
else if (parameterName.equalsIgnoreCase(
Constants.PARAM_HIDE_OPTIMIZING_ITERATIONS))
{
hideOptimizingIterations = ((param != null) &&
(param.equalsIgnoreCase("true") ||
param.equalsIgnoreCase("on") ||
param.equalsIgnoreCase("yes")));
}
else if (parameterName.equalsIgnoreCase(
Constants.PARAM_DEFAULT_GRAPH_WIDTH))
{
if ((param != null) && (param.length() > 0))
{
try
{
defaultGraphWidth = Integer.parseInt(param);
}
catch (NumberFormatException nfe)
{
defaultGraphWidth = Constants.DEFAULT_GRAPH_WIDTH;
}
}
else
{
defaultGraphWidth = Constants.DEFAULT_GRAPH_WIDTH;
}
}
else if (parameterName.equalsIgnoreCase(
Constants.PARAM_DEFAULT_GRAPH_HEIGHT))
{
if ((param != null) && (param.length() > 0))
{
try
{
defaultGraphHeight = Integer.parseInt(param);
}
catch (NumberFormatException nfe)
{
defaultGraphHeight = Constants.DEFAULT_GRAPH_HEIGHT;
}
}
else
{
defaultGraphHeight = Constants.DEFAULT_GRAPH_HEIGHT;
}
}
else if (parameterName.equalsIgnoreCase(
Constants.PARAM_DEFAULT_MONITOR_GRAPH_HEIGHT))
{
if ((param != null) && (param.length() > 0))
{
try
{
defaultMonitorGraphHeight = Integer.parseInt(param);
}
catch (NumberFormatException nfe)
{
defaultMonitorGraphHeight = Constants.DEFAULT_MONITOR_GRAPH_HEIGHT;
}
}
else
{
defaultMonitorGraphHeight = Constants.DEFAULT_MONITOR_GRAPH_HEIGHT;
}
}
else if (parameterName.equalsIgnoreCase(
Constants.PARAM_INCLUDE_SERVER_IN_TITLE))
{
includeAddressInPageTitle = ((param != null) &&
(param.equalsIgnoreCase("true") ||
param.equalsIgnoreCase("on") ||
param.equalsIgnoreCase("yes")));
}
else if (parameterName.equalsIgnoreCase(Constants.PARAM_DISABLE_UPLOADS))
{
disableUploads = ((param != null) &&
(param.equalsIgnoreCase("true") ||
param.equalsIgnoreCase("on") ||
param.equalsIgnoreCase("yes")));
}
else if (parameterName.equalsIgnoreCase(Constants.PARAM_MAX_UPLOAD_SIZE))
{
if ((param != null) && (param.length() > 0))
{
try
{
maxUploadSize = Integer.parseInt(param);
}
catch (NumberFormatException nfe)
{
maxUploadSize = Constants.DEFAULT_MAX_UPLOAD_SIZE;
}
}
else
{
maxUploadSize = Constants.DEFAULT_MAX_UPLOAD_SIZE;
}
}
else if (parameterName.equalsIgnoreCase(Constants.PARAM_MANAGE_READ_ONLY))
{
enableReadOnlyManagement = ((param != null) &&
(param.equalsIgnoreCase("true") ||
param.equalsIgnoreCase("on") ||
param.equalsIgnoreCase("yes")));
}
else if (parameterName.equalsIgnoreCase(
Constants.PARAM_REPORT_GENERATOR_CLASSES))
{
if ((param == null) || (param.length() == 0))
{
reportGenerators = new ReportGenerator[0];
}
else
{
ArrayList<ReportGenerator> generatorList =
new ArrayList<ReportGenerator>();
StringTokenizer tokenizer = new StringTokenizer(param, " \t\r\n");
while (tokenizer.hasMoreTokens())
{
String className = tokenizer.nextToken();
try
{
Class<?> generatorClass = Constants.classForName(className);
ReportGenerator generator =
(ReportGenerator) generatorClass.newInstance();
generatorList.add(generator);
}
catch (Exception e)
{
slamdServer.logMessage(Constants.LOG_LEVEL_ANY,
"Unable to instantiate report generator \"" +
className + "\" -- " + e);
}
}
reportGenerators = new ReportGenerator[generatorList.size()];
generatorList.toArray(reportGenerators);
}
}
else if (parameterName.equalsIgnoreCase(Constants.PARAM_ADD_TO_HTML_HEADER))
{
if ((param != null) && (param.length() > 0))
{
addedHeaderLines = param;
}
else
{
addedHeaderLines = "";
}
}
else if (parameterName.equalsIgnoreCase(Constants.PARAM_STYLE_SHEET))
{
if ((param != null) && (param.length() > 0))
{
styleSheet = param;
}
else
{
styleSheet = Constants.STYLE_SHEET_DATA;
}
}
else if (parameterName.equalsIgnoreCase(Constants.PARAM_PAGE_HEADER))
{
// Set the header to null to have it taken care of the next time a page is
// rendered.
pageHeader = null;
}
else if (parameterName.equalsIgnoreCase(Constants.PARAM_PAGE_FOOTER))
{
// Set the footer to null to have it taken care of the next time a page is
// rendered.
pageFooter = null;
}
else if (parameterName.equalsIgnoreCase(Constants.PARAM_DEFAULT_HTML))
{
// Set the default HTML to null to have it taken care of the next time the
// page is rendered.
AdminUI.defaultHTML = null;
}
}
/**
* Applies any changes to the specified parameter, if possible. Some
* parameters may not be dynamically reconfigured, in which case this method
* will do nothing.
*
* @param requestInfo The state information for this request.
* @param name The name of the configuration parameter whose value
* should be refreshed.
* @param value The new value to use for the parameter.
* @param apply Indicates whether the new value should be immediately
* applied if the change is for a parameter that may be
* dynamically reconfigured.
*/
static void updateServletConfiguration(RequestInfo requestInfo, String name,
String value, boolean apply)
{
logMessage(requestInfo,
"In updateServletConfiguration(" + name + ", " + value + ')');
// Check for each of the known configuration parameters and make the
// change to the corresponding static instance variable
if (name.equals(Constants.SERVLET_INIT_PARAM_JOB_CLASS_PATH))
{
classPath = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_SSL_KEY_STORE))
{
sslKeyStore = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_SSL_KEY_PASSWORD))
{
sslKeyStorePassword = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_SSL_TRUST_STORE))
{
sslTrustStore = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_SSL_TRUST_PASSWORD))
{
sslTrustStorePassword = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_USE_ACCESS_CONTROL))
{
useAccessControl = (value.equalsIgnoreCase("true") ||
value.equalsIgnoreCase("yes") ||
value.equalsIgnoreCase("on"));
if (useAccessControl)
{
if (accessManager == null)
{
accessManager = new AccessManager(userDirHost, userDirPort,
userDirBindDN, userDirBindPW,
userDirBase, userIDAttribute,
userDirUseSSL, userDirBlindTrust,
sslKeyStore, sslKeyStorePassword,
sslTrustStore,
sslTrustStorePassword);
registerACL(requestInfo, Constants.SERVLET_INIT_PARAM_ACCESS_FULL,
resourceDNFullAccess, false);
registerACL(requestInfo,
Constants.SERVLET_INIT_PARAM_ACCESS_RESTART_SLAMD,
resourceDNRestartSLAMD, false);
registerACL(requestInfo,
Constants.SERVLET_INIT_PARAM_ACCESS_RESTART_ACL,
resourceDNRestartACL, false);
registerACL(requestInfo,
Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_SERVLET_CONFIG,
resourceDNViewServletConfig, false);
registerACL(requestInfo,
Constants.SERVLET_INIT_PARAM_ACCESS_EDIT_SERVLET_CONFIG,
resourceDNEditServletConfig, false);
registerACL(requestInfo,
Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_SLAMD_CONFIG,
resourceDNViewSLAMDConfig, false);
registerACL(requestInfo,
Constants.SERVLET_INIT_PARAM_ACCESS_EDIT_SLAMD_CONFIG,
resourceDNEditSLAMDConfig, false);
registerACL(requestInfo,
Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_STATUS,
resourceDNViewStatus, false);
registerACL(requestInfo,
Constants.SERVLET_INIT_PARAM_ACCESS_DISCONNECT_CLIENT,
resourceDNDisconnectClient, false);
registerACL(requestInfo, Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_JOB,
resourceDNViewJob, false);
registerACL(requestInfo,
Constants.SERVLET_INIT_PARAM_ACCESS_EXPORT_JOB,
resourceDNExportJob, false);
registerACL(requestInfo,
Constants.SERVLET_INIT_PARAM_ACCESS_SCHEDULE_JOB,
resourceDNScheduleJob, false);
registerACL(requestInfo,
Constants.SERVLET_INIT_PARAM_ACCESS_CANCEL_JOB,
resourceDNCancelJob, false);
registerACL(requestInfo,
Constants.SERVLET_INIT_PARAM_ACCESS_DELETE_JOB,
resourceDNDeleteJob, false);
registerACL(requestInfo,
Constants.SERVLET_INIT_PARAM_ACCESS_MANAGE_JOB_FOLDERS,
resourceDNManageJobFolders, false);
registerACL(requestInfo,
Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_JOB_CLASS,
resourceDNViewJobClass, false);
registerACL(requestInfo,
Constants.SERVLET_INIT_PARAM_ACCESS_ADD_JOB_CLASS,
resourceDNAddJobClass, false);
registerACL(requestInfo,
Constants.SERVLET_INIT_PARAM_ACCESS_DELETE_JOB_CLASS,
resourceDNDeleteJobClass, false);
try
{
accessManager.startAccessManager();
}
catch (LDAPException le)
{
requestInfo.infoMessage.append("ERROR: Could not start access " +
"control manager: " + le + "<BR>" +
EOL);
}
}
}
else
{
if (accessManager != null)
{
accessManager.stopAccessManager();
accessManager.flushUserCache();
accessManager = null;
}
}
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_USER_DIR_HOST))
{
userDirHost = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_USER_DIR_PORT))
{
try
{
userDirPort = Integer.parseInt(value);
} catch (NumberFormatException nfe) {}
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_USER_DIR_BIND_DN))
{
userDirBindDN = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_USER_DIR_BIND_PW))
{
userDirBindPW = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_USER_DIR_BASE))
{
userDirBase = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_USER_USE_SSL))
{
userDirUseSSL = (value.equalsIgnoreCase("true") ||
value.equalsIgnoreCase("yes") ||
value.equalsIgnoreCase("on"));
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_USER_BLIND_TRUST))
{
userDirBlindTrust = (! (value.equalsIgnoreCase("false") ||
value.equalsIgnoreCase("no") ||
value.equalsIgnoreCase("off")));
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_USER_ID_ATTR))
{
userIDAttribute = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_FULL))
{
resourceDNFullAccess = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_RESTART_SLAMD))
{
resourceDNRestartSLAMD = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_RESTART_ACL))
{
resourceDNRestartACL = value;
}
else if
(name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_SERVLET_CONFIG))
{
resourceDNViewServletConfig = value;
}
else if
(name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_EDIT_SERVLET_CONFIG))
{
resourceDNEditServletConfig = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_SLAMD_CONFIG))
{
resourceDNViewSLAMDConfig = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_EDIT_SLAMD_CONFIG))
{
resourceDNEditSLAMDConfig = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_STATUS))
{
resourceDNViewStatus = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_DISCONNECT_CLIENT))
{
resourceDNDisconnectClient = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_JOB))
{
resourceDNViewJob = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_EXPORT_JOB))
{
resourceDNExportJob = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_SCHEDULE_JOB))
{
resourceDNScheduleJob = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_CANCEL_JOB))
{
resourceDNCancelJob = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_DELETE_JOB))
{
resourceDNDeleteJob = value;
}
else if (name.equals(
Constants.SERVLET_INIT_PARAM_ACCESS_MANAGE_JOB_FOLDERS))
{
resourceDNManageJobFolders = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_JOB_CLASS))
{
resourceDNViewJobClass = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_ADD_JOB_CLASS))
{
resourceDNAddJobClass = value;
}
else if (name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_DELETE_JOB_CLASS))
{
resourceDNDeleteJobClass = value;
}
else if (name.equals(
Constants.SERVLET_INIT_PARAM_ACCESS_AUTHENTICATE_CLIENT))
{
resourceDNAuthenticateClient = value;
}
// All of the resource DNs are dynamically reconfigurable. There's no
// reason to check for each one, so just make one blanket update.
if (apply && (accessManager != null) && isResourceDNParameter(name))
{
if ((value == null) || (value.length() == 0))
{
accessManager.deregister(name, true);
}
else
{
accessManager.register(name, value, true);
}
}
}
/**
* Indicates whether the specified parameter name is the parameter for one
* of the resource DN parameters.
*
* @param name The parameter name for which to make the determination.
*
* @return <CODE>true</CODE> if the specified parameter is one of the
* resource DN parameter names, or <CODE>false</CODE> if not.
*/
static boolean isResourceDNParameter(String name)
{
return
name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_FULL) ||
name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_RESTART_SLAMD) ||
name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_RESTART_ACL) ||
name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_SERVLET_CONFIG) ||
name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_EDIT_SERVLET_CONFIG) ||
name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_SLAMD_CONFIG) ||
name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_EDIT_SLAMD_CONFIG) ||
name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_STATUS) ||
name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_DISCONNECT_CLIENT) ||
name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_JOB) ||
name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_EXPORT_JOB) ||
name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_SCHEDULE_JOB) ||
name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_CANCEL_JOB) ||
name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_DELETE_JOB) ||
name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_MANAGE_JOB_FOLDERS) ||
name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_VIEW_JOB_CLASS) ||
name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_ADD_JOB_CLASS) ||
name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_DELETE_JOB_CLASS) ||
name.equals(Constants.SERVLET_INIT_PARAM_ACCESS_AUTHENTICATE_CLIENT);
}
/**
* Indicates whether a change in the specified parameter requires that the
* SLAMD server be restarted before the change will take effect.
*
* @param name The name of the parameter for which to make the
* determination.
*
* @return <CODE>true</CODE> if a change in the specified parameter requires
* a restart, or <CODE>false</CODE> if not.
*/
static boolean changeRequiresSLAMDRestart(String name)
{
return (name.equals(Constants.SERVLET_INIT_PARAM_SSL_KEY_STORE) ||
name.equals(Constants.SERVLET_INIT_PARAM_SSL_KEY_PASSWORD) ||
name.equals(Constants.SERVLET_INIT_PARAM_SSL_TRUST_STORE) ||
name.equals(Constants.SERVLET_INIT_PARAM_SSL_TRUST_PASSWORD));
}
/**
* Indicates whether a change in the specified parameter requires that the
* access manager be restarted before the change will take effect.
*
* @param name The name of the parameter for which to make the
* determination.
*
* @return <CODE>true</CODE> if a change in the specified parameter requires
* a restart, or <CODE>false</CODE> if not.
*/
static boolean changeRequiresAccessManagerRestart(String name)
{
return (name.equals(Constants.SERVLET_INIT_PARAM_USER_DIR_PORT) ||
name.equals(Constants.SERVLET_INIT_PARAM_USER_DIR_BIND_DN) ||
name.equals(Constants.SERVLET_INIT_PARAM_USER_DIR_BIND_PW) ||
name.equals(Constants.SERVLET_INIT_PARAM_USER_DIR_BASE) ||
name.equals(Constants.SERVLET_INIT_PARAM_USER_ID_ATTR) ||
name.equals(Constants.SERVLET_INIT_PARAM_USER_USE_SSL) ||
(userDirUseSSL &&
(name.equals(Constants.SERVLET_INIT_PARAM_SSL_KEY_STORE) ||
name.equals(Constants.SERVLET_INIT_PARAM_SSL_KEY_PASSWORD) ||
name.equals(Constants.SERVLET_INIT_PARAM_SSL_TRUST_STORE) ||
name.equals(Constants.SERVLET_INIT_PARAM_SSL_TRUST_PASSWORD))));
}
}