public abstract class SSL
extends java.lang.Object
implements java.lang.Runnable
Modifier and Type | Field and Description |
---|---|
static java.util.Set<javax.net.ssl.SSLEngineResult.HandshakeStatus> |
AFTER_HANDSHAKE
Set of HandshakeStatus values after the end of SSL handshake
|
protected int |
appBufferMax
Application buffer size
|
protected boolean |
checkSeqNo
Use packet seqNo instrumentation
|
protected long |
cSeqNo
Current packet seqNo
|
protected java.util.concurrent.atomic.AtomicBoolean |
done
Handshake done flag
|
private boolean |
dumpSSL
Dump SSL packets flasg
|
protected javax.net.ssl.SSLEngine |
engine
SSLEngine instance
|
protected java.util.concurrent.ExecutorService |
fsmWorkers
ExecutorService for internal tasks' execution
|
protected HexDump |
hex
dump halper
|
protected java.util.Queue<java.nio.ByteBuffer> |
incomingBuffers
Input chunks' queue
|
protected java.util.concurrent.locks.ReentrantLock |
inpGuard
Input stream guard
|
protected java.util.concurrent.atomic.AtomicLong |
inpSeqNo
Input packet seqNo holder
|
protected java.nio.ByteBuffer |
inpUnwrap
Outgoing buffers
|
protected java.nio.ByteBuffer |
inpWrap
Outgoing buffers
|
protected static java.util.logging.Logger |
LOG
Logger
|
private int |
maxMessageSize
Max message size
|
protected int |
netBufferMax
Packet buffer size
|
protected java.util.concurrent.locks.ReentrantLock |
outGuard
Output stream guard
|
protected java.util.concurrent.atomic.AtomicLong |
outSeqNo
Output packet seqNo generator
|
protected java.nio.ByteBuffer |
outUnwrap
Incoming buffers
|
protected java.nio.ByteBuffer |
outWrap
Incoming buffers
|
private boolean |
trackSeqNo
Use packet seqNo instrumentation
|
Constructor and Description |
---|
SSL(javax.net.ssl.SSLEngine engine,
java.util.concurrent.ExecutorService fsmWorkers)
Constructor
|
Modifier and Type | Method and Description |
---|---|
private boolean |
appendIncoming()
Append input data to the processing buffer if possible.
|
abstract void |
checkInput()
Check if more input is available for processing
|
private boolean |
doUnwrap()
Decrypt the next portion of input.
|
private boolean |
doWrap()
Encrypt the next portion of output.
|
protected int |
getMaxMessageSize()
Get maximal message size
|
private boolean |
handshake()
Make a next step of handshake or process input/output data
|
boolean |
handshakeDone()
Check if handshake is finished
|
protected void |
log(java.lang.String message)
Write message to stderr
|
protected void |
log(java.lang.String fmt,
java.lang.Object... args)
Write a message to stdout using the specified format string and
arguments.
|
abstract void |
nextChunk(java.nio.ByteBuffer decrypted)
Accept the next decrypted portion of the input
|
void |
notify(java.nio.ByteBuffer data)
Notify about new portion of the input
|
abstract void |
onClosed()
Called on the SSL session close
|
protected abstract void |
onFailure(java.lang.Exception ex)
Report the handshake failure
|
void |
onInput(java.nio.ByteBuffer decrypted)
Process the next portion of the decrypted input
|
abstract void |
onOutput(java.nio.ByteBuffer encrypted)
Process the next portion of the encrypted output
|
protected void |
onSuccess()
Report the handshake success
|
void |
run()
Perform next FSM step
|
void |
send(java.nio.ByteBuffer data)
Process the next portion of the output
|
protected void |
tryLock(java.util.concurrent.locks.Lock lock)
Timed lock acquisition
|
private boolean |
unwrap()
Decrypt the next portion of input (guarded).
|
private boolean |
wrap()
Encrypt the next portion of output (guarded).
|
protected static final java.util.logging.Logger LOG
public static final java.util.Set<javax.net.ssl.SSLEngineResult.HandshakeStatus> AFTER_HANDSHAKE
protected final javax.net.ssl.SSLEngine engine
protected final java.util.concurrent.ExecutorService fsmWorkers
protected final int appBufferMax
protected final int netBufferMax
protected final java.nio.ByteBuffer outWrap
protected final java.nio.ByteBuffer outUnwrap
protected final java.nio.ByteBuffer inpWrap
protected final java.nio.ByteBuffer inpUnwrap
protected volatile java.util.concurrent.atomic.AtomicBoolean done
protected final java.util.Queue<java.nio.ByteBuffer> incomingBuffers
protected final java.util.concurrent.locks.ReentrantLock inpGuard
protected final java.util.concurrent.locks.ReentrantLock outGuard
private final int maxMessageSize
private final boolean dumpSSL
private final boolean trackSeqNo
protected final java.util.concurrent.atomic.AtomicLong inpSeqNo
protected final java.util.concurrent.atomic.AtomicLong outSeqNo
protected long cSeqNo
protected boolean checkSeqNo
protected final HexDump hex
public SSL(javax.net.ssl.SSLEngine engine, java.util.concurrent.ExecutorService fsmWorkers)
engine
- the SSLEngine instancefsmWorkers
- ExecutorService for internal tasks' executionpublic boolean handshakeDone()
true
if handshake is finishedpublic abstract void nextChunk(java.nio.ByteBuffer decrypted)
decrypted
- the next decrypted portion of the inputpublic abstract void checkInput() throws java.io.IOException
java.io.IOException
- on network failurepublic abstract void onOutput(java.nio.ByteBuffer encrypted)
encrypted
- the next portion of the encrypted outputpublic abstract void onClosed()
public void onInput(java.nio.ByteBuffer decrypted)
decrypted
- the next portion of the decrypted inputpublic void send(java.nio.ByteBuffer data)
data
- the next portion of the outputpublic void notify(java.nio.ByteBuffer data)
data
- a new portion of the inputpublic void run()
run
in interface java.lang.Runnable
protected abstract void onFailure(java.lang.Exception ex)
ex
- The exception which caused the failureprotected void onSuccess()
protected int getMaxMessageSize()
protected void log(java.lang.String message)
message
- message to be writtenprotected void log(java.lang.String fmt, java.lang.Object... args)
fmt
- A format stringargs
- Arguments referenced by the format specifiers in the format
string.protected void tryLock(java.util.concurrent.locks.Lock lock)
lock
- lock to be acquiredprivate boolean appendIncoming()
true
if data was appended to the incoming bufferprivate boolean handshake()
true
if the step was successful and the engine is ready for
the next stepprivate boolean wrap()
true
if the operation was successfulprivate boolean doWrap()
true
if the operation was successfulprivate boolean unwrap()
true
if the operation was successfulprivate boolean doUnwrap()
true
if the operation was successful