1 kumpf 1.1 //
2 // GlobalConfig.java
3 //
4 // The contents of this file are subject to the SNIA Public License Version 1.0
5 // (the "License"); you may not use this file except in compliance with the
6 // License. You may obtain a copy of the License at
7 //
8 // http://www.snia.org/resources/openSource.html
9 //
10 // Software distributed under the License is distributed on an "AS IS" basis,
11 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
12 // License for the specific language governing rights and limitations
13 // under the License.
14 //
15 // The Original Code is GlobalConfig.java
16 //
17 // The Initial Developer of the Original Code is David Simons.
18 //
19 // Contributor(s): Nag Boranna
20 //
21 //
22 kumpf 1.1 // This source uses the Solaris WBEM APIs version 2.2.
23 // Synchronization will be maintained with the Solaris WBEM APIS,
24 // which are being standardized through the Java Community Process.
25 //
26 //
27 // $Id: GlobalConfig.java,v 1.3 2001/11/04 14:06:56 david Exp $
28 //
29 package org.snia.wbemcfg;
30
31 import java.util.Properties;
32 import java.io.FileInputStream;
33 import java.io.IOException;
34
35 import org.snia.wbemcmd.utils.Log;
36
37
38 /**
39 * GlobalConfig provides config information in a centralized location
40 * These configurations are used by both CIMOM and the client API.
41 * This will use the properties if defined in cim.properties else the
42 * default configuration will be used.
43 kumpf 1.1 *
44 * GlobalConfig defines all the properties as static properties. Once
45 * the GlobalConfig object gets initialized the values can not be changed.
46 *
47 * This class is shared by bith CIMOM and CIM Client API. CIM Clients may not
48 * use all the properties defined here; However, CIMOM may use.
49 */
50 public class GlobalConfig
51 {
52
53 ///////////////////////////////////////////////////////////////////
54 // Following properties are used by both CIMOM and Client API.
55 //
56 ///////////////////////////////////////////////////////////////////
57
58 /**
59 * httpClient specifies the class that will be used
60 * to act as an HTTPClient currently it can be set to either.
61 *
62 */
63 static public String httpClient = "org.snia.wbemcmd.xml.HTTPOutputSimple";
64 kumpf 1.1
65
66 /**
67 * Provides basic XML request, response logging.
68 */
69 static public boolean DEBUG_XML= false;
70
71
72 /**
73 * Provides XML parser level(each XML node) logging.
74 */
75 static public boolean DEBUG_XMLDECODE = false;
76
77
78 /**
79 * Name of file with absolute path used for client Log.
80 */
81 static public String clientLogFilePath = null;
82
83 /**
84 * Default logging file.
85 kumpf 1.1 */
86 static public String defaultLogFile = "log.txt";
87
88
89 /**
90 * Specify the Socket Provider used to create sockets for HTTP
91 * communication.
92 */
93 static public String httpSocketProvider = "org.snia.wbemcmd.xml.PlainSocketProvider";
94
95
96 /**
97 * Specify the Socket Provider used to create sockets for HTTPS
98 * communication.
99 */
100 static public String httpsSocketProvider = "org.snia.wbemcmd.xml.JSSESocketProvider";
101
102
103 /**
104 * Used only with JSSESocketProvider. Remote Clients may specify
105 * their own Certification Manager to use on client side.
106 kumpf 1.1 *
107 * e.g., TrustManager= "org.mycompany.cimapp.myCertManager";
108 */
109 static public String TrustManager = null;
110
111
112 ///////////////////////////////////////////////////////////////////
113 // Following properties are used by CIMOM only.
114 //
115 ///////////////////////////////////////////////////////////////////
116
117 /**
118 disconnectAfterTransfer determines whether the connection is dropped and made
119 for each operation (when true). If false then the connection is held open.
120 Holding the connection open is faster.
121 */
122 static public boolean disconnectAfterTransfer=false;
123
124
125 /**
126 compressStrings when true forces the server to share
127 kumpf 1.1 as much information as possible across definitions to
128 save memory. The impact of this is a slight increase
129 in CPU utilization when creating classes (etc), though
130 not when retrieving AND a potential memory leak. When
131 a class is removed any strings it used won't be.
132 */
133 static public boolean compressStrings=true;
134
135
136 /**
137 Set true if contentLength header is to be set on a response,
138 otherwise the connection will be dropped at the end of the
139 transmission (implies disconnectAfterTransfer). Enable
140 this (set to true) for improved performance.
141 */
142 static public boolean useContentLength=true;
143
144 /**
145 Enables threads when true
146 */
147 static public boolean useThreads=true;
148 kumpf 1.1
149 /**
150 Maximum number of threads for CIMOM
151 */
152 static public int maxThreadCounter=32;
153
154 /**
155 Call yield after sending a request/response
156 */
157 static public boolean forceYield=true;
158
159 /**
160 Specifies whether MOF parsing should be strict. Non strict
161 parsing will allow classes to specify references without
162 being formally qualified as an ASSOCIATION. This is necessary
163 for the DMTF CIM 2.3 schema which does not correctly
164 specify such qualifiers.
165 */
166 static public boolean strictParse=false;
167
168 /**
169 kumpf 1.1 Specifies whether persistence is required for qualifiers,
170 classes and instances
171 */
172 static public boolean usePersistence=true;
173
174 /**
175 basicAuthModule specifies the class that will be used
176 to authenticate a basic authorization
177 */
178 static public String basicAuthModule = "org.snia.wbemcmd.xml.BasicAuthorization";
179
180 //
181 // Set true to enable authorization
182 //
183 static public boolean requireAuthorization=false;
184
185
186 /**
187 Specify persistence directory
188 On Unix systems set the following to /var/sniacimom/persistence
189 */
190 kumpf 1.1 static public String persistenceDir="persistence" + java.io.File.separator;
191
192 /**
193 This specifies whether providers should be called with a Vector
194 of CIMValue instances (when callMethodsWithValues = true) otherwise
195 providers will be called with a Vector of CIMProperty
196 */
197 static public boolean callMethodsWithValues = false;
198
199 /**
200 Set true to enable the delivery of CIMEvents in a concurrent manner (e.g.
201 in a separate Thread). The default value is "false". The purpose of
202 this new property is to control an alternative way to send the
203 events toward the registered CIMProvider(s). Whenever this property
204 is "true" a separate Thread is used for the delivery of the
205 CIMEvent(s) toward the registered CIMProvider(s) in order to prevent
206 the current Thread to be blocked for the time required to execute the
207 handlers. This property can be turned-back to "false" as soon as
208 some reentrancy problems will be appearing into the CIM-Repository
209 or in the provider itself.
210 */
211 kumpf 1.1 static public boolean concurrentDeliveryOfEvents = false;
212
213
214
215 /////////////////////////////////////////////////////////////////////
216 // Set methods to set the properties
217 //
218 /////////////////////////////////////////////////////////////////////
219
220 /**
221 * Sets the httpSocketProvider to the one specified.
222 * @param value - Socket Provider name.
223 */
224 public static void setHTTPSocketProvider(String value )
225 {
226 httpSocketProvider = value;
227 }
228
229 /**
230 * Sets the httpsSocketProvider to the one specified.
231 * @param value - Socket Provider name.
232 kumpf 1.1 */
233 public static void setHTTPSSocketProvider(String value )
234 {
235 httpsSocketProvider = value;
236 }
237
238 /**
239 * Sets the TrustManager to the one specified.
240 * @param value - Trust manager name.
241 */
242 public static void setTrustManager(String value )
243 {
244 TrustManager = value;
245 }
246
247 /**
248 * Sets the httpclient to the one specified.
249 * @param value - httpClient name.
250 */
251 public static void setHttpClient(String value )
252 {
253 kumpf 1.1 httpClient = value;
254 }
255
256 /////////////////////////////////////////////////////////////////////
257 // Load properties from the properties file
258 //
259 /////////////////////////////////////////////////////////////////////
260 static {
261
262 String value = System.getProperty("org.snia.wbem.cimom.properties");
263 if (value!=null)
264 {
265 Properties cfg = new Properties();
266
267 try {
268 FileInputStream ins = new FileInputStream(value);
269 cfg.load(ins);
270
271 // set configuration variables.
272 value = cfg.getProperty("DEBUG_XML");
273 if ( value != null )
274 kumpf 1.1 {
275 DEBUG_XML = new Boolean(value).booleanValue();
276 }
277
278 value = cfg.getProperty("DEBUG_XMLDECODE");
279 if ( value != null )
280 {
281 DEBUG_XMLDECODE = new Boolean(value).booleanValue();;
282 }
283
284 value = cfg.getProperty("clientLogFilePath");
285 if ( value != null )
286 {
287 //TODO: Validate the file path
288 //try
289 //{
290 // File file = new File(value);
291 //
292 //} catch() {
293 //
294 //}
295 kumpf 1.1
296 clientLogFilePath = value;
297
298 //
299 // Set the Log file path
300 //
301 Log.assignLogFileName(clientLogFilePath);
302
303 }
304
305 value = cfg.getProperty("TrustManager");
306 if ( value != null )
307 {
308 TrustManager = value;
309 }
310
311 /*
312
313 // FOR 2.0 added by Bapu
314 value = cfg.getProperty("basicAuthModule");
315 if ( value != null)
316 kumpf 1.1 basicAuthModule = value;
317
318 value = cfg.getProperty("requireAuthorization");
319 if ( value != null )
320 requireAuthorization = new Boolean(value).booleanValue();
321 // end of FOR 2.0 added by Bapu
322
323 value = cfg.getProperty("httpClient");
324 if ( value != null)
325 {
326 httpClient = value;
327 }
328
329 value = cfg.getProperty("httpSocketProvider");
330 if ( value != null )
331 {
332 httpSocketProvider = value;
333 }
334
335 value = cfg.getProperty("httpsSocketProvider");
336 if ( value != null )
337 kumpf 1.1 {
338 httpsSocketProvider = value;
339 }
340
341 */
342
343 } catch ( IOException e ) {
344 Log.println("Could not find the property file.\n");
345 } catch ( Exception e ) {
346 Log.println("Error setting properties, " +
347 "default configurations are used.\n");
348 }
349 }
350 }
351
352 }
|