1 24 25 package org.objectweb.cjdbc.common.net; 26 27 import java.io.File ; 28 import java.io.Serializable ; 29 30 36 public class SSLConfiguration implements Serializable 37 { 38 private static final long serialVersionUID = -7030030045041996566L; 39 40 41 private File keyStore; 42 43 private String keyStorePassword; 44 45 private String keyStoreKeyPassword; 46 47 49 50 private boolean isClientAuthenticationRequired = false; 51 52 53 private File trustStore; 54 55 private String trustStorePassword; 56 57 62 public boolean isClientAuthenticationRequired() 63 { 64 return isClientAuthenticationRequired; 65 } 66 67 73 public void setClientAuthenticationRequired( 74 boolean isClientAuthenticationRequired) 75 { 76 this.isClientAuthenticationRequired = isClientAuthenticationRequired; 77 } 78 79 84 public File getKeyStore() 85 { 86 return keyStore; 87 } 88 89 94 public void setKeyStore(File keyStore) 95 { 96 this.keyStore = keyStore; 97 } 98 99 104 public String getKeyStoreKeyPassword() 105 { 106 if (keyStoreKeyPassword != null) 107 return keyStoreKeyPassword; 108 return getKeyStorePassword(); 109 } 110 111 116 public void setKeyStoreKeyPassword(String keyStoreKeyPassword) 117 { 118 this.keyStoreKeyPassword = keyStoreKeyPassword; 119 } 120 121 126 public String getKeyStorePassword() 127 { 128 return keyStorePassword; 129 } 130 131 136 public void setKeyStorePassword(String keyStorePassword) 137 { 138 this.keyStorePassword = keyStorePassword; 139 } 140 141 146 public File getTrustStore() 147 { 148 if (trustStore != null) 149 return trustStore; 150 151 return getKeyStore(); 152 } 153 154 159 public void setTrustStore(File trustStore) 160 { 161 this.trustStore = trustStore; 162 } 163 164 169 public String getTrustStorePassword() 170 { 171 if (trustStorePassword != null) 172 return trustStorePassword; 173 174 return getKeyStorePassword(); 175 } 176 177 182 public void setTrustStorePassword(String trustStorePassword) 183 { 184 this.trustStorePassword = trustStorePassword; 185 } 186 187 193 public static SSLConfiguration getDefaultConfig() 194 { 195 SSLConfiguration config = new SSLConfiguration(); 196 config.keyStore = new File (System.getProperty("javax.net.ssl.keyStore")); 197 config.keyStorePassword = System 198 .getProperty("javax.net.ssl.keyStorePassword"); 199 config.keyStoreKeyPassword = System 200 .getProperty("javax.net.ssl.keyStorePassword"); 201 config.trustStore = new File (System.getProperty("javax.net.ssl.trustStore")); 202 config.trustStorePassword = System 203 .getProperty("javax.net.ssl.trustStorePassword"); 204 return config; 205 } 206 207 } 208 | Popular Tags |