Project JXTA

net.jxta.impl.membership
Class PasswdMembership

java.lang.Object
  |
  +--net.jxta.membership.Membership
        |
        +--net.jxta.impl.membership.PasswdMembership

public class PasswdMembership
extends net.jxta.membership.Membership

The passwd membership service provides a Membership implementation which is based on a password scheme similar to the unix /etc/passwd system. It is intended mostly as an example of a simple Membership service and not as a practical Membership service.

Since:
JXTA 1.0

Inner Class Summary
 class PasswdMembership.PasswdAuthenticator
          The authenticator associated with the password membership service.
 
Constructor Summary
PasswdMembership()
           
 
Method Summary
 net.jxta.membership.Authenticator apply(net.jxta.credential.AuthenticationCredential application)
          Request the necessary credentials to join the group with which this policy is associated.
 net.jxta.document.Advertisement getAdvertisement()
          Returns the ServiceAdvertisement assocaiated with this Service.
 java.util.Enumeration getAuthCredentials()
          Returns an enumeration of the AuthencticationCredentials which were used as the basis for the current set of credentials.
 java.util.Enumeration getCurrentCredentials()
          Returns an enumeration of the current credentials associated with this peer within in this peergroup.
 net.jxta.service.Service getInterface()
          Returns the interface for this service.
 net.jxta.peergroup.PeerGroup getPeerGroup()
          Returns the peer group assocaited with this Membership service.
 void init(net.jxta.peergroup.PeerGroup group, net.jxta.document.Advertisement myAdv)
          Initialize the application
 net.jxta.credential.Credential join(net.jxta.membership.Authenticator authenticated)
          Join the group by virtue of the completed authentication provided.
 net.jxta.credential.Credential makeCredential(net.jxta.document.Element element)
          Given a fragment of a StructuredDocument, reconstruct a Credential object from that fragment.
static java.lang.String makePsswd(java.lang.String source)
          This is the method used to make the password strings.
 void resign()
          Leave the group to which this policy is attached.
 int startApp(java.lang.String[] arg)
          Supply arguments and starts this service if it hadn't started by itself.
 void stopApp()
          Ask this service to stop.
 
Methods inherited from class net.jxta.membership.Membership
getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PasswdMembership

public PasswdMembership()
Method Detail

init

public void init(net.jxta.peergroup.PeerGroup group,
                 net.jxta.document.Advertisement myAdv)
          throws net.jxta.exception.PeerGroupException
Initialize the application
Overrides:
init in class net.jxta.membership.Membership
Parameters:
myAdv - The Advertisement for this service from the PeerGroupAdvertisement.
group - PeerGroup this service is started from
Throws:
net.jxta.exception.PeerGroupException - in the event of errors. this exception spec needs to be narrowed.

getInterface

public net.jxta.service.Service getInterface()
Returns the interface for this service. Some services return proxy versions of themselves to impose security upon the service object or to count references to the service.
Overrides:
getInterface in class net.jxta.membership.Membership
Returns:
the interface version of this service.

getAdvertisement

public net.jxta.document.Advertisement getAdvertisement()
Returns the ServiceAdvertisement assocaiated with this Service.
Overrides:
getAdvertisement in class net.jxta.membership.Membership
Returns:
the ServiceAdvertisement assocaiated with this Service.

startApp

public int startApp(java.lang.String[] arg)
Supply arguments and starts this service if it hadn't started by itself. Currently this service starts by itself and does not expect arguments.
Overrides:
startApp in class net.jxta.membership.Membership
Parameters:
arg - A table of strings arguments.
Returns:
int status indication.

stopApp

public void stopApp()
Ask this service to stop. This request is currently ignored.
Overrides:
stopApp in class net.jxta.membership.Membership

getPeerGroup

public net.jxta.peergroup.PeerGroup getPeerGroup()
Returns the peer group assocaited with this Membership service.
Returns:
the peer group assocaited with this Membership service.

apply

public net.jxta.membership.Authenticator apply(net.jxta.credential.AuthenticationCredential application)
                                        throws net.jxta.exception.PeerGroupException,
                                               net.jxta.exception.ProtocolNotSupportedException
Request the necessary credentials to join the group with which this policy is associated.
Overrides:
apply in class net.jxta.membership.Membership
Parameters:
application - The AuthenticationCredential containing the authentication method being requested and any identity information which is required to initialize the specified authentication method.
Returns:
Authenticator which must be completed before this peergroup may be joined.
Throws:
net.jxta.exception.PeerGroupException - in the event of errors. this exception spec needs to be narrowed.
net.jxta.exception.ProtocolNotSupportedException - if the authentication method requested in the application is not supported by this policy.

getCurrentCredentials

public java.util.Enumeration getCurrentCredentials()
                                            throws net.jxta.exception.PeerGroupException
Returns an enumeration of the current credentials associated with this peer within in this peergroup.
Overrides:
getCurrentCredentials in class net.jxta.membership.Membership
Returns:
Enumeration of the current credentials associated with this peer within in this peergroup.
Throws:
net.jxta.exception.PeerGroupException - in the event of errors. this exception spec needs to be narrowed.

getAuthCredentials

public java.util.Enumeration getAuthCredentials()
                                         throws net.jxta.exception.PeerGroupException
Returns an enumeration of the AuthencticationCredentials which were used as the basis for the current set of credentials.
Overrides:
getAuthCredentials in class net.jxta.membership.Membership
Returns:
enumeration of the AuthencticationCredentials which were used as the basis for the current set of credentials.
Throws:
net.jxta.exception.PeerGroupException - in the event of errors. this exception spec needs to be narrowed.

join

public net.jxta.credential.Credential join(net.jxta.membership.Authenticator authenticated)
                                    throws net.jxta.exception.PeerGroupException
Join the group by virtue of the completed authentication provided.
Overrides:
join in class net.jxta.membership.Membership
Parameters:
authenticated - the completed authentication object.
Returns:
The credential created by this join operation.
Throws:
net.jxta.exception.PeerGroupException - in the event of errors. this exception spec needs to be narrowed.

resign

public void resign()
            throws net.jxta.exception.PeerGroupException
Leave the group to which this policy is attached.
Overrides:
resign in class net.jxta.membership.Membership
Throws:
net.jxta.exception.PeerGroupException - in the event of errors. this exception spec needs to be narrowed.

makeCredential

public net.jxta.credential.Credential makeCredential(net.jxta.document.Element element)
                                              throws net.jxta.exception.PeerGroupException,
                                                     java.lang.Exception
Given a fragment of a StructuredDocument, reconstruct a Credential object from that fragment.
Overrides:
makeCredential in class net.jxta.membership.Membership
Parameters:
element - The StructuredDocument fragment to use for building the credential.
Returns:
Credential which was created from the document fragment.
Throws:
net.jxta.exception.PeerGroupException - in the event of errors. this exception spec needs to be narrowed.
java.lang.Exception - in the event of errors. this exception spec needs to be narrowed.

makePsswd

public static java.lang.String makePsswd(java.lang.String source)
This is the method used to make the password strings. We only provide one way encoding since we can compare the encoded strings. FIXME MJD 20010402 : switch to use the standard crypt(3) algorithm for encoding the passwords. The current algorithm has been breakable since ancient times, crypt(3) is also weak, but harder to break.
Parameters:
source - the string to encode
Returns:
String the encoded version of the password.

Project JXTA