ibspan.tss.dao
Class UsersDAO

java.lang.Object
  extended by ibspan.tss.dao.UsersDAO

public class UsersDAO
extends Object

Data Access Object providing nice interface to model with users accounts.

Author:
Maciej Gawinecki

Constructor Summary
UsersDAO(OntModel mUsersDB)
          Creates UserDAO object providing interface to the given users model.
 
Method Summary
 int getNextUserID()
          Returns ID under which next user can be registered.
 int getUserID(String login)
          Returns ID of a user with the given login name.
 String getUserName(int userID)
          Returns a name for the user with the given ID.
 boolean isLoginPasswordMatching(String login, String password)
          Checks whether given login name matches to the given password, i.e.
 boolean isUserKnown(String name, String login)
          Checks whether given name or login name has been registered.
 int registerUser(String name, String login, String password)
          Creates (registers) an account for the user with given properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UsersDAO

public UsersDAO(OntModel mUsersDB)
         throws DAOException
Creates UserDAO object providing interface to the given users model.

Parameters:
mUsersDB - is model with users.
Throws:
DAOException - when there is a problem with initializing this object.
Method Detail

registerUser

public int registerUser(String name,
                        String login,
                        String password)
                 throws UserAlreadyKnownException
Creates (registers) an account for the user with given properties.

Parameters:
name - is a name for a new user.
login - is a login name for a new user.
password - is a password for a new user.
Returns:
ID of user registered.
Throws:
UserAlreadyKnownException - when trying to register user which have the name or login name exactly the same as the one already registered.

isLoginPasswordMatching

public boolean isLoginPasswordMatching(String login,
                                       String password)
Checks whether given login name matches to the given password, i.e. authorizes user.

Parameters:
login - is a login name.
password - is a password.
Returns:
true if authorization passed successfully.

getUserID

public int getUserID(String login)
Returns ID of a user with the given login name.

Parameters:
login - is a login name.
Returns:
ID of a user.

getUserName

public String getUserName(int userID)
Returns a name for the user with the given ID.

Parameters:
userID - is ID of user
Returns:
a name of a user

isUserKnown

public boolean isUserKnown(String name,
                           String login)
Checks whether given name or login name has been registered.

Parameters:
name - is name of a user
login - is login name of a user
Returns:
true is such user exists.

getNextUserID

public int getNextUserID()
Returns ID under which next user can be registered.

Returns:
user ID