Search in sources :

Example 26 with TTransport

use of org.apache.thrift.transport.TTransport in project alluxio by Alluxio.

the class TransportProviderTest method simpleAuthenticationEmptyUser.

/**
   * In SIMPLE mode, if client's username is empty, an exception should be thrown in server side.
   */
@Test
public void simpleAuthenticationEmptyUser() throws Exception {
    Configuration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.SIMPLE.getAuthName());
    mTransportProvider = TransportProvider.Factory.create();
    // start server
    startServerThread();
    // check case that user is empty
    mThrown.expect(TTransportException.class);
    mThrown.expectMessage("Peer indicated failure: Plain authentication failed: No authentication" + " identity provided");
    TTransport client = ((PlainSaslTransportProvider) mTransportProvider).getClientTransport("", "whatever", mServerAddress);
    try {
        client.open();
    } finally {
        mServer.stop();
    }
}
Also used : TTransport(org.apache.thrift.transport.TTransport) Test(org.junit.Test)

Example 27 with TTransport

use of org.apache.thrift.transport.TTransport in project alluxio by Alluxio.

the class TransportProviderTest method simpleAuthentication.

/**
   * In SIMPLE mode, the TTransport mechanism is PLAIN. When server authenticate the connected
   * client user, it use {@link SimpleAuthenticationProvider}.
   */
@Test
public void simpleAuthentication() throws Exception {
    Configuration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.SIMPLE.getAuthName());
    mTransportProvider = TransportProvider.Factory.create();
    // start server
    startServerThread();
    // when connecting, authentication happens. It is a no-op in Simple mode.
    TTransport client = mTransportProvider.getClientTransport(mServerAddress);
    client.open();
    Assert.assertTrue(client.isOpen());
    // clean up
    client.close();
    mServer.stop();
}
Also used : TTransport(org.apache.thrift.transport.TTransport) Test(org.junit.Test)

Example 28 with TTransport

use of org.apache.thrift.transport.TTransport in project alluxio by Alluxio.

the class TransportProviderTest method simpleAuthenticationEmptyPassword.

/**
   * In SIMPLE mode, if client's password is empty, an exception should be thrown in server side.
   * Although password is actually not used and we do not really authenticate the user in SIMPLE
   * mode, we need the Plain SASL server has ability to check empty password.
   */
@Test
public void simpleAuthenticationEmptyPassword() throws Exception {
    Configuration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.SIMPLE.getAuthName());
    mTransportProvider = TransportProvider.Factory.create();
    // start server
    startServerThread();
    // check case that password is empty
    mThrown.expect(TTransportException.class);
    mThrown.expectMessage("Peer indicated failure: Plain authentication failed: No password " + "provided");
    TTransport client = ((PlainSaslTransportProvider) mTransportProvider).getClientTransport("anyone", "", mServerAddress);
    try {
        client.open();
    } finally {
        mServer.stop();
    }
}
Also used : TTransport(org.apache.thrift.transport.TTransport) Test(org.junit.Test)

Example 29 with TTransport

use of org.apache.thrift.transport.TTransport in project metacat by Netflix.

the class HiveMetastoreClientFactory method createRawTransport.

protected TTransport createRawTransport(final String host, final int port) throws TTransportException {
    if (socksProxy == null) {
        final TTransport transport = new TSocket(host, port, timeoutMillis);
        try {
            transport.open();
            return transport;
        } catch (Throwable t) {
            transport.close();
            throw t;
        }
    }
    final Socket socks = createSocksSocket(socksProxy);
    try {
        try {
            socks.connect(InetSocketAddress.createUnresolved(host, port), timeoutMillis);
            socks.setSoTimeout(timeoutMillis);
            return new TSocket(socks);
        } catch (Throwable t) {
            closeQuietly(socks);
            throw t;
        }
    } catch (IOException e) {
        throw new TTransportException(e);
    }
}
Also used : TTransportException(org.apache.thrift.transport.TTransportException) TTransport(org.apache.thrift.transport.TTransport) IOException(java.io.IOException) Socket(java.net.Socket) TSocket(org.apache.thrift.transport.TSocket) TSocket(org.apache.thrift.transport.TSocket)

Example 30 with TTransport

use of org.apache.thrift.transport.TTransport in project eiger by wlloyd.

the class WordCountSetup method createConnection.

private static Cassandra.Client createConnection(String host, Integer port, boolean framed) throws TTransportException {
    TSocket socket = new TSocket(host, port);
    TTransport trans = framed ? new TFramedTransport(socket) : socket;
    trans.open();
    TProtocol protocol = new TBinaryProtocol(trans);
    return new Cassandra.Client(protocol);
}
Also used : TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) TProtocol(org.apache.thrift.protocol.TProtocol) TFramedTransport(org.apache.thrift.transport.TFramedTransport) TTransport(org.apache.thrift.transport.TTransport) TSocket(org.apache.thrift.transport.TSocket)

Aggregations

TTransport (org.apache.thrift.transport.TTransport)99 TSocket (org.apache.thrift.transport.TSocket)43 TProtocol (org.apache.thrift.protocol.TProtocol)42 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)36 TFramedTransport (org.apache.thrift.transport.TFramedTransport)28 TTransportException (org.apache.thrift.transport.TTransportException)20 Test (org.junit.Test)20 TException (org.apache.thrift.TException)18 IOException (java.io.IOException)12 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)10 ArrayList (java.util.ArrayList)9 TIOStreamTransport (org.apache.thrift.transport.TIOStreamTransport)8 HashMap (java.util.HashMap)6 Socket (java.net.Socket)5 TCLIService (org.apache.hive.service.rpc.thrift.TCLIService)5 THttpClient (org.apache.thrift.transport.THttpClient)4 TSaslClientTransport (org.apache.thrift.transport.TSaslClientTransport)4 ChannelBuffer (com.alibaba.dubbo.remoting.buffer.ChannelBuffer)3 Request (com.alibaba.dubbo.remoting.exchange.Request)3 Demo (com.alibaba.dubbo.rpc.gen.thrift.Demo)3