OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
com.mapd.common.SockTransportProperties Class Reference
+ Collaboration diagram for com.mapd.common.SockTransportProperties:

Classes

enum  TransportType
 

Public Member Functions

 SockTransportProperties (String truststore_name, String truststore_passwd) throws Exception
 
TTransport openClientTransport (String server_host, int port) throws org.apache.thrift.TException
 
TTransport openHttpsClientTransport (String server_host, int port) throws Exception
 
TTransport openHttpClientTransport (String server_host, int port) throws org.apache.thrift.TException
 
TServerTransport openServerTransport (int port) throws org.apache.thrift.TException
 

Static Public Member Functions

static SockTransportProperties getUnencryptedClient () throws Exception
 
static SockTransportProperties getEncryptedClientDefaultTrustStore (boolean validate_server_name) throws Exception
 
static SockTransportProperties getEncryptedClientSpecifiedTrustStore (String trustStoreName, String trustStorePassword) throws Exception
 
static SockTransportProperties getEncryptedClientSpecifiedTrustStore (String trustStoreName, String trustStorePassword, boolean validate_server_name) throws Exception
 
static SockTransportProperties getEncryptedServer (String keyStoreName, String keyStorePassword) throws Exception
 
static SockTransportProperties getUnecryptedServer () throws Exception
 

Package Attributes

X509HostnameVerifier x509HostnameVerifier_
 

Static Package Attributes

static final org.slf4j.Logger HEAVYDBLOGGER
 

Private Member Functions

 SockTransportProperties (TransportType tT, String store_name, String passwd, boolean validate_server_name) throws Exception
 
 SockTransportProperties (TransportType transportType, boolean validate_server_name) throws Exception
 
void initializeAcceptedIssuers (KeyStore trust_store) throws Exception
 
TTransport openBinaryEncrypted (String server_host, int port) throws org.apache.thrift.TException
 
TServerTransport openServerTransportEncrypted (int port) throws org.apache.thrift.TException
 

Private Attributes

TrustManager[] trustManagers
 
TransportType transportType = null
 
KeyManager[] keyManagers
 
String key_store_name = null
 
char[] key_store_password = null
 

Detailed Description

Definition at line 34 of file SockTransportProperties.java.

Constructor & Destructor Documentation

com.mapd.common.SockTransportProperties.SockTransportProperties ( String  truststore_name,
String  truststore_passwd 
) throws Exception
inline
com.mapd.common.SockTransportProperties.SockTransportProperties ( TransportType  tT,
String  store_name,
String  passwd,
boolean  validate_server_name 
) throws Exception
inlineprivate

private constructors called from public static methods

Definition at line 116 of file SockTransportProperties.java.

References com.mapd.common.SockTransportProperties.initializeAcceptedIssuers(), com.mapd.common.SockTransportProperties.key_store_name, com.mapd.common.SockTransportProperties.key_store_password, com.mapd.common.SockTransportProperties.transportType, and com.mapd.common.SockTransportProperties.x509HostnameVerifier_.

119  {
120  x509HostnameVerifier_ = (validate_server_name == true)
121  ? SSLConnectionSocketFactory.STRICT_HOSTNAME_VERIFIER
122  : SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
123  transportType = tT;
124 
125  char[] store_password = "".toCharArray();
126  if (passwd != null && !passwd.isEmpty()) {
127  store_password = passwd.toCharArray();
128  }
129  switch (transportType) {
130  case encryptedServer: {
131  key_store_password = store_password;
132  key_store_name = store_name;
133  break;
134  }
135  case encryptedClientSpecifiedTrustStore: {
136  if (store_name == null) {
138  } else {
139  KeyStore trust_store = KeyStore.getInstance(KeyStore.getDefaultType());
140  try {
141  java.io.FileInputStream fis = new java.io.FileInputStream(store_name);
142  trust_store.load(fis, store_password);
143  } catch (Exception eX) {
144  String err_str =
145  new String("Error loading key/trust store [" + store_name + "]");
146  HEAVYDBLOGGER.error(err_str, eX);
147  throw(eX);
148  }
149  initializeAcceptedIssuers(trust_store);
150  }
151  break;
152  }
153  default: {
154  String errStr = new String(
155  "Invalid transportType [" + transportType + "] used in constructor");
156  RuntimeException rE = new RuntimeException(errStr);
157  HEAVYDBLOGGER.error(errStr, rE);
158  throw(rE);
159  }
160  }
161  }

+ Here is the call graph for this function:

com.mapd.common.SockTransportProperties.SockTransportProperties ( TransportType  transportType,
boolean  validate_server_name 
) throws Exception
inlineprivate

Definition at line 163 of file SockTransportProperties.java.

References com.mapd.common.SockTransportProperties.initializeAcceptedIssuers(), com.mapd.common.SockTransportProperties.transportType, and com.mapd.common.SockTransportProperties.x509HostnameVerifier_.

164  {
165  x509HostnameVerifier_ = (validate_server_name == true)
166  ? SSLConnectionSocketFactory.STRICT_HOSTNAME_VERIFIER
167  : SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
168  this.transportType = transportType;
169  switch (transportType) {
170  case encryptedClientDefaultTrustStore:
171  // load default trust_store
172  initializeAcceptedIssuers((KeyStore) null);
173  break;
174  case unencryptedClient:
175  case unencryptedServer:
176  break;
177  default:
178  String errStr = new String(
179  "Invalid transportType [" + transportType + "] used in constructor");
180  RuntimeException rE = new RuntimeException(errStr);
181  HEAVYDBLOGGER.error(errStr, rE);
182  throw(rE);
183  }
184  }

+ Here is the call graph for this function:

Member Function Documentation

static SockTransportProperties com.mapd.common.SockTransportProperties.getEncryptedClientDefaultTrustStore ( boolean  validate_server_name) throws Exception
inlinestatic

Encrypted Client method

Definition at line 52 of file SockTransportProperties.java.

References com.mapd.common.SockTransportProperties.TransportType.encryptedClientDefaultTrustStore, and com.mapd.common.SockTransportProperties.SockTransportProperties().

53  {
54  return new SockTransportProperties(
55  TransportType.encryptedClientDefaultTrustStore, validate_server_name);
56  }
SockTransportProperties(String truststore_name, String truststore_passwd)

+ Here is the call graph for this function:

static SockTransportProperties com.mapd.common.SockTransportProperties.getEncryptedClientSpecifiedTrustStore ( String  trustStoreName,
String  trustStorePassword 
) throws Exception
inlinestatic

Definition at line 59 of file SockTransportProperties.java.

60  {
62  trustStoreName, trustStorePassword, true);
63  }
static SockTransportProperties getEncryptedClientSpecifiedTrustStore(String trustStoreName, String trustStorePassword)
static SockTransportProperties com.mapd.common.SockTransportProperties.getEncryptedClientSpecifiedTrustStore ( String  trustStoreName,
String  trustStorePassword,
boolean  validate_server_name 
) throws Exception
inlinestatic

Definition at line 64 of file SockTransportProperties.java.

References com.mapd.common.SockTransportProperties.TransportType.encryptedClientSpecifiedTrustStore, and com.mapd.common.SockTransportProperties.SockTransportProperties().

66  {
67  return new SockTransportProperties(TransportType.encryptedClientSpecifiedTrustStore,
68  trustStoreName,
69  trustStorePassword,
70  validate_server_name);
71  }
SockTransportProperties(String truststore_name, String truststore_passwd)

+ Here is the call graph for this function:

static SockTransportProperties com.mapd.common.SockTransportProperties.getEncryptedServer ( String  keyStoreName,
String  keyStorePassword 
) throws Exception
inlinestatic

Server methods

Definition at line 74 of file SockTransportProperties.java.

References com.mapd.common.SockTransportProperties.TransportType.encryptedServer, and com.mapd.common.SockTransportProperties.SockTransportProperties().

75  {
76  boolean validate_server_name = false;
77  if (keyStoreName == null || keyStorePassword == null) {
78  String errStr = new String(
79  "Invalid null parameter(s) used for getEncryptedServer. Both keyStoreName and keyStorePassword must be specified");
80  RuntimeException rE = new RuntimeException(errStr);
81  HEAVYDBLOGGER.error(errStr, rE);
82  throw(rE);
83  }
84  return new SockTransportProperties(TransportType.encryptedServer,
85  keyStoreName,
86  keyStorePassword,
87  validate_server_name);
88  }
SockTransportProperties(String truststore_name, String truststore_passwd)

+ Here is the call graph for this function:

static SockTransportProperties com.mapd.common.SockTransportProperties.getUnecryptedServer ( ) throws Exception
inlinestatic

Definition at line 90 of file SockTransportProperties.java.

References com.mapd.common.SockTransportProperties.SockTransportProperties(), and com.mapd.common.SockTransportProperties.TransportType.unencryptedServer.

90  {
91  boolean validate_server_name = false;
92  return new SockTransportProperties(
93  TransportType.unencryptedServer, validate_server_name);
94  }
SockTransportProperties(String truststore_name, String truststore_passwd)

+ Here is the call graph for this function:

static SockTransportProperties com.mapd.common.SockTransportProperties.getUnencryptedClient ( ) throws Exception
inlinestatic

Unencrypted Client method

Definition at line 46 of file SockTransportProperties.java.

References com.mapd.common.SockTransportProperties.SockTransportProperties(), and com.mapd.common.SockTransportProperties.TransportType.unencryptedClient.

Referenced by com.mapd.parser.extension.ddl.DDLTest.setup().

46  {
47  boolean validate_server_name = false;
48  return new SockTransportProperties(
49  TransportType.unencryptedClient, validate_server_name);
50  }
SockTransportProperties(String truststore_name, String truststore_passwd)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void com.mapd.common.SockTransportProperties.initializeAcceptedIssuers ( KeyStore  trust_store) throws Exception
inlineprivate

end private constructors

Definition at line 187 of file SockTransportProperties.java.

References com.mapd.common.SockTransportProperties.trustManagers.

Referenced by com.mapd.common.SockTransportProperties.SockTransportProperties().

187  {
188  // Initialize a trust manager to either the trust store already loaded or the
189  // default trust store. Order of searching for default is:
190  // 1. system property javax.net.ssl.trustStore
191  // 2. <java-home>/lib/security/jssecacerts
192  // 3. <java-home</lib/security/cacerts
193 
194  TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance("PKIX");
195  // If trust_store is null init will load the default trust_store
196  trustManagerFactory.init(trust_store);
197  trustManagers = trustManagerFactory.getTrustManagers();
198  }

+ Here is the caller graph for this function:

TTransport com.mapd.common.SockTransportProperties.openBinaryEncrypted ( String  server_host,
int  port 
) throws org.apache.thrift.TException
inlineprivate

Definition at line 228 of file SockTransportProperties.java.

References com.mapd.common.SockTransportProperties.trustManagers.

Referenced by com.mapd.common.SockTransportProperties.openClientTransport().

229  {
230  // Used to set Socket.setSoTimeout ms. 0 == inifinite.
231  int socket_so_timeout_ms = 0;
232  TSocket tsocket = null;
233  try {
234  SSLContext sc = SSLContext.getInstance("TLS");
235  sc.init(null, trustManagers, new java.security.SecureRandom());
236 
237  SSLSocket sx = (SSLSocket) sc.getSocketFactory().createSocket(server_host, port);
238  sx.setSoTimeout(socket_so_timeout_ms);
239  tsocket = new TSocket(sx);
240  } catch (Exception ex) {
241  String errStr = new String("Error openBinaryEncrypted [" + server_host + ":" + port
242  + "] used in openClientTransport - ");
243  errStr += ex.toString();
244  RuntimeException rE = new RuntimeException(errStr);
245  HEAVYDBLOGGER.error(errStr, rE);
246  throw(rE);
247  }
248  return tsocket;
249  }

+ Here is the caller graph for this function:

TTransport com.mapd.common.SockTransportProperties.openClientTransport ( String  server_host,
int  port 
) throws org.apache.thrift.TException
inline

Definition at line 207 of file SockTransportProperties.java.

References com.mapd.common.SockTransportProperties.openBinaryEncrypted(), and com.mapd.common.SockTransportProperties.transportType.

208  {
209  TTransport tTransport = null;
210  switch (transportType) {
211  case encryptedClientDefaultTrustStore:
212  case encryptedClientSpecifiedTrustStore:
213  tTransport = openBinaryEncrypted(server_host, port);
214  break;
215  case unencryptedClient:
216  tTransport = new TSocket(server_host, port);
217  break;
218  default:
219  String errStr = new String("Invalid transportType [" + transportType
220  + "] used in openClientTransport");
221  RuntimeException rE = new RuntimeException(errStr);
222  HEAVYDBLOGGER.error(errStr, rE);
223  throw(rE);
224  }
225  return tTransport;
226  }
TTransport openBinaryEncrypted(String server_host, int port)

+ Here is the call graph for this function:

TTransport com.mapd.common.SockTransportProperties.openHttpClientTransport ( String  server_host,
int  port 
) throws org.apache.thrift.TException
inline

Definition at line 287 of file SockTransportProperties.java.

References com.mapd.common.SockTransportProperties.transportType, and com.mapd.common.SockTransportProperties.TransportType.unencryptedClient.

288  {
289  if (transportType != TransportType.unencryptedClient) {
290  String errStr = new String("Invalid transportType [" + transportType
291  + "] used in openHttpClientTransport");
292  RuntimeException rE = new RuntimeException(errStr);
293  HEAVYDBLOGGER.error(errStr, rE);
294  throw(rE);
295  }
296 
297  String url = "http://" + server_host + ":" + port;
298  return (new THttpClient(url));
299  }
TTransport com.mapd.common.SockTransportProperties.openHttpsClientTransport ( String  server_host,
int  port 
) throws Exception
inline

Definition at line 251 of file SockTransportProperties.java.

References com.mapd.common.SockTransportProperties.TransportType.encryptedClientDefaultTrustStore, com.mapd.common.SockTransportProperties.TransportType.encryptedClientSpecifiedTrustStore, com.mapd.common.SockTransportProperties.transportType, com.mapd.common.SockTransportProperties.trustManagers, and com.mapd.common.SockTransportProperties.x509HostnameVerifier_.

252  {
255  String errStr = new String("Invalid transportType [" + transportType
256  + "] used in openHttpsClientTransport");
257  RuntimeException rE = new RuntimeException(errStr);
258  HEAVYDBLOGGER.error(errStr, rE);
259  throw(rE);
260  }
261  TTransport transport = null;
262 
263  try {
264  SSLContext sc = SSLContext.getInstance("TLS");
265  sc.init(null, trustManagers, new java.security.SecureRandom());
266  SSLConnectionSocketFactory sslConnectionSocketFactory = null;
267  sslConnectionSocketFactory =
268  new SSLConnectionSocketFactory(sc, x509HostnameVerifier_);
269 
270  CloseableHttpClient closeableHttpClient =
271  HttpClients.custom()
272  .setSSLSocketFactory(sslConnectionSocketFactory)
273  .build();
274  transport =
275  new THttpClient("https://" + server_host + ":" + port, closeableHttpClient);
276 
277  } catch (Exception ex) {
278  String err_str = new String("Exception:" + ex.getClass().getCanonicalName()
279  + " thrown. Unable to create Secure socket for the HTTPS connection");
280  HEAVYDBLOGGER.error(err_str, ex);
281  throw ex;
282  }
283 
284  return transport;
285  }
TServerTransport com.mapd.common.SockTransportProperties.openServerTransport ( int  port) throws org.apache.thrift.TException
inline

Definition at line 304 of file SockTransportProperties.java.

References com.mapd.common.SockTransportProperties.TransportType.encryptedServer, com.mapd.common.SockTransportProperties.openServerTransportEncrypted(), com.mapd.common.SockTransportProperties.transportType, and com.mapd.common.SockTransportProperties.TransportType.unencryptedServer.

305  {
306  if (transportType == TransportType.encryptedServer) {
307  return openServerTransportEncrypted(port);
308  } else if (transportType == TransportType.unencryptedServer) {
309  return (new TServerSocket(port));
310  } else {
311  String errStr = new String("Invalid transportType [" + transportType
312  + "] used in openServerTransport");
313  RuntimeException rE = new RuntimeException(errStr);
314  HEAVYDBLOGGER.error(errStr, rE);
315  throw(rE);
316  }
317  }
TServerTransport openServerTransportEncrypted(int port)

+ Here is the call graph for this function:

TServerTransport com.mapd.common.SockTransportProperties.openServerTransportEncrypted ( int  port) throws org.apache.thrift.TException
inlineprivate

Definition at line 319 of file SockTransportProperties.java.

References com.mapd.common.SockTransportProperties.key_store_name, com.mapd.common.SockTransportProperties.key_store_password, and report.params.

Referenced by com.mapd.common.SockTransportProperties.openServerTransport().

320  {
321  // Used to set Socket.setSoTimeout ms. 0 == inifinite.
322  int socket_so_timeout_ms = 0;
323  TSSLTransportFactory.TSSLTransportParameters params =
324  new TSSLTransportFactory.TSSLTransportParameters();
325  params.setKeyStore(key_store_name,
326  (key_store_password != null) ? new String(key_store_password) : null);
327  params.requireClientAuth(false);
328 
329  // return TSSLTransportFactory.getClientSocket(server_host, port,
330  // socket_so_timeout_ms, params);
331  TServerTransport t = TSSLTransportFactory.getServerSocket(
332  port, socket_so_timeout_ms, null, params);
333  return t;
334  }
dictionary params
Definition: report.py:27

+ Here is the caller graph for this function:

Member Data Documentation

final org.slf4j.Logger com.mapd.common.SockTransportProperties.HEAVYDBLOGGER
staticpackage
Initial value:
=
LoggerFactory.getLogger(SockTransportProperties.class)

Definition at line 35 of file SockTransportProperties.java.

String com.mapd.common.SockTransportProperties.key_store_name = null
private
char [] com.mapd.common.SockTransportProperties.key_store_password = null
private
KeyManager [] com.mapd.common.SockTransportProperties.keyManagers
private

Definition at line 338 of file SockTransportProperties.java.

X509HostnameVerifier com.mapd.common.SockTransportProperties.x509HostnameVerifier_
package
Initial value:
=
SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER

Definition at line 341 of file SockTransportProperties.java.

Referenced by com.mapd.common.SockTransportProperties.openHttpsClientTransport(), and com.mapd.common.SockTransportProperties.SockTransportProperties().


The documentation for this class was generated from the following file: