fi.paatti.paattiloginutils
Class LoginHelper

java.lang.Object
  extended by fi.paatti.paattiloginutils.LoginHelper

public class LoginHelper
extends Object

The helper class for user login. It handles the login and and controls the cookies. It creates an User object that has users groups, roles and researches.

Author:
Toni Salminen, toni.a.j.salminen@student.jyu.fi, Lauri Satokangas, lauri.n.satokangas@student.jyu.fi
 

Constructor Summary
LoginHelper(fi.paatti.paattidatabaseutils.dbservice.PaattiDBService db, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          The constructor.
 
Method Summary
 void deleteLoginCookie(String usernameCookieName, String passwordCookieName, String cookiePath)
          Removes the specified login cookie from the browser memory.
 fi.paatti.paattidatabaseutils.dbobjects.User getUser(String username, String password)
          Returns the User object using the given username and password.
 void setLoginCookie(String usernameCookieName, String username, String passwordCookieName, String password, String cookiePath, int cookieLifetime)
          Sets the login cookies in the browser memory.
 void setRequest(javax.servlet.http.HttpServletRequest request)
          Sets the HttpServletRequest.
 void setResponse(javax.servlet.http.HttpServletResponse response)
          Sets the HttpServletResponse.
 fi.paatti.paattidatabaseutils.dbobjects.User TryLoginWithCookies(String usernameCookieName, String passwordCookieName)
          Tries to log in with the browser cookies.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoginHelper

public LoginHelper(fi.paatti.paattidatabaseutils.dbservice.PaattiDBService db,
                   javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
The constructor.

Parameters:
db - the database service to be used.
request - the HttpServletRequest.
response - the HttpServletResponse.
Method Detail

setRequest

public void setRequest(javax.servlet.http.HttpServletRequest request)
Sets the HttpServletRequest.

Parameters:
request - the HttpServletRequest to be set.

setResponse

public void setResponse(javax.servlet.http.HttpServletResponse response)
Sets the HttpServletResponse.

Parameters:
response - the HttpServletResponse to be set.

getUser

public fi.paatti.paattidatabaseutils.dbobjects.User getUser(String username,
                                                            String password)
Returns the User object using the given username and password.

Parameters:
username - the user's name.
password - the user's password.
Returns:
The User object if successful or null if not successful.

TryLoginWithCookies

public fi.paatti.paattidatabaseutils.dbobjects.User TryLoginWithCookies(String usernameCookieName,
                                                                        String passwordCookieName)
Tries to log in with the browser cookies.

Parameters:
usernameCookieName - the name of the cookie containing the user name.
passwordCookieName - the name of the cookie containing the user password.
Returns:
The user matching the given (cookie) values, otherwise null.

setLoginCookie

public void setLoginCookie(String usernameCookieName,
                           String username,
                           String passwordCookieName,
                           String password,
                           String cookiePath,
                           int cookieLifetime)
Sets the login cookies in the browser memory.

Parameters:
usernameCookieName - the user name cookie name.
username - the user name.
passwordCookieName - the password cookie name.
cookieLifetime - the lifetime of the cookie.
password - the user's password.
cookiePath - the path to cookie.

deleteLoginCookie

public void deleteLoginCookie(String usernameCookieName,
                              String passwordCookieName,
                              String cookiePath)
Removes the specified login cookie from the browser memory.

Parameters:
usernameCookieName - the user name cookie name.
passwordCookieName - the password cookie name.
cookiePath - the path for the cookie.


Copyright © 2012. All Rights Reserved.