public final class SSLUtil extends Object
Modifier and Type | Method and Description |
---|---|
static void |
doHandshake(SocketChannel p_socketChannel,
SSLEngine p_sslEngine,
ByteBuffer p_outAppBuf,
ByteBuffer p_outNetBuf,
ByteBuffer p_inAppBuf,
ByteBuffer p_inNetBuf)
Perform a SSL handshake.
|
static KeyStore |
loadKeyStore(String p_strType,
String p_strPath,
String p_strPassphrase)
Load a keystore.
|
static int |
read(SocketChannel p_channel,
SSLEngine p_sslEngine,
ByteBuffer p_inAppBuf,
ByteBuffer p_inNetBuf)
The buffer
p_inAppBuf is flipped and contains
decrypted data when this method returns. |
static void |
readClosingMessage(SocketChannel p_channel,
SSLEngine p_sslEngine,
ByteBuffer p_inAppBuf,
ByteBuffer p_inNetBuf)
Receive a SSL close message from the peer.
|
static void |
write(SocketChannel p_channel,
SSLEngine p_sslEngine,
ByteBuffer p_outAppBuf,
ByteBuffer p_outNetBuf) |
static void |
writeClosingMessage(SocketChannel p_channel,
SSLEngine p_sslEngine,
ByteBuffer p_outAppBuf,
ByteBuffer p_outNetBuf)
Clear the output buffers and send a SSL close message to the peer.
|
public static KeyStore loadKeyStore(String p_strType, String p_strPath, String p_strPassphrase) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException
p_strType
- The keystore type, or null
if
the default keystore type should be used.p_strPath
- The path to the keystore.p_strPassphrase
- The keystore passphrase, or null
.KeyStoreException
NoSuchAlgorithmException
CertificateException
IOException
public static void doHandshake(SocketChannel p_socketChannel, SSLEngine p_sslEngine, ByteBuffer p_outAppBuf, ByteBuffer p_outNetBuf, ByteBuffer p_inAppBuf, ByteBuffer p_inNetBuf) throws IOException
The buffers passed to this method must be clear.
p_outAppBuf
, p_outNetBuf
, and
p_inAppBuf
are clear when this method returns.
The buffer p_inNetBuf
is compacted and may contain
input data that are not handshake but payload data.
IOException
public static int read(SocketChannel p_channel, SSLEngine p_sslEngine, ByteBuffer p_inAppBuf, ByteBuffer p_inNetBuf) throws IOException
The buffer p_inAppBuf
is flipped and contains
decrypted data when this method returns.
The buffer p_inNetBuf
is compacted when this
method returns. The caller must not modify the contents of this
buffer between two subsequent calls of this method
p_inAppBuf
- A compacted buffer that will receive decrypted data.p_inNetBuf
- An buffer that will receive network data.IOException
public static void write(SocketChannel p_channel, SSLEngine p_sslEngine, ByteBuffer p_outAppBuf, ByteBuffer p_outNetBuf) throws IOException
IOException
public static void writeClosingMessage(SocketChannel p_channel, SSLEngine p_sslEngine, ByteBuffer p_outAppBuf, ByteBuffer p_outNetBuf) throws IOException
The output buffers are cleared when this method returns.
p_channel
- The socket channel to write to.p_sslEngine
- The SSL engine to be used.p_outAppBuf
- The application output buffer.p_outNetBuf
- The network output buffer.IOException
- If an I/O error occurred.public static void readClosingMessage(SocketChannel p_channel, SSLEngine p_sslEngine, ByteBuffer p_inAppBuf, ByteBuffer p_inNetBuf) throws IOException
The input buffers are cleared when this method returns.
p_channel
- The socket channel to read from.p_sslEngine
- The SSL engine to be used.p_inAppBuf
- The application input buffer.p_inNetBuf
- The network input buffer.IOException
Copyright © 2009-2013 Alexander Veit. All Rights Reserved.