use of javax.servlet.http.HttpSession in project head by mifos.
the class MifosLegacyUsernamePasswordAuthenticationFilter method doFilter.
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
//LocaleContextHolder.setLocale(Localization.getInstance().getConfiguredLocale());
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
AuthenticationException denied = null;
boolean allowAuthenticationToContinue = true;
if (MifosBatchJob.isBatchJobRunningThatRequiresExclusiveAccess()) {
allowAuthenticationToContinue = false;
HttpSession session = request.getSession(false);
if (session != null) {
session.invalidate();
}
denied = new AuthenticationServiceException(messages.getMessage(LoginConstants.BATCH_JOB_RUNNING, "You have been logged out of the system because batch jobs are running."));
}
ShutdownManager shutdownManager = (ShutdownManager) ServletUtils.getGlobal(request, ShutdownManager.class.getName());
if (shutdownManager.isShutdownDone()) {
allowAuthenticationToContinue = false;
request.getSession(false).invalidate();
denied = new AuthenticationServiceException(messages.getMessage(LoginConstants.SHUTDOWN, "You have been logged out of the system because Mifos is shutting down."));
}
if (shutdownManager.isInShutdownCountdownNotificationThreshold()) {
request.setAttribute("shutdownIsImminent", true);
}
if (allowAuthenticationToContinue) {
super.doFilter(request, response, chain);
} else {
unsuccessfulAuthentication(request, response, denied);
}
}
use of javax.servlet.http.HttpSession in project head by mifos.
the class LoginAction method setUserContextInSession.
private void setUserContextInSession(UserContext userContext, HttpServletRequest request) {
HttpSession hs = request.getSession(false);
hs.setAttribute(Constants.USERCONTEXT, userContext);
hs.setAttribute(Globals.LOCALE_KEY, userContext.getCurrentLocale());
}
use of javax.servlet.http.HttpSession in project head by mifos.
the class BulkEntryActionStrutsTest method getUserLocale.
private Locale getUserLocale(final HttpServletRequest request) {
Locale locale = null;
HttpSession session = request.getSession();
if (session != null) {
UserContext userContext = (UserContext) session.getAttribute(LoginConstants.USERCONTEXT);
if (null != userContext) {
locale = userContext.getCurrentLocale();
}
}
return locale;
}
use of javax.servlet.http.HttpSession in project hudson-2.x by hudson.
the class SecurityRealm method doLogout.
/**
* Handles the logout processing.
* <p/>
* <p/>
* The default implementation erases the session and do a few other clean up, then
* redirect the user to the URL specified by {@link #getPostLogOutUrl(StaplerRequest, Authentication)}.
*
* @since 1.314
*/
public void doLogout(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
HttpSession session = req.getSession(false);
if (session != null) {
session.invalidate();
}
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
SecurityContextHolder.clearContext();
//Clear env property.
EnvVars.clearHudsonUserEnvVar();
// reset remember-me cookie
Cookie cookie = new Cookie(ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE_KEY, "");
cookie.setPath(req.getContextPath().length() > 0 ? req.getContextPath() : "/");
rsp.addCookie(cookie);
rsp.sendRedirect2(getPostLogOutUrl(req, auth));
}
use of javax.servlet.http.HttpSession in project nutz by nutzam.
the class ModuleProcessor method process.
public void process(ActionContext ac) throws Throwable {
RequestIocContext reqContext = null;
try {
if (null != moduleObj) {
ac.setModule(moduleObj);
} else {
Ioc ioc = ac.getIoc();
Object obj;
/*
* 如果 Ioc 容器实现了高级接口,那么会为当前请求设置上下文对象
*/
if (NutSessionListener.isSessionScopeEnable && ioc instanceof Ioc2) {
reqContext = new RequestIocContext(ac.getRequest());
HttpSession sess = Mvcs.getHttpSession(false);
IocContext myContext = null;
// 如果容器可以创建 Session ...
if (null != sess) {
SessionIocContext sessionContext = new SessionIocContext(sess);
myContext = new ComboContext(reqContext, sessionContext);
} else // 如果容器禁止了 Session ...
{
myContext = reqContext;
}
Mvcs.setIocContext(myContext);
obj = ((Ioc2) ioc).get(moduleType, injectName, myContext);
} else
/*
* 否则,则仅仅简单的从容器获取
*/
obj = ioc.get(moduleType, injectName);
ac.setModule(obj);
}
ac.setMethod(method);
// if (log.isDebugEnabled()) //打印实际执行的Method信息
// log.debugf("Handle URL[%s] by Method[%s]",ac.getPath(),method);
doNext(ac);
} finally {
if (reqContext != null)
try {
reqContext.depose();
} catch (Throwable e) {
if (log.isDebugEnabled())
log.debug("ReqContext depose fail?!", e);
}
}
}
Aggregations