src/java.base/share/classes/sun/security/ssl/Debug.java

Print this page




 184     /**
 185      * Return the value of the boolean System property propName.
 186      *
 187      * Note use of privileged action. Do NOT make accessible to applications.
 188      */
 189     static boolean getBooleanProperty(String propName, boolean defaultValue) {
 190         // if set, require value of either true or false
 191         String b = GetPropertyAction.privilegedGetProperty(propName);
 192         if (b == null) {
 193             return defaultValue;
 194         } else if (b.equalsIgnoreCase("false")) {
 195             return false;
 196         } else if (b.equalsIgnoreCase("true")) {
 197             return true;
 198         } else {
 199             throw new RuntimeException("Value of " + propName
 200                 + " must either be 'true' or 'false'");
 201         }
 202     }
 203 


















 204     static String toString(byte[] b) {
 205         return sun.security.util.Debug.toString(b);
 206     }
 207 
 208     static void printHex(String prefix, byte[] bytes) {
 209         HexDumpEncoder dump = new HexDumpEncoder();
 210 
 211         synchronized (System.out) {
 212             System.out.println(prefix);
 213             try {
 214                 dump.encodeBuffer(bytes, System.out);
 215             } catch (Exception e) {
 216                 // ignore
 217             }
 218             System.out.flush();
 219         }
 220     }
 221 
 222     static void printHex(String prefix, ByteBuffer bb) {
 223         HexDumpEncoder dump = new HexDumpEncoder();




 184     /**
 185      * Return the value of the boolean System property propName.
 186      *
 187      * Note use of privileged action. Do NOT make accessible to applications.
 188      */
 189     static boolean getBooleanProperty(String propName, boolean defaultValue) {
 190         // if set, require value of either true or false
 191         String b = GetPropertyAction.privilegedGetProperty(propName);
 192         if (b == null) {
 193             return defaultValue;
 194         } else if (b.equalsIgnoreCase("false")) {
 195             return false;
 196         } else if (b.equalsIgnoreCase("true")) {
 197             return true;
 198         } else {
 199             throw new RuntimeException("Value of " + propName
 200                 + " must either be 'true' or 'false'");
 201         }
 202     }
 203 
 204     /**
 205      * Return the value of the integer System property propName.
 206      *
 207      * Note use of doPrivileged(). Do make accessible to applications.
 208      */
 209     static int getIntegerProperty(String propName, int defaultValue) {
 210         String i = GetPropertyAction.privilegedGetProperty(propName);
 211         if (i != null) {
 212             try {
 213                 return Integer.parseInt(i);
 214             } catch(NumberFormatException e) {
 215                 throw new RuntimeException("Value of " + propName
 216                     + " must be a valid integer");
 217             }
 218         }
 219         return defaultValue;
 220     }
 221 
 222     static String toString(byte[] b) {
 223         return sun.security.util.Debug.toString(b);
 224     }
 225 
 226     static void printHex(String prefix, byte[] bytes) {
 227         HexDumpEncoder dump = new HexDumpEncoder();
 228 
 229         synchronized (System.out) {
 230             System.out.println(prefix);
 231             try {
 232                 dump.encodeBuffer(bytes, System.out);
 233             } catch (Exception e) {
 234                 // ignore
 235             }
 236             System.out.flush();
 237         }
 238     }
 239 
 240     static void printHex(String prefix, ByteBuffer bb) {
 241         HexDumpEncoder dump = new HexDumpEncoder();