jChatBox.Service
Class UserLogin
java.lang.Object
|
+--jChatBox.Service.Login
|
+--jChatBox.Service.UserLogin
- public class UserLogin
- extends Login
This class implements features to login user.
Method Summary |
protected void |
boundUser(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpSession session,
int chatroomID,
UserParams uParams,
java.lang.String nickname)
Bounds ChatroomUser to selected chatroom (and its HttpSession). |
java.lang.String |
doLogin(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpSession session)
Login (name, chatrooms) from JSP form.
|
protected void |
trace(int level,
java.lang.String msg)
Sends trace to debug. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
UserLogin
public UserLogin()
doLogin
public java.lang.String doLogin(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpSession session)
- Login (name, chatrooms) from JSP form.
You can overide this method to implement your own authentification scheme as :
X509 Certificates, LDAP, Database ...
ChatroomUser is logged in once he's attached to its HttpSession.
To do so you have 3 steps to implement :
Step 1 : Get user's info and the chatroom that he wants to log in
String login = request.getParameter("name");
String chatroomIDstr = request.getParameter("chatrooms");
...
...
Step 2 : Do controls (authentication/authorization) and instantiate UserParams
// Your authentication : returns null if it fails.
..
..
UserParams uParams = new UserParams();
uParams.setEmail(email);
...
...
Step 3 : Bound ChatroomUser to chatroom and HttpSession
// Join Chatroom.
try
{
boundUser(request,session,chatroomID,uParams,login);
// Logged.
return Conf.JSPROOM;
} catch (ChatException e)
{
setSysMessage(e.getMessage());
// Fail.
return null;
}
- Specified by:
doLogin
in class Login
boundUser
protected void boundUser(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpSession session,
int chatroomID,
UserParams uParams,
java.lang.String nickname)
throws ChatException
- Bounds ChatroomUser to selected chatroom (and its HttpSession).
It also notify users' Monitor.
ChatException
trace
protected void trace(int level,
java.lang.String msg)
- Sends trace to debug.