public class Session extends java.lang.Object
Constructor and Description |
---|
Session() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getLastVisitedURL(HttpServletRequest request)
Based on the request referer returns the address of the previously visited
page or to the default main page if none.
|
static LoggedIn |
getSuccessfulLogin(java.lang.String username,
java.lang.String password)
Attemps to login using the supplied params.
|
static LoggedIn |
getUserLoggedIn(HttpSession session)
Gets the LoggedIn object that has the information relative to user logged in on the session supplied.
|
static boolean |
isSuccessfulLogin(java.lang.String username,
java.lang.String password)
Attemps to login using the supplied params.
|
static boolean |
isUserLoggedIn(HttpSession session)
Check if there is a user logged in on the session supplied.
|
static boolean |
isUserLoggedInAnAdmin(HttpSession session)
Check if there is a user logged in on the session supplied and if (s)he ia an administrator.
|
static boolean |
logout(HttpServletRequest request)
If there is a user logged in on the current HttpSession, log out.
|
static LoggedIn |
servletLogin(HttpServletRequest request,
HttpServletResponse response,
boolean requiresAdminRights)
Checks if the request made to a servlet was made by a logged is user,
or if the request carries the required login information.
|
static LoggedInStatus |
webappLogin(HttpServletRequest request,
HttpServletResponse response,
boolean requiresAdminRights)
Checks if the request made to a webapp was made by a logged is user,
or if the request carries the required login information.
|
public Session()
public static boolean isSuccessfulLogin(java.lang.String username, java.lang.String password)
username
- the user name.password
- the users password.public static LoggedIn getSuccessfulLogin(java.lang.String username, java.lang.String password)
username
- the user name.password
- the users password.public static boolean isUserLoggedIn(HttpSession session)
session
- the HttpSession object of the request.public static boolean isUserLoggedInAnAdmin(HttpSession session)
session
- the HttpSession object of the request.public static LoggedIn getUserLoggedIn(HttpSession session)
session
- the HttpSession object of the request.public static boolean logout(HttpServletRequest request)
session
- the HttpSession object of the request.public static LoggedIn servletLogin(HttpServletRequest request, HttpServletResponse response, boolean requiresAdminRights) throws java.io.IOException
requiresAdminRights
- if the current request requires admin rights to be served/performed.java.io.IOException
public static LoggedInStatus webappLogin(HttpServletRequest request, HttpServletResponse response, boolean requiresAdminRights) throws java.io.IOException
requiresAdminRights
- if the current request requires admin rights to be served/performed.java.io.IOException
public static java.lang.String getLastVisitedURL(HttpServletRequest request)
request
- the original http request object.