authentication
Class UserDb

java.lang.Object
  extended by authentication.UserDb

public class UserDb
extends java.lang.Object

This class is the interface to the XML file containing the list of users. It is used to retrieve a user, check that the password is correct and get the resource offering for the discovery service for that user.

Author:
Gunn Olaussen & Kirsti N. Torgersen

Field Summary
private  ResourceOffering offering
           
private  java.lang.String userdb
           
 
Constructor Summary
UserDb()
           
 
Method Summary
 boolean authenticate(java.lang.String un, java.lang.String pwd)
          This method authenticates the user by checking that the username is identical with one contained in the list of users and that the password is the same as the password of that user.
private  boolean correctPassword(java.lang.String pwd, org.w3c.dom.Node user)
           
private  org.w3c.dom.Node getOffering(org.w3c.dom.Node user)
           
 ResourceOffering readOffering()
           
private  boolean usernameFound(java.lang.String un, org.w3c.dom.Node user)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

userdb

private final java.lang.String userdb
See Also:
Constant Field Values

offering

private ResourceOffering offering
Constructor Detail

UserDb

public UserDb()
Method Detail

authenticate

public boolean authenticate(java.lang.String un,
                            java.lang.String pwd)
This method authenticates the user by checking that the username is identical with one contained in the list of users and that the password is the same as the password of that user. Then it retrieves the resource offering of that user and stores it in the offering variable so that it can be returned later.

Parameters:
un - String The user identifier of the user to be authenticated.
pwd - String The password of the user to be authenticated.
Returns:
boolean Returns true if the authentication was successful, false otherwise.

correctPassword

private boolean correctPassword(java.lang.String pwd,
                                org.w3c.dom.Node user)
Returns:
boolean Checks whether the password is correct for the current user. Returns true if it is and false otherwise.

usernameFound

private boolean usernameFound(java.lang.String un,
                              org.w3c.dom.Node user)
Returns:
boolean Checks whether the user identifier is correct for the current user. Returns true if it is and false otherwise.

getOffering

private org.w3c.dom.Node getOffering(org.w3c.dom.Node user)
Returns:
Node Retrieves the user's resource offering for the discovery service.

readOffering

public ResourceOffering readOffering()
Returns:
ResourceOffering The ResourceOffering object containing the user's resource offering for the discovery service.