List of usage examples for org.apache.thrift.transport TSSLTransportFactory getClientSocket
public static TSocket getClientSocket(String host, int port, int timeout, TSSLTransportParameters params) throws TTransportException
From source file:JavaClient.java
License:Apache License
public static void main(String[] args) { if (args.length != 1) { System.out.println("Please enter 'simple' or 'secure'"); System.exit(0);//w w w. j a va2 s . c om } try { TTransport transport; if (args[0].contains("simple")) { transport = new TSocket("localhost", 9090); transport.open(); } else { /* * Similar to the server, you can use the parameters to setup client parameters or * use the default settings. On the client side, you will need a TrustStore which * contains the trusted certificate along with the public key. * For this example it's a self-signed cert. */ TSSLTransportParameters params = new TSSLTransportParameters(); params.setTrustStore("../../lib/java/test/.truststore", "thrift", "SunX509", "JKS"); /* * Get a client transport instead of a server transport. The connection is opened on * invocation of the factory method, no need to specifically call open() */ transport = TSSLTransportFactory.getClientSocket("localhost", 9091, 0, params); } TProtocol protocol = new TBinaryProtocol(transport); Calculator.Client client = new Calculator.Client(protocol); perform(client); transport.close(); } catch (TException x) { x.printStackTrace(); } }
From source file:apache.JavaClient.java
License:Apache License
public static void main(String[] args) { if (args.length != 1) { System.out.println("Please enter 'simple' or 'secure'"); System.exit(0);/*www. j ava 2s .c o m*/ } try { TTransport transport; if (args[0].contains("simple")) { transport = new TSocket("localhost", 9090); transport.open(); } else { /* * Similar to the server, you can use the parameters to setup * client parameters or use the default settings. On the client * side, you will need a TrustStore which contains the trusted * certificate along with the public key. For this example it's * a self-signed cert. */ TSSLTransportParameters params = new TSSLTransportParameters(); params.setTrustStore(JavaClient.class.getClass().getResource("/") + "key.truststore", "thrift", "SunX509", "JKS"); /* * Get a client transport instead of a server transport. The * connection is opened on invocation of the factory method, no * need to specifically call open() */ transport = TSSLTransportFactory.getClientSocket("localhost", 9091, 0, params); } TProtocol protocol = new TBinaryProtocol(transport); Calculator.Client client = new Calculator.Client(protocol); perform(client); transport.close(); } catch (TException x) { x.printStackTrace(); } }
From source file:client.CalculateClient.java
License:Apache License
public static void main(String[] args) { if (args.length != 1) { System.out.println("Please enter 'simple' or 'secure'"); System.exit(0);//from ww w. ja v a 2 s .c om } try { TTransport transport; if (args[0].contains("simple")) { transport = new TSocket(SERVER_HOST_NAME, SIMPLE_CONN_PORT_NUMBER); transport.open(); } else { /* * Similar to the server, you can use the parameters to setup * client parameters or use the default settings. On the client * side, you will need a TrustStore which contains the trusted * certificate along with the public key. For this example it's * a self-signed cert. */ TSSLTransportParameters params = new TSSLTransportParameters(); params.setTrustStore(PATH_TO_TRUST_STORE, PASSWORD_TRUST_STORE, "SunX509", "JKS"); /* * Get a client transport instead of a server transport. The * connection is opened on invocation of the factory method, no * need to specifically call open() */ transport = TSSLTransportFactory.getClientSocket(SERVER_HOST_NAME, SECURE_CONN_PORT_NUMBER, 0, params); } TProtocol protocol = new TBinaryProtocol(transport); Calculator.Client client = new Calculator.Client(protocol); perform(client); transport.close(); } catch (TException x) { x.printStackTrace(); } }
From source file:client.JavaClient.java
License:Apache License
public static void main(String[] args) { if (args.length != 1) { System.out.println("Please enter 'simple' or 'secure'"); System.exit(0);// w ww .ja v a 2s . c o m } try { TTransport transport; if (args[0].contains("simple")) { transport = new TSocket("localhost", 9090); transport.open(); } else { /* * Similar to the server, you can use the parameters to setup client parameters or * use the default settings. On the client side, you will need a TrustStore which * contains the trusted certificate along with the public key. * For this example it's a self-signed cert. */ TSSLTransportParameters params = new TSSLTransportParameters(); params.setTrustStore("./src/main/java/client/.truststore", "shihuc", "SunX509", "JKS"); /* * Get a client transport instead of a server transport. The connection is opened on * invocation of the factory method, no need to specifically call open() */ transport = TSSLTransportFactory.getClientSocket("localhost", 9091, 0, params); } TProtocol protocol = new TBinaryProtocol(transport); Calculator.Client client = new Calculator.Client(protocol); perform(client); transport.close(); } catch (TException x) { x.printStackTrace(); } }
From source file:com.an.antry.JavaClient.java
License:Apache License
public static void main(String[] args) { if (args.length != 1) { System.out.println("Please enter 'simple' or 'secure'"); System.exit(0);//from www . j a v a 2 s . c o m } try { TTransport transport; if (args[0].contains("simple")) { transport = new TSocket("localhost", 9090); transport.open(); } else { /* * Similar to the server, you can use the parameters to setup client parameters or use the default * settings. On the client side, you will need a TrustStore which contains the trusted certificate along * with the public key. For this example it's a self-signed cert. */ TSSLTransportParameters params = new TSSLTransportParameters(); params.setTrustStore("../../lib/java/test/.truststore", "thrift", "SunX509", "JKS"); /* * Get a client transport instead of a server transport. The connection is opened on invocation of the * factory method, no need to specifically call open() */ transport = TSSLTransportFactory.getClientSocket("localhost", 9091, 0, params); } TProtocol protocol = new TBinaryProtocol(transport); Calculator.Client client = new Calculator.Client(protocol); perform(client); transport.close(); } catch (TException x) { x.printStackTrace(); } }
From source file:com.dell.doradus.service.db.thrift.DBConn.java
License:Apache License
private TSocket createTLSSocket(String host) throws TTransportException { ServerConfig config = ServerConfig.getInstance(); String[] cipherSuites = config.dbtls_cipher_suites.toArray(new String[] {}); TSSLTransportParameters sslParams = new TSSLTransportParameters("SSL", cipherSuites); if (!Utils.isEmpty(config.keystore)) { sslParams.setKeyStore(config.keystore, config.keystorepassword); }//from w w w .j a va2 s. c o m if (!Utils.isEmpty(config.truststore)) { sslParams.setTrustStore(config.truststore, config.truststorepassword); } return TSSLTransportFactory.getClientSocket(host, config.dbport, config.db_timeout_millis, sslParams); }
From source file:com.fjn.helper.frameworkex.apache.thrift.TestClient.java
License:Apache License
public static void main(String[] args) { if (args.length != 1) { System.out.println("Please enter 'simple' or 'secure'"); System.exit(0);//from w ww. jav a2s. c o m } try { TTransport transport; if (args[0].contains("simple")) { transport = new TSocket("localhost", 9090); transport.open(); } else { /* * Similar to the server, you can use the parameters to setup * client parameters or use the default settings. On the client * side, you will need a TrustStore which contains the trusted * certificate along with the public key. For this example it's * a self-signed cert. */ TSSLTransportParameters params = new TSSLTransportParameters(); params.setTrustStore("com/fjn/frame/apache/thrift/.truststore", "thrift", "SunX509", "JKS"); /* * Get a client transport instead of a server transport. The * connection is opened on invocation of the factory method, no * need to specifically call open() */ transport = TSSLTransportFactory.getClientSocket("localhost", 9091, 0, params); } TProtocol protocol = new TBinaryProtocol(transport); Calculator.Client client = new Calculator.Client(protocol); perform(client); transport.close(); } catch (TException x) { x.printStackTrace(); } }
From source file:com.github.katsurakkkk.thrift.JavaClient.java
License:Apache License
public static void main(String[] args) { if (args.length != 1) { System.out.println("Please enter 'simple' or 'secure'"); System.exit(0);/* ww w .ja va 2 s . c o m*/ } try { TTransport transport; if (args[0].contains("simple")) { transport = new TSocket("localhost", 9090); transport.open(); } else { /* * Similar to the server, you can use the parameters to setup client parameters or * use the default settings. On the client side, you will need a TrustStore which * contains the trusted certificate along with the public key. * For this example it's a self-signed cert. */ TSSLTransportParameters params = new TSSLTransportParameters(); params.setTrustStore("src/main/resources/thrift/java.truststore", "thrift", "SunX509", "JKS"); /* * Get a client transport instead of a server transport. The connection is opened on * invocation of the factory method, no need to specifically call open() */ transport = TSSLTransportFactory.getClientSocket("localhost", 9091, 0, params); } TProtocol protocol = new TBinaryProtocol(transport); Calculator.Client client = new Calculator.Client(protocol); perform(client); transport.close(); } catch (TException x) { x.printStackTrace(); } }
From source file:com.realtimecep.pilots.thrift.JavaClient.java
License:Apache License
public static void main(String[] args) { if (args.length != 1) { System.out.println("Please enter 'simple' or 'secure'"); System.exit(0);//from w w w . j ava 2 s.c o m } try { TTransport transport; if (args[0].contains("simple")) { transport = new TSocket("localhost", 9090); transport.open(); } else { /* * Similar to the server, you can use the parameters to setup client parameters or * use the default settings. On the client side, you will need a TrustStore which * contains the trusted certificate along with the public key. * For this example it's a self-signed cert. */ TSSLTransportParameters params = new TSSLTransportParameters(); params.setTrustStore("../../lib/java/test/.truststore", "thrift", "SunX509", "JKS"); /* * Get a client transport instead of a server transport. The connection is opened on * invocation of the factory method, no need to specifically call open() */ transport = TSSLTransportFactory.getClientSocket("localhost", 9091, 0, params); } TProtocol protocol = new TBinaryProtocol(transport); Calculator.Client client = new Calculator.Client(protocol); perform(client); transport.close(); } catch (TException x) { x.printStackTrace(); } }
From source file:com.sleepycat.client.BdbServerConnection.java
License:Open Source License
private void open(SslConfig sslConfig, int timeout) throws TTransportException { TTransport transport;//w w w. ja v a2 s . c o m if (sslConfig == null) { TSocket socket = new TSocket(this.host, this.port); transport = new TFramedTransport(socket); transport.open(); } else { transport = TSSLTransportFactory.getClientSocket(this.host, this.port, timeout, sslConfig.getParameters()); } TProtocol protocol = new TCompactProtocol(transport); this.client = new BdbService.Client(protocol); TProtocolVersionTestResult testResult = remoteCall( () -> this.client.isProtocolVersionSupported(dbConstants.PROTOCOL_VERSION)); if (!testResult.isSupported()) { throw new BdbConnectionException( "Driver is not compatible with the server. The " + "server requires drivers with protocol version: " + testResult.serverProtocolVersion, null); } }