/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* The main entry point into AppletViewer.
*/
public class Main {
/**
* The file which contains all of the AppletViewer specific properties.
*/
/**
*/
// There's a bootstrapping problem here. If we don't have a proxyHost,
// 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.proxyHost", ""},
{"http.proxyPort", "80"},
{"package.restrict.access.sun", "true"}
};
static {
// make sure we can write to this location
}
// i18n
/**
* Member variables set according to options passed in to AppletViewer.
*/
private boolean debugFlag = false;
private boolean helpFlag = false;
private boolean noSecurityFlag = false;
private static boolean cmdLineTestFlag = false;
/**
* 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.
}
// DECODE ARGS
try {
usage();
return 0;
}
if (j == 0) {
args[i]));
}
i += j;
}
} catch (ParseException e) {
return 1;
}
// CHECK ARGUMENTS
if (helpFlag) {
usage();
return 0;
}
return 1;
}
if (debugFlag) {
// START A DEBUG SESSION
// Given the current architecture, we will end up decoding the
// arguments again, but at least we are guaranteed to have
// arguments which are valid.
return invokeDebugger(args);
}
// INSTALL THE SECURITY MANAGER (if necessary)
init();
// LAUNCH APPLETVIEWER FOR EACH URL
try {
// it doesn't do both parsing of the html file and launching of
// the AppletPanel
} catch (IOException e) {
return 1;
}
}
return 0;
}
private static void usage() {
}
/**
* Decode a single argument in an array and return the number of elements
* used.
*
* @param args The array of arguments.
* @param i The argument to decode.
* @return The number of array elements used when the argument was
* decoded.
* @exception ParseException
* Thrown when there is a problem with something in the
* argument array.
*/
helpFlag = true;
return 1;
return 2;
debugFlag = true;
return 1;
// This is an undocumented (and, in the future, unsupported)
// flag which prevents AppletViewer from installing its own
// SecurityManager.
noSecurityFlag = true;
return 1;
// 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.
cmdLineTestFlag = true;
return 1;
} else {
// we found what we hope is a url
return 1;
}
}
return 0;
}
/**
* Following the relevant RFC, construct a valid URL based on the passed in
* string.
*
* @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
* passed in string.
*/
// prefix of the urls with 'file' scheme
try {
{
// appletviewer accepts only unencoded filesystem paths
{
// relative file URL, like this "file:index.html"
// ensure that this file URL is absolute
// ParseUtil.fileToEncodedURL should be done last (see 6329251)
} else {
// appletviewer accepts only encoded urls
}
} catch (MalformedURLException e) {
url, e.getMessage()));
}
return u;
}
/**
* 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
int current = 0;
// 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.
}
}
// LAUNCH THE DEBUGGER
// 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
// and jdb.
try {
} catch (ClassNotFoundException cnfe) {
return 1;
} catch (NoSuchMethodException nsme) {
return 1;
} catch (InvocationTargetException ite) {
return 1;
} catch (IllegalAccessException iae) {
return 1;
}
return 0;
}
private void init() {
// 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
// Define which packages can be extended by applets
// XXX 5/19 probably not needed, not checked in AppletSecurity
// 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
// -J-Dkey.applet=true
// 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
if (!noSecurityFlag) {
} else {
}
// 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
* be gleaned from $USER/.hotjava/properties. If that file does not exist,
* 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
// just read the file
} else {
// send out warning and use defaults
avProps = setDefaultAVProps();
}
} else {
// create the $USER/.appletviewer file
// see if $USER/.hotjava/properties exists
// just read the file
} else {
// send out warning and use defaults
avProps = setDefaultAVProps();
}
// SAVE THE FILE
try {
} catch (IOException e) {
}
}
return avProps;
}
/**
* 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.
*/
avDefaultUserProps[i][1]);
}
return avProps;
}
/**
* Given a file, find only the properties that are setable by AppletViewer.
*
* @param inFile A Properties file from which we select the properties of
* interest.
* @return A Properties object containing all of the AppletViewer
* user-specific properties.
*/
// read the file
try {
} catch (IOException e) {
}
// pick off the properties we care about
// the property exists in the file, so replace the default
} else {
// just use the default
avDefaultUserProps[i][1]);
}
}
return avProps;
}
/**
* Methods for easier i18n handling.
*/
}
}
}
}
{
super(msg);
}
super(t.getMessage());
this.t = t;
}
}
}