001/*
002 * #%L
003 * Netarchivesuite - deploy
004 * %%
005 * Copyright (C) 2005 - 2014 The Royal Danish Library, the Danish State and University Library,
006 *             the National Library of France and the Austrian National Library.
007 * %%
008 * This program is free software: you can redistribute it and/or modify
009 * it under the terms of the GNU Lesser General Public License as
010 * published by the Free Software Foundation, either version 2.1 of the
011 * License, or (at your option) any later version.
012 * 
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Lesser Public License for more details.
017 * 
018 * You should have received a copy of the GNU General Lesser Public
019 * License along with this program.  If not, see
020 * <http://www.gnu.org/licenses/lgpl-2.1.html>.
021 * #L%
022 */
023package dk.netarkivet.deploy;
024
025import dk.netarkivet.common.exceptions.ArgumentNotValid;
026import dk.netarkivet.common.utils.StringUtils;
027
028/**
029 * This class contains constants and functions specific for creating the scripts and other files for the different
030 * machines and applications.
031 */
032public final class ScriptConstants {
033
034    /**
035     * Private constructor to avoid instantiation of this class.
036     */
037    private ScriptConstants() {
038    }
039
040    // Character constants as Strings.
041    /** The newline '\n' - acquired from Constants. */
042    static final String NEWLINE = Constants.NEWLINE;
043    /** The directory separator for policy files. */
044    static final String SECURITY_DIR_SEPARATOR = "${/}";
045
046    // Strings
047    /** The header of some scripts. */
048    static final String BIN_BASH_COMMENT = "#!/bin/bash";
049    /** The call for running a batch script from another batch script. */
050    static final String OPERATING_SYSTEM_WINDOWS_RUN_BATCH_FILE = "\"C:\\Program Files\\Bitvise WinSSHD\\bvRun\" -brj -new -cmd=";
051    /** The call to the wait.vbs script that waits 10 seconds. */
052    static final String OPERATING_SYSTEM_WINDOWS_10_SECONDS_WAIT = ScriptConstants.CSCRIPT + Constants.SPACE 
053                + Constants.SCRIPT_NAME_WAIT + Constants.EXTENSION_VBS_FILES;   
054    /** Ddk.netarkivet.settings.file=. */
055    static final String OPTION_SETTINGS = "Ddk.netarkivet.settings.file=";
056    /** Ddk.netarkivet.settings.file=\"\". */
057    static final String OPTION_SETTINGS_WIN = OPTION_SETTINGS + "\"\"";
058    /** Dlogback.configurationFile=. */
059    static final String OPTION_LOGBACK_CONFIG = "Dlogback.configurationFile=";
060    static final String OPTION_LOGBACK_CONFIG_WIN = OPTION_LOGBACK_CONFIG + "\"\"";
061    /** Djava.security.manager. */
062    static final String OPTION_SECURITY_MANAGER = "Djava.security.manager";
063    /** Djava.security.policy=. */
064    static final String OPTION_SECURITY_POLICY = "Djava.security.policy=";
065    /** Djava.security.policy=\"\". */
066    static final String OPTION_SECURITY_POLICY_WIN = OPTION_SECURITY_POLICY + "\"\"";
067    /**
068     * Array of classpaths for libraries used to access the database. Currently: lib/db/derbynet.jar and
069     * lib/db/derby.jar .
070     */
071    static final String[] DERBY_ACCESS_CLASSPATH = new String[] {"lib/db/derbynet.jar", "lib/db/derby.jar"};
072    /** org.apache.derby.drda.NetworkServerControl . */
073    static final String DERBY_ACCESS_METHOD = "org.apache.derby.drda.NetworkServerControl";
074    /** start . */
075    static final String DERBY_COMMAND_START = "start";
076    /** shutdown . */
077    static final String DERBY_COMMAND_KILL = "shutdown";
078
079    /** The message when database is trying to overwrite a non-empty dir. */
080    static final String DATABASE_ERROR_PROMPT_DIR_NOT_EMPTY = "The database directory already exists. Thus database not reset.";
081
082    /** cmd /c - Command for running programs on windows. */
083    static final String WINDOWS_COMMAND_RUN = "cmd /c";
084    /** more - the command for reading a log file. */
085    static final String WINDOWS_COMMAND_TYPE = "type";
086    /** cmd /c unzip.exe -q -d - Command for unzipping on windows. */
087    static final String WINDOWS_UNZIP_COMMAND = WINDOWS_COMMAND_RUN + " unzip.exe -q -d";
088    /** output. -o. */
089    static final String SCRIPT_OUTPUT = "-o";
090    /** directory. -d. */
091    static final String SCRIPT_DIR = "-d";
092    /** repository. -r. */
093    static final String SCRIPT_REPOSITORY = "-r";
094    /** unzip -q -o. */
095    static final String LINUX_UNZIP_COMMAND = "unzip -q -o";
096
097    /** Linux chmod u+rwx. */
098    static final String LINUX_USER_ONLY = "chmod u+rwx";
099    /** Linux chmod 700. */
100    static final String LINUX_USER_700 = "chmod 700";
101    /** Linux chmod 400. */
102    static final String LINUX_USER_400 = "chmod 400";
103    /** Linux sent output to dev/null. */
104    static final String LINUX_DEV_NULL = "< /dev/null >";
105    /** & . */
106    static final String LINUX_RUN_BACKGROUND = " &";
107    /** 2>&1 &. */
108    static final String LINUX_ERROR_MESSAGE_TO_1 = "2>&1 &";
109    /** /etc/profile. */
110    static final String ETC_PROFILE = "/etc/profile";
111    /** /etc/profile. */
112    static final String USER_BASH_PROFILE = "~/.bash_profile";
113    /** The linux command for sleeping. sleep. */
114    static final String SLEEP = "sleep";
115    /** sleep 2. */
116    static final String SLEEP_2 = SLEEP + " 2";
117    /** sleep 5. */
118    static final String SLEEP_5 = SLEEP + " 5";
119    /** .log. */
120    static final String STAR_LOG = "*.log";
121    /** ' '. */
122    static final String MULTI_SPACE_6 = "      ";
123    /** ' '. */
124    static final String MULTI_SPACE_4 = "    ";
125    /** ' '. */
126    static final String MULTI_SPACE_2 = "  ";
127    /** ssh. */
128    static final String SSH = "ssh";
129    /** scp. */
130    static final String SCP = "scp";
131    /** $PIDS. */
132    static final String PIDS = "$PIDS";
133    /** "    kill $PIDS". */
134    static final String KILL_PIDS = "    kill $PIDS";
135    /** "    kill -9 $PIDS". */
136    static final String KILL_9_PIDS = "    kill -9 $PIDS";
137    /** "    export CLASSPATH=". */
138    static final String EXPORT_CLASSPATH = "export CLASSPATH=";
139    /** to. */
140    static final String TO = "to";
141    /** if. */
142    static final String IF = "if";
143    /** fi. */
144    static final String FI = "fi";
145    /** at. */
146    static final String AT = "at";
147    /** cd. */
148    static final String CD = "cd";
149    /** cat. */
150    static final String CAT = "cat";
151    /** exist. */
152    static final String EXIST = "exist";
153    /** exit. */
154    static final String EXIT = "exit";
155    /** then. */
156    static final String THEN = "then";
157    /** cacls. */
158    static final String CACLS = "cacls";
159    /** cscript. */
160    static final String CSCRIPT = "cscript";
161    /** goto. */
162    static final String GOTO = "goto";
163    /** else. */
164    static final String ELSE = "else";
165    /** else rm -r. */
166    static final String ELSE_REMOVE = "else rm -r";
167    /** del. */
168    static final String DEL = "del";
169    /** cd ~. */
170    static final String LINUX_HOME_DIR = "cd ~";
171    /** if [ -e. */
172    static final String LINUX_IF_EXIST = "if [ -e";
173    /** if [ -d. */
174    static final String LINUX_IF_DIR_EXIST = "if [ -d";
175    /** if [ ! -d. */
176    static final String LINUX_IF_NOT_DIR_EXIST = "if [ ! -d";
177    /** if [ -n. */
178    static final String LINUX_IF_N_EXIST = "if [ -n";
179    /** ]; then. */
180    static final String LINUX_THEN = "]; then";
181    /** ] ; then. */
182    static final String LINUX_N_THEN = "] ; then";
183    /** java. */
184    static final String JAVA = "java";
185    /** -cp. */
186    static final String JAVA_CLASSPATH = "-cp";
187    /** rd. (windows for remove dir). */
188    static final String RD = "rd";
189    /** not. */
190    static final String NOT = "not";
191    /** md. (windows for makedir). */
192    static final String MD = "md";
193    /** mkdir. (linux for makedir). */
194    static final String MKDIR = "mkdir";
195    /** mv -f. (Linux force move of file). */
196    static final String LINUX_FORCE_MOVE = "mv -f";
197    /** move /Y. (force move on windows). */
198    static final String WINDOWS_FORCE_MOVE = "move /Y";
199    /** classpath. */
200    static final String CLASSPATH = "classpath";
201    /** $CLASSPATH. */
202    static final String VALUE_OF_CLASSPATH = "$CLASSPATH";
203    /** label KILL. */
204    static final String LABEL_KILL = "KILL";
205    /** label NOKILL. */
206    static final String LABEL_NOKILL = "NOKILL";
207    /** label DONE. */
208    static final String LABEL_DONE = "DONE";
209    /** label START. */
210    static final String LABEL_START = "START";
211    /** label NOSTART. */
212    static final String LABEL_NOSTART = "NOSTART";
213    /** /P - slash p. */
214    static final String SLASH_P = "/P";
215    /** :F - colon f. */
216    static final String COLON_F = ":F";
217    /** :R - colon r. */
218    static final String COLON_R = ":R";
219    /** -r - dash r. */
220    static final String DASH_R = "-r";
221    /** BITARKIV\\\\ - prefix for windows user rights. */
222    static final String BITARKIV_BACKSLASH_BACKSLASH = "BITARKIV\\\\";
223    /** readonly - for the monitorRole. */
224    static final String JMXREMOTE_MONITOR_PRIVILEGES = "readonly";
225    /** readonly - for the controlRole. */
226    static final String JMXREMOTE_HERITRIX_PRIVILEGES = "readwrite";
227    /** The argument for the port for the external database: -p. */
228    static final String DATABASE_PORT_ARGUMENT = "-p";
229
230    // echos
231    /** echo. */
232    static final String ECHO = "echo";
233    /** echo copying. */
234    static final String ECHO_COPYING = "echo copying";
235    /** echo unzipping. */
236    static final String ECHO_UNZIPPING = "echo unzipping";
237    /** echo deleting. */
238    static final String ECHO_DELETING = "echo deleting";
239
240    /** Do a recursive delete in Linux. */
241    static final String LINUX_FORCE_RECURSIVE_DELETE = "rm -rf";
242    /** echo preparing for copying of settings and scripts. */
243    static final String ECHO_PREPARING_FOR_COPY = "echo preparing for copying of settings and scripts";
244    /** echo 1. */
245    static final String ECHO_ONE = "echo 1";
246    /** echo Y. */
247    static final String ECHO_Y = "echo Y";
248    /** echo copying settings and scripts. */
249    static final String ECHO_COPY_SETTINGS_AND_SCRIPTS = "echo copying settings and scripts";
250    /** echo make password files readonly. */
251    static final String ECHO_MAKE_PASSWORD_FILES = "echo make password and access files readonly";
252    /** echo Killing all applications on. */
253    static final String ECHO_KILL_ALL_APPS = "echo Killing all applications on";
254    /** echo Starting all applications on. */
255    static final String ECHO_START_ALL_APPS = "echo Starting all applications on";
256    /** ECHO Killing windows application. */
257    static final String ECHO_KILL_WINDOWS_APPLICATION = "ECHO Killing windows application";
258    /** echo Killing linux application. */
259    static final String ECHO_KILL_LINUX_APPLICATION = "echo Killing linux application";
260    /** ECHO Cannot kill application. Is not running. */
261    static final String ECHO_CANNOT_KILL_APP = "ECHO Cannot kill application. Is not running.";
262    /** echo Cannot start. Application already running. */
263    static final String ECHO_CANNOT_START_APP = "echo Cannot start. Application already running.";
264    /** echo Database not implemented for windows. */
265    static final String ECHO_WINDOWS_DATABASE = "echo Database not implemented " + "for windows.";
266    /** echo Creating directories. */
267    static final String ECHO_CREATING_DIRECTORIES = "echo Creating directories.";
268    /** echo Installing external jar files. */
269    static final String ECHO_INSTALLING_EXTERNAL_JAR_FILES = "echo Installing external jar files.";
270    /** echo make scripts executable. */
271    static final String ECHO_MAKE_EXECUTABLE = "echo make scripts executable";
272    /** echo Starting linux application. */
273    static final String ECHO_START_LINUX_APP = "echo Starting linux application";
274    /** "    echo Application already running.". */
275    static final String ECHO_APP_ALREADY_RUNNING = "    echo Application already running.";
276    /** echo Copying database. */
277    static final String ECHO_COPYING_DATABASE = "echo Copying harvest definition database";
278    /** echo Copying archive database. */
279    static final String ECHO_COPYING_ARCHIVE_DATABASE = "echo Copying archive database";
280    /** echo Unzipping harvest definition database. */
281    static final String ECHO_UNZIPPING_DATABASE = "echo Unzipping harvest definition database";
282    /** echo Unzipping archive database. */
283    static final String ECHO_UNZIPPING_ARCHIVE_DATABASE = "echo Unzipping archive database";
284    /** echo Starting external admin database. */
285    static final String ECHO_START_EXTERNAL_ADMIN_DATABASE = "echo Starting external admin database.";
286    /** echo Killing external admin database. */
287    static final String ECHO_KILL_EXTERNAL_ADMIN_DATABASE = "echo Killing external admin database.";
288    /** echo Starting external harvest database. */
289    static final String ECHO_START_EXTERNAL_HARVEST_DATABASE = "echo Starting external harvest database.";
290    /** echo Killing external harvest database. */
291    static final String ECHO_KILL_EXTERNAL_HARVEST_DATABASE = "echo Killing external harvest database.";
292
293    /** echo Updating external harvest database. */
294    static final String ECHO_UPDATE_EXTERNAL_HARVEST_DATABASE = "echo Updating external harvest database.";
295
296    /** Name of the app called in the harvest database update script. */
297    static final String HARVEST_DATABASE_UPDATE_APP = "dk.netarkivet.harvester.tools.HarvestdatabaseUpdateApplication";
298
299    static final String BITARCHIVE_APPLICATION_NAME = "BitarchiveApplication";
300
301    // VB script
302    /** Set WshShell= CreateObject(\"WScript.Shell\"). */
303    static final String VB_CREATE_SHELL_OBJ = "Set WshShell= CreateObject(\"WScript.Shell\")";
304    /** Set oExec = WshShell.exec( \". */
305    static final String VB_CREATE_EXECUTE = "Set oExec = WshShell.exec( \"";
306    /** "set fso= CreateObject(\"Scripting.FileSystemObject\")". */
307    static final String VB_CREATE_FSO = "set fso= " + "CreateObject(\"Scripting.FileSystemObject\")";
308    /** "set f=fso.OpenTextFile(\".\\conf\\". */
309    static final String VB_WRITE_F_PREFIX = "set f=fso.OpenTextFile(\".\\conf\\";
310    /** "\",2,True)". */
311    static final String VB_WRITE_F_SURFIX = "\",2,True)";
312    /** "f.WriteLine \"taskkill /F /PID \" & oExec.ProcessID". */
313    static final String VB_WRITE_F_KILL = "f.WriteLine \"taskkill /F /PID \"" + " & oExec.ProcessID";
314    /** f.close. */
315    static final String VB_WRITE_F_CLOSE = "f.close";
316    /** "set f=fso.OpenTextFile(\".\\conf\\". */
317    static final String VB_WRITE_TF_PREFIX = "set tf=fso.OpenTextFile(\".\\conf\\";
318    /** "\",8,True)". */
319    static final String VB_WRITE_TF_SURFIX = "\",8,True)";
320    /** "tf.WriteLine \"taskkill /F /PID \" & oExec.ProcessID". */
321    static final String VB_WRITE_TF_CONTENT = "tf.WriteLine \"running process: " + "\" & oExec.ProcessID";
322    /** f.close. */
323    static final String VB_WRITE_TF_CLOSE = "tf.close";
324    /** WScript.Sleep. */
325    static final String VB_WRITE_WAIT = "WScript.Sleep";
326    /** 'Create a new start-log for the application. */
327    static final String VB_COMMENT_NEW_START_LOG = "'Create a new start-log for the application";
328    /** CreateObject("Scripting.FileSystemObject").OpenTextFile(". */
329    static final String VB_OPEN_WRITE_FILE_PREFIX = "CreateObject(\"Scripting.FileSystemObject\").OpenTextFile(\"";
330    /** ", 2, True). Means "write to new file", e.g. override existing. */
331    static final String VB_OPEN_WRITE_FILE_SUFFIX_2 = "\", 2, True)";
332    /** ", 8, True). Means "append to file" */
333    static final String VB_OPEN_WRITE_FILE_SUFFIX_8 = "\", 8, True)";
334    /** .close. */
335    static final String VB_CLOSE = ".close";
336    /** Do While oExec.Status = 0. */
337    static final String VB_DO_WHILE_OEXEC_STATUS_0 = "Do While oExec.Status = 0";
338    /** WScript.Sleep 1000. */
339    static final String VB_WSCRIPT_SLEEP_1000 = "WScript.Sleep 1000";
340    /** Do While. */
341    static final String VB_DO_WHILE = "Do While ";
342    /** oExec.StdOut. */
343    static final String VB_OEXEC_STD_OUT = "oExec.StdOut";
344    /** oExec.StdErr. */
345    static final String VB_OEXEC_STD_ERR = "oExec.StdErr";
346    /** .AtEndOfStream <> True. */
347    static final String VB_AT_END_OF_STREAM_FALSE = ".AtEndOfStream <> True";
348    /** Set outFile = . */
349    static final String VB_SET_OUTFILE = "Set outFile = ";
350    /** outFile.WriteLine. */
351    static final String VB_OUTFILE_WRITELINE = "outFile.WriteLine ";
352    /** ReadLine. */
353    static final String VB_READ_LINE = ".ReadLine";
354    /** outFile.close. */
355    static final String VB_OUTFILE_CLOSE = "outFile.close";
356    /** Loop. */
357    static final String VB_LOOP = "Loop";
358
359    // integers
360    /** Number of '-' repeat for the writeDashLine function. */
361    static final int SCRIPT_DASH_NUM_REPEAT = 44;
362
363    // functions
364
365    /**
366     * Function for creating dash lines in scripts.
367     *
368     * @return A line of dashes.
369     */
370    public static String writeDashLine() {
371        return "echo " + StringUtils.repeat("-", SCRIPT_DASH_NUM_REPEAT);
372    }
373
374    /**
375     * The header for the kill all script for the machine.
376     *
377     * @param login The login to the machine (username@machinename)
378     * @return The echo header for killing a machine.
379     * @throws ArgumentNotValid If the login is null or the empty string.
380     */
381    public static String writeKillMachineHeader(String login) throws ArgumentNotValid {
382        ArgumentNotValid.checkNotNullOrEmpty(login, "String login");
383        return "echo KILLING MACHINE: " + login + NEWLINE;
384    }
385
386    /**
387     * The header for the start all script for the machine.
388     *
389     * @param login The login to the machine (username@machinename)
390     * @return The echo header for killing a machine.
391     * @throws ArgumentNotValid If the login is null or the empty string.
392     */
393    public static String writeStartMachineHeader(String login) throws ArgumentNotValid {
394        ArgumentNotValid.checkNotNullOrEmpty(login, "String login");
395        return "echo STARTING MACHINE: " + login + NEWLINE;
396    }
397
398    /**
399     * The header for the install all script for the machine.
400     *
401     * @param login The login to the machine (username@machinename)
402     * @return The echo header for killing a machine.
403     * @throws ArgumentNotValid If the login is null or the empty string.
404     */
405    public static String writeInstallMachineHeader(String login) throws ArgumentNotValid {
406        ArgumentNotValid.checkNotNullOrEmpty(login, "String login");
407        return "echo INSTALLING TO MACHINE: " + login + NEWLINE;
408    }
409
410    /**
411     * Changes a string into correct formatted style. The '.vbs' script needs '\\' instead of '\', which is quite
412     * annoying when using regular expressions, since a final '\' in regular expressions is '\\\\', thus '\\' =
413     * '\\\\\\\\' (8).
414     *
415     * @param path The directory path to change to appropriate format.
416     * @return The formatted path.
417     * @throws ArgumentNotValid If the path is null or the empty string.
418     */
419    public static String doubleBackslashes(String path) throws ArgumentNotValid {
420        ArgumentNotValid.checkNotNullOrEmpty(path, "String path");
421        return path.replaceAll("[\\\\]", "\\\\\\\\");
422    }
423
424    /**
425     * Changes a string into correct formatted style. The '.vbs' script needs '\\' instead of '\', which is quite
426     * annoying when using regular expressions, since a final '\' in regular expressions is '/', thus '\\' = '\\\\\\\\'
427     * (8).
428     *
429     * @param path The directory path to change to appropriate format.
430     * @return The formatted path.
431     * @throws ArgumentNotValid If the path is null or the empty string.
432     */
433    public static String replaceWindowsDirSeparators(String path) throws ArgumentNotValid {
434        ArgumentNotValid.checkNotNullOrEmpty(path, "String path");
435        return path.replaceAll("[/]", "\\\\\\\\");
436    }
437
438    /**
439     * For giving readonly permission to a directory in the security policy.
440     *
441     * @param dir The path to the directory. This has to be formatted to have the correct directory separator: '${/}',
442     * instead of '/' or '\\' for Windows and Linux respectively.
443     * @return The permission string.
444     * @throws ArgumentNotValid If the dir is null or the empty string.
445     */
446    public static String writeSecurityPolicyDirPermission(String dir) throws ArgumentNotValid {
447        ArgumentNotValid.checkNotNullOrEmpty(dir, "String dir");
448        return "  permission java.io.FilePermission \"" + dir + "-\", \"read\"" + ";" + "\n";
449    }
450
451    /**
452     * Creates the script for extracting the processes of a specific application, depending on the name of the
453     * application and the settings file.
454     *
455     * @param totalName The total name of the application.
456     * @param path The path to the directory of the settings file (conf-dir).
457     * @param id The identification of the application (name + instanceId).
458     * @return The script for getting the list of running application.
459     * @throws ArgumentNotValid If the totalName, the path or the id is either null or the empty string.
460     */
461    public static String getLinuxPIDS(String totalName, String path, String id) throws ArgumentNotValid {
462        ArgumentNotValid.checkNotNullOrEmpty(totalName, "String totalName");
463        ArgumentNotValid.checkNotNullOrEmpty(path, "String path");
464        ArgumentNotValid.checkNotNullOrEmpty(id, "String id");
465        return "PIDS=$(ps -wwfe | grep " + totalName + " | grep -v grep | grep " + path + "settings_" + id + ".xml"
466                + " | awk \"{print \\$2}\")";
467    }
468
469    // Headers
470    /** The header for the jxmremote.password file. */
471    public static final String JMXREMOTE_PASSWORD_HEADER = "##############################################################"
472            + NEWLINE
473            + "#        Password File for Remote JMX Monitoring"
474            + NEWLINE
475            + "##############################################################"
476            + NEWLINE
477            + "#"
478            + NEWLINE
479            + "# Password file for Remote JMX API access to monitoring.  This"
480            + NEWLINE
481            + "# file defines the different roles and their passwords.  The access"
482            + NEWLINE
483            + "# control file (jmxremote.access by default) defines the allowed"
484            + NEWLINE
485            + "# access for each role.  To be functional, a role must have an entry"
486            + NEWLINE
487            + "# in both the password and the access files."
488            + NEWLINE
489            + "#"
490            + NEWLINE
491            + "# Default location of this file is "
492            + "$JRE/lib/management/jmxremote.password"
493            + NEWLINE
494            + "# You can specify an alternate location by specifying a property in"
495            + NEWLINE
496            + "# the management config file "
497            + "$JRE/lib/management/management.properties"
498            + NEWLINE
499            + "# or by specifying a system property (See that file for details)."
500            + NEWLINE
501            + NEWLINE
502            + NEWLINE
503            + "##############################################################"
504            + NEWLINE
505            + "#    File permissions of the jmxremote.password file"
506            + NEWLINE
507            + "##############################################################"
508            + NEWLINE
509            + "#      Since there are cleartext passwords stored in this file,"
510            + NEWLINE
511            + "#      this file must be readable by ONLY the owner,"
512            + NEWLINE
513            + "#      otherwise the program will exit with an error."
514            + NEWLINE
515            + "#"
516            + NEWLINE
517            + "# The file format for password and access files "
518            + "is syntactically the same"
519            + NEWLINE
520            + "# as the Properties file format.  The syntax is "
521            + "described in the Javadoc"
522            + NEWLINE
523            + "# for java.util.Properties.load."
524            + NEWLINE
525            + "# Typical password file has multiple  lines, "
526            + "where each line is blank,"
527            + NEWLINE
528            + "# a comment (like this one), or a password entry."
529            + NEWLINE
530            + "#"
531            + NEWLINE
532            + "#"
533            + NEWLINE
534            + "# A password entry consists of a role name and an associated"
535            + NEWLINE
536            + "# password. "
537            + " The role name is any string that does not itself contain"
538            + NEWLINE
539            + "# spaces or tabs.  The password is again any string that does not"
540            + NEWLINE
541            + "# contain spaces or tabs. "
542            + " Note that passwords appear in the clear in"
543            + NEWLINE
544            + "# this file, so it is a good idea not to use valuable passwords."
545            + NEWLINE
546            + "#"
547            + NEWLINE
548            + "# A given role should have at most one entry in this file. "
549            + " If a role"
550            + NEWLINE
551            + "# has no entry"
552            + NEWLINE
553            + "# If multiple entries are found for the same role name, "
554            + "then the last one"
555            + NEWLINE
556            + "# is used."
557            + NEWLINE
558            + "#"
559            + NEWLINE
560            + "# In a typical installation, this file can be read by anybody on the"
561            + NEWLINE
562            + "# local machine, and possibly by people on other machines."
563            + NEWLINE
564            + "# For # security, you should either restrict the"
565            + " access to this file,"
566            + NEWLINE
567            + "# or specify another, less accessible file in "
568            + "the management config file"
569            + NEWLINE
570            + "# as described above." + NEWLINE + "#" + NEWLINE;
571    /** The header for the jmxremote.access file. */
572    public static final String JMXREMOTE_ACCESS_HEADER = "#################################################################"
573            + "#####"
574            + NEWLINE
575            + "#Default Access Control File for Remote JMX(TM) Monitoring"
576            + NEWLINE
577            + "################################################################"
578            + "######"
579            + NEWLINE
580            + "#"
581            + NEWLINE
582            + "# Access control file for Remote JMX API access to monitoring."
583            + NEWLINE
584            + "# This file defines the allowed access for different roles.  The"
585            + NEWLINE
586            + "# password file (jmxremote.password by default) defines the "
587            + "roles and their"
588            + NEWLINE
589            + "# passwords.  To be functional, a role must have an entry in"
590            + NEWLINE
591            + "# both the password and the access files."
592            + NEWLINE
593            + "#"
594            + NEWLINE
595            + "# Default location of this file is "
596            + "$JRE/lib/management/jmxremote.access"
597            + NEWLINE
598            + "# You can specify an alternate location by specifying a property in"
599            + NEWLINE
600            + "# the management config file "
601            + "$JRE/lib/management/management.properties"
602            + NEWLINE
603            + "# (See that file for details)"
604            + NEWLINE
605            + "#"
606            + NEWLINE
607            + "# The file format for password and access files is syntactically "
608            + "the same"
609            + NEWLINE
610            + "# as the Properties file format.  The syntax is described in "
611            + "the Javadoc"
612            + NEWLINE
613            + "# for java.util.Properties.load."
614            + NEWLINE
615            + "# Typical access file has multiple  lines, where each line is blank,"
616            + NEWLINE
617            + "# a comment (like this one), or an access control entry."
618            + NEWLINE
619            + "#"
620            + NEWLINE
621            + "# An access control entry consists of a role name, and an"
622            + NEWLINE
623            + "# associated access level.  The role name is any string that "
624            + "does not"
625            + NEWLINE
626            + "# itself contain spaces or tabs.  It corresponds to an entry in the"
627            + NEWLINE
628            + "# password file (jmxremote.password).  The access level is one "
629            + "of the"
630            + NEWLINE
631            + "# following:"
632            + NEWLINE
633            + "#       \"readonly\" grants access to read attributes of MBeans."
634            + NEWLINE
635            + "#                   For monitoring, this means that a remote "
636            + "client in this"
637            + NEWLINE
638            + "#                   role can read measurements but cannot perform "
639            + "any action"
640            + NEWLINE
641            + "#                   that changes the environment of the "
642            + "running program."
643            + NEWLINE
644            + "#       \"readwrite\" grants access to read and write attributes "
645            + "of MBeans,"
646            + NEWLINE
647            + "#                   to invoke operations on them, and to create "
648            + "or remove them."
649            + NEWLINE
650            + "#                   This access should be granted to only "
651            + "trusted clients,"
652            + NEWLINE
653            + "#                   since they can potentially interfere with "
654            + "the smooth"
655            + NEWLINE
656            + "#                   operation of a running program"
657            + NEWLINE
658            + "#"
659            + NEWLINE
660            + "# A given role should have at most one entry in this file.  "
661            + "If a role"
662            + NEWLINE
663            + "# has no entry, it has no access."
664            + NEWLINE
665            + "# If multiple entries are found for the same role name, "
666            + "then the last"
667            + NEWLINE
668            + "# access entry is used."
669            + NEWLINE
670            + "#"
671            + NEWLINE
672            + "#"
673            + NEWLINE
674            + "# Default access control entries:"
675            + NEWLINE
676            + "# o The \"monitorRole\" role has readonly access."
677            + NEWLINE
678            + "# o The \"controlRole\" role has readwrite access." + NEWLINE + "" + NEWLINE;
679
680    static final String ECHO_DELETING_OLD_LIBRARIES = "echo removing old libraries if they exist.";
681
682}