Package org.apache.thrift.transport.sasl
Class NonblockingSaslHandler
- java.lang.Object
-
- org.apache.thrift.transport.sasl.NonblockingSaslHandler
-
public class NonblockingSaslHandler extends java.lang.ObjectState machine managing one sasl connection in a nonblocking way.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNonblockingSaslHandler.Phase
-
Constructor Summary
Constructors Constructor Description NonblockingSaslHandler(java.nio.channels.SelectionKey selectionKey, TNonblockingTransport underlyingTransport, TSaslServerFactory saslServerFactory, TSaslProcessorFactory processorFactory, TProtocolFactory inputProtocolFactory, TProtocolFactory outputProtocolFactory, TServerEventHandler eventHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Release all the resources managed by this state machine (connection, selection and sasl server).NonblockingSaslHandler.PhasegetCurrentPhase()Get current phase of the state machine.NonblockingSaslHandler.PhasegetNextPhase()Get next phase of the state machine.javax.security.sasl.SaslServergetSaslServer()TNonblockingTransportgetUnderlyingTransport()voidhandleRead()When current phase is intrested in read selection, calling this will run the current phase and its following phases if the following ones are interested to read, until there is nothing available in the underlying transport.voidhandleWrite()Similiar to handleRead.booleanisCurrentPhaseDone()voidrunCurrentPhase()Run state machine.voidstepToNextPhase()When current phase is finished, it's expected to call this method first before running the state machine again.
-
-
-
Constructor Detail
-
NonblockingSaslHandler
public NonblockingSaslHandler(java.nio.channels.SelectionKey selectionKey, TNonblockingTransport underlyingTransport, TSaslServerFactory saslServerFactory, TSaslProcessorFactory processorFactory, TProtocolFactory inputProtocolFactory, TProtocolFactory outputProtocolFactory, TServerEventHandler eventHandler)
-
-
Method Detail
-
getCurrentPhase
public NonblockingSaslHandler.Phase getCurrentPhase()
Get current phase of the state machine.- Returns:
- current phase.
-
getNextPhase
public NonblockingSaslHandler.Phase getNextPhase()
Get next phase of the state machine. It is different from current phase iff current phase is done (and next phase not yet started).- Returns:
- next phase.
-
getUnderlyingTransport
public TNonblockingTransport getUnderlyingTransport()
- Returns:
- underlying nonblocking socket
-
getSaslServer
public javax.security.sasl.SaslServer getSaslServer()
- Returns:
- SaslServer instance
-
isCurrentPhaseDone
public boolean isCurrentPhaseDone()
- Returns:
- true if current phase is done.
-
runCurrentPhase
public void runCurrentPhase()
Run state machine.- Throws:
java.lang.IllegalStateException- if current state is already done.
-
handleRead
public void handleRead()
When current phase is intrested in read selection, calling this will run the current phase and its following phases if the following ones are interested to read, until there is nothing available in the underlying transport.- Throws:
java.lang.IllegalStateException- if is called in an irrelevant phase.
-
handleWrite
public void handleWrite()
Similiar to handleRead. But it is for write ops.- Throws:
java.lang.IllegalStateException- if it is called in an irrelevant phase.
-
stepToNextPhase
public void stepToNextPhase()
When current phase is finished, it's expected to call this method first before running the state machine again. By calling this, "next phase" is marked as started (and not done), thus is ready to run.- Throws:
java.lang.IllegalArgumentException- if current phase is not yet done.
-
close
public void close()
Release all the resources managed by this state machine (connection, selection and sasl server). To avoid being blocked, this should be invoked in the network thread that manages the selector.
-
-