nl.pbemengine.engine.ng.base.webserver
Class SessionManager

java.lang.Object
  extended by nl.pbemengine.engine.ng.base.webserver.SessionManager

public class SessionManager
extends java.lang.Object

A Session Management class. Keeps track of all sessions currently active, and provides facilities for validating users. Follows the Singleton pattern

Author:
Jeroen Steenbeeke

Field Summary
static java.lang.String SESSION_COOKIE
           
 
Constructor Summary
protected SessionManager()
          Creates a new instance of SessionManager
 
Method Summary
 java.lang.String authorizeAdmin(java.lang.String username, java.lang.String password, UserDAO dao)
          Verifies an Admin's username and password, and creates a session id if correct
 java.lang.String authorizeGame(int ID, GameDAO dao, java.lang.String password)
          Determines whether or not a Game Master is validly logged in by examing the game number and password
static SessionManager getManager()
          Gets an instance of the Sessionmanager
 Session getSession(java.util.Map<java.lang.String,java.lang.String> cookies)
          Returns the session object based on the user's cookies
 void invalidate(java.util.Map<java.lang.String,java.lang.String> cookies)
          Removes a Session from the manager
 boolean validateAdmin(java.util.Map<java.lang.String,java.lang.String> cookies)
          Determines whether or not a user is validly logged in by examining it's cookies.
 boolean validateGame(java.util.Map<java.lang.String,java.lang.String> cookies)
          Determines whether or not a GM is validly logged in by examining it's cookies.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SESSION_COOKIE

public static final java.lang.String SESSION_COOKIE
See Also:
Constant Field Values
Constructor Detail

SessionManager

protected SessionManager()
Creates a new instance of SessionManager

Method Detail

getManager

public static SessionManager getManager()
Gets an instance of the Sessionmanager

Returns:
A SessionManager

authorizeGame

public java.lang.String authorizeGame(int ID,
                                      GameDAO dao,
                                      java.lang.String password)
Determines whether or not a Game Master is validly logged in by examing the game number and password

Parameters:
ID - The game's ID
dao - The game data access object associated with this login
password - The game's password
Returns:
A String with the session ID if correct, null otherwise

validateGame

public boolean validateGame(java.util.Map<java.lang.String,java.lang.String> cookies)
Determines whether or not a GM is validly logged in by examining it's cookies.

Parameters:
cookies - The user's cookies
Returns:
true if logged in, false otherwise

validateAdmin

public boolean validateAdmin(java.util.Map<java.lang.String,java.lang.String> cookies)
Determines whether or not a user is validly logged in by examining it's cookies.

Parameters:
cookies - The user's cookies
Returns:
true if logged in, false otherwise

authorizeAdmin

public java.lang.String authorizeAdmin(java.lang.String username,
                                       java.lang.String password,
                                       UserDAO dao)
Verifies an Admin's username and password, and creates a session id if correct

Parameters:
username - The username specified
password - The password specified
dao - A UserDAO object to perform user-based database operations
Returns:
A String with the session ID if correct, null otherwise

invalidate

public void invalidate(java.util.Map<java.lang.String,java.lang.String> cookies)
Removes a Session from the manager

Parameters:
cookies - The user's cookies.

getSession

public Session getSession(java.util.Map<java.lang.String,java.lang.String> cookies)
Returns the session object based on the user's cookies

Parameters:
cookies - The user's cookies.
Returns:
A Session object, or null if unable to get a valid session ID


Copyright © 2008. All Rights Reserved.