In our examples so far, peers have been able to join peergroups without facing any restrictions. The Peer Membership Protocol, however, allows peergroups to restrict their membership by requiring new peers to present a set of credentials. The peergroup then examines these credentials and determines if the peer will be allowed to join the peergroup.
In order to
perform this authentication, you must have a class that extends the
net.jxta.membership.Membership). This class
implements the peergroup’s policy with respect to
membership: peers that want to join the peergroup are responsible for
supplying a set of credentials when they join the group. The
membership class examines these credentials and determines if they
are valid; if they are, the peer is allowed to join the group.
implementation of the membership class is the
class is initialized with a list of users and their passwords; peers
that want to join a peergroup using password membership must supply
the credentials with the appropriate password.
Let’s enhance our RestoNet example so that the RestoNet peergroup requires a password in order to join it. This requires changes both to the RestoPeer (which must set up the peergroup with the appropriate membership policy) and to the HungryPeer (which must now supply credentials in order to join the peergroup).
We’ll start with the RestoPeer. In our previous ...