Main.java revision 0
2362N/A * Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Sun designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Sun in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 2362N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * The main entry point into AppletViewer. 0N/A * The file which contains all of the AppletViewer specific properties. 0N/A * The default key/value pairs for the required user-specific properties. 0N/A // There's a bootstrapping problem here. If we don't have a proxyHost, 0N/A // then we will not be able to connect to a URL outside the firewall; // however, there's no way for us to set the proxyHost without starting // AppletViewer. This problem existed before the re-write. {
"http.proxyPort",
"80"},
{
"package.restrict.access.sun",
"true"}
// make sure we can write to this location * Member variables set according to options passed in to AppletViewer. * The list of valid URLs passed in to AppletViewer. // This is used in init(). Getting rid of this is desirable but depends * The main entry point into AppletViewer. // Exit immediately if we got some sort of error along the way. // For debugging purposes, if we have passed in "-XcmdLineTest" we // force a premature exit. // Given the current architecture, we will end up decoding the // arguments again, but at least we are guaranteed to have // arguments which are valid. // INSTALL THE SECURITY MANAGER (if necessary) // LAUNCH APPLETVIEWER FOR EACH URL // XXX 5/17 this parsing method should be changed/fixed so that // it doesn't do both parsing of the html file and launching of private static void usage() {
* Decode a single argument in an array and return the number of elements * @param args The array of arguments. * @param i The argument to decode. * @return The number of array elements used when the argument was * @exception ParseException * Thrown when there is a problem with something in the // This is an undocumented (and, in the future, unsupported) // flag which prevents AppletViewer from installing its own // This is an internal flag which should be used for command-line // testing. It instructs AppletViewer to force a premature exit // immediately after the applet has been launched. // we found what we hope is a url * Following the relevant RFC, construct a valid URL based on the passed in * @param url a string which represents either a relative or absolute URL. * @return a URL when the passed in string can be interpreted according * to the RFC, <code>null</code> otherwise. * @exception ParseException * Thrown when we are unable to construct a proper URL from the // prefix of the urls with 'file' scheme // appletviewer accepts only unencoded filesystem paths // ensure that this file URL is absolute // ParseUtil.fileToEncodedURL should be done last (see 6329251) // appletviewer accepts only encoded urls * Invoke the debugger with the arguments passed in to appletviewer. * @param args The arguments passed into the debugger. * @return <code>0</code> if the debugger is invoked successfully, * <code>1</code> otherwise. // CONSTRUCT THE COMMAND LINE // Add a -classpath argument that prevents // the debugger from launching appletviewer with the default of // ".". appletviewer's classpath should never contain valid // classes since they will result in security exceptions. // Ideally, the classpath should be set to "", but the VM won't // allow an empty classpath, so a phony directory name is used. // Appletviewer's main class is the debuggee // Append all the of the original appletviewer arguments, // leaving out the "-debug" option. // Reflection is used for two reasons: // 1) The debugger classes are on classpath and thus must be loaded // by the application class loader. (Currently, appletviewer are // loaded through the boot class path out of rt.jar.) // 2) Reflection removes any build dependency between appletviewer // GET APPLETVIEWER USER-SPECIFIC PROPERTIES // ADD OTHER RANDOM PROPERTIES // XXX 5/18 need to revisit why these are here, is there some // standard for what is available? // Standard browser properties avProps.
put(
"browser",
"sun.applet.AppletViewer");
avProps.
put(
"browser.vendor",
"Sun Microsystems Inc.");
// Define which packages can be extended by applets // XXX 5/19 probably not needed, not checked in AppletSecurity avProps.
put(
"package.restrict.definition.sun",
"true");
// Define which properties can be read by applets. // A property named by "key" can be read only when its twin // property "key.applet" is true. The following ten properties // are open by default. Any other property can be explicitly // opened up by the browser user by calling appletviewer with // Read in the System properties. If something is going to be // over-written, warn about it. // INSTALL THE PROPERTY LIST // Create and install the security manager // REMIND: Create and install a socket factory! * Read the AppletViewer user-specific properties. Typically, these * properties should reside in the file $USER/.appletviewer. If this file * does not exist, one will be created. Information for this file will * then default values will be used. * @return A Properties object containing all of the AppletViewer * user-specific properties. // we must have already done the conversion // send out warning and use defaults // create the $USER/.appletviewer file // send out warning and use defaults * Set the AppletViewer user-specific properties to be the default values. * @return A Properties object containing all of the AppletViewer * user-specific properties, set to the default values. * Given a file, find only the properties that are setable by AppletViewer. * @param inFile A Properties file from which we select the properties of * @return A Properties object containing all of the AppletViewer * user-specific properties. // pick off the properties we care about // the property exists in the file, so replace the default * Methods for easier i18n handling.