@Contract(threading=SAFE_CONDITIONAL) @Internal public class SSLIOSession extends Object implements IOSession
SSLIOSession
is a decorator class intended to transparently extend
an IOSession
with transport layer security capabilities based on
the SSL/TLS protocol.IOSession.Status
Constructor and Description |
---|
SSLIOSession(NamedEndpoint targetEndpoint,
IOSession session,
SSLMode sslMode,
SSLContext sslContext,
SSLBufferMode sslBufferMode,
SSLSessionInitializer initializer,
SSLSessionVerifier verifier,
Callback<SSLIOSession> sessionStartCallback,
Callback<SSLIOSession> sessionEndCallback,
Timeout connectTimeout)
Creates new instance of
SSLIOSession class. |
Modifier and Type | Method and Description |
---|---|
ByteChannel |
channel()
Returns the underlying I/O channel associated with this session.
|
void |
clearEvent(int op)
Clears interest in a particular I/O event type by updating the event
mask associated with the session.
|
void |
close()
Terminates the session gracefully and closes the underlying I/O channel.
|
void |
close(CloseMode closeMode)
Closes this process or endpoint and releases any system resources associated
with it.
|
void |
enqueue(Command command,
Command.Priority priority)
Inserts
Command at the end of the command queue. |
int |
getEventMask()
Returns mask of I/O evens this session declared interest in.
|
IOEventHandler |
getHandler()
Returns event handler associated with the session.
|
String |
getId() |
long |
getLastEventTime()
Returns timestamp of the last I/O event including socket timeout reset.
|
long |
getLastReadTime()
Returns timestamp of the last read event.
|
long |
getLastWriteTime()
Returns timestamp of the last write event.
|
SocketAddress |
getLocalAddress()
Returns local address.
|
Lock |
getLock()
Returns session lock that should be used by I/O event handlers
to synchronize access to the session.
|
SocketAddress |
getRemoteAddress()
Returns address of the remote peer.
|
Timeout |
getSocketTimeout()
Returns value of the socket timeout in milliseconds.
|
IOSession.Status |
getStatus()
Returns status of the session:
|
TlsDetails |
getTlsDetails() |
boolean |
hasCommands()
Tests if there enqueued commands pending execution.
|
boolean |
isOpen() |
Command |
poll()
Removes first
Command from the command queue if available. |
int |
read(ByteBuffer dst) |
void |
setEvent(int op)
Declares interest in a particular I/O event type by updating the event
mask associated with the session.
|
void |
setEventMask(int ops)
Declares interest in I/O event notifications by setting the event mask
associated with the session
|
void |
setSocketTimeout(Timeout timeout)
Sets value of the socket timeout in milliseconds.
|
String |
toString() |
void |
updateReadTime()
Updates the timestamp of the last read event
|
void |
updateWriteTime()
Updates the timestamp of the last write event
|
void |
upgrade(IOEventHandler handler)
Upgrades event handler associated with the session.
|
int |
write(ByteBuffer src) |
public SSLIOSession(NamedEndpoint targetEndpoint, IOSession session, SSLMode sslMode, SSLContext sslContext, SSLBufferMode sslBufferMode, SSLSessionInitializer initializer, SSLSessionVerifier verifier, Callback<SSLIOSession> sessionStartCallback, Callback<SSLIOSession> sessionEndCallback, Timeout connectTimeout)
SSLIOSession
class.session
- I/O session to be decorated with the TLS/SSL capabilities.sslMode
- SSL mode (client or server)targetEndpoint
- target endpoint (applicable in client mode only). May be null
.sslContext
- SSL context to use for this I/O session.sslBufferMode
- buffer management modeinitializer
- optional SSL session initializer. May be null
.verifier
- optional SSL session verifier. May be null
.connectTimeout
- timeout to apply for the TLS/SSL handshake. May be null
.public IOEventHandler getHandler()
IOSession
getHandler
in interface IOSession
public int write(ByteBuffer src) throws IOException
write
in interface WritableByteChannel
IOException
public int read(ByteBuffer dst)
read
in interface ReadableByteChannel
public String getId()
getId
in interface Identifiable
public Lock getLock()
IOSession
public void upgrade(IOEventHandler handler)
IOSession
public TlsDetails getTlsDetails()
public void close()
IOSession
public void close(CloseMode closeMode)
ModalCloseable
close
in interface ModalCloseable
closeMode
- How to close the receiver.public IOSession.Status getStatus()
IOSession
IOSession.Status.ACTIVE
: session is active.
IOSession.Status.CLOSING
: session is being closed.
IOSession.Status.CLOSED
: session has been terminated.
public void enqueue(Command command, Command.Priority priority)
IOSession
Command
at the end of the command queue.public boolean hasCommands()
IOSession
hasCommands
in interface IOSession
public Command poll()
IOSession
Command
from the command queue if available.public ByteChannel channel()
IOSession
public SocketAddress getLocalAddress()
IOSession
getLocalAddress
in interface IOSession
public SocketAddress getRemoteAddress()
IOSession
getRemoteAddress
in interface IOSession
public int getEventMask()
IOSession
getEventMask
in interface IOSession
public void setEventMask(int ops)
IOSession
setEventMask
in interface IOSession
ops
- new I/O event mask.public void setEvent(int op)
IOSession
public void clearEvent(int op)
IOSession
clearEvent
in interface IOSession
op
- I/O event type.public Timeout getSocketTimeout()
IOSession
0
signifies the session cannot time out.getSocketTimeout
in interface SocketModalCloseable
getSocketTimeout
in interface IOSession
public void setSocketTimeout(Timeout timeout)
IOSession
0
signifies the session cannot time out.
Please note this operation may affect the last event time.
setSocketTimeout
in interface SocketModalCloseable
setSocketTimeout
in interface IOSession
timeout
- socket timeout.IOSession.getLastEventTime()
public void updateReadTime()
IOSession
updateReadTime
in interface IOSession
public void updateWriteTime()
IOSession
updateWriteTime
in interface IOSession
public long getLastReadTime()
IOSession
getLastReadTime
in interface IOSession
public long getLastWriteTime()
IOSession
getLastWriteTime
in interface IOSession
public long getLastEventTime()
IOSession
getLastEventTime
in interface IOSession
IOSession.getSocketTimeout()
Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.