List of usage examples for javax.servlet.http HttpSession getAttribute
public Object getAttribute(String name);
null
if no object is bound under the name. From source file:mx.com.quadrum.contratos.controller.HomeController.java
@RequestMapping(value = "*") public String error404(HttpSession session, Model model) { Usuario usuario = (Usuario) session.getAttribute("usuario"); if (usuario == null) { return "templates/index"; }/*from w w w . j a v a 2s . co m*/ if (usuario.getEsAdmin()) { model.addAttribute("esAdmin", "esAdmin"); } return "templates/404"; }
From source file:se.inera.certificate.web.security.BrowserClosedInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException { HttpSession session = request.getSession(); DateTime then = (DateTime) session.getAttribute(BROWSER_CLOSED_TIMESTAMP); if (then != null) { if (then.plusSeconds(timeoutSeconds).isBefore(DateTime.now())) { LOG.warn("Browser closed and protected page revisited, user logged out"); // log out user logoutHandler.logout(request, response, null); response.sendRedirect(redirectLocation); return false; } else {/* www.jav a 2 s . c o m*/ // valid reqest remove timestamp session.removeAttribute(BROWSER_CLOSED_TIMESTAMP); LOG.debug("Valid refresh of browser"); return true; } } // normal request return true; }
From source file:com.ateam.login.UserSession.java
@Override public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { HttpSession session = ((HttpServletRequest) request).getSession(); String redirectUrl = (String) session.getAttribute(LAST_URL_REDIRECT_KEY); if (isAuthenticated() && (redirectUrl != null) && !redirectUrl.isEmpty()) { session.removeAttribute(LAST_URL_REDIRECT_KEY); HttpServletResponse resp = (HttpServletResponse) response; resp.sendRedirect(redirectUrl);//from w w w .j a v a 2 s . co m } else { chain.doFilter(request, response); } }
From source file:com.kalai.controller.ContactController.java
@RequestMapping("/contactform") public String contactform(ModelMap map, HttpSession session) { String username = ""; try {/* w w w . j av a 2 s .co m*/ username = (String) session.getAttribute("username"); if (username != null && username.trim().length() != 0) { map.addAttribute("Status", "input"); return "contactpage"; } else { return "index"; } } catch (Exception e) { return "PageNotFound"; } }
From source file:puma.sp.authentication.controllers.authentication.AccessController.java
@RequestMapping(value = "/SubmitWAYF", method = RequestMethod.GET) public String submitWAYF(ModelMap model, HttpSession session) { if (session.getAttribute("Authenticated") == null || !((Boolean) session.getAttribute("Authenticated")).booleanValue()) { Tenant tenantObject = (Tenant) session.getAttribute("ChosenTenant"); session.removeAttribute("ChosenTenant"); if (tenantObject == null) { // Redirect back to WAYF with message session.setAttribute("FlowRedirectionElement", new FlowDirecter("/SubmitWAYF")); return "redirect:/"; } else {// ww w .j a v a 2 s .co m session.setAttribute("Tenant", tenantObject); this.ensureRelayState(session); // Redirect to next flow element return "redirect:/AuthenticationRequestServlet"; } } else { // Obtain relay state String relayState = this.ensureRelayState(session); // Check tenants, if different or null ('something went wrong'), logout Tenant one = (Tenant) session.getAttribute("ChosenTenant"); Tenant other = (Tenant) session.getAttribute("Tenant"); if (one == null || other == null || !one.equals(other)) return "redirect:/LogoutServlet?RelayState=" + relayState; // Else, redirect to authenticatino servlet session.removeAttribute("ChosenTenant"); return "redirect:/AuthenticationRequestServlet"; } }
From source file:puma.sp.authentication.controllers.authentication.AccessController.java
private String ensureRelayState(HttpSession session) { String result = (String) session.getAttribute("RelayState"); if (result == null || result.isEmpty()) { result = DEFAULT_RELAYSTATE;/* www .j av a 2s . c o m*/ session.setAttribute("RelayState", result); } return result; }
From source file:be.fedict.eid.dss.webapp.TempFileCleanerHttpSessionListener.java
@Override public void sessionDestroyed(HttpSessionEvent event) { LOG.debug("sessionDestroyed"); HttpSession httpSession = event.getSession(); Set<String> tmpFileSet = (Set<String>) httpSession .getAttribute(ModelDSSDocumentContext.TMP_FILE_SET_SESSION_ATTRIBUTE); if (null == tmpFileSet) { LOG.debug("no temp file set in HTTP session present"); return;//from w w w . j av a 2s .com } for (String tmpFilename : tmpFileSet) { File tmpFile = new File(tmpFilename); if (false == tmpFile.exists()) { LOG.debug("tmp file already removed: " + tmpFilename); continue; } if (tmpFile.delete()) { LOG.debug("tmp file successfully deleted: " + tmpFilename); } else { LOG.warn("tmp file could not be removed: " + tmpFilename); } } }
From source file:com.banyou.backend.web.front.HomepageController.java
@RequestMapping(value = { "/", "index", "" }, method = RequestMethod.GET) public String index(HttpSession session, Model model) { String lunboCode = "INDEX_LUNBO"; Long[] ids = (Long[]) session.getAttribute(DEST_CODE); if (!ArrayUtils.isEmpty(ids)) { model.addAttribute("dests", destService.findDests(ids)); }/*from w w w. j ava 2 s. co m*/ List<AdContent> lunboAD = adService.getAdPositionByCode(lunboCode).getContent(); int lunboMax = 1; if (!lunboAD.isEmpty()) { model.addAttribute("lunboAd", lunboAD.subList(0, Math.min(lunboAD.size(), lunboMax))); } destService.findDests(ids); return "front/index"; }
From source file:com.nec.nsgui.action.cifs.CifsSetGlobalAction.java
public ActionForward set(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { DynaValidatorForm dynaForm = (DynaValidatorForm) form; int group = NSActionUtil.getCurrentNodeNo(request); HttpSession session = request.getSession(); String domainName = (String) session.getAttribute(CifsActionConst.SESSION_DOMAIN_NAME); String computerName = (String) session.getAttribute(CifsActionConst.SESSION_COMPUTER_NAME); CifsGlobalInfoBean bean = (CifsGlobalInfoBean) dynaForm.get("info"); CifsGlobalInfoBean bean4perl = (CifsGlobalInfoBean) BeanUtils.cloneBean(bean); changEncodingForForm(bean);/*from w w w .j a v a 2 s . c om*/ bean4perl.setServerString(NSActionUtil.page2Perl(bean4perl.getServerString(), request)); bean4perl.setAlogFile(NSActionUtil.page2Perl(bean4perl.getAlogFile(), request)); CifsCmdHandler.setGlobalInfo(group, domainName, computerName, bean4perl); NSActionUtil.setSuccess(request); return mapping.findForward("displaySuccess"); }
From source file:FormLogin.java
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException { resp.setContentType("text/html"); java.io.PrintWriter out = resp.getWriter(); HttpSession session = req.getSession(true); String user = (String) session.getAttribute(USER_KEY); if (user == null) { String username = req.getParameter(FIELD_USER); String password = req.getParameter(FIELD_PASSWORD); if (!validUser(username, password)) { out.println("<html>"); out.println("<title>Invalid User</title>"); out.println("<body><center><h2>" + "Invalid User!</h2><br>"); out.println("Press the 'Back' button to try again"); out.println("</center></body></html>"); out.flush();/*from www. j a v a2 s . com*/ return; } session.setAttribute(USER_KEY, username); } resp.sendRedirect(req.getRequestURI()); }