Bees v0.5.0 API

bees.core
Class Neighbor

java.lang.Object
  |
  +--bees.core.Neighbor
Direct Known Subclasses:
BroadcastNeighbor, LiveNeighbor

public class Neighbor
extends java.lang.Object

A Neighbor is used to "activate" a NeighborImpl for a protocol flow. In this context, "activation" involves attaching handlers to receive and send capsules.

See Also:
NeighborImpl, Neighborhood

Constructor Summary
Neighbor(NeighborImpl ni)
          Construct a Neighbor that uses the given capability for communication.
 
Method Summary
 void attachReceivers(ProtocolSession ps)
          Attach the receiver hooks for a set of capsule types.
 void dequeueKey()
          Dequeue a key previously enqueued.
 void detachReceivers(ProtocolSession ps)
          Detach the receiver hooks for a set of capsule types.
 void enqueueKey(CapabilityEnvelope ce, java.lang.String algorithm)
          Enqueue a key for checking hop-by-hop integrity.
 void enqueueKey(SecretKey sk, java.lang.String algorithm)
          Enqueue a key for checking hop-by-hop integrity.
 NeighborImpl getNeighborImpl()
           
 void send(Capsule cap)
          Send a Capsule to this neighbor.
 void send(CapsuleGroup cg)
          Send a group of capsule to this neighbor.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Neighbor

public Neighbor(NeighborImpl ni)
Construct a Neighbor that uses the given capability for communication.
Parameters:
ni - The neighbor capability to use for communication.
Method Detail

getNeighborImpl

public final NeighborImpl getNeighborImpl()
Returns:
The neighbor implementation that this neighor uses to send and receive capsules.

enqueueKey

public void enqueueKey(CapabilityEnvelope ce,
                       java.lang.String algorithm)
                throws MissingCapabilityException,
                       java.security.NoSuchAlgorithmException,
                       java.lang.InstantiationException,
                       java.security.InvalidKeyException
Enqueue a key for checking hop-by-hop integrity.
Parameters:
ce - An envelope containing the secret key to use when computing MACs.
algorithm - The MAC algorithm to use with the key.
Throws:
MissingCapabilityException - If the capability has since been deleted.
java.lang.InstantiationException - If there was an error constructing the SecretKey capability.
java.security.NoSuchAlgorithmException - If the algorithm value is unknown.
java.security.InvalidKeyException - If the given key is invalid.

enqueueKey

public void enqueueKey(SecretKey sk,
                       java.lang.String algorithm)
                throws java.security.NoSuchAlgorithmException,
                       java.security.InvalidKeyException
Enqueue a key for checking hop-by-hop integrity.
Parameters:
sk - The SecretKey to use when computing MACs.
algorithm - The MAC algorithm to use with the key.
Throws:
java.security.NoSuchAlgorithmException - If the algorithm value is unknown.
java.security.InvalidKeyException - If the given key is invalid.

dequeueKey

public void dequeueKey()
Dequeue a key previously enqueued. This method has the effect of invalidating any capsules that have a MAC based on this key.

attachReceivers

public final void attachReceivers(ProtocolSession ps)
                           throws java.io.IOException
Attach the receiver hooks for a set of capsule types. XXX Not sure about this method, should it be called by the constructor?
Parameters:
ps - A ProtocolSession whose capsule types should have receivers attached.

detachReceivers

public final void detachReceivers(ProtocolSession ps)
Detach the receiver hooks for a set of capsule types.
Parameters:
ps - A ProtocolSession whose capsule types should have receivers detached.

send

public void send(Capsule cap)
          throws EncodingException,
                 java.io.IOException
Send a Capsule to this neighbor.
Parameters:
cap - The Capsule to send.
Throws:
Throws - an EncodingException if there was an error while marshalling the capsule.
Throws - an IOException if there was an error during transmission.

send

public void send(CapsuleGroup cg)
          throws EncodingException,
                 java.io.IOException
Send a group of capsule to this neighbor.
Parameters:
cg - The CapsuleGroup to send.
Throws:
Throws - an EncodingException if there was an error while marshalling the capsule(s).
Throws - an IOException if there was an error during transmission.

toString

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

Bees v0.5.0 API

This documentation is Copyright (C) 2002 The University of Utah. All Rights Reserved. See the individual source files for distribution terms.
Documentation, software, and mailing lists for Bees v0.5.0 can be found at the Janos Project: http://www.cs.utah.edu/flux/janos/