public class SSLSocketChannel extends Object implements Closeable
| Modifier and Type | Class and Description |
|---|---|
private static class |
SSLSocketChannel.ChannelStatus |
| Modifier and Type | Field and Description |
|---|---|
private BufferStateManager |
appDataManager |
private static long |
BUFFER_FULL_EMPTY_WAIT_NANOS |
private SocketChannel |
channel |
private SSLSocketChannel.ChannelStatus |
channelStatus |
private static boolean |
CLIENT_AUTHENTICATION_REQUIRED |
private static int |
DISCARD_BUFFER_LENGTH |
private static byte[] |
EMPTY_MESSAGE |
private static int |
END_OF_STREAM |
private SSLEngine |
engine |
private static long |
FINISH_CONNECT_SLEEP |
private static long |
INITIAL_INCREMENTAL_SLEEP |
private boolean |
interrupted |
private static org.slf4j.Logger |
LOGGER |
private static int |
MINIMUM_READ_BUFFER_SIZE |
private int |
port |
private String |
remoteAddress |
private SocketAddress |
socketAddress |
private BufferStateManager |
streamInManager |
private BufferStateManager |
streamOutManager |
private int |
timeoutMillis |
| Constructor and Description |
|---|
SSLSocketChannel(SSLContext sslContext,
SocketChannel socketChannel,
boolean useClientMode)
SSLSocketChannel constructor with SSLContext and connected SocketChannel
|
SSLSocketChannel(SSLContext sslContext,
String remoteAddress,
int port,
InetAddress bindAddress,
boolean useClientMode)
SSLSocketChannel constructor with SSLContext and remote address parameters
|
SSLSocketChannel(SSLEngine sslEngine,
SocketChannel socketChannel)
SSLSocketChannel constructor with configured SSLEngine and connected SocketChannel
|
| Modifier and Type | Method and Description |
|---|---|
int |
available()
Get application bytes available for reading
|
private void |
checkChannelStatus() |
private void |
checkInterrupted() |
private void |
checkTimeoutExceeded(long started) |
void |
close()
Close Channel and process notifications
|
private void |
closeQuietly(Closeable closeable) |
void |
connect()
Connect Channel when not connected and perform handshake process
|
void |
consume()
Shutdown Socket Channel input and read available bytes
|
private static SSLEngine |
createEngine(SSLContext sslContext,
boolean useClientMode) |
private static SocketChannel |
createSocketChannel(InetAddress bindAddress) |
private SSLHandshakeException |
getHandshakeException(SSLEngineResult.HandshakeStatus handshakeStatus,
String message) |
int |
getTimeout() |
private long |
incrementalSleep(long nanoseconds) |
void |
interrupt()
Interrupt processing and disable transmission
|
boolean |
isClosed()
Is Channel Closed
|
private void |
logEngineResult(SSLEngineResult result,
String method) |
private void |
logHandshakeStatus(SSLEngineResult.HandshakeStatus handshakeStatus) |
private void |
logOperation(String operation) |
private void |
logOperationBytes(String operation,
int bytes) |
private void |
performHandshake() |
int |
read()
Read and return one byte
|
int |
read(byte[] buffer)
Read available bytes into buffer
|
int |
read(byte[] buffer,
int offset,
int len)
Read available bytes into buffer based on offset and length requested
|
private int |
readApplicationBuffer(byte[] buffer,
int offset,
int len) |
private int |
readChannel() |
private void |
readChannelDiscard() |
private void |
runDelegatedTasks() |
void |
setTimeout(int timeoutMillis) |
private SSLEngineResult |
unwrap() |
private SSLEngineResult |
unwrapBufferReadChannel() |
private SSLEngineResult |
wrap(ByteBuffer inputBuffer,
ByteBuffer outputBuffer) |
private SSLEngineResult.Status |
wrapWriteChannel(BufferStateManager inputManager) |
void |
write(byte[] data)
Write bytes to channel
|
void |
write(byte[] data,
int offset,
int len)
Write data to channel performs multiple iterations based on data length
|
void |
write(int data)
Write one byte to channel
|
private void |
writeChannel(ByteBuffer inputBuffer) |
private static final org.slf4j.Logger LOGGER
private static final int MINIMUM_READ_BUFFER_SIZE
private static final int DISCARD_BUFFER_LENGTH
private static final int END_OF_STREAM
private static final byte[] EMPTY_MESSAGE
private static final long BUFFER_FULL_EMPTY_WAIT_NANOS
private static final long FINISH_CONNECT_SLEEP
private static final long INITIAL_INCREMENTAL_SLEEP
private static final boolean CLIENT_AUTHENTICATION_REQUIRED
private final String remoteAddress
private final int port
private final SSLEngine engine
private final SocketAddress socketAddress
private final BufferStateManager streamInManager
private final BufferStateManager streamOutManager
private final BufferStateManager appDataManager
private final SocketChannel channel
private int timeoutMillis
private volatile boolean interrupted
private volatile SSLSocketChannel.ChannelStatus channelStatus
public SSLSocketChannel(SSLContext sslContext, String remoteAddress, int port, InetAddress bindAddress, boolean useClientMode) throws IOException
sslContext - SSLContext used to create SSLEngine with specified client moderemoteAddress - Remote Address used for connectionport - Remote Port used for connectionbindAddress - Local address used for binding server channel when provideduseClientMode - Use Client ModeIOException - Thrown on failures creating Socket Channelpublic SSLSocketChannel(SSLContext sslContext, SocketChannel socketChannel, boolean useClientMode) throws IOException
sslContext - SSLContext used to create SSLEngine with specified client modesocketChannel - Connected SocketChanneluseClientMode - Use Client ModeIOException - Thrown on SocketChannel.getRemoteAddress()public SSLSocketChannel(SSLEngine sslEngine, SocketChannel socketChannel) throws IOException
sslEngine - SSLEngine configured with mode and client authenticationsocketChannel - Connected SocketChannelIOException - Thrown on SocketChannel.getRemoteAddress()public void setTimeout(int timeoutMillis)
public int getTimeout()
public void connect()
throws IOException
IOException - Thrown on connection failurespublic void consume()
throws IOException
IOException - Thrown on Socket Channel failurespublic boolean isClosed()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOException - Thrown on SSLEngine.wrap() failurespublic int available()
throws IOException
IOException - Thrown on failures checking for available bytespublic int read()
throws IOException
IOException - Thrown on read failurespublic int read(byte[] buffer)
throws IOException
buffer - Byte array bufferIOException - Thrown on read failurespublic int read(byte[] buffer,
int offset,
int len)
throws IOException
buffer - Byte array bufferoffset - Buffer offsetlen - Length of bytes to readIOException - Thrown on read failurespublic void write(int data)
throws IOException
data - Byte to be writtenIOException - Thrown on write failurespublic void write(byte[] data)
throws IOException
data - Byte array to be writtenIOException - Thrown on write failurespublic void write(byte[] data,
int offset,
int len)
throws IOException
data - Byte array to be writtenoffset - Byte array offsetlen - Length of bytes for writingIOException - Thrown on write failurespublic void interrupt()
private void performHandshake()
throws IOException
IOExceptionprivate SSLEngineResult unwrapBufferReadChannel() throws IOException
IOExceptionprivate int readChannel()
throws IOException
IOExceptionprivate void readChannelDiscard()
private void writeChannel(ByteBuffer inputBuffer) throws IOException
IOExceptionprivate long incrementalSleep(long nanoseconds)
throws IOException
IOExceptionprivate int readApplicationBuffer(byte[] buffer,
int offset,
int len)
private SSLEngineResult.Status wrapWriteChannel(BufferStateManager inputManager) throws IOException
IOExceptionprivate SSLEngineResult wrap(ByteBuffer inputBuffer, ByteBuffer outputBuffer) throws SSLException
SSLExceptionprivate SSLEngineResult unwrap() throws IOException
IOExceptionprivate void runDelegatedTasks()
private void closeQuietly(Closeable closeable)
private SSLHandshakeException getHandshakeException(SSLEngineResult.HandshakeStatus handshakeStatus, String message)
private void checkChannelStatus()
throws IOException
IOExceptionprivate void checkInterrupted()
private void checkTimeoutExceeded(long started)
throws SocketTimeoutException
SocketTimeoutExceptionprivate void logOperation(String operation)
private void logOperationBytes(String operation, int bytes)
private void logHandshakeStatus(SSLEngineResult.HandshakeStatus handshakeStatus)
private void logEngineResult(SSLEngineResult result, String method)
private static SocketChannel createSocketChannel(InetAddress bindAddress) throws IOException
IOExceptionprivate static SSLEngine createEngine(SSLContext sslContext, boolean useClientMode)
Copyright © 2023 Apache NiFi Project. All rights reserved.