1 /*
   2  * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.jmx.snmp.defaults;
  27 
  28 // java import
  29 //
  30 import java.io.FileInputStream;
  31 import java.io.InputStream;
  32 import java.io.IOException;
  33 import java.util.Properties;
  34 import java.util.Enumeration;
  35 
  36 /**
  37  * This class reads a file containing the property list defined for Java DMK
  38  * and adds all the read properties to the list of system properties.
  39  *
  40  * <p><b>This API is a Sun Microsystems internal API  and is subject
  41  * to change without notice.</b></p>
  42  *
  43  * @since 1.5
  44  */
  45 public class SnmpProperties {
  46 
  47     // private constructor defined to "hide" the default public constructor
  48     private SnmpProperties() {
  49     }
  50 
  51     // PUBLIC STATIC METHODS
  52     //----------------------
  53 
  54     /**
  55      * Reads the Java DMK property list from a file and
  56      * adds the read properties as system properties.
  57      */
  58     public static void load(String file) throws IOException {
  59         Properties props = new Properties();
  60         InputStream is = new FileInputStream(file);
  61         props.load(is);
  62         is.close();
  63         for (final Enumeration<?> e = props.keys(); e.hasMoreElements() ; ) {
  64             final String key = (String) e.nextElement();
  65             System.setProperty(key,props.getProperty(key));
  66         }
  67     }
  68 
  69     // PUBLIC STATIC VARIABLES
  70     //------------------------
  71 
  72     /**
  73      * References the property that specifies the directory where
  74      * the native libraries will be stored before the MLet Service
  75      * loads them into memory.
  76      * <p>
  77      * Property Name: <B>jmx.mlet.library.dir</B>
  78      */
  79     public static final String MLET_LIB_DIR = "jmx.mlet.library.dir";
  80 
  81     /**
  82      * References the property that specifies the ACL file
  83      * used by the SNMP protocol adaptor.
  84      * <p>
  85      * Property Name: <B>jdmk.acl.file</B>
  86      */
  87     public static final String ACL_FILE = "jdmk.acl.file";
  88 
  89     /**
  90      * References the property that specifies the Security file
  91      * used by the SNMP protocol adaptor.
  92      * <p>
  93      * Property Name: <B>jdmk.security.file</B>
  94      */
  95     public static final String SECURITY_FILE = "jdmk.security.file";
  96 
  97     /**
  98      * References the property that specifies the User ACL file
  99      * used by the SNMP protocol adaptor.
 100      * <p>
 101      * Property Name: <B>jdmk.uacl.file</B>
 102      */
 103     public static final String UACL_FILE = "jdmk.uacl.file";
 104 
 105     /**
 106      * References the property that specifies the default mib_core file
 107      * used by the mibgen compiler.
 108      * <p>
 109      * Property Name: <B>mibcore.file</B>
 110      */
 111     public static final String MIB_CORE_FILE = "mibcore.file";
 112 
 113     /**
 114      * References the property that specifies the full name of the JMX
 115      * specification implemented by this product.
 116      * <p>
 117      * Property Name: <B>jmx.specification.name</B>
 118      */
 119      public static final String JMX_SPEC_NAME = "jmx.specification.name";
 120 
 121     /**
 122      * References the property that specifies the version of the JMX
 123      * specification implemented by this product.
 124      * <p>
 125      * Property Name: <B>jmx.specification.version</B>
 126      */
 127      public static final String JMX_SPEC_VERSION = "jmx.specification.version";
 128 
 129     /**
 130      * References the property that specifies the vendor of the JMX
 131      * specification implemented by this product.
 132      * <p>
 133      * Property Name: <B>jmx.specification.vendor</B>
 134      */
 135      public static final String JMX_SPEC_VENDOR = "jmx.specification.vendor";
 136 
 137     /**
 138      * References the property that specifies the full name of this product
 139      * implementing the  JMX specification.
 140      * <p>
 141      * Property Name: <B>jmx.implementation.name</B>
 142      */
 143     public static final String JMX_IMPL_NAME = "jmx.implementation.name";
 144 
 145     /**
 146      * References the property that specifies the name of the vendor of this product
 147      * implementing the  JMX specification.
 148      * <p>
 149      * Property Name: <B>jmx.implementation.vendor</B>
 150      */
 151     public static final String JMX_IMPL_VENDOR = "jmx.implementation.vendor";
 152 
 153     /**
 154      * References the property that specifies the version of this product
 155      * implementing the  JMX specification.
 156      * <p>
 157      * Property Name: <B>jmx.implementation.version</B>
 158      */
 159     public static final String JMX_IMPL_VERSION = "jmx.implementation.version";
 160 
 161     /**
 162      * References the property that specifies the SSL cipher suites to
 163      * be enabled by the HTTP/SSL connector.
 164      * <p>
 165      * Property Name: <B>jdmk.ssl.cipher.suite.</B>
 166      * <p>
 167      * The list of SSL cipher suites is specified in the format:
 168      * <p>
 169      * <DD><B>jdmk.ssl.cipher.suite.</B>&lt;n&gt;<B>=</B>&lt;cipher suite name&gt;</DD>
 170      * <p>
 171      * For example:
 172      * <p>
 173      * <DD>jdmk.ssl.cipher.suite.1=SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA</DD>
 174      * <DD>jdmk.ssl.cipher.suite.2=SSL_RSA_EXPORT_WITH_RC4_40_MD5</DD>
 175      * <DD>. . .</DD>
 176      */
 177     public static final String SSL_CIPHER_SUITE = "jdmk.ssl.cipher.suite.";
 178 }