本文整理汇总了Java中org.apache.thrift.transport.TSSLTransportFactory.getClientSocket方法的典型用法代码示例。如果您正苦于以下问题:Java TSSLTransportFactory.getClientSocket方法的具体用法?Java TSSLTransportFactory.getClientSocket怎么用?Java TSSLTransportFactory.getClientSocket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.thrift.transport.TSSLTransportFactory
的用法示例。
在下文中一共展示了TSSLTransportFactory.getClientSocket方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAiravataSecureClient
import org.apache.thrift.transport.TSSLTransportFactory; //导入方法依赖的package包/类
/**
* This method returns a Airavata Client that talks to the API Server exposed over TLS.
*
* @param serverHost
* @param serverPort
* @param trustStorePath
* @param trustStorePassword
* @param clientTimeOut
* @return
* @throws AiravataClientConnectException
*/
public static Airavata.Client createAiravataSecureClient(String serverHost, int serverPort, String trustStorePath,
String trustStorePassword, int clientTimeOut)
throws AiravataClientException {
try {
TSSLTransportFactory.TSSLTransportParameters params =
new TSSLTransportFactory.TSSLTransportParameters();
params.setTrustStore(trustStorePath, trustStorePassword);
TSocket transport = TSSLTransportFactory.getClientSocket(serverHost, serverPort, clientTimeOut, params);
TProtocol protocol = new TBinaryProtocol(transport);
return new Airavata.Client(protocol);
} catch (TTransportException e) {
logger.error(e.getMessage(), e);
AiravataClientException clientError = new AiravataClientException();
clientError.setParameter("Unable to connect to the server at " + serverHost + ":" + serverPort);
throw clientError;
}
}
示例2: init
import org.apache.thrift.transport.TSSLTransportFactory; //导入方法依赖的package包/类
public synchronized void init() throws TTransportException {
if (null != client) {
return;
}
if (null == truststore) {
transport = new TSocket(ip, port);
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.
*/
String truststore_arr[] = truststore.split("@");
if (truststore_arr.length != 2) {
throw new RuntimeException("client.truststore 格式错误(缺少 @密码):" + truststore);
}
TSSLTransportParameters params = new TSSLTransportParameters();
if (truststore_arr[0].endsWith(".truststore")) {
params.setTrustStore(truststore_arr[0], truststore_arr[1], "SunX509", "JKS");
} else {
params.setTrustStore(truststore_arr[0], truststore_arr[1], "X509", "BKS");
}
/*
* 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(ip, port, RemoteSyncConfig.getTimeout(), params);
}
TProtocol protocol = new TBinaryProtocol(transport);
client = new SyncFileServer.Client(protocol);
}
示例3: openTransport
import org.apache.thrift.transport.TSSLTransportFactory; //导入方法依赖的package包/类
@Override
public TTransport openTransport(String host, int port) throws Exception
{
TSSLTransportFactory.TSSLTransportParameters params = new TSSLTransportFactory.TSSLTransportParameters(protocol, cipherSuites);
params.setTrustStore(truststore, truststorePassword);
if (null != keystore)
params.setKeyStore(keystore, keystorePassword);
TTransport trans = TSSLTransportFactory.getClientSocket(host, port, SOCKET_TIMEOUT, params);
int frameSize = 15 * 1024 * 1024; // 15 MiB
return new TFramedTransport(trans, frameSize);
}
示例4: getTransport
import org.apache.thrift.transport.TSSLTransportFactory; //导入方法依赖的package包/类
public TTransport getTransport(TTransport trans)
{
final CliSessionState sessionState = CliMain.sessionState;
try
{
TSSLTransportParameters params = new TSSLTransportParameters(sessionState.encOptions.protocol, sessionState.encOptions.cipher_suites);
params.setTrustStore(sessionState.encOptions.truststore, sessionState.encOptions.truststore_password);
trans = TSSLTransportFactory.getClientSocket(sessionState.hostName, sessionState.thriftPort, SOCKET_TIMEOUT, params);
return new FramedTransportFactory().getTransport(trans);
}
catch (TTransportException e)
{
throw new RuntimeException("Failed to create a client SSL connection.", e);
}
}
示例5: openTransport
import org.apache.thrift.transport.TSSLTransportFactory; //导入方法依赖的package包/类
@Override
@SuppressWarnings("resource")
public TTransport openTransport(String host, int port) throws Exception
{
TSSLTransportFactory.TSSLTransportParameters params = new TSSLTransportFactory.TSSLTransportParameters(protocol, cipherSuites);
params.setTrustStore(truststore, truststorePassword);
if (null != keystore)
params.setKeyStore(keystore, keystorePassword);
TTransport trans = TSSLTransportFactory.getClientSocket(host, port, SOCKET_TIMEOUT, params);
return new TFramedTransport(trans, DEFAULT_MAX_FRAME_SIZE);
}
示例6: getThriftClient
import org.apache.thrift.transport.TSSLTransportFactory; //导入方法依赖的package包/类
private EntitlementThriftClient.Client getThriftClient() throws Exception {
TSSLTransportFactory.TSSLTransportParameters param = new TSSLTransportFactory.TSSLTransportParameters();
param.setTrustStore(trustStore, trustStorePass);
TTransport transport;
transport = TSSLTransportFactory.getClientSocket(thriftHost, thriftPort, ProxyConstants.THRIFT_TIME_OUT, param);
TProtocol protocol = new TBinaryProtocol(transport);
return new EntitlementThriftClient.Client(protocol);
}
示例7: openTransport
import org.apache.thrift.transport.TSSLTransportFactory; //导入方法依赖的package包/类
@Override
public TTransport openTransport(String host, int port) throws Exception
{
TSSLTransportFactory.TSSLTransportParameters params = new TSSLTransportFactory.TSSLTransportParameters(protocol, cipherSuites);
params.setTrustStore(truststore, truststorePassword);
if (null != keystore)
params.setKeyStore(keystore, keystorePassword);
TTransport trans = TSSLTransportFactory.getClientSocket(host, port, SOCKET_TIMEOUT, params);
return new FramedTransportFactory().getTransport(trans);
}
示例8: getClientProtocol
import org.apache.thrift.transport.TSSLTransportFactory; //导入方法依赖的package包/类
@Override
public TProtocol getClientProtocol(String serviceInterfaceClassName, String host, Integer port) throws TTransportException {
if(truststoreFile == null || truststorePass == null){
throw new IllegalStateException("truststore not defined. Initialize the Factory properly");
}
TSSLTransportFactory.TSSLTransportParameters paramsClient = new TSSLTransportFactory.TSSLTransportParameters();
paramsClient.setTrustStore(truststoreFile, truststorePass);
TTransport transport = TSSLTransportFactory.getClientSocket(host, port, 1000, paramsClient);
TProtocol protocol = new TBinaryProtocol(transport);
return new TMultiplexedProtocol(protocol, serviceInterfaceClassName);
}
示例9: createTLSSocket
import org.apache.thrift.transport.TSSLTransportFactory; //导入方法依赖的package包/类
private TSocket createTLSSocket(String host) throws TTransportException {
TSSLTransportParameters sslParams = new TSSLTransportParameters("SSL", m_dbtls_cipher_suites);
if (!Utils.isEmpty(m_keystore)) {
sslParams.setKeyStore(m_keystore, m_keystorepassword);
}
if (!Utils.isEmpty(m_truststore)) {
sslParams.setTrustStore(m_truststore, m_truststorepassword);
}
return TSSLTransportFactory.getClientSocket(host, m_dbport, m_db_timeout_millis, sslParams);
}
示例10: main
import org.apache.thrift.transport.TSSLTransportFactory; //导入方法依赖的package包/类
public static void main(String [] args) {
if (args.length != 1) {
System.out.println("Please enter 'simple' or 'secure'");
System.exit(0);
}
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();
}
}