public class SSLEngineFilterLayer extends FilterLayer
FilterLayer
that encrypts the communication between the upper layers and the lower layers using
the supplied SSLEngine
.Modifier and Type | Class and Description |
---|---|
static interface |
SSLEngineFilterLayer.Listener
A listener for the connection headers.
|
ProtocolLayer.Recv, ProtocolLayer.Send
EMPTY_BUFFER
Constructor and Description |
---|
SSLEngineFilterLayer(SSLEngine engine,
SSLEngineFilterLayer.Listener listener)
Constructs a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
doCloseSend()
Notify the lower layer that it should close.
|
void |
doSend(ByteBuffer message)
SPI: Sends data to the lower layer.
|
boolean |
isRecvOpen()
Tracks if this layer is accepting received data via
ProtocolLayer.Recv.onRecv(ByteBuffer) . |
boolean |
isSendOpen()
Tracks if this layer is submitting data to be sent via
ProtocolLayer.Send.doSend(ByteBuffer) . |
void |
onRecv(ByteBuffer readBuffer)
SPI: Callback on data being received from the lower layer.
|
void |
onRecvClosed(IOException cause)
Callback on the lower layer's source of data being closed.
|
void |
start()
Starts this layer.
|
public SSLEngineFilterLayer(@NonNull SSLEngine engine, @CheckForNull SSLEngineFilterLayer.Listener listener)
engine
- the engine to use.listener
- the listener to notify when handshaking is completed.public void start() throws IOException
start
in interface ProtocolLayer
start
in class FilterLayer
IOException
- if something goes wrong.public void onRecv(@NonNull ByteBuffer readBuffer) throws IOException
onRecv
in interface ProtocolLayer.Recv
onRecv
in class FilterLayer
readBuffer
- the data received. Any data consumed from the ByteBuffer
can be assumed as processed.
Any data not consumed from the ByteBuffer
will be the responsibility of the caller
to resubmit in subsequent calls.IOException
- if there was an error during processing of the received data.public void onRecvClosed(IOException cause) throws IOException
onRecvClosed
in interface ProtocolLayer.Recv
onRecvClosed
in class FilterLayer
cause
- the cause of the lower layer being closed or null
.IOException
- if there was an error during the processing of the close notification.public boolean isRecvOpen()
ProtocolLayer.Recv.onRecv(ByteBuffer)
.
Once this method returns false
it must always return false
and can be assumed to behave in
this way.isRecvOpen
in interface ProtocolLayer.Recv
isRecvOpen
in class FilterLayer
true
if accepting received data via ProtocolLayer.Recv.onRecv(ByteBuffer)
.public void doSend(@NonNull ByteBuffer message) throws IOException
doSend
in interface ProtocolLayer.Send
doSend
in class FilterLayer
message
- the data to send. Any data consumed from the ByteBuffer
can be assumed as processed.
Any data not consumed from the ByteBuffer
will be the responsibility of the caller
to resubmit in subsequent calls.IOException
- if there was an error during processing of the data.public void doCloseSend() throws IOException
ProtocolLayer.Recv.onRecvClosed(IOException)
for any upper layers.doCloseSend
in interface ProtocolLayer.Send
doCloseSend
in class FilterLayer
IOException
- if there was an error closing the lower layer.public boolean isSendOpen()
ProtocolLayer.Send.doSend(ByteBuffer)
.
Once this method returns false
it must always return false
and can be assumed to behave in
this way.isSendOpen
in interface ProtocolLayer.Send
isSendOpen
in class FilterLayer
true
if submitting data to be sent via ProtocolLayer.Send.doSend(ByteBuffer)
.Copyright © 2004–2022. All rights reserved.