de.janicke.hj.tools.servlet
Class AbstractUserAdministration

java.lang.Object
  |
  +--de.janicke.hj.tools.servlet.AbstractUserAdministration
Direct Known Subclasses:
SimpleUserAdministration

public abstract class AbstractUserAdministration
extends java.lang.Object

Handles the user administration with a database.


Constructor Summary
AbstractUserAdministration()
           
 
Method Summary
abstract  boolean acceptUser(int id)
          Returns if a user exists in the database.
abstract  boolean acceptUser(int id, java.lang.String sid)
          Returns if a user exists in the database.
abstract  boolean acceptUser(java.lang.String nick)
          Returns if a user exists in the database.
abstract  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.
abstract  boolean addUser(User user)
          Adds a user to the database.
abstract  boolean deleteUser(int id)
          Deletes an existing user from the database.
abstract  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.
abstract  User editUser(User user)
          Edits an existing user from the database.
abstract  User editUser(User user, java.lang.String passwd)
          Edits an existing user password from the database.
static java.lang.String getRandomSecureId(int n)
          Generates a SecureIdentity String with n chars.
abstract  User getUser(int id)
          Gets a user from the database.
abstract  User getUser(int id, java.lang.String sid)
          Gets a user from the database.
abstract  User getUser(java.lang.String nick)
          Gets a user from the database.
abstract  User getUser(java.lang.String nick, java.lang.String passwd)
          Gets a user from the database.
abstract  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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractUserAdministration

public AbstractUserAdministration()
Method Detail

getRandomSecureId

public static java.lang.String getRandomSecureId(int n)
Generates a SecureIdentity String with n chars.
Parameters:
n - Length of the generated String.
Returns:
A randomly choosen String with a length of n.

addUser

public abstract 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 abstract 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 abstract 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 abstract 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 abstract 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 abstract 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 abstract boolean deleteUser(int id)
                            throws java.lang.Exception
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 abstract 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 abstract 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 abstract 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 abstract 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 abstract 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 abstract 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 abstract 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.