org.p2psockets
Class P2PNetwork

java.lang.Object
  extended byorg.p2psockets.P2PNetwork

public class P2PNetwork
extends java.lang.Object

This class signs us into the JXTA network. It is meant to model the JXTA network as a whole. By default, we re-profile this peer every time it starts up using the JXTA Profiler. To turn off this behavior, call the signin() method with the fourth boolean argument set to false to indicate not to peform profiling. Threading: the entire object is locked if any methods are called to mediate access to the netPeerGroup. We are assuming net.jxta.peergroup.PeerGroup is thread-safe.

Version:
0.6
Author:
Brad GNUberg, bkn3@columbia.edu

Field Summary
static java.lang.String JXTA_HOME
          The system property name that specifies where to find the Jxta configuration files.
static java.lang.String JXTA_PASSWORD
          The system property name for the password of this Jxta peer.
static java.lang.String JXTA_USERNAME
          The system property name for the username of this Jxta peer.
static java.lang.String P2PSOCKETS_NETWORK
          The system property name for setting the P2P network to sign into and initialize.
 
Constructor Summary
P2PNetwork()
           
 
Method Summary
static boolean accountExists(java.lang.String userName)
          Determines if an account exists for the given username.
protected static void contactRendezVous(net.jxta.peergroup.PeerGroup inGroup)
           
static void createAccount()
          Removes any old JXTA account and creates a new one, profiling the peer and signing them into the JXTA network.
static void createAccount(java.lang.String userName, java.lang.String password)
          Removes any old JXTA account and creates a new one, profiling the peer and signing them into the JXTA network.
static void createAccount(java.lang.String userName, java.lang.String password, java.lang.String appName)
          Removes any old JXTA account and creates a new one, profiling the peer and signing them into the JXTA network.
static java.lang.String getApplicationName()
           
static net.jxta.peergroup.PeerGroup getNetPeerGroup()
           
static void setApplicationName(java.lang.String appName)
           
static void signin()
           
static void signin(java.lang.String userName, java.lang.String password)
           
static void signin(java.lang.String userName, java.lang.String password, java.lang.String appName)
           
static void signin(java.lang.String userName, java.lang.String password, java.lang.String appName, boolean createIfNotExist)
           
static void signOff()
          Signs us out of the P2P network.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

P2PSOCKETS_NETWORK

public static java.lang.String P2PSOCKETS_NETWORK
The system property name for setting the P2P network to sign into and initialize.


JXTA_USERNAME

public static java.lang.String JXTA_USERNAME
The system property name for the username of this Jxta peer.


JXTA_PASSWORD

public static java.lang.String JXTA_PASSWORD
The system property name for the password of this Jxta peer.


JXTA_HOME

public static java.lang.String JXTA_HOME
The system property name that specifies where to find the Jxta configuration files.

Constructor Detail

P2PNetwork

public P2PNetwork()
Method Detail

accountExists

public static boolean accountExists(java.lang.String userName)
                             throws java.lang.Exception
Determines if an account exists for the given username.

Throws:
java.lang.Exception

createAccount

public static void createAccount()
                          throws java.lang.Exception
Removes any old JXTA account and creates a new one, profiling the peer and signing them into the JXTA network. This version of createAccount() uses the username and password given in the shell variables net.jxta.tls.principal and net.jxta.tls.password.

Throws:
java.lang.Exception

createAccount

public static void createAccount(java.lang.String userName,
                                 java.lang.String password)
                          throws java.lang.Exception
Removes any old JXTA account and creates a new one, profiling the peer and signing them into the JXTA network. This version of createAccount() uses the application peer group name given in the shell variable p2psockets.network.

Throws:
java.lang.Exception

createAccount

public static void createAccount(java.lang.String userName,
                                 java.lang.String password,
                                 java.lang.String appName)
                          throws java.lang.Exception
Removes any old JXTA account and creates a new one, profiling the peer and signing them into the JXTA network.

Throws:
java.lang.Exception

signin

public static void signin()
                   throws java.lang.Exception
Throws:
java.lang.Exception

signin

public static void signin(java.lang.String userName,
                          java.lang.String password)
                   throws java.lang.Exception
Throws:
java.lang.Exception

signin

public static void signin(java.lang.String userName,
                          java.lang.String password,
                          java.lang.String appName)
                   throws java.lang.Exception
Throws:
java.lang.Exception

signin

public static void signin(java.lang.String userName,
                          java.lang.String password,
                          java.lang.String appName,
                          boolean createIfNotExist)
                   throws java.lang.Exception
Parameters:
userName - The username to use for signing in.
password - The password to use for signing in.
appName - A unique string identifying your application.
createIfNotExist - Whether to create this account if it doesn't exist.
Throws:
java.lang.Exception

signOff

public static void signOff()
                    throws java.lang.Exception
Signs us out of the P2P network. FIXME: Actually do something here.

Throws:
java.lang.Exception

getNetPeerGroup

public static net.jxta.peergroup.PeerGroup getNetPeerGroup()

setApplicationName

public static void setApplicationName(java.lang.String appName)

getApplicationName

public static java.lang.String getApplicationName()

contactRendezVous

protected static void contactRendezVous(net.jxta.peergroup.PeerGroup inGroup)
                                 throws java.lang.Exception
Throws:
java.lang.Exception