org.apache.blur.thirdparty.thrift_0_9_0.transport
Class TSaslServerTransport

java.lang.Object
  extended by org.apache.blur.thirdparty.thrift_0_9_0.transport.TTransport
      extended by org.apache.blur.thirdparty.thrift_0_9_0.transport.TSaslServerTransport

public class TSaslServerTransport
extends TTransport

Wraps another Thrift TTransport, but performs SASL server negotiation on the call to open(). This class will wrap ensuing communication over it, if a SASL QOP is negotiated with the other party.


Nested Class Summary
static class TSaslServerTransport.Factory
          TTransportFactory to create TSaslServerTransports.
 
Constructor Summary
TSaslServerTransport(String mechanism, String protocol, String serverName, Map<String,String> props, CallbackHandler cbh, TTransport transport)
          Creates a SaslServer using the given SASL-specific parameters.
TSaslServerTransport(TTransport transport)
          Uses the given underlying transport.
 
Method Summary
 void addServerDefinition(String mechanism, String protocol, String serverName, Map<String,String> props, CallbackHandler cbh)
          Add a supported server definition to this transport.
 void close()
          Closes the underlying transport and disposes of the SASL implementation underlying this transport.
 void flush()
          Flushes to the underlying transport.
 javax.security.sasl.SaslClient getSaslClient()
          Get the underlying SaslClient.
 javax.security.sasl.SaslServer getSaslServer()
          Get the underlying SaslServer.
 TTransport getUnderlyingTransport()
          Get the underlying transport that Sasl is using.
 boolean isOpen()
          True if the underlying transport is open and the SASL handshake is complete.
 void open()
          Opens the underlying transport if it's not already open and then performs SASL negotiation.
 int read(byte[] buf, int off, int len)
          Read from the underlying transport.
 void write(byte[] buf, int off, int len)
          Write to the underlying transport.
 
Methods inherited from class org.apache.blur.thirdparty.thrift_0_9_0.transport.TTransport
consumeBuffer, getBuffer, getBufferPosition, getBytesRemainingInBuffer, peek, readAll, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TSaslServerTransport

public TSaslServerTransport(TTransport transport)
Uses the given underlying transport. Assumes that addServerDefinition is called later.

Parameters:
transport - Transport underlying this one.

TSaslServerTransport

public TSaslServerTransport(String mechanism,
                            String protocol,
                            String serverName,
                            Map<String,String> props,
                            CallbackHandler cbh,
                            TTransport transport)
Creates a SaslServer using the given SASL-specific parameters. See the Java documentation for Sasl.createSaslServer for the details of the parameters.

Parameters:
transport - The underlying Thrift transport.
Method Detail

addServerDefinition

public void addServerDefinition(String mechanism,
                                String protocol,
                                String serverName,
                                Map<String,String> props,
                                CallbackHandler cbh)
Add a supported server definition to this transport. See the Java documentation for Sasl.createSaslServer for the details of the parameters.


open

public void open()
          throws TTransportException
Opens the underlying transport if it's not already open and then performs SASL negotiation. If a QOP is negotiated during this SASL handshake, it used for all communication on this transport after this call is complete.

Specified by:
open in class TTransport
Throws:
TTransportException - if the transport could not be opened

getSaslClient

public javax.security.sasl.SaslClient getSaslClient()
Get the underlying SaslClient.

Returns:
The SaslClient, or null if this transport is backed by a SaslServer.

getUnderlyingTransport

public TTransport getUnderlyingTransport()
Get the underlying transport that Sasl is using.

Returns:
The TTransport transport

getSaslServer

public javax.security.sasl.SaslServer getSaslServer()
Get the underlying SaslServer.

Returns:
The SaslServer, or null if this transport is backed by a SaslClient.

close

public void close()
Closes the underlying transport and disposes of the SASL implementation underlying this transport.

Specified by:
close in class TTransport

isOpen

public boolean isOpen()
True if the underlying transport is open and the SASL handshake is complete.

Specified by:
isOpen in class TTransport
Returns:
True if the transport is open.

read

public int read(byte[] buf,
                int off,
                int len)
         throws TTransportException
Read from the underlying transport. Unwraps the contents if a QOP was negotiated during the SASL handshake.

Specified by:
read in class TTransport
Parameters:
buf - Array to read into
off - Index to start reading at
len - Maximum number of bytes to read
Returns:
The number of bytes actually read
Throws:
TTransportException - if there was an error reading data

write

public void write(byte[] buf,
                  int off,
                  int len)
           throws TTransportException
Write to the underlying transport.

Specified by:
write in class TTransport
Parameters:
buf - The output data buffer
off - The offset to start writing from
len - The number of bytes to write
Throws:
TTransportException - if there was an error writing data

flush

public void flush()
           throws TTransportException
Flushes to the underlying transport. Wraps the contents if a QOP was negotiated during the SASL handshake.

Overrides:
flush in class TTransport
Throws:
TTransportException - if there was an error writing out data.


Copyright © 2012-2014 The Apache Software Foundation. All Rights Reserved.