22,7 → 22,10 |
|
import ak.backpath.BackPath; |
|
import ak.hostadmiral.util.ModelException; |
import ak.hostadmiral.core.servlet.LoginInfo; |
import ak.hostadmiral.core.model.User; |
import ak.hostadmiral.core.model.UserManager; |
|
/** |
* Ensures that user is logged in to the system to process its request. |
127,15 → 130,39 |
throw new AccessControlException("No session"); |
|
Object userObj = session.getAttribute(SessionKeys.USER); |
if(userObj == null) |
throw new AccessControlException("No user"); |
if(userObj == null) { |
// try to relogin |
Object loginInfoObj = session.getAttribute(SessionKeys.LOGIN_INFO); |
if(loginInfoObj == null) |
throw new AccessControlException("No user"); |
|
if(!(userObj instanceof User)) |
throw new ServletException( |
"Wrong type of user information: " + userObj.getClass().getName()); |
if(!(loginInfoObj instanceof LoginInfo)) |
throw new ServletException( |
"Wrong type of login info information: " |
+ loginInfoObj.getClass().getName()); |
|
try { |
userObj = UserManager.getInstance().get(((LoginInfo)loginInfoObj).getId()); |
} |
catch(ModelException ex) { |
throw new AccessControlException("No user"); |
} |
|
if(userObj == null) |
throw new AccessControlException("No user"); |
|
session.setAttribute(SessionKeys.USER, userObj); |
logger.debug("User re-logined: " + userObj); |
} |
else { |
if(!(userObj instanceof User)) |
throw new ServletException( |
"Wrong type of user information: " + userObj.getClass().getName()); |
|
logger.debug("User found - OK"); |
} |
|
processNext = true; |
logger.debug("User found - OK"); |
} |
catch(AccessControlException ex) { |
String redirectUrl; |