Rice Pastry API

org.mpisws.p2p.transport.ssl
Class SSLTransportLayerImpl<Identifier,MessageType>

java.lang.Object
  extended by org.mpisws.p2p.transport.ssl.SSLTransportLayerImpl<Identifier,MessageType>
Type Parameters:
Identifier -
All Implemented Interfaces:
SSLTransportLayer<Identifier,MessageType>, TransportLayer<Identifier,MessageType>, TransportLayerCallback<Identifier,MessageType>, Destructable

public class SSLTransportLayerImpl<Identifier,MessageType>
extends java.lang.Object
implements SSLTransportLayer<Identifier,MessageType>

Does not encrypt UDP messages The server authenticates to the client via a CACert

Author:
Jeff Hoye

Field Summary
protected  TransportLayerCallback<Identifier,MessageType> callback
           
protected  javax.net.ssl.SSLContext context
           
protected  Environment environment
           
protected  ErrorHandler<Identifier> errorHandler
           
protected  Logger logger
           
protected  TransportLayer<Identifier,MessageType> tl
           
 
Fields inherited from interface org.mpisws.p2p.transport.ssl.SSLTransportLayer
CLIENT_AUTH_NONE, CLIENT_AUTH_OPTIONAL, CLIENT_AUTH_REQUIRED, NO, OPTION_AUTHENTICATION, OPTION_CERT_SUBJECT, OPTION_ENCRYPTION, YES
 
Constructor Summary
SSLTransportLayerImpl(TransportLayer<Identifier,MessageType> tl, java.security.KeyStore keyStore, java.security.KeyStore trustStore, Environment env)
           
SSLTransportLayerImpl(TransportLayer<Identifier,MessageType> tl, java.security.KeyStore keyStore, java.security.KeyStore trustStore, int clientAuth, Environment env)
           
 
Method Summary
 void acceptMessages(boolean b)
          Toggle accepting incoming messages.
 void acceptSockets(boolean b)
          Toggle accepting new sockets.
 void destroy()
           
 Identifier getLocalIdentifier()
          The local node.
protected  SSLSocketManager<Identifier> getSocketManager(SSLTransportLayerImpl<Identifier,?> sslTL, P2PSocket<Identifier> s, Continuation<SSLSocketManager<Identifier>,java.lang.Exception> c, boolean server, boolean useClientAuth)
           
 void incomingSocket(P2PSocket<Identifier> s)
          TODO: support resuming
 void messageReceived(Identifier i, MessageType m, java.util.Map<java.lang.String,java.lang.Object> options)
          Called when a new message is received.
 SocketRequestHandle<Identifier> openSocket(Identifier i, SocketCallback<Identifier> deliverSocketToMe, java.util.Map<java.lang.String,java.lang.Object> options)
          Open a socket to the Identifier
 MessageRequestHandle<Identifier,MessageType> sendMessage(Identifier i, MessageType m, MessageCallback<Identifier,MessageType> deliverAckToMe, java.util.Map<java.lang.String,java.lang.Object> options)
          Send the message to the identifier
 void setCallback(TransportLayerCallback<Identifier,MessageType> callback)
          Set the callback for incoming sockets/messages
 void setErrorHandler(ErrorHandler<Identifier> handler)
          To be notified of problems not related to an outgoing messaage/socket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tl

protected TransportLayer<Identifier,MessageType> tl

callback

protected TransportLayerCallback<Identifier,MessageType> callback

errorHandler

protected ErrorHandler<Identifier> errorHandler

logger

protected Logger logger

environment

protected Environment environment

context

protected javax.net.ssl.SSLContext context
Constructor Detail

SSLTransportLayerImpl

public SSLTransportLayerImpl(TransportLayer<Identifier,MessageType> tl,
                             java.security.KeyStore keyStore,
                             java.security.KeyStore trustStore,
                             Environment env)
                      throws java.io.IOException
Throws:
java.io.IOException

SSLTransportLayerImpl

public SSLTransportLayerImpl(TransportLayer<Identifier,MessageType> tl,
                             java.security.KeyStore keyStore,
                             java.security.KeyStore trustStore,
                             int clientAuth,
                             Environment env)
                      throws java.io.IOException
Parameters:
tl -
ks - set a cert on the client, and optionally a keypair (if want clientauth), on the server, need a keypair, cert if want clientauth
clientAuth - NO, OPTIONAL, REQUIRED // on the server side
env -
Throws:
java.lang.Exception
java.io.IOException
Method Detail

openSocket

public SocketRequestHandle<Identifier> openSocket(Identifier i,
                                                  SocketCallback<Identifier> deliverSocketToMe,
                                                  java.util.Map<java.lang.String,java.lang.Object> options)
Description copied from interface: TransportLayer
Open a socket to the Identifier

Specified by:
openSocket in interface TransportLayer<Identifier,MessageType>
Parameters:
i - who to open the socket to
deliverSocketToMe - the callback when the socket is opened
options - options on how to open the socket (don't source route, encrypt etc) (may not be respected if layer cannot provide service)
Returns:
an object to cancel opening the socket if it takes to long, or is no longer relevant

incomingSocket

public void incomingSocket(P2PSocket<Identifier> s)
                    throws java.io.IOException
TODO: support resuming

Specified by:
incomingSocket in interface TransportLayerCallback<Identifier,MessageType>
Parameters:
s - the incoming socket
Throws:
java.io.IOException

setCallback

public void setCallback(TransportLayerCallback<Identifier,MessageType> callback)
Description copied from interface: TransportLayer
Set the callback for incoming sockets/messages

Specified by:
setCallback in interface TransportLayer<Identifier,MessageType>
Parameters:
callback - the callback for incoming sockets/messages

acceptMessages

public void acceptMessages(boolean b)
Description copied from interface: TransportLayer
Toggle accepting incoming messages. Useful in flow control if overwhelmed by incoming sockets. Default: true

Specified by:
acceptMessages in interface TransportLayer<Identifier,MessageType>

acceptSockets

public void acceptSockets(boolean b)
Description copied from interface: TransportLayer
Toggle accepting new sockets. Useful in flow control if overwhelmed by incoming sockets. Default: true

Specified by:
acceptSockets in interface TransportLayer<Identifier,MessageType>

destroy

public void destroy()
Specified by:
destroy in interface Destructable

getLocalIdentifier

public Identifier getLocalIdentifier()
Description copied from interface: TransportLayer
The local node.

Specified by:
getLocalIdentifier in interface TransportLayer<Identifier,MessageType>
Returns:
The local node.

sendMessage

public MessageRequestHandle<Identifier,MessageType> sendMessage(Identifier i,
                                                                MessageType m,
                                                                MessageCallback<Identifier,MessageType> deliverAckToMe,
                                                                java.util.Map<java.lang.String,java.lang.Object> options)
Description copied from interface: TransportLayer
Send the message to the identifier

Specified by:
sendMessage in interface TransportLayer<Identifier,MessageType>
Parameters:
i - the destination
m - the message
deliverAckToMe - layer dependent notification when the message is sent (can indicate placed on the wire, point-to-point acknowledgment, or end-to-end acknowledgement)
options - delivery options (don't source route, encrypt etc) (may not be respected if layer cannot provide service)
Returns:
ability to cancel the message if no longer relevant

setErrorHandler

public void setErrorHandler(ErrorHandler<Identifier> handler)
Description copied from interface: TransportLayer
To be notified of problems not related to an outgoing messaage/socket. Or to be notified if a callback isn't provided.

Specified by:
setErrorHandler in interface TransportLayer<Identifier,MessageType>
Parameters:
handler - to be notified of problems not related to a specific messaage/socket.

messageReceived

public void messageReceived(Identifier i,
                            MessageType m,
                            java.util.Map<java.lang.String,java.lang.Object> options)
                     throws java.io.IOException
Description copied from interface: TransportLayerCallback
Called when a new message is received.

Specified by:
messageReceived in interface TransportLayerCallback<Identifier,MessageType>
Parameters:
i - The node it is coming from
m - the message
options - describe how the message arrived (udp/tcp, encrypted etc)
Throws:
java.io.IOException - if there is a problem decoding the message

getSocketManager

protected SSLSocketManager<Identifier> getSocketManager(SSLTransportLayerImpl<Identifier,?> sslTL,
                                                        P2PSocket<Identifier> s,
                                                        Continuation<SSLSocketManager<Identifier>,java.lang.Exception> c,
                                                        boolean server,
                                                        boolean useClientAuth)

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection