Rice Pastry API

org.mpisws.p2p.transport.ssl
Class SSLSocketManager<Identifier>

java.lang.Object
  extended by org.mpisws.p2p.transport.ssl.SSLSocketManager<Identifier>
All Implemented Interfaces:
P2PSocket<Identifier>, P2PSocketReceiver<Identifier>

public class SSLSocketManager<Identifier>
extends java.lang.Object
implements P2PSocket<Identifier>, P2PSocketReceiver<Identifier>


Field Summary
protected  int appBufferMax
           
protected  java.nio.ByteBuffer bogusEncryptMe
           
protected  Continuation<SSLSocketManager<Identifier>,java.lang.Exception> c
           
protected  boolean closed
           
protected  boolean doneHandshaking
           
protected  javax.net.ssl.SSLEngine engine
           
protected  boolean handshaking
           
protected  Logger logger
           
protected  java.lang.String name
           
protected  int netBufferMax
           
protected  java.util.Map<java.lang.String,java.lang.Object> options
           
protected  java.security.cert.X509Certificate peerCert
          The cert of the remote node.
protected  java.util.LinkedList<java.nio.ByteBuffer> readMe
           
protected  javax.net.ssl.SSLEngineResult result
           
protected  boolean server
           
protected  P2PSocket<Identifier> socket
           
protected  SSLTransportLayerImpl<Identifier,?> sslTL
           
protected  javax.net.ssl.SSLEngineResult.HandshakeStatus status
           
protected  java.util.LinkedList<java.nio.ByteBuffer> unwrapMe
           
protected  boolean useClientAuth
           
protected  java.util.LinkedList<java.nio.ByteBuffer> writeMe
           
 
Constructor Summary
SSLSocketManager(SSLTransportLayerImpl<Identifier,?> sslTL, P2PSocket<Identifier> s, Continuation<SSLSocketManager<Identifier>,java.lang.Exception> c, boolean server, boolean useClientAuth)
          Called on incoming side
 
Method Summary
protected  boolean checkDone()
          Return true when done.
 void close()
          Closes this socket.
protected  void continueHandshaking()
           
protected  void fail(java.lang.Exception e)
           
 java.security.cert.X509Certificate getCert()
           
 Identifier getIdentifier()
          The identification of the node at the other end of the socket.
 java.util.Map<java.lang.String,java.lang.Object> getOptions()
          Details on the connectivity of the socket (encrypted, source-routed etc)
protected  void handleResult(javax.net.ssl.SSLEngineResult result)
           
protected  void handshakeUnwrap()
           
protected  void handshakeWrap()
           
protected  boolean read()
           
 long read(java.nio.ByteBuffer dsts)
          Reads a sequence of bytes from this channel into a subsequence of the given buffer.
 void receiveException(P2PSocket<Identifier> socket, java.lang.Exception ioe)
          Called when there is an error
 void receiveSelectResult(P2PSocket<Identifier> socket, boolean canRead, boolean canWrite)
          Called when a socket is available for read/write
 void register(boolean wantToRead, boolean wantToWrite, P2PSocketReceiver<Identifier> receiver)
          Must be called every time a Read/Write occurs to continue operation.
 void shutdownOutput()
          Disables the output stream for this socket.
 java.lang.String toString()
           
protected  void unwrap()
           
 long write(java.nio.ByteBuffer srcs)
          Writes a sequence of bytes to this channel from a subsequence of the given buffers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

peerCert

protected java.security.cert.X509Certificate peerCert
The cert of the remote node. (not applicable for non-clientAuth servers.


socket

protected P2PSocket<Identifier> socket

engine

protected javax.net.ssl.SSLEngine engine

sslTL

protected SSLTransportLayerImpl<Identifier,?> sslTL

logger

protected Logger logger

handshaking

protected boolean handshaking

closed

protected boolean closed

result

protected javax.net.ssl.SSLEngineResult result

status

protected javax.net.ssl.SSLEngineResult.HandshakeStatus status

writeMe

protected java.util.LinkedList<java.nio.ByteBuffer> writeMe

unwrapMe

protected java.util.LinkedList<java.nio.ByteBuffer> unwrapMe

readMe

protected java.util.LinkedList<java.nio.ByteBuffer> readMe

bogusEncryptMe

protected java.nio.ByteBuffer bogusEncryptMe

appBufferMax

protected int appBufferMax

netBufferMax

protected int netBufferMax

c

protected Continuation<SSLSocketManager<Identifier>,java.lang.Exception> c

doneHandshaking

protected boolean doneHandshaking

options

protected java.util.Map<java.lang.String,java.lang.Object> options

useClientAuth

protected boolean useClientAuth

server

protected boolean server

name

protected java.lang.String name
Constructor Detail

SSLSocketManager

public SSLSocketManager(SSLTransportLayerImpl<Identifier,?> sslTL,
                        P2PSocket<Identifier> s,
                        Continuation<SSLSocketManager<Identifier>,java.lang.Exception> c,
                        boolean server,
                        boolean useClientAuth)
Called on incoming side

Parameters:
transportLayerImpl -
s -
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

handleResult

protected void handleResult(javax.net.ssl.SSLEngineResult result)

receiveSelectResult

public void receiveSelectResult(P2PSocket<Identifier> socket,
                                boolean canRead,
                                boolean canWrite)
                         throws java.io.IOException
Description copied from interface: P2PSocketReceiver
Called when a socket is available for read/write

Specified by:
receiveSelectResult in interface P2PSocketReceiver<Identifier>
Throws:
java.io.IOException

read

protected boolean read()
                throws java.io.IOException
Throws:
java.io.IOException

handshakeWrap

protected void handshakeWrap()

unwrap

protected void unwrap()
               throws javax.net.ssl.SSLException
Throws:
javax.net.ssl.SSLException

handshakeUnwrap

protected void handshakeUnwrap()

fail

protected void fail(java.lang.Exception e)

continueHandshaking

protected void continueHandshaking()

checkDone

protected boolean checkDone()
Return true when done.

Returns:

getCert

public java.security.cert.X509Certificate getCert()

register

public void register(boolean wantToRead,
                     boolean wantToWrite,
                     P2PSocketReceiver<Identifier> receiver)
Description copied from interface: P2PSocket
Must be called every time a Read/Write occurs to continue operation. Can cancel this task by calling with null.

Specified by:
register in interface P2PSocket<Identifier>
Parameters:
wantToRead - if you want to read from this socket
wantToWrite - if you want to write to this socket
receiver - will have receiveSelectResult() called on it note that you must call select() each time receiveSelectResult() is called. This is so your application can properly handle flow control

read

public long read(java.nio.ByteBuffer dsts)
          throws java.io.IOException
Description copied from interface: P2PSocket
Reads a sequence of bytes from this channel into a subsequence of the given buffer.

Specified by:
read in interface P2PSocket<Identifier>
Returns:
Throws:
java.io.IOException

write

public long write(java.nio.ByteBuffer srcs)
           throws java.io.IOException
Description copied from interface: P2PSocket
Writes a sequence of bytes to this channel from a subsequence of the given buffers.

Specified by:
write in interface P2PSocket<Identifier>
Throws:
java.io.IOException

close

public void close()
Description copied from interface: P2PSocket
Closes this socket.

Specified by:
close in interface P2PSocket<Identifier>

getIdentifier

public Identifier getIdentifier()
Description copied from interface: P2PSocket
The identification of the node at the other end of the socket.

Specified by:
getIdentifier in interface P2PSocket<Identifier>
Returns:
The identification of the node at the other end of the socket.

getOptions

public java.util.Map<java.lang.String,java.lang.Object> getOptions()
Description copied from interface: P2PSocket
Details on the connectivity of the socket (encrypted, source-routed etc)

Specified by:
getOptions in interface P2PSocket<Identifier>
Returns:
a read-only list of options on this socket

shutdownOutput

public void shutdownOutput()
Description copied from interface: P2PSocket
Disables the output stream for this socket. Used to properly close down a socket used for bi-directional communication that can be initated by either side.

Specified by:
shutdownOutput in interface P2PSocket<Identifier>

receiveException

public void receiveException(P2PSocket<Identifier> socket,
                             java.lang.Exception ioe)
Description copied from interface: P2PSocketReceiver
Called when there is an error

Specified by:
receiveException in interface P2PSocketReceiver<Identifier>

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection