public class SslConnection extends AbstractConnection
Connection like HttpConnection) that
wants unencrypted data.
The connector uses an EndPoint (typically SelectChannelEndPoint) as
it's source/sink of encrypted data. It then provides an endpoint via getDecryptedEndPoint() to
expose a source/sink of unencrypted data to another connection (eg HttpConnection).
The design of this class is based on a clear separation between the passive methods, which do not block nor schedule any asynchronous callbacks, and active methods that do schedule asynchronous callbacks.
The passive methods are SslConnection.DecryptedEndPoint.fill(ByteBuffer) and SslConnection.DecryptedEndPoint.flush(ByteBuffer...). They make best
effort attempts to progress the connection using only calls to the encrypted EndPoint.fill(ByteBuffer) and EndPoint.flush(ByteBuffer...)
methods. They will never block nor schedule any readInterest or write callbacks. If a fill/flush cannot progress either because
of network congestion or waiting for an SSL handshake message, then the fill/flush will simply return with zero bytes filled/flushed.
Specifically, if a flush cannot proceed because it needs to receive a handshake message, then the flush will attempt to fill bytes from the
encrypted endpoint, but if insufficient bytes are read it will NOT call EndPoint.fillInterested(Callback).
It is only the active methods : AbstractEndPoint.fillInterested(Callback) and
AbstractEndPoint.write(Callback, ByteBuffer...) that may schedule callbacks by calling the encrypted
EndPoint.fillInterested(Callback) and EndPoint.write(Callback, ByteBuffer...)
methods. For normal data handling, the decrypted fillInterest method will result in an encrypted fillInterest and a decrypted
write will result in an encrypted write. However, due to SSL handshaking requirements, it is also possible for a decrypted fill
to call the encrypted write and for the decrypted flush to call the encrypted fillInterested methods.
MOST IMPORTANTLY, the encrypted callbacks from the active methods (#onFillable() and WriteFlusher#completeWrite()) do no filling or flushing themselves. Instead they simple make the callbacks to the decrypted callbacks, so that the passive encrypted fill/flush will be called again and make another best effort attempt to progress the connection.
| Modifier and Type | Class and Description |
|---|---|
class |
SslConnection.DecryptedEndPoint |
AbstractConnection.FillingInterestedCallback, AbstractConnection.NestedState, AbstractConnection.StateConnection.ListenerEXECUTE_ONFILLABLE, FILL_INTERESTED, FILLING, FILLING_FILL_INTERESTED, IDLE, REFILLING| Constructor and Description |
|---|
SslConnection(ByteBufferPool byteBufferPool,
Executor executor,
EndPoint endPoint,
SSLEngine sslEngine) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Performs a logical close of this connection.
|
SslConnection.DecryptedEndPoint |
getDecryptedEndPoint() |
SSLEngine |
getSSLEngine() |
boolean |
isRenegotiationAllowed() |
protected SslConnection.DecryptedEndPoint |
newDecryptedEndPoint() |
void |
onClose()
Callback method invoked when this
Connection is closed. |
void |
onFillable()
Callback method invoked when the endpoint is ready to be read.
|
void |
onFillInterestedFailed(Throwable cause)
Callback method invoked when the endpoint failed to be ready to be read.
|
void |
onOpen()
Callback method invoked when this
Connection is opened. |
void |
setRenegotiationAllowed(boolean renegotiationAllowed) |
String |
toString() |
addListener, failedCallback, fillInterested, fillInterested, getBytesIn, getBytesOut, getCreatedTimeStamp, getEndPoint, getExecutor, getInputBufferSize, getMessagesIn, getMessagesOut, next, onReadTimeout, setInputBufferSizepublic SslConnection(ByteBufferPool byteBufferPool, Executor executor, EndPoint endPoint, SSLEngine sslEngine)
protected SslConnection.DecryptedEndPoint newDecryptedEndPoint()
public SSLEngine getSSLEngine()
public SslConnection.DecryptedEndPoint getDecryptedEndPoint()
public boolean isRenegotiationAllowed()
public void setRenegotiationAllowed(boolean renegotiationAllowed)
public void onOpen()
ConnectionCallback method invoked when this Connection is opened.
Creators of the connection implementation are responsible for calling this method.
onOpen in interface ConnectiononOpen in class AbstractConnectionpublic void onClose()
ConnectionCallback method invoked when this Connection is closed.
Creators of the connection implementation are responsible for calling this method.
onClose in interface ConnectiononClose in class AbstractConnectionpublic void close()
ConnectionPerforms a logical close of this connection.
For simple connections, this may just mean to delegate the close to the associated
EndPoint but, for example, SSL connections should write the SSL close message
before closing the associated EndPoint.
close in interface Closeableclose in interface AutoCloseableclose in interface Connectionclose in class AbstractConnectionpublic void onFillable()
AbstractConnectionCallback method invoked when the endpoint is ready to be read.
onFillable in class AbstractConnectionAbstractConnection.fillInterested()public void onFillInterestedFailed(Throwable cause)
AbstractConnectionCallback method invoked when the endpoint failed to be ready to be read.
onFillInterestedFailed in class AbstractConnectioncause - the exception that caused the failurepublic String toString()
toString in class AbstractConnectionCopyright © 1995-2015 Webtide. All Rights Reserved.