home *** CD-ROM | disk | FTP | other *** search
- package sun.activator.panel;
-
- import java.io.BufferedInputStream;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.util.Observable;
- import java.util.Properties;
- import sun.activator.AppletMessageHandler;
- import sun.activator.AppletViewer;
-
- public class ConfigurationInfo extends Observable {
- private static File theUserPropertiesFile;
- private Properties props;
- private String[] networkAccessTable = new String[3];
- private String[] classAccessTable = new String[2];
- private String[] unsignedAppletTable = new String[2];
- private boolean debugMode;
- private boolean activatorEnabled;
- private boolean showConsole;
- private boolean useJIT = false;
- private String JITPath;
- private int networkMode;
- private int classAccess;
- private int unsignedAccess;
- private String debugPort;
- private String[] installedJavaVersion;
- private String jdk;
- private boolean useDefaultProxy;
- private boolean useSameProxy;
- private String proxySettings;
- private static final String networkKey = "appletviewer.security.mode";
- static final int NETWORK_NONE = 0;
- static final int NETWORK_HOST = 1;
- static final int NETWORK_UNRESTRICTED = 2;
- private static final String classKey = "package.restrict.access.netscape";
- private static final int CLASS_ACCESS_RESTRICTED = 0;
- private static final int CLASS_ACCESS_UNRESTRICTED = 1;
- private static final String unsignedKey = "appletviewer.security.allowUnsigned";
- private static final int UNSIGNED_ACCESS_NO = 0;
- private static final int UNSIGNED_ACCESS_YES = 1;
- private static AppletMessageHandler amh = new AppletMessageHandler("appletprops");
-
- public ConfigurationInfo() {
- if (theUserPropertiesFile == null) {
- String var1 = File.separator;
- theUserPropertiesFile = new File(System.getProperty("user.home") + var1 + ".java" + var1 + "properties");
- (new File(theUserPropertiesFile.getParent())).mkdirs();
- }
-
- this.initialize();
- this.reset();
- }
-
- public void applyChanges() {
- this.props.put("activator.version", AppletViewer.theVersion);
- this.props.put("activator.console", this.showConsole ? "true" : "false");
- this.props.put("activator.enabled", this.activatorEnabled ? "true" : "false");
- if (this.classAccess == 0) {
- this.props.put("package.restrict.access.sun", "true");
- this.props.put("package.restrict.access.netscape", "true");
- } else {
- this.props.put("package.restrict.access.sun", "false");
- this.props.put("package.restrict.access.netscape", "false");
- }
-
- if (this.networkMode == 0) {
- this.props.put("appletviewer.security.mode", "none");
- } else if (this.networkMode == 2) {
- this.props.put("appletviewer.security.mode", "unrestricted");
- } else {
- this.props.put("appletviewer.security.mode", "host");
- }
-
- if (this.unsignedAccess == 0) {
- this.props.put("appletviewer.security.allowUnsigned", "false");
- } else {
- this.props.put("appletviewer.security.allowUnsigned", "true");
- }
-
- if (this.debugMode) {
- this.props.put("activator.debug.mode", "true");
- this.props.put("activator.debug.port", this.debugPort);
- } else {
- this.props.put("activator.debug.mode", "false");
- }
-
- if (this.useDefaultProxy) {
- this.props.put("activator.proxy.usebrowsersettings", "true");
- } else {
- this.props.put("activator.proxy.usebrowsersettings", "false");
- }
-
- if (this.proxySettings != null) {
- this.props.put("activator.proxy.settings", this.proxySettings);
- } else {
- this.props.remove("activator.proxy.settings");
- }
-
- if (this.useSameProxy) {
- this.props.put("activator.proxy.forallprotocols", "true");
- } else {
- this.props.put("activator.proxy.forallprotocols", "false");
- }
-
- if (this.jdk != null) {
- this.props.put("activator.jre.path", this.jdk);
- } else {
- this.props.remove("activator.jre.path");
- }
-
- try {
- FileOutputStream var1 = new FileOutputStream(theUserPropertiesFile);
- this.props.save(var1, " Java Properties");
- var1.close();
- } catch (IOException var2) {
- System.out.println(amh.getMessage("apply.exception", var2));
- ((Throwable)var2).printStackTrace();
- }
-
- }
-
- public String getClassAcccessLabel() {
- return amh.getMessage("label.class");
- }
-
- public int getClassAccessLevel() {
- return this.classAccess;
- }
-
- public String[] getClassAccessLevels() {
- return this.classAccessTable;
- }
-
- public String getDebugPort() {
- return this.debugPort;
- }
-
- public String[] getInstalledJavaList() {
- return this.installedJavaVersion;
- }
-
- public String getJDK() {
- return this.jdk;
- }
-
- public String getJITPath() {
- return this.JITPath;
- }
-
- public String getMessage(String var1) {
- return amh.getMessage(var1);
- }
-
- public String getNetworkAccessLabel() {
- return amh.getMessage("label.network");
- }
-
- public int getNetworkAccessLevel() {
- return this.networkMode;
- }
-
- public String[] getNetworkAccessLevels() {
- return this.networkAccessTable;
- }
-
- public String getProxySettingsString() {
- return this.proxySettings;
- }
-
- public String[] getSupportedVersionList() {
- String[] var1 = new String[]{"1.1", "1.2"};
- return var1;
- }
-
- public int getUnsignedAccessLevel() {
- return this.unsignedAccess;
- }
-
- public String[] getUnsignedAccessLevels() {
- return this.unsignedAppletTable;
- }
-
- public String getUnsignedAppletChoice() {
- return amh.getMessage("label.unsignedapplet");
- }
-
- private void initialize() {
- this.networkAccessTable[0] = amh.getMessage("choice.network.item.none");
- this.networkAccessTable[1] = amh.getMessage("choice.network.item.applethost");
- this.networkAccessTable[2] = amh.getMessage("choice.network.item.unrestricted");
- this.classAccessTable[0] = amh.getMessage("choice.class.item.restricted");
- this.classAccessTable[1] = amh.getMessage("choice.class.item.unrestricted");
- this.unsignedAppletTable[0] = amh.getMessage("choice.unsignedapplet.no");
- this.unsignedAppletTable[1] = amh.getMessage("choice.unsignedapplet.yes");
- }
-
- public boolean isConsoleEnabled() {
- return this.showConsole;
- }
-
- public boolean isDebugEnabled() {
- return this.debugMode;
- }
-
- public boolean isJITEnabled() {
- return this.useJIT;
- }
-
- public boolean isJavaEnabled() {
- return this.activatorEnabled;
- }
-
- public void reset() {
- this.setChanged("All");
- this.props = new Properties();
-
- try {
- FileInputStream var1 = new FileInputStream(theUserPropertiesFile);
- this.props.load(new BufferedInputStream(var1));
- var1.close();
- } catch (Exception var2) {
- System.out.println("[no properties loaded, using defaults]");
- }
-
- String var3 = this.props.getProperty("activator.console");
- if (var3 != null && var3.equals("true")) {
- this.showConsole = true;
- } else {
- this.showConsole = false;
- }
-
- var3 = this.props.getProperty("activator.enabled");
- if (var3 != null && !var3.equals("true")) {
- this.activatorEnabled = false;
- } else {
- this.activatorEnabled = true;
- }
-
- var3 = this.props.getProperty("appletviewer.security.mode");
- if (var3 == null) {
- this.setNetworkAccessLevel(1);
- } else if (var3.equals("none")) {
- this.setNetworkAccessLevel(0);
- } else if (var3.equals("unrestricted")) {
- this.setNetworkAccessLevel(2);
- } else {
- this.setNetworkAccessLevel(1);
- }
-
- var3 = this.props.getProperty("package.restrict.access.netscape");
- if (var3 != null && !var3.equals("true")) {
- this.setClassAccessLevel(1);
- } else {
- this.setClassAccessLevel(0);
- }
-
- var3 = this.props.getProperty("appletviewer.security.allowUnsigned");
- if (var3 != null && !var3.equals("true")) {
- this.setUnsignedAccessLevel(0);
- } else {
- this.setUnsignedAccessLevel(1);
- }
-
- var3 = this.props.getProperty("activator.debug.mode");
- if (var3 != null && var3.equals("true")) {
- this.debugMode = true;
- } else {
- this.debugMode = false;
- }
-
- this.debugPort = this.props.getProperty("activator.debug.port");
- if (this.debugPort == null) {
- this.debugPort = "2502";
- }
-
- var3 = this.props.getProperty("activator.proxy.usebrowsersettings");
- if (var3 != null && !var3.equals("true")) {
- this.useDefaultProxy = false;
- } else {
- this.useDefaultProxy = true;
- }
-
- this.proxySettings = this.props.getProperty("activator.proxy.settings");
- var3 = this.props.getProperty("activator.proxy.forallprotocols");
- this.useSameProxy = "true".equals(var3);
- this.jdk = this.props.getProperty("activator.jre.path");
- }
-
- protected void setChanged(String var1) {
- super.setChanged();
- ((Observable)this).notifyObservers(var1);
- }
-
- public void setClassAccessLevel(int var1) {
- this.classAccess = var1;
- this.setChanged("Class Access");
- }
-
- public void setConsoleEnabled(boolean var1) {
- this.showConsole = var1;
- this.setChanged("Show Console");
- }
-
- public void setDebugEnabled(boolean var1) {
- this.debugMode = var1;
- this.setChanged("Debug Mode");
- }
-
- public void setDebugPort(String var1) {
- this.debugPort = var1;
- this.setChanged("Debug Port");
- }
-
- public void setDefaultProxySettings(boolean var1) {
- this.useDefaultProxy = var1;
- this.setChanged("Default Proxy Settings");
- }
-
- public void setInstalledJavaList(String[] var1) {
- this.installedJavaVersion = var1;
- }
-
- public void setJDK(String var1) {
- this.jdk = var1;
- this.setChanged("JDK");
- }
-
- public void setJITEnabled(boolean var1) {
- this.useJIT = var1;
- this.setChanged("Use JIT");
- }
-
- public void setJITPath(String var1) {
- this.JITPath = var1;
- this.setChanged("JIT Path");
- }
-
- public void setJavaEnabled(boolean var1) {
- this.activatorEnabled = var1;
- this.setChanged("Java Enabled");
- }
-
- public void setNetworkAccessLevel(int var1) {
- this.networkMode = var1;
- this.setChanged("Network Access");
- }
-
- public void setProxySettingsString(String var1) {
- this.proxySettings = var1;
- this.setChanged("Proxy String");
- }
-
- public void setUnsignedAccessLevel(int var1) {
- this.unsignedAccess = var1;
- this.setChanged("Unsigned Access");
- }
-
- public void setUseSameProxy(boolean var1) {
- this.useSameProxy = var1;
- this.setChanged("Same Proxy Settings");
- }
-
- public boolean useDefaultProxy() {
- return this.useDefaultProxy;
- }
-
- public boolean useSameProxy() {
- return this.useSameProxy;
- }
- }
-