update dev300-m58
[ooovba.git] / sj2 / stardiv / controller / SjSettings.java
blob74d570353b29c87d8804967011e4680292d18839
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SjSettings.java,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package stardiv.controller;
33 import java.util.Properties;
34 import java.util.Hashtable;
35 import java.util.Enumeration;
37 import com.sun.star.lib.sandbox.SandboxSecurity;
39 /**
40 * Ueber diese Klasse werden alle globalen Einstellungen, die fuer das Sj Projekt
41 * wichtig sind, dokumentiert und modifiziert.
43 * @version $Version: 1.0 $
44 * @author Markus Meyer
47 public class SjSettings {
48 /**
49 * The following properties are used to setup the environment for
50 * the stardiv packages.<BR>
51 * "appletviewer.security.mode"="unrestricted" | "host" | "none": Set the
52 * security level of the default SecurityManager. The default is "host".<BR>
53 * "stardiv.security.defaultSecurityManager"="true" | "false": Create and set
54 * the stardiv.security.AppletSecurity, if the property is "true". This occures
55 * only in the first call.<BR>
56 * "stardiv.security.noExit"="true" | "false": no exit is allowed. Use this property
57 * if you are running more than one java application in the virtual machine. This occures
58 * only in the first call.<BR>
59 * "stardiv.security.disableSecurity"="true" | "false": disable security checking. Only usefull
60 * if a SecurityManager is installed. The default is "false".<BR>
61 * if you are running more than one java application in the virtual machine. This occures
62 * only in the first call.<BR>
63 * "stardiv.js.debugOnError"="true" | "false": Start the javascript ide, if an error
64 * occures. The default is "false".<BR>
65 * "stardiv.js.debugImmediate"="true" | "false": Start the javascript ide, if a script
66 * starts. The default is "false".<BR>
67 * "stardiv.debug.trace"="messageBox" | "window" | "file" | "none": The trace pipe is
68 * set to one of the four mediums. The Default is "none".<BR>
69 * "stardiv.debug.error"="messageBox" | "window" | "file" | "none": The error pipe is
70 * set to one of the four mediums. The Default is "none".<BR>
71 * "stardiv.debug.warning"="messageBox" | "window" | "file" | "none": The warning pipe is
72 * set to one of the four mediums. The Default is "none".<BR>
73 * If the properties http.proxyHost, http.proxyPort, http.maxConnections,
74 * http.keepAlive or http.nonProxyHosts are changed, the method
75 * sun.net.www.http.HttpClient.resetProperties() is called.<BR>
76 * If the properties ftpProxySet, ftpProxyHost or ftpProxyPort are changed,
77 * the static variables useFtpProxy, ftpProxyHost and ftpProxyPort in the class
78 * sun.net.ftp.FtpClient are set.<BR>
79 * <B>If you are writing your own SecurityManager and ClassLoader, please implement the
80 * interfaces stardiv.security.ClassLoaderExtension and
81 * stardiv.security.SecurityManagerExtension. Be shure to set the
82 * stardiv.security.ClassLoaderFactory, to enable dynamic class loading, otherwise
83 * the stardiv.security.AppletClassLoader is used. Set the factory with
84 * SjSettings.setClassLoaderFactory().</B>
86 static public synchronized void changeProperties( Properties pChangeProps )
88 SecurityManager pSM = System.getSecurityManager();
89 if( pSM != null )
90 pSM.checkPropertiesAccess();
91 Properties props = new Properties( System.getProperties() );
92 boolean bInited = Boolean.getBoolean( "stardiv.controller.SjSettings.inited" );
95 if( !bInited )
97 // check the awt.toolkit property: if none is set use com.sun.star.comp.jawt.peer.Toolkit
98 //if ( props.getProperty("awt.toolkit") == null )
99 // props.put("awt.toolkit", "com.sun.star.comp.jawt.peer.Toolkit");
101 // Define a number of standard properties
102 props.put("acl.read", "+");
103 props.put("acl.read.default", "");
104 props.put("acl.write", "+");
105 props.put("acl.write.default", "");
107 // Standard browser properties
108 props.put("browser", "stardiv.applet.AppletViewerFrame");
109 props.put("browser.version", "4.02");
110 props.put("browser.vendor", "Sun Microsystems, Inc.");
111 props.put("http.agent", "JDK/1.1");
113 // Define which packages can be accessed by applets
114 props.put("package.restrict.access.sun", "true");
115 props.put("package.restrict.access.netscape", "true");
116 props.put("package.restrict.access.stardiv", "true");
118 // Define which packages can be extended by applets
119 props.put("package.restrict.definition.java", "true");
120 props.put("package.restrict.definition.sun", "true");
121 props.put("package.restrict.definition.netscape", "true");
122 props.put("package.restrict.definition.stardiv", "true");
124 // Define which properties can be read by applets.
125 // A property named by "key" can be read only when its twin
126 // property "key.applet" is true. The following ten properties
127 // are open by default. Any other property can be explicitly
128 // opened up by the browser user setting key.applet=true in
129 // ~/.hotjava/properties. Or vice versa, any of the following can
130 // be overridden by the user's properties.
131 props.put("java.version.applet", "true");
132 props.put("java.vendor.applet", "true");
133 props.put("java.vendor.url.applet", "true");
134 props.put("java.class.version.applet", "true");
135 props.put("os.name.applet", "true");
136 props.put("os.version.applet", "true");
137 props.put("os.arch.applet", "true");
138 props.put("file.separator.applet", "true");
139 props.put("path.separator.applet", "true");
140 props.put("line.separator.applet", "true");
144 // put new and changed properties to the property table
145 if( pChangeProps != null )
147 Enumeration aEnum = pChangeProps.propertyNames();
148 while( aEnum.hasMoreElements() )
150 String aKey = (String)aEnum.nextElement();
151 props.put( aKey, pChangeProps.getProperty( aKey ) );
155 // Install a property list.
156 if( !bInited )
157 props.put( "stardiv.controller.SjSettings.inited", "true" );
158 System.setProperties(props);
159 if( !bInited )
161 // Security Manager setzten
162 boolean bNoExit = Boolean.getBoolean( "stardiv.security.noExit" );
163 //Create and install the security manager
164 if (System.getSecurityManager() == null)
165 System.setSecurityManager(new SandboxSecurity(bNoExit));
167 // if( Boolean.getBoolean("stardiv.controller.installConsole") )
168 // Console.installConsole();
172 private static boolean equalsImpl( Object p1, Object p2 )
174 return p1 == p2 || (p1 != null && p2 != null && p1.equals( p2 ) );