O'Reilly logo

JXTA in a Nutshell by Li Gong, Bernard Traversat, Scott Oaks

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

JXTA Authentication

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 abstract Membership class (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.

One implementation of the membership class is the PasswdMembership class (net.jxta.impl.membership.PasswdMembership). This 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required