|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--br.shob.AbstractCommLayer
This class contains all common processing for the Communications Layer, which involves connecting to peer machines and sending/receiving signed messages from a socket.
Field Summary | |
static String |
keyPairGeneratorAlgorithm
KeyPair generator algorithm name. |
protected Logger |
logger
Description of the Field |
protected HostId |
myId
The HostId of this host. |
static String |
signatureAlgorithm
The algorithm used in all digital signatures in all hosts. |
Constructor Summary | |
protected |
AbstractCommLayer()
Creates new CommLayer |
|
AbstractCommLayer(HostId myId,
PrivateKey pKey)
Constructs a new instance of the communications layer. |
|
AbstractCommLayer(String hostname,
int port)
Constructs a new instance of the communications layer. |
Method Summary | |
Socket |
connect(String hostname,
int port)
connects with the peer . |
Socket |
connect(URL url)
connects with the peer . |
Logger |
getLogger()
Gets the logger for this comm layer. |
boolean |
isOnline()
Checks if this commlayer is online (i.e., running and listening). |
Message |
recvMessage(Socket s,
HostId peer)
Receives a message using the Root class loader. |
Message |
recvMessage(Socket s,
HostId peer,
ClassLoader loader)
Reads a message coming from the given socket and verifies its authenticity using the public key from peer . |
void |
sendMessage(Socket s,
Message m)
Signs and send a message through the given socket. |
void |
setLogger(Logger logger)
Sets the logger for this instance |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String keyPairGeneratorAlgorithm
public static final String signatureAlgorithm
protected Logger logger
protected HostId myId
HostId
of this host.
Constructor Detail |
public AbstractCommLayer(HostId myId, PrivateKey pKey)
myId
- HostId
of the local host.pKey
- PrivateKey
to be used for signing.public AbstractCommLayer(String hostname, int port) throws CommLayerException
HostId
and a Key Pair for the instance on the fly.
hostname
- Hostname for this host's HostId
port
- Listening port for this comm layer
CommLayerException
- If a URL cannot be formed using the provided
hostname and port or if the intended KeyPair
Generator Algorithm is not found.keyPairGeneratorAlgorithm
protected AbstractCommLayer()
Method Detail |
public Socket connect(String hostname, int port) throws CommLayerException
peer
.
hostname
- the peer hostnameport
- the peer's listening port number
peer
CommLayerException
- if any communication error occurs.public Socket connect(URL url) throws CommLayerException
peer
.
url
- the url of the peer.
peer
CommLayerException
- if any communication error occurs.public Logger getLogger()
public boolean isOnline()
public Message recvMessage(Socket s, HostId peer, ClassLoader loader) throws CommLayerException
peer
.
peer
- HostId
of the peer.s
- the socket through which the message comesloader
- the class loader used to load remote classes
Message
.
CommLayerException
- if any communication error occurs.public Message recvMessage(Socket s, HostId peer) throws CommLayerException
recvMessage(s, peer, null)
s
- the socket through which the message comespeer
- HostId
of the peer.
Message
CommLayerException
- if any communication error occurs.public void sendMessage(Socket s, Message m) throws CommLayerException
s
- socket connecting the two hosts.m
- Message
to be sent.
CommLayerException
- if any communication error occurs.public void setLogger(Logger logger)
logger
- The new logger
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |