1 45 package org.exolab.jms.net.util; 46 47 import java.util.Properties ; 48 49 50 56 public class SSLHelper { 57 58 61 public static final String KEY_STORE = "javax.net.ssl.keyStore"; 62 63 66 public static final String KEY_STORE_TYPE 67 = "javax.net.ssl.keyStoreType"; 68 69 72 public static final String KEY_STORE_PASSWORD 73 = "javax.net.ssl.keyStorePassword"; 74 75 78 public static final String TRUST_STORE = "javax.net.ssl.trustStore"; 79 80 83 public static final String TRUST_STORE_PASSWORD 84 = "javax.net.ssl.trustStorePassword"; 85 86 89 public static final String TRUST_STORE_TYPE 90 = "javax.net.ssl.trustStoreType"; 91 92 102 public static void configure(SSLProperties properties) 103 throws SecurityException { 104 update(KEY_STORE, properties.getKeyStore()); 105 update(KEY_STORE_PASSWORD, properties.getKeyStorePassword()); 106 update(KEY_STORE_TYPE, properties.getKeyStoreType()); 107 update(TRUST_STORE, properties.getTrustStore()); 108 update(TRUST_STORE_PASSWORD, properties.getTrustStorePassword()); 109 update(TRUST_STORE_TYPE, properties.getTrustStoreType()); 110 } 111 112 121 private static void update(String key, String value) 122 throws SecurityException { 123 if (value != null) { 124 System.setProperty(key, value); 125 } else if (System.getProperty(key) == null) { 126 Properties properties = System.getProperties(); 127 properties.remove(key); 128 } 129 } 130 } 131 | Popular Tags |