|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--de.janicke.hj.tools.servlet.AbstractUserAdministration | +--de.janicke.hj.tools.servlet.SimpleUserAdministration
Handles the user administration with a database.
Field Summary | |
protected Database |
database
|
protected java.sql.PreparedStatement |
preSQLAcceptUserById
|
protected java.sql.PreparedStatement |
preSQLAcceptUserById_Sid
|
protected java.sql.PreparedStatement |
preSQLAcceptUserByNick
|
protected java.sql.PreparedStatement |
preSQLAcceptUserByNick_Passwd
|
protected java.sql.PreparedStatement |
preSQLAddUser
Precompiled SQL statement to add a servlet user. |
protected java.sql.PreparedStatement |
preSQLDeleteUserById
Precompiled SQL statement to delete a servlet user. |
protected java.sql.PreparedStatement |
preSQLDeleteUserByNick_Passwd
Precompiled SQL statement to delete a servlet user. |
protected java.sql.PreparedStatement |
preSQLEditUser
|
protected java.sql.PreparedStatement |
preSQLEditUserPwd
|
protected java.sql.PreparedStatement |
preSQLGetUserById
Precompiled SQL statement to get a servlet user. |
protected java.sql.PreparedStatement |
preSQLGetUserById_Sid
Precompiled SQL statement to get a servlet user. |
protected java.sql.PreparedStatement |
preSQLGetUserByNick
Precompiled SQL statement to get a servlet user. |
protected java.sql.PreparedStatement |
preSQLGetUserByNick_Passwd
Precompiled SQL statement to get a servlet user. |
protected java.sql.PreparedStatement |
preSQLSetSecureIdentity
|
Constructor Summary | |
SimpleUserAdministration(Database db)
Sets the database for the UserAdministration. |
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 |
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. |
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. |
void |
init()
Initializes the database. |
User |
loginUser(java.lang.String nick,
java.lang.String passwd)
Tries to login a new user. |
User |
loginUser(java.lang.String nick,
java.lang.String passwd,
javax.servlet.http.HttpServletRequest request)
Tries to login a new user. |
Methods inherited from class de.janicke.hj.tools.servlet.AbstractUserAdministration |
acceptUser, deleteUser, getRandomSecureId, loginUser |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Database database
protected java.sql.PreparedStatement preSQLSetSecureIdentity
protected java.sql.PreparedStatement preSQLAddUser
protected java.sql.PreparedStatement preSQLDeleteUserByNick_Passwd
protected java.sql.PreparedStatement preSQLDeleteUserById
protected java.sql.PreparedStatement preSQLGetUserById
protected java.sql.PreparedStatement preSQLGetUserByNick
protected java.sql.PreparedStatement preSQLGetUserByNick_Passwd
protected java.sql.PreparedStatement preSQLGetUserById_Sid
protected java.sql.PreparedStatement preSQLAcceptUserById
protected java.sql.PreparedStatement preSQLAcceptUserById_Sid
protected java.sql.PreparedStatement preSQLAcceptUserByNick_Passwd
protected java.sql.PreparedStatement preSQLAcceptUserByNick
protected java.sql.PreparedStatement preSQLEditUser
protected java.sql.PreparedStatement preSQLEditUserPwd
Constructor Detail |
public SimpleUserAdministration(Database db)
db
- The used Database.Method Detail |
public void init() throws java.lang.Exception
java.lang.Exception
- if there is no connect to the database, or the precompile of SQL statements fails.public boolean addUser(User user)
addUser
in class AbstractUserAdministration
user
- The user to add.public boolean acceptUser(java.lang.String nick)
acceptUser
in class AbstractUserAdministration
nick
- The nick of the user to check with database.public boolean acceptUser(int id, java.lang.String sid)
acceptUser
in class AbstractUserAdministration
id
- The userid to check with database.sid
- The secureIdentity of the user to check with database.public boolean acceptUser(java.lang.String nick, java.lang.String passwd)
acceptUser
in class AbstractUserAdministration
nick
- The nick of the user to check with database.passwd
- The password of the user to check with database.public boolean acceptUser(int id)
acceptUser
in class AbstractUserAdministration
id
- The userid to check with database.public boolean deleteUser(java.lang.String nick, java.lang.String passwd) throws java.lang.Exception
deleteUser
in class AbstractUserAdministration
nick
- The nickname of the user to delete.passwd
- The password of the user to delete.java.lang.Exception
- if user exists, but cannot be delted from database.public boolean deleteUser(int id) throws java.lang.Exception
deleteUser
in class AbstractUserAdministration
id
- The userid to delete.java.lang.Exception
- if user exists, but cannot be delted from database.public User editUser(User user) throws java.lang.Exception
editUser
in class AbstractUserAdministration
user
- The user to edit.java.sql.SQLException
- if database cannot be reached or problems with the SQL statements.java.lang.Exception
- if user does not exists.public User editUser(User user, java.lang.String passwd) throws java.lang.Exception
editUser
in class AbstractUserAdministration
user
- The user to edit.passwd
- The new password.java.sql.SQLException
- if database cannot be reached or problems with the SQL statements.java.lang.Exception
- if user does not exists.public User loginUser(java.lang.String nick, java.lang.String passwd) throws java.lang.Exception
loginUser
in class AbstractUserAdministration
nick
- The nickname of the user who wants to loginpasswd
- The password of the user who wants to loginjava.lang.Exception
- if user exists but secureIdentity could not be set.public User loginUser(java.lang.String nick, java.lang.String passwd, javax.servlet.http.HttpServletRequest request) throws java.lang.Exception
nick
- The nickname of the user who wants to loginpasswd
- The password of the user who wants to loginrequest
- The HttpServletRequest.java.lang.Exception
- if user exists but secureIdentity could not be set.public User getUser(int id) throws java.sql.SQLException
getUser
in class AbstractUserAdministration
id
- The id of the user to get.java.sql.SQLException
- if there is no conection to the database or problems with the SQL statements.public User getUser(java.lang.String nick) throws java.sql.SQLException
getUser
in class AbstractUserAdministration
nick
- The nickname of the user to get.java.sql.SQLException
- if there is no conection to the database or problems with the SQL statements.public User getUser(int id, java.lang.String sid) throws java.sql.SQLException
getUser
in class AbstractUserAdministration
id
- The id of the user to get.sid
- The secureIdentity of the user to get,java.sql.SQLException
- if there is no conection to the database or problems with the SQL statements.public User getUser(java.lang.String nick, java.lang.String passwd) throws java.sql.SQLException
getUser
in class AbstractUserAdministration
nick
- The nickname of the user to get.passwd
- The password of the user to get.java.sql.SQLException
- if there is no conection to the database or problems with the SQL statements.
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |