|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.http.nio.reactor.ssl.SSLIOSession
@ThreadSafe public class SSLIOSession
SSLIOSession is a decorator class intended to transparently extend
an IOSession with transport layer security capabilities based on
the SSL/TLS protocol.
SESSION_KEY key.
SSLContext sslcontext = SSLContext.getInstance("SSL");
sslcontext.init(null, null, null);
SSLIOSession sslsession = new SSLIOSession(
iosession, SSLMode.CLIENT, sslcontext, null);
iosession.setAttribute(SSLIOSession.SESSION_KEY, sslsession);
| Field Summary | |
|---|---|
static String |
SESSION_KEY
Name of the context attribute key, which can be used to obtain the SSL session. |
| Fields inherited from interface org.apache.http.nio.reactor.IOSession |
|---|
ACTIVE, ATTACHMENT_KEY, CLOSED, CLOSING |
| Constructor Summary | |
|---|---|
SSLIOSession(IOSession session,
SSLMode defaultMode,
SSLContext sslContext,
SSLSetupHandler handler)
Creates new instance of SSLIOSession class. |
|
| Method Summary | |
|---|---|
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. |
Object |
getAttribute(String name)
Returns the value of the attribute with the given name. |
int |
getEventMask()
Returns mask of I/O evens this session declared interest in. |
SocketAddress |
getLocalAddress()
Returns local address. |
SocketAddress |
getRemoteAddress()
Returns address of the remote peer. |
Socket |
getSocket()
Return the underlying socket |
int |
getSocketTimeout()
Returns value of the socket timeout in milliseconds. |
SSLSession |
getSSLSession()
|
protected SSLSetupHandler |
getSSLSetupHandler()
|
int |
getStatus()
Returns status of the session: |
boolean |
hasBufferedInput()
Determines if the input buffer associated with the session contains data. |
boolean |
hasBufferedOutput()
Determines if the output buffer associated with the session contains data. |
void |
inboundTransport()
Executes inbound SSL transport operations. |
void |
initialize()
Initializes the session in the default operation mode. |
void |
initialize(SSLMode mode)
Initializes the session in the given SSLMode. |
boolean |
isAppInputReady()
Reads encrypted data and returns whether the channel associated with this session has any decrypted inbound data available for reading. |
boolean |
isAppOutputReady()
Returns whether the channel associated with this session is ready to accept outbound unecrypted data for writing. |
boolean |
isClosed()
Determines if the session has been terminated. |
boolean |
isInboundDone()
Returns whether the session will produce any more inbound data. |
boolean |
isInitialized()
Returns true is the session has been fully initialized,
false otherwise. |
boolean |
isOutboundDone()
Returns whether the session will accept any more outbound data. |
void |
outboundTransport()
Sends encrypted data and executes outbound SSL transport operations. |
Object |
removeAttribute(String name)
Removes attribute with the given name. |
void |
setAttribute(String name,
Object obj)
This method can be used to associate a particular object with the session by the given attribute name. |
void |
setBufferStatus(SessionBufferStatus status)
Quite often I/O sessions need to maintain internal I/O buffers in order to transform input / output data prior to returning it to the consumer or writing it to the underlying channel. |
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(int timeout)
Sets value of the socket timeout in milliseconds. |
void |
shutdown()
Terminates the session by shutting down the underlying I/O channel. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String SESSION_KEY
| Constructor Detail |
|---|
public SSLIOSession(IOSession session,
SSLMode defaultMode,
SSLContext sslContext,
SSLSetupHandler handler)
session - I/O session to be decorated with the TLS/SSL capabilities.defaultMode - default mode (client or server)sslContext - SSL context to use for this I/O session.handler - optional SSL setup handler. May be null.| Method Detail |
|---|
protected SSLSetupHandler getSSLSetupHandler()
public boolean isInitialized()
true is the session has been fully initialized,
false otherwise.
public void initialize(SSLMode mode)
throws SSLException
SSLMode. This method
invokes the SSLSetupHandler.initalize(SSLEngine) callback
if an instance of SSLSetupHandler was specified at
the construction time.
mode - mode of operation (client or server).
SSLException - in case of a SSL protocol exception.
IllegalStateException - if the session has already been initialized.
public void initialize()
throws SSLException
SSLSetupHandler.initalize(SSLEngine) callback
if an instance of SSLSetupHandler was specified at
the construction time.
SSLException - in case of a SSL protocol exception.
IllegalStateException - if the session has already been initialized.public SSLSession getSSLSession()
public boolean isAppInputReady()
throws IOException
IOException - in case of an I/O error.
public boolean isAppOutputReady()
throws IOException
IOException - - not thrown currently
public void inboundTransport()
throws IOException
IOException - - not thrown currently
public void outboundTransport()
throws IOException
IOException - in case of an I/O error.public boolean isInboundDone()
public boolean isOutboundDone()
public void close()
IOSession
close in interface IOSessionpublic void shutdown()
IOSession
shutdown in interface IOSessionpublic int getStatus()
IOSession
IOSession.ACTIVE: session is active.
IOSession.CLOSING: session is being closed.
IOSession.CLOSED: session has been terminated.
getStatus in interface IOSessionpublic boolean isClosed()
IOSession
isClosed in interface IOSessiontrue if the session has been terminated,
false otherwise.public ByteChannel channel()
IOSession
channel in interface IOSessionpublic SocketAddress getLocalAddress()
IOSession
getLocalAddress in interface IOSessionpublic SocketAddress getRemoteAddress()
IOSession
getRemoteAddress in interface IOSessionpublic int getEventMask()
IOSession
getEventMask in interface IOSessionpublic void setEventMask(int ops)
IOSession
setEventMask in interface IOSessionops - new I/O event mask.public void setEvent(int op)
IOSession
setEvent in interface IOSessionop - I/O event type.public void clearEvent(int op)
IOSession
clearEvent in interface IOSessionop - I/O event type.public int getSocketTimeout()
IOSession0 signifies the session cannot time out.
getSocketTimeout in interface IOSessionpublic void setSocketTimeout(int timeout)
IOSession0 signifies the session cannot time out.
setSocketTimeout in interface IOSessiontimeout - socket timeout.public boolean hasBufferedInput()
IOSession
hasBufferedInput in interface IOSessionhasBufferedInput in interface SessionBufferStatustrue if the session input buffer contains data,
false otherwise.public boolean hasBufferedOutput()
IOSession
hasBufferedOutput in interface IOSessionhasBufferedOutput in interface SessionBufferStatustrue if the session output buffer contains data,
false otherwise.public void setBufferStatus(SessionBufferStatus status)
IOSession
I/O sessions can be made aware of the status of external session buffers
using the SessionBufferStatus interface.
setBufferStatus in interface IOSessionpublic Object getAttribute(String name)
IOSessionnull if not set.
The value of the session attachment object can be obtained using
IOSession.ATTACHMENT_KEY name.
getAttribute in interface IOSessionname - name of the attribute.
IOSession.setAttribute(String, Object)public Object removeAttribute(String name)
IOSession
removeAttribute in interface IOSessionname - name of the attribute to be removed.
IOSession.setAttribute(String, Object)
public void setAttribute(String name,
Object obj)
IOSessionI/O sessions are not bound to an execution thread, therefore one cannot use the context of the thread to store a session's state. All details about a particular session must be stored within the session itself.
setAttribute in interface IOSessionname - name of the attribute.obj - value of the attribute.public String toString()
toString in class Objectpublic Socket getSocket()
SocketAccessor
getSocket in interface SocketAccessornull.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||