Package org.mozilla.jss.ssl.javax
Class JSSSocketChannel
java.lang.Object
java.nio.channels.spi.AbstractInterruptibleChannel
java.nio.channels.SelectableChannel
java.nio.channels.spi.AbstractSelectableChannel
java.nio.channels.SocketChannel
org.mozilla.jss.ssl.javax.JSSSocketChannel
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ByteChannel
,Channel
,GatheringByteChannel
,InterruptibleChannel
,NetworkChannel
,ReadableByteChannel
,ScatteringByteChannel
,WritableByteChannel
SSL-enabled SocketChannel following the javax.net.ssl.SSLSocket interface.
This class should never be constructed directly and instead only accessed
once a Socket is wrapped in a JSSSocket.
This class contains all low-level interactions with the underlying
SSLEngine and reading/writing to/from the underlying Socket.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private InputStream
private ReadableByteChannel
private ByteBuffer
private JSSEngine
private boolean
private boolean
private boolean
private SocketChannel
private Socket
private ByteBuffer
private ReadableByteChannel
private JSSSocket
private ByteBuffer
private WritableByteChannel
-
Constructor Summary
ConstructorsConstructorDescriptionJSSSocketChannel
(JSSSocket sslSocket, Socket parentSocket, ReadableByteChannel readChannel, WritableByteChannel writeChannel, JSSEngine engine) JSSSocketChannel
(JSSSocket sslSocket, SocketChannel parent, Socket parentSocket, ReadableByteChannel readChannel, WritableByteChannel writeChannel, JSSEngine engine) JSSSocketChannel
(JSSSocket sslSocket, SocketChannel parent, JSSEngine engine) -
Method Summary
Modifier and TypeMethodDescriptionbind
(SocketAddress local) private static long
computeSize
(ByteBuffer[] buffers, int offset, int length) Compute the total size of a list of buffers from the specified offest and length.boolean
connect
(SocketAddress remote) boolean
Collection
<? extends EventListener> Gets the current list of event listeners this SSLSocket will fire on certain events.<T> T
getOption
(SocketOption<T> name) void
void
implConfigureBlocking
(boolean block) boolean
boolean
int
read
(ByteBuffer dst) long
read
(ByteBuffer[] dsts, int offset, int length) private int
void
setAutoClose
(boolean on) Set whether or not to close the underlying Socket when the SSLSocket or this channel is closed.void
setConsumedData
(InputStream consumed) Give data already consumed by a call to the underlying socket's read method to this Socket, allowing it to be read by the SSLEngine.void
setListeners
(Collection<? extends EventListener> listeners) Set the listeners this SSLSocket will fire on certain events.<T> JSSSocketChannel
setOption
(SocketOption<T> name, T value) socket()
Set
<SocketOption<?>> int
write
(ByteBuffer src) long
write
(ByteBuffer[] srcs, int offset, int length) Methods inherited from class java.nio.channels.SocketChannel
open, open, open, read, validOps, write
Methods inherited from class java.nio.channels.spi.AbstractSelectableChannel
blockingLock, configureBlocking, implCloseChannel, isBlocking, isRegistered, keyFor, provider, register
Methods inherited from class java.nio.channels.SelectableChannel
register
Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel
begin, close, end, isOpen
-
Field Details
-
sslSocket
-
parent
-
parentSocket
-
readChannel
-
writeChannel
-
engine
-
consumed
-
consumedChannel
-
autoClose
private boolean autoClose -
inboundClosed
private boolean inboundClosed -
outboundClosed
private boolean outboundClosed -
empty
-
readBuffer
-
writeBuffer
-
handshakeCompleted
private boolean handshakeCompleted
-
-
Constructor Details
-
JSSSocketChannel
public JSSSocketChannel(JSSSocket sslSocket, SocketChannel parent, Socket parentSocket, ReadableByteChannel readChannel, WritableByteChannel writeChannel, JSSEngine engine) throws IOException - Throws:
IOException
-
JSSSocketChannel
public JSSSocketChannel(JSSSocket sslSocket, SocketChannel parent, JSSEngine engine) throws IOException - Throws:
IOException
-
JSSSocketChannel
public JSSSocketChannel(JSSSocket sslSocket, Socket parentSocket, ReadableByteChannel readChannel, WritableByteChannel writeChannel, JSSEngine engine) throws IOException - Throws:
IOException
-
-
Method Details
-
setConsumedData
Give data already consumed by a call to the underlying socket's read method to this Socket, allowing it to be read by the SSLEngine.- Throws:
IOException
-
setAutoClose
public void setAutoClose(boolean on) Set whether or not to close the underlying Socket when the SSLSocket or this channel is closed. -
remoteRead
- Throws:
IOException
-
finishConnect
- Specified by:
finishConnect
in classSocketChannel
- Throws:
IOException
-
computeSize
Compute the total size of a list of buffers from the specified offest and length.- Throws:
IOException
-
read
- Specified by:
read
in interfaceReadableByteChannel
- Specified by:
read
in classSocketChannel
- Throws:
IOException
-
read
- Specified by:
read
in interfaceScatteringByteChannel
- Specified by:
read
in classSocketChannel
- Throws:
IOException
-
write
- Specified by:
write
in interfaceWritableByteChannel
- Specified by:
write
in classSocketChannel
- Throws:
IOException
-
write
- Specified by:
write
in interfaceGatheringByteChannel
- Specified by:
write
in classSocketChannel
- Throws:
IOException
-
implCloseSelectableChannel
- Specified by:
implCloseSelectableChannel
in classAbstractSelectableChannel
- Throws:
IOException
-
setListeners
Set the listeners this SSLSocket will fire on certain events.- See Also:
-
getListeners
Gets the current list of event listeners this SSLSocket will fire on certain events.- See Also:
-
bind
- Specified by:
bind
in interfaceNetworkChannel
- Specified by:
bind
in classSocketChannel
- Throws:
IOException
-
connect
- Specified by:
connect
in classSocketChannel
- Throws:
IOException
-
getOption
- Throws:
IOException
-
supportedOptions
-
setOption
- Specified by:
setOption
in interfaceNetworkChannel
- Specified by:
setOption
in classSocketChannel
- Throws:
IOException
-
socket
- Specified by:
socket
in classSocketChannel
-
isConnected
public boolean isConnected()- Specified by:
isConnected
in classSocketChannel
-
isConnectionPending
public boolean isConnectionPending()- Specified by:
isConnectionPending
in classSocketChannel
-
getLocalAddress
- Specified by:
getLocalAddress
in interfaceNetworkChannel
- Specified by:
getLocalAddress
in classSocketChannel
- Throws:
IOException
-
getRemoteAddress
- Specified by:
getRemoteAddress
in classSocketChannel
- Throws:
IOException
-
shutdownInput
- Specified by:
shutdownInput
in classSocketChannel
- Throws:
IOException
-
shutdownOutput
- Specified by:
shutdownOutput
in classSocketChannel
- Throws:
IOException
-
implConfigureBlocking
- Specified by:
implConfigureBlocking
in classAbstractSelectableChannel
- Throws:
IOException
-