de.janicke.hj.tools.servlet
Interface UserAdministration


public interface UserAdministration

Handles the user administration with a database.


Method Summary
 boolean acceptUser(int id)
          Returns if a user exists in the database.
 boolean acceptUser(int id, java.lang.String sid)
          Returns if a user exists in the database.
 boolean acceptUser(java.lang.String nick)
          Returns if a user exists in the database.
 boolean acceptUser(java.lang.String nick, java.lang.String passwd)
          Returns if a user exists in the database.
 boolean acceptUser(User user)
          Returns if a user exists in the database.
 boolean addUser(User user)
          Adds a user to the database.
 boolean deleteUser(int id)
          Deletes an existing user from the database.
 boolean deleteUser(java.lang.String nick, java.lang.String passwd)
          Deletes an existing user from the database.
 boolean deleteUser(User user)
          Deletes an existing user from the database.
 User editUser(User user)
          Edits an existing user from the database.
 User editUser(User user, java.lang.String passwd)
          Edits an existing user password from the database.
 User getUser(int id)
          Gets a user from the database.
 User getUser(int id, java.lang.String sid)
          Gets a user from the database.
 User getUser(java.lang.String nick)
          Gets a user from the database.
 User getUser(java.lang.String nick, java.lang.String passwd)
          Gets a user from the database.
 User loginUser(java.lang.String nick, java.lang.String passwd)
          Tries to login a new user.
 User loginUser(User user)
          Tries to login a new user.
 

Method Detail

addUser

public boolean addUser(User user)
Adds a user to the database.
Parameters:
user - The user to add.
Returns:
true if the adding succesfull, else false.

acceptUser

public boolean acceptUser(User user)
Returns if a user exists in the database.
Parameters:
user - The user to check with database.
Returns:
true if the user exist, else false.

acceptUser

public boolean acceptUser(int id,
                          java.lang.String sid)
Returns if a user exists in the database.
Parameters:
id - The userid to check with database.
sid - The secureIdentity of the user to check with database.
Returns:
true if the user exist, else false.

acceptUser

public boolean acceptUser(java.lang.String nick,
                          java.lang.String passwd)
Returns if a user exists in the database.
Parameters:
nick - The nick of the user to check with database.
passwd - The password of the user to check with database.
Returns:
true if the user exist, else false.

acceptUser

public boolean acceptUser(int id)
Returns if a user exists in the database.
Parameters:
id - The userid to check with database.
Returns:
true if the user exist, else false.

acceptUser

public boolean acceptUser(java.lang.String nick)
Returns if a user exists in the database.
Parameters:
nick - The nick of the user to check with database.
Returns:
true if the user exist, else false.

deleteUser

public boolean deleteUser(User user)
                   throws java.lang.Exception
Deletes an existing user from the database.
Parameters:
user - The user to delete.
Returns:
true if the user exist and was successfully deleted, if user does not exists it returns false.
Throws:
java.lang.Exception - if user exists, but cannot be delted from database.

deleteUser

public boolean deleteUser(java.lang.String nick,
                          java.lang.String passwd)
                   throws java.lang.Exception
Deletes an existing user from the database.
Parameters:
nick - The nickname of the user to delete.
passwd - The password of the user to delete.
Returns:
true if the user exist and was successfully deleted, if user does not exists it returns false.
Throws:
java.lang.Exception - if user exists, but cannot be delted from database.

deleteUser

public boolean deleteUser(int id)
Deletes an existing user from the database.
Parameters:
id - The userid to delete.
Returns:
true if the user exist and was successfully deleted, if user does not exists it returns false.
Throws:
java.lang.Exception - if user exists, but cannot be delted from database.

editUser

public User editUser(User user)
              throws java.lang.Exception
Edits an existing user from the database.
Parameters:
user - The user to edit.
Returns:
If the user exist and was successfully updated the old user will be returned.
Throws:
java.sql.SQLException - if database cannot be reached or problems with the SQL statements.
java.lang.Exception - if user does not exists.

editUser

public User editUser(User user,
                     java.lang.String passwd)
              throws java.lang.Exception
Edits an existing user password from the database.
Parameters:
user - The user to edit.
passwd - The new password.
Returns:
If the user exist and password was successfully updated the old user will be returned.
Throws:
java.sql.SQLException - if database cannot be reached or problems with the SQL statements.
java.lang.Exception - if user does not exists.

loginUser

public User loginUser(User user)
               throws java.lang.Exception
Tries to login a new user.
Parameters:
user - The user who wants to login
Returns:
It returns the existing user object from the database if it exists, else null.
Throws:
java.lang.Exception - if user exists but secureIdentity could not be set.

loginUser

public User loginUser(java.lang.String nick,
                      java.lang.String passwd)
               throws java.lang.Exception
Tries to login a new user.
Parameters:
nick - The nickname of the user who wants to login
passwd - The password of the user who wants to login
Returns:
It returns the existing user object from the database if it exists, else null.
Throws:
java.lang.Exception - if user exists but secureIdentity could not be set.

getUser

public User getUser(int id)
             throws java.sql.SQLException
Gets a user from the database.
Parameters:
id - The id of the user to get.
Returns:
The user from the database chooesen by the id, if not exists it returns null.
Throws:
java.sql.SQLException - if there is no conection to the database or problems with the SQL statements.

getUser

public User getUser(java.lang.String nick)
             throws java.sql.SQLException
Gets a user from the database.
Parameters:
nick - The nickname of the user to get.
Returns:
The user from the database choosen by the nickname, if not exists it returns null.
Throws:
java.sql.SQLException - if there is no conection to the database or problems with the SQL statements.

getUser

public User getUser(int id,
                    java.lang.String sid)
             throws java.sql.SQLException
Gets a user from the database.
Parameters:
id - The id of the user to get.
sid - The secureIdentity of the user to get,
Returns:
The user from the database choosen by the id and secureIdentity, if not exists it returns null.
Throws:
java.sql.SQLException - if there is no conection to the database or problems with the SQL statements.

getUser

public User getUser(java.lang.String nick,
                    java.lang.String passwd)
             throws java.sql.SQLException
Gets a user from the database.
Parameters:
nick - The nickname of the user to get.
passwd - The password of the user to get.
Returns:
The user from the database choosen by the nickname and password, if not exists it returns null.
Throws:
java.sql.SQLException - if there is no conection to the database or problems with the SQL statements.