// // GlobalConfig.java // // The contents of this file are subject to the SNIA Public License Version 1.0 // (the "License"); you may not use this file except in compliance with the // License. You may obtain a copy of the License at // // http://www.snia.org/resources/openSource.html // // Software distributed under the License is distributed on an "AS IS" basis, // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the // License for the specific language governing rights and limitations // under the License. // // The Original Code is GlobalConfig.java // // The Initial Developer of the Original Code is David Simons. // // Contributor(s): Nag Boranna // Bapu Patil // // // This source uses the Solaris WBEM APIs version 2.2. // Synchronization will be maintained with the Solaris WBEM APIS, // which are being standardized through the Java Community Process. // // // $Id: GlobalConfig.java,v 1.6 2006/10/09 13:32:04 mateus.baur Exp $ // package org.snia.wbemcfg; import java.util.Properties; import java.io.FileInputStream; import java.io.IOException; import org.snia.wbemcmd.utils.Log; /** * GlobalConfig provides config information in a centralized location * These configurations are used by both CIMOM and the client API. * This will use the properties if defined in cim.properties else the * default configuration will be used. * * GlobalConfig defines all the properties as static properties. Once * the GlobalConfig object gets initialized the values can not be changed. * * This class is shared by bith CIMOM and CIM Client API. CIM Clients may not * use all the properties defined here; However, CIMOM may use. */ public class GlobalConfig { /////////////////////////////////////////////////////////////////// // Following properties are used by both CIMOM and Client API. // /////////////////////////////////////////////////////////////////// /** * useHTTP11 specifies if HTTP11 (which includes M-POST) should * used. * */ static public boolean useHTTP11 = true; // For 2.0 static public String PACKAGE_DESCRIPTION = "Java CIM Client and" + " CIM Listener SDK Version"; static public String PACKAGE_VERSION="2.6 (May 12 2006)"; /** * httpClient specifies the class that will be used * to act as an HTTPClient currently it can be set to either. * */ static public String httpClient = "org.snia.wbemcmd.xml.HTTPOutputSimple"; /** * Provides basic XML request, response logging. */ static public boolean DEBUG_XML= false; /** * Provides XML parser level(each XML node) logging. */ static public boolean DEBUG_XMLDECODE = false; /** * Name of file with absolute path used for client Log. */ static public String clientLogFilePath = null; /** * Default logging file. */ static public String defaultLogFile = "log.txt"; /** * Specify the Socket Provider used to create sockets for HTTP * communication. */ static public String httpSocketProvider = "org.snia.wbemcmd.xml.PlainSocketProvider"; /** * Specify the Socket Provider used to create sockets for HTTPS * communication. */ static public String httpsSocketProvider = "org.snia.wbemcmd.xml.JSSESocketProvider"; /** * Used only with JSSESocketProvider. Remote Clients may specify * their own Certification Manager to use on client side. * * e.g., TrustManager= "org.mycompany.cimapp.myCertManager"; */ static public String TrustManager = null; /////////////////////////////////////////////////////////////////// // Following properties are used by CIMOM only. // /////////////////////////////////////////////////////////////////// /** disconnectAfterTransfer determines whether the connection is dropped and made for each operation (when true). If false then the connection is held open. Holding the connection open is faster. */ static public boolean disconnectAfterTransfer=false; /** compressStrings when true forces the server to share as much information as possible across definitions to save memory. The impact of this is a slight increase in CPU utilization when creating classes (etc), though not when retrieving AND a potential memory leak. When a class is removed any strings it used won't be. */ static public boolean compressStrings=true; /** Set true if contentLength header is to be set on a response, otherwise the connection will be dropped at the end of the transmission (implies disconnectAfterTransfer). Enable this (set to true) for improved performance. */ static public boolean useContentLength=true; /** Enables threads when true */ static public boolean useThreads=true; /** Maximum number of threads for CIMOM */ static public int maxThreadCounter=32; /** Call yield after sending a request/response */ static public boolean forceYield=true; /** Specifies whether MOF parsing should be strict. Non strict parsing will allow classes to specify references without being formally qualified as an ASSOCIATION. This is necessary for the DMTF CIM 2.3 schema which does not correctly specify such qualifiers. */ static public boolean strictParse=false; /** Specifies whether persistence is required for qualifiers, classes and instances */ static public boolean usePersistence=true; /** basicAuthModule specifies the class that will be used to authenticate a basic authorization */ static public String basicAuthModule = "org.snia.wbemcmd.xml.BasicAuthorization"; // // Set true to enable authorization // static public boolean requireAuthorization=false; /** Specify persistence directory On Unix systems set the following to /var/sniacimom/persistence */ static public String persistenceDir="persistence" + java.io.File.separator; /** This specifies whether providers should be called with a Vector of CIMValue instances (when callMethodsWithValues = true) otherwise providers will be called with a Vector of CIMProperty */ static public boolean callMethodsWithValues = false; /** Set true to enable the delivery of CIMEvents in a concurrent manner (e.g. in a separate Thread). The default value is "false". The purpose of this new property is to control an alternative way to send the events toward the registered CIMProvider(s). Whenever this property is "true" a separate Thread is used for the delivery of the CIMEvent(s) toward the registered CIMProvider(s) in order to prevent the current Thread to be blocked for the time required to execute the handlers. This property can be turned-back to "false" as soon as some reentrancy problems will be appearing into the CIM-Repository or in the provider itself. */ static public boolean concurrentDeliveryOfEvents = false; ///////////////////////////////////////////////////////////////////// // Set methods to set the properties // ///////////////////////////////////////////////////////////////////// /** * Sets the httpSocketProvider to the one specified. * @param value - Socket Provider name. */ public static void setHTTPSocketProvider(String value ) { httpSocketProvider = value; } /** * Sets the httpsSocketProvider to the one specified. * @param value - Socket Provider name. */ public static void setHTTPSSocketProvider(String value ) { httpsSocketProvider = value; } /** * Sets the TrustManager to the one specified. * @param value - Trust manager name. */ public static void setTrustManager(String value ) { TrustManager = value; } /** * Sets the httpclient to the one specified. * @param value - httpClient name. */ public static void setHttpClient(String value ) { httpClient = value; } /** * gets the CIM Client and CIM Listener package version number. * @return String version number. */ public static String getPackageVersion() { return(PACKAGE_VERSION); } ///////////////////////////////////////////////////////////////////// // Load properties from the properties file // ///////////////////////////////////////////////////////////////////// static { String value = System.getProperty("org.snia.wbem.cimom.properties"); if (value!=null) { Properties cfg = new Properties(); try { FileInputStream ins = new FileInputStream(value); cfg.load(ins); // set configuration variables. value = cfg.getProperty("DEBUG_XML"); if ( value != null ) { DEBUG_XML = new Boolean(value).booleanValue(); } value = cfg.getProperty("DEBUG_XMLDECODE"); if ( value != null ) { DEBUG_XMLDECODE = new Boolean(value).booleanValue();; } // Added to support turning off HTTP11 M-POST as first try value = cfg.getProperty("useHTTP11"); if(value != null) { useHTTP11 = (new Boolean(value)).booleanValue(); } value = cfg.getProperty("clientLogFilePath"); if ( value != null ) { //TODO: Validate the file path //try //{ // File file = new File(value); // //} catch() { // //} clientLogFilePath = value; // // Set the Log file path // Log.assignLogFileName(clientLogFilePath); } value = cfg.getProperty("TrustManager"); if ( value != null ) { TrustManager = value; } value = cfg.getProperty("httpSocketProvider"); if ( value != null ) { httpSocketProvider = value; } value = cfg.getProperty("httpsSocketProvider"); if ( value != null ) { httpsSocketProvider = value; } /* // FOR 2.0 added by Bapu value = cfg.getProperty("basicAuthModule"); if ( value != null) basicAuthModule = value; value = cfg.getProperty("requireAuthorization"); if ( value != null ) requireAuthorization = new Boolean(value).booleanValue(); // end of FOR 2.0 added by Bapu value = cfg.getProperty("httpClient"); if ( value != null) { httpClient = value; } value = cfg.getProperty("httpSocketProvider"); if ( value != null ) { httpSocketProvider = value; } value = cfg.getProperty("httpsSocketProvider"); if ( value != null ) { httpsSocketProvider = value; } */ } catch ( IOException e ) { Log.println("Could not find the property file.\n"); } catch ( Exception e ) { Log.println("Error setting properties, " + "default configurations are used.\n"); } } } }