Main.java revision 3183
2362N/A * Copyright (c) 1999, 2006, Oracle and/or its affiliates. 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. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 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; 0N/A // however, there's no way for us to set the proxyHost without starting 0N/A // AppletViewer. This problem existed before the re-write. 0N/A {
"http.proxyHost",
""},
0N/A {
"http.proxyPort",
"80"},
0N/A {
"package.restrict.access.sun",
"true"}
0N/A // make sure we can write to this location 0N/A * Member variables set according to options passed in to AppletViewer. 0N/A * The list of valid URLs passed in to AppletViewer. 0N/A // This is used in init(). Getting rid of this is desirable but depends 0N/A * The main entry point into AppletViewer. 0N/A // Exit immediately if we got some sort of error along the way. 0N/A // For debugging purposes, if we have passed in "-XcmdLineTest" we 0N/A // force a premature exit. 0N/A // START A DEBUG SESSION 0N/A // Given the current architecture, we will end up decoding the 0N/A // arguments again, but at least we are guaranteed to have 0N/A // arguments which are valid. 0N/A // INSTALL THE SECURITY MANAGER (if necessary) 0N/A // LAUNCH APPLETVIEWER FOR EACH URL 0N/A // it doesn't do both parsing of the html file and launching of 0N/A * Decode a single argument in an array and return the number of elements 0N/A * @param args The array of arguments. 0N/A * @param i The argument to decode. 0N/A * @return The number of array elements used when the argument was 0N/A * @exception ParseException 0N/A * Thrown when there is a problem with something in the 0N/A // This is an undocumented (and, in the future, unsupported) 0N/A // flag which prevents AppletViewer from installing its own 0N/A // This is an internal flag which should be used for command-line 0N/A // testing. It instructs AppletViewer to force a premature exit 0N/A // immediately after the applet has been launched. 0N/A // we found what we hope is a url 0N/A * Following the relevant RFC, construct a valid URL based on the passed in 0N/A * @param url a string which represents either a relative or absolute URL. 0N/A * @return a URL when the passed in string can be interpreted according 0N/A * to the RFC, <code>null</code> otherwise. 0N/A * @exception ParseException 0N/A * Thrown when we are unable to construct a proper URL from the 0N/A // prefix of the urls with 'file' scheme 0N/A // appletviewer accepts only unencoded filesystem paths 0N/A // ensure that this file URL is absolute 0N/A // ParseUtil.fileToEncodedURL should be done last (see 6329251) 0N/A // appletviewer accepts only encoded urls 0N/A * Invoke the debugger with the arguments passed in to appletviewer. 0N/A * @param args The arguments passed into the debugger. 0N/A * @return <code>0</code> if the debugger is invoked successfully, 0N/A * <code>1</code> otherwise. 0N/A // CONSTRUCT THE COMMAND LINE 0N/A // Add a -classpath argument that prevents 0N/A // the debugger from launching appletviewer with the default of 0N/A // ".". appletviewer's classpath should never contain valid 0N/A // classes since they will result in security exceptions. 0N/A // Ideally, the classpath should be set to "", but the VM won't 0N/A // allow an empty classpath, so a phony directory name is used. 0N/A // Appletviewer's main class is the debuggee 0N/A // Append all the of the original appletviewer arguments, 0N/A // leaving out the "-debug" option. 0N/A // LAUNCH THE DEBUGGER 0N/A // Reflection is used for two reasons: 0N/A // 1) The debugger classes are on classpath and thus must be loaded 0N/A // by the application class loader. (Currently, appletviewer are 0N/A // loaded through the boot class path out of rt.jar.) 0N/A // 2) Reflection removes any build dependency between appletviewer 0N/A // GET APPLETVIEWER USER-SPECIFIC PROPERTIES 0N/A // ADD OTHER RANDOM PROPERTIES 0N/A // XXX 5/18 need to revisit why these are here, is there some 0N/A // standard for what is available? 0N/A // Standard browser properties 0N/A // Define which packages can be extended by applets 0N/A // XXX 5/19 probably not needed, not checked in AppletSecurity 0N/A // Define which properties can be read by applets. 0N/A // A property named by "key" can be read only when its twin 0N/A // property "key.applet" is true. The following ten properties 0N/A // are open by default. Any other property can be explicitly 0N/A // opened up by the browser user by calling appletviewer with 0N/A // -J-Dkey.applet=true 0N/A // Read in the System properties. If something is going to be 0N/A // over-written, warn about it. 0N/A // INSTALL THE PROPERTY LIST 0N/A // Create and install the security manager 0N/A // REMIND: Create and install a socket factory! 0N/A * Read the AppletViewer user-specific properties. Typically, these 0N/A * properties should reside in the file $USER/.appletviewer. If this file 0N/A * does not exist, one will be created. Information for this file will 0N/A * then default values will be used. 0N/A * @return A Properties object containing all of the AppletViewer 0N/A * user-specific properties. 0N/A // we must have already done the conversion 0N/A // just read the file 0N/A // send out warning and use defaults 0N/A // create the $USER/.appletviewer file 0N/A // just read the file 0N/A // send out warning and use defaults 0N/A * Set the AppletViewer user-specific properties to be the default values. 0N/A * @return A Properties object containing all of the AppletViewer 0N/A * user-specific properties, set to the default values. 0N/A * Given a file, find only the properties that are setable by AppletViewer. 0N/A * @param inFile A Properties file from which we select the properties of 0N/A * @return A Properties object containing all of the AppletViewer 0N/A * user-specific properties. 0N/A // pick off the properties we care about 0N/A // the property exists in the file, so replace the default 0N/A // just use the default 0N/A * Methods for easier i18n handling.