sg.edu.nus.peer
Class Session

java.lang.Object
  extended by sg.edu.nus.peer.Session

public class Session
extends java.lang.Object

Implement a session during a user login the system. For each user, there exists an unique session. After logout the system, the session will be deleted.

This class is a singleton class. That is, for a user we do not allow the user to switch to another role during his own session.

NOTE: In the future, the password should be encrypted.

Version:
1.0 2005-10-25
Author:
Xu Linhao

Method Summary
static void clear()
          Clear the current session.
static Session getInstance()
          Get the instance of the session.
static Session getInstance(java.lang.String userID, java.lang.String pwd)
          Get the instance of the session.
 java.lang.String getPassword()
          Get the password of the user.
 java.lang.String getUserID()
          Get the identifier of the user.
static boolean hasInstance()
          Determine if the session has already been created.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Session getInstance(java.lang.String userID,
                                  java.lang.String pwd)
Get the instance of the session.

Parameters:
userID - the identifier of the user
pwd - the password of the user

getInstance

public static Session getInstance()
                           throws java.lang.RuntimeException
Get the instance of the session.

Returns:
the instance of the session
Throws:
java.lang.RuntimeException - if instance cannot be found

hasInstance

public static boolean hasInstance()
Determine if the session has already been created.

Returns:
if the session is null, return false; otherwise, return true

clear

public static void clear()
Clear the current session.


getUserID

public java.lang.String getUserID()
Get the identifier of the user.

Returns:
the identifier of the user

getPassword

public java.lang.String getPassword()
Get the password of the user.

Returns:
the password of the user