org.bibalex.daf.managers
Class MainController

java.lang.Object
  extended by org.bibalex.daf.managers.MainController

public final class MainController
extends java.lang.Object

Main Controller of the System. This class is final, (sealed)

Author:
Fadi.Edward

Nested Class Summary
static class MainController.Views
          An enumeration listing the different views in the system.
 
Field Summary
private  WorkStation currentWorkstation
           
private static MainController defaultInstance
           
private  User loggedInUser
           
protected  ResourceManager resourceManager
           
private  java.lang.String userName
           
 
Constructor Summary
private MainController()
          Constructor, private Applying singltone pattern.
 
Method Summary
 boolean authenticateUser(java.lang.String userName, java.lang.String password)
          Authenticates a user using a Username and Password.
 User getCurrentUser()
          Gets the currently logged in User
 WorkStation getCurrentWorkstation()
          Gets the current workstation
 java.lang.String getCurrentWorkstationIP()
          Retreives Current Workstation IP
 java.lang.String getCurrentWorkstationName()
          Retreives Current Workstation Name
static MainController getMainController()
          Public method to retrieve or create the only instance of the MainController
 boolean hasAccessTo(MainController.Views view)
          Indicate whether the current logged in user has access or not to a specific view in the System.
 boolean isLoggedIn()
          Indicates if a user is logged in or not.
 boolean isValidUser()
          This method validates the user using only the UserName, either he is an LDAP user or not.
 boolean isValidWorkstation(java.lang.String workstationName, java.lang.String workstationIP)
          This method validates the current workstation in the system DB.
 void logoffUser()
          Log-Off the currently logged in user if exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loggedInUser

private User loggedInUser

currentWorkstation

private WorkStation currentWorkstation

defaultInstance

private static MainController defaultInstance

userName

private java.lang.String userName

resourceManager

protected ResourceManager resourceManager
Constructor Detail

MainController

private MainController()
Constructor, private Applying singltone pattern.

Method Detail

getMainController

public static MainController getMainController()
Public method to retrieve or create the only instance of the MainController

Returns:
the only instance of the MainController

isValidWorkstation

public boolean isValidWorkstation(java.lang.String workstationName,
                                  java.lang.String workstationIP)
This method validates the current workstation in the system DB.

Parameters:
workstationName - The name of the Workstation to check for validity.
workstationIP - The IP of the Workstation to check for validity (used only in case the name didn't match).
Returns:
true if it is a valid one, false otherwise.

getCurrentUser

public User getCurrentUser()
Gets the currently logged in User

Returns:
Currently logged in User

getCurrentWorkstation

public WorkStation getCurrentWorkstation()
Gets the current workstation

Returns:
Current Workstation

getCurrentWorkstationName

public java.lang.String getCurrentWorkstationName()
Retreives Current Workstation Name

Returns:
Current Workstation Name

getCurrentWorkstationIP

public java.lang.String getCurrentWorkstationIP()
Retreives Current Workstation IP

Returns:
Current Workstation IP

isLoggedIn

public boolean isLoggedIn()
Indicates if a user is logged in or not.

Returns:
true if logged-in, false otherwise.

isValidUser

public boolean isValidUser()
This method validates the user using only the UserName, either he is an LDAP user or not. It depends on a user name retrieved using System.getProperty("user.name"). It may be considered as security issue, working on it.

Returns:
true if the user is valid, false otherwise.

authenticateUser

public boolean authenticateUser(java.lang.String userName,
                                java.lang.String password)
Authenticates a user using a Username and Password. This method checks if the user is in the System (non-LDAP user) or not, if not checks if it is an LDAP user.

Parameters:
userName - the UserName to authenticate
password - the password to authenticate with
Returns:
true if authenticated user, false otherwise

logoffUser

public void logoffUser()
Log-Off the currently logged in user if exists.


hasAccessTo

public boolean hasAccessTo(MainController.Views view)
Indicate whether the current logged in user has access or not to a specific view in the System.

Parameters:
view - The view to check access for.
Returns:
true if the user has access to that view, false otherwise.