Java Code Examples for org.apache.thrift.transport.TSSLTransportFactory#TSSLTransportParameters

The following examples show how to use org.apache.thrift.transport.TSSLTransportFactory#TSSLTransportParameters . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TCPThriftAuthenticationService.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public void start() throws TTransportException, UnknownHostException {
    InetAddress inetAddress = InetAddress.getByName(hostName);

    TSSLTransportFactory.TSSLTransportParameters params =
            new TSSLTransportFactory.TSSLTransportParameters();
    params.setKeyStore(keyStore, keyStorePassword);

    TServerSocket serverTransport;

    serverTransport = TSSLTransportFactory.getServerSocket(port, clientTimeout, inetAddress, params);


    AuthenticatorService.Processor<AuthenticatorServiceImpl> processor =
            new AuthenticatorService.Processor<AuthenticatorServiceImpl>(
                    new AuthenticatorServiceImpl(thriftAuthenticatorService));
    authenticationServer = new TThreadPoolServer(
            new TThreadPoolServer.Args(serverTransport).processor(processor));
    Thread thread = new Thread(new ServerRunnable(authenticationServer));
    if (log.isDebugEnabled()) {
        log.debug("Thrift Authentication Service started at ssl://" + hostName + ":" + port);
    }
    thread.start();
}
 
Example 2
Source File: ThriftEntitlementServiceClient.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
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);
    }
 
Example 3
Source File: ThriftEntitlementServiceClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
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);
    }
 
Example 4
Source File: SSLTransportFactory.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 5
Source File: TCPThriftAuthenticationService.java    From carbon-identity-framework with Apache License 2.0 4 votes vote down vote up
public void start() throws TTransportException, UnknownHostException {
    InetAddress inetAddress = InetAddress.getByName(hostName);

    TSSLTransportFactory.TSSLTransportParameters params =
            new TSSLTransportFactory.TSSLTransportParameters();
    params.setKeyStore(keyStore, keyStorePassword);

    TServerSocket serverTransport;

    serverTransport = TSSLTransportFactory.getServerSocket(port, clientTimeout, inetAddress, params);
    SSLServerSocket sslServerSocket = (javax.net.ssl.SSLServerSocket) serverTransport.getServerSocket();

    OMElement sslEnabledProtocolsElement = ThriftAuthenticationConfigParser.getInstance()
            .getConfigElement(ThriftAuthenticationConstants.CONFIG_SSL_ENABLED_PROTOCOLS);
    if (sslEnabledProtocolsElement != null) {
        String sslEnabledProtocols = sslEnabledProtocolsElement.getText();
        if (StringUtils.isNotBlank(sslEnabledProtocols)) {
            String[] sslProtocolsArray = sslEnabledProtocols.split(",");
            sslServerSocket.setEnabledProtocols(sslProtocolsArray);
        }
    }

    OMElement ciphersElement = ThriftAuthenticationConfigParser.getInstance()
            .getConfigElement(ThriftAuthenticationConstants.CONFIG_CIPHERS);
    if (ciphersElement != null) {
        String ciphers = ciphersElement.getText();
        if (StringUtils.isNotBlank(ciphers)) {
            String[] ciphersArray = ciphers.split(",");
            sslServerSocket.setEnabledCipherSuites(ciphersArray);
        }
    }

    AuthenticatorService.Processor<AuthenticatorServiceImpl> processor =
            new AuthenticatorService.Processor<AuthenticatorServiceImpl>(
                    new AuthenticatorServiceImpl(thriftAuthenticatorService));
    authenticationServer = new TThreadPoolServer(
            new TThreadPoolServer.Args(serverTransport).processor(processor));
    Thread thread = new Thread(new ServerRunnable(authenticationServer));
    if (log.isDebugEnabled()) {
        log.debug("Thrift Authentication Service started at ssl://" + hostName + ":" + port);
    }
    thread.start();
}