net.sourceforge.pavlov.controllers
Class LoginController

java.lang.Object
  extended by net.sourceforge.sillyview.Widget
      extended by net.sourceforge.pavlov.controllers.LoginController
All Implemented Interfaces:
EventListener, HyperlinkListener, LogonListener

public class LoginController
extends Widget
implements LogonListener, HyperlinkListener

Creates and manages model, view, and controller for the Logon system.

Since:
1.1

Field Summary
static String CHOOSE_ANOTHER_PASSWORD
          Token for communicating with velocity model
static String CREATE
          Token for communicating with velocity model
static String CREATE_NEW_USER
          Token for communicating with velocity model
static String ERROR
           
static String MODE
          Token for communicating with velocity model
static String NAME_IN_USE
          Token for communicating with velocity model
static String PASSWORD
          Token for communicating with velocity model
static String USER_NAME
          Token for communicating with velocity model
static String WRONG_PASSWORD
          Token for communicating with velocity model
 
Fields inherited from class net.sourceforge.sillyview.Widget
view
 
Constructor Summary
LoginController(WidgetView vu)
           
 
Method Summary
 void addLogonListener(LogonListener l)
          Adds a LogonListener.
 void addTokens(HashMap<Object,Object> map)
           
protected  User createNewUser(String username, String pass)
          Creates a new user with the given name and password.
protected  boolean goodPassword(String name, String pass)
          Returns true if the user file exists, and its password is equal to the one provided.
 void hyperlinkUpdate(HyperlinkEvent e)
          Catches the form submit event, and makes a login attempt from it.
 void logonAttempt(LogonEvent event)
          Description of the Method
protected  void notify(LogonEvent e)
          Notify listeners that a logonevent has occured.
protected  LogonEvent parseURL(String url)
          Converts the URL command to a LogonEvent.
 void setToken(String nam, String val)
          Sets the given token to the given value in the backing model.
protected  void startSession(User u)
          Notifies listeners that the user has successfully logged in and closes the Login view.
protected  boolean userNameExists(String name)
          Returns true if a file exists for the given user.
 
Methods inherited from class net.sourceforge.sillyview.Widget
getView, setView
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHOOSE_ANOTHER_PASSWORD

public static final String CHOOSE_ANOTHER_PASSWORD
Token for communicating with velocity model

See Also:
Constant Field Values

CREATE_NEW_USER

public static final String CREATE_NEW_USER
Token for communicating with velocity model

See Also:
Constant Field Values

NAME_IN_USE

public static final String NAME_IN_USE
Token for communicating with velocity model

See Also:
Constant Field Values

PASSWORD

public static final String PASSWORD
Token for communicating with velocity model

See Also:
Constant Field Values

USER_NAME

public static final String USER_NAME
Token for communicating with velocity model

See Also:
Constant Field Values

WRONG_PASSWORD

public static final String WRONG_PASSWORD
Token for communicating with velocity model

See Also:
Constant Field Values

MODE

public static final String MODE
Token for communicating with velocity model

See Also:
Constant Field Values

CREATE

public static final String CREATE
Token for communicating with velocity model

See Also:
Constant Field Values

ERROR

public static final String ERROR
See Also:
Constant Field Values
Constructor Detail

LoginController

public LoginController(WidgetView vu)
                throws Exception
Throws:
Exception
Method Detail

userNameExists

protected boolean userNameExists(String name)
Returns true if a file exists for the given user.

Returns:
Description of the Return Value

goodPassword

protected boolean goodPassword(String name,
                               String pass)
Returns true if the user file exists, and its password is equal to the one provided. Returns false for usernames less than 2 characters and passwords less than 3 characters.

Parameters:
name - Username to check
pass - Password provided by user
Returns:
Whether password is correct

createNewUser

protected User createNewUser(String username,
                             String pass)
Creates a new user with the given name and password.

Parameters:
username - Description of the Parameter
pass - Description of the Parameter
Returns:
Description of the Return Value

startSession

protected void startSession(User u)
Notifies listeners that the user has successfully logged in and closes the Login view.

Parameters:
u - Description of the Parameter

logonAttempt

public void logonAttempt(LogonEvent event)
Description of the Method

Specified by:
logonAttempt in interface LogonListener
Parameters:
event - Description of the Parameter

setToken

public void setToken(String nam,
                     String val)
Sets the given token to the given value in the backing model.

Parameters:
n - The new token key
v - The new token value

addTokens

public void addTokens(HashMap<Object,Object> map)

parseURL

protected LogonEvent parseURL(String url)
Converts the URL command to a LogonEvent.

Parameters:
url - Description of the Parameter
Returns:
Description of the Return Value

hyperlinkUpdate

public void hyperlinkUpdate(HyperlinkEvent e)
Catches the form submit event, and makes a login attempt from it.

Specified by:
hyperlinkUpdate in interface HyperlinkListener
Parameters:
e - Description of the Parameter

notify

protected void notify(LogonEvent e)
Notify listeners that a logonevent has occured.

Parameters:
e - Description of the Parameter

addLogonListener

public void addLogonListener(LogonListener l)
Adds a LogonListener.

Parameters:
l - The feature to be added to the LogonListener attribute