|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.grizzly.util.SSLUtils
public class SSLUtils
SSL over NIO utility class. The class handle the SSLEngine operations needed to support SSL over NIO. TODO: Create an object that Wrap SSLEngine and its associated buffers.
Field Summary | |
---|---|
static int |
DEFAULT_SSL_INACTIVITY_TIMEOUT
The time to wait before timing out when reading bytes |
protected static ByteBuffer |
hsBB
|
static int |
MAX_BB_SIZE
The maximum size a ByteBuffer can take. |
Constructor Summary | |
---|---|
SSLUtils()
|
Method Summary | |
---|---|
static void |
allocateThreadBuffers(int defaultBufferSize)
Allocate the mandatory ByteBuffer s. |
static ByteBuffer |
doHandshake(SelectableChannel channel,
ByteBuffer byteBuffer,
ByteBuffer inputBB,
ByteBuffer outputBB,
SSLEngine sslEngine,
SSLEngineResult.HandshakeStatus handshakeStatus)
Perform an SSL handshake using the SSLEngine. |
static ByteBuffer |
doHandshake(SelectableChannel channel,
ByteBuffer byteBuffer,
ByteBuffer inputBB,
ByteBuffer outputBB,
SSLEngine sslEngine,
SSLEngineResult.HandshakeStatus handshakeStatus,
int timeout)
Perform an SSL handshake using the SSLEngine. |
static ByteBuffer |
doHandshake(SelectableChannel channel,
ByteBuffer byteBuffer,
ByteBuffer inputBB,
ByteBuffer outputBB,
SSLEngine sslEngine,
SSLEngineResult.HandshakeStatus handshakeStatus,
int timeout,
boolean useReadyBuffer)
Perform an SSL handshake using the SSLEngine. |
static Object[] |
doPeerCertificateChain(SelectableChannel channel,
ByteBuffer byteBuffer,
ByteBuffer inputBB,
ByteBuffer outputBB,
SSLEngine sslEngine,
boolean needClientAuth,
int timeout)
Get the peer certificate list by initiating a new handshake. |
static Utils.Result |
doRead(SelectableChannel channel,
ByteBuffer inputBB,
SSLEngine sslEngine,
int timeout)
Read encrypted bytes using an SSLEngine . |
static Utils.Result |
doSecureRead(SelectableChannel channel,
SSLEngine sslEngine,
ByteBuffer byteBuffer,
ByteBuffer inputBB)
Read and decrypt bytes from the underlying SSL connections. |
static Utils.Result |
doSecureRead(SelectableChannel channel,
SSLEngine sslEngine,
ByteBuffer byteBuffer,
ByteBuffer inputBB,
int timeout)
Read and decrypt bytes from the underlying SSL connections. |
static SSLEngineResult.HandshakeStatus |
executeDelegatedTask(SSLEngine sslEngine)
Complete handshake operations. |
static SSLEngineResult |
unwrap(ByteBuffer byteBuffer,
ByteBuffer inputBB,
SSLEngine sslEngine)
Unwrap available encrypted bytes from inputBB to
ByteBuffer using theSSLEngine |
static ByteBuffer |
unwrapAll(ByteBuffer byteBuffer,
ByteBuffer inputBB,
SSLEngine sslEngine)
Unwrap all encrypted bytes from inputBB to
ByteBuffer using theSSLEngine |
static SSLEngineResult |
wrap(ByteBuffer byteBuffer,
ByteBuffer outputBB,
SSLEngine sslEngine)
Encrypt bytes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MAX_BB_SIZE
protected static final ByteBuffer hsBB
public static int DEFAULT_SSL_INACTIVITY_TIMEOUT
Constructor Detail |
---|
public SSLUtils()
Method Detail |
---|
public static Utils.Result doSecureRead(SelectableChannel channel, SSLEngine sslEngine, ByteBuffer byteBuffer, ByteBuffer inputBB) throws IOException
channel
- underlying socket channelsslEngine{@link
- SSLEngine}byteBuffer
- buffer for application decrypted datainputBB
- buffer for reading encrypted data from socket
IOException
public static Utils.Result doSecureRead(SelectableChannel channel, SSLEngine sslEngine, ByteBuffer byteBuffer, ByteBuffer inputBB, int timeout) throws IOException
channel
- underlying socket channelsslEngine{@link
- SSLEngine}byteBuffer
- buffer for application decrypted datainputBB
- buffer for reading encrypted data from sockettimeout
- ssl inactivity timeout
IOException
public static Utils.Result doRead(SelectableChannel channel, ByteBuffer inputBB, SSLEngine sslEngine, int timeout)
SSLEngine
.
channel
- The SelectableChannel
inputBB
- The byteBuffer to store encrypted bytessslEngine
- TheSSLEngine
uses to manage the
SSL operations.timeout
- The Selector.select() timeout value. A value of 0 will
be executed as a Selector.selectNow();
public static ByteBuffer unwrapAll(ByteBuffer byteBuffer, ByteBuffer inputBB, SSLEngine sslEngine) throws IOException
inputBB
to
ByteBuffer
using theSSLEngine
byteBuffer
- the decrypted ByteBufferinputBB
- the encrypted ByteBuffersslEngine
- The SSLEngine used to manage the SSL operations.
IOException
public static SSLEngineResult unwrap(ByteBuffer byteBuffer, ByteBuffer inputBB, SSLEngine sslEngine) throws IOException
inputBB
to
ByteBuffer
using theSSLEngine
byteBuffer
- the decrypted ByteBufferinputBB
- the encrypted ByteBuffersslEngine
- The SSLEngine used to manage the SSL operations.
IOException
public static SSLEngineResult wrap(ByteBuffer byteBuffer, ByteBuffer outputBB, SSLEngine sslEngine) throws IOException
byteBuffer
- the decrypted ByteBufferoutputBB
- the encrypted ByteBuffersslEngine
- The SSLEngine used to manage the SSL operations.
IOException
public static SSLEngineResult.HandshakeStatus executeDelegatedTask(SSLEngine sslEngine)
sslEngine
- The SSLEngine used to manage the SSL operations.
public static ByteBuffer doHandshake(SelectableChannel channel, ByteBuffer byteBuffer, ByteBuffer inputBB, ByteBuffer outputBB, SSLEngine sslEngine, SSLEngineResult.HandshakeStatus handshakeStatus) throws IOException
channel
- the SelectableChannel
byteBuffer
- The application ByteBuffer
inputBB
- The encrypted input ByteBuffer
outputBB
- The encrypted output ByteBuffer
sslEngine
- The SSLEngine used.handshakeStatus
- The current handshake status
IOException
public static ByteBuffer doHandshake(SelectableChannel channel, ByteBuffer byteBuffer, ByteBuffer inputBB, ByteBuffer outputBB, SSLEngine sslEngine, SSLEngineResult.HandshakeStatus handshakeStatus, int timeout) throws IOException
channel
- the SelectableChannel
byteBuffer
- The application ByteBuffer
inputBB
- The encrypted input ByteBuffer
outputBB
- The encrypted output ByteBuffer
sslEngine
- The SSLEngine used.handshakeStatus
- The current handshake statustimeout
-
IOException
IOException
- if the handshake fail.public static ByteBuffer doHandshake(SelectableChannel channel, ByteBuffer byteBuffer, ByteBuffer inputBB, ByteBuffer outputBB, SSLEngine sslEngine, SSLEngineResult.HandshakeStatus handshakeStatus, int timeout, boolean useReadyBuffer) throws IOException
channel
- the SelectableChannel
byteBuffer
- The application ByteBuffer
inputBB
- The encrypted input ByteBuffer
outputBB
- The encrypted output ByteBuffer
sslEngine
- The SSLEngine used.handshakeStatus
- The current handshake statustimeout
- useReadyBuffer
- does method need to read data before UNWRAP or use
a data from inputBB
IOException
IOException
- if the handshake fail.public static Object[] doPeerCertificateChain(SelectableChannel channel, ByteBuffer byteBuffer, ByteBuffer inputBB, ByteBuffer outputBB, SSLEngine sslEngine, boolean needClientAuth, int timeout) throws IOException
channel
- SelectableChannel
needClientAuth
-
IOException
public static void allocateThreadBuffers(int defaultBufferSize)
ByteBuffer
s. Since the ByteBuffer
are maintained on the WorkerThread
lazily, this method
makes sure the ByteBuffers are properly allocated and configured.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |