List of usage examples for javax.servlet.http HttpSession removeAttribute
public void removeAttribute(String name);
From source file:org.impalaframework.extension.mvc.flash.FlashHelper.java
void unpackFlashState(HttpServletRequest request) { final HttpSession session = request.getSession(false); if (session != null) { final Map<String, Object> flashState = (Map<String, Object>) session .getAttribute(sessionPrefix + "flashState"); if (flashState != null) { request.setAttribute("flashState", flashState); session.removeAttribute(sessionPrefix + "flashState"); Set<String> flashKeys = flashState.keySet(); for (String flashKey : flashKeys) { Object currentRequestAttribute = request.getAttribute(flashKey); if (currentRequestAttribute == null) { request.setAttribute(flashKey, flashState.get(flashKey)); }//from w w w . j a v a2s . co m } } } }
From source file:wqm.web.server.controller.BaseWQMController.java
protected void addCommonParams(ModelAndView view, HttpServletRequest request) { HttpSession session = request.getSession(true); view.addObject("stations", stationManager.getBaseStations()); for (String sessionField : Messages.SESSION_FIELDS) { Object val = session.getAttribute(sessionField); if (val != null) { view.addObject(sessionField, val); session.removeAttribute(sessionField); }/*from www. j ava 2 s . c om*/ } }
From source file:de.hybris.platform.yb2bacceleratorstorefront.controllers.pages.AbstractLoginPageController.java
protected String getDefaultLoginPage(final boolean loginError, final HttpSession session, final Model model) throws CMSItemNotFoundException { final LoginForm loginForm = new LoginForm(); model.addAttribute(loginForm);/*from w w w . ja va 2 s .c o m*/ model.addAttribute(new RegisterForm()); final String username = (String) session.getAttribute(SPRING_SECURITY_LAST_USERNAME); if (username != null) { session.removeAttribute(SPRING_SECURITY_LAST_USERNAME); } loginForm.setJ_username(username); storeCmsPageInModel(model, getLoginCmsPage()); setUpMetaDataForContentPage(model, (ContentPageModel) getLoginCmsPage()); model.addAttribute("metaRobots", "index,no-follow"); final Breadcrumb loginBreadcrumbEntry = new Breadcrumb("#", getMessageSource().getMessage("header.link.login", null, getI18nService().getCurrentLocale()), null); model.addAttribute("breadcrumbs", Collections.singletonList(loginBreadcrumbEntry)); if (loginError) { GlobalMessages.addErrorMessage(model, "login.error.account.not.found.title"); } return getLoginView(); }
From source file:alfio.controller.AdminConfigurationController.java
@RequestMapping(CONNECT_REDIRECT_PATH) public String authorize(Principal principal, @RequestParam("state") String state, @RequestParam(value = "code", required = false) String code, @RequestParam(value = "error", required = false) String errorCode, @RequestParam(value = "error_description", required = false) String errorDescription, HttpSession session, RedirectAttributes redirectAttributes) { return Optional.ofNullable(session.getAttribute(STRIPE_CONNECT_ORG)).map(Integer.class::cast) .filter(orgId -> userManager .isOwnerOfOrganization(userManager.findUserByUsername(principal.getName()), orgId)) .map(orgId -> {// w w w . j av a2 s. c o m session.removeAttribute(STRIPE_CONNECT_ORG); String persistedState = (String) session.getAttribute(STRIPE_CONNECT_STATE_PREFIX + orgId); session.removeAttribute(STRIPE_CONNECT_STATE_PREFIX + orgId); boolean stateVerified = Objects.equals(persistedState, state); if (stateVerified && code != null) { StripeManager.ConnectResult connectResult = stripeManager.storeConnectedAccountId(code, Configuration.from(orgId)); if (connectResult.isSuccess()) { return "redirect:/admin/#/configuration/organization/" + orgId; } } else if (stateVerified && StringUtils.isNotEmpty(errorCode)) { log.warn("error from stripe. {}={}", errorCode, errorDescription); redirectAttributes.addFlashAttribute("errorMessage", StringUtils.defaultString(errorDescription, errorCode)); return "redirect:/admin/"; } redirectAttributes.addFlashAttribute("errorMessage", "Couldn't connect your account. Please retry."); return "redirect:/admin/"; }).orElse("redirect:/admin/"); }
From source file:org.kmnet.com.fw.web.token.transaction.HttpSessionTransactionTokenStore.java
/** * Removes the session attribute corresponding to the transactionToken instance passed as argument to this method * @see org.kmnet.com.fw.web.token.transaction.TransactionTokenStore#remove(org.kmnet.com.fw.web.token.transaction.TransactionToken) *//*from w ww. ja v a2s . c om*/ @Override public void remove(TransactionToken token) { String key = createSessionAttributeName(token); HttpSession session = getSession(); Object mutex = getMutex(session); synchronized (mutex) { try { session.removeAttribute(key); } catch (IllegalStateException e) { logger.debug("session is already invalidated.", e); } } }
From source file:com.huateng.ebank.framework.session.SessionManager.java
/** * Remove a session object based on the request and the attribute name. *//* w w w .j a va 2 s. co m*/ public boolean removeSessionObject(HttpServletRequest req, String attrName) { if (logger.isDebugEnabled()) { logger.debug("removeSessionObject(HttpServletRequest, String) - start"); //$NON-NLS-1$ } HttpSession session = req.getSession(false); if (null == session) return false; session.removeAttribute(attrName); if (logger.isDebugEnabled()) { logger.debug("removeSessionObject(HttpServletRequest, String) - end"); //$NON-NLS-1$ } return true; }
From source file:com.ggfix.gg.user.controller.UserAuthorityController.java
@RequestMapping("/login") public String login(String account, String password, HttpSession session) { if (this.userManager.login(account, password)) { List<User> users = this.userManager.getUsersByEmail(account); if (users != null) { session.setAttribute("User", users.get(0)); session.setAttribute("UserId", users.get(0).getId()); session.setAttribute("UserName", users.get(0).getFirstName()); session.removeAttribute("errorInfo"); }/*from www. ja va 2s .c o m*/ } else { if (session.getAttribute("UserName") == null) session.setAttribute("UserName", session.getId()); session.setAttribute("errorInfo", "wrongUserOrPassword"); } return "index"; }
From source file:de.hybris.platform.acceleratorstorefrontcommons.controllers.pages.AbstractLoginPageController.java
protected String getDefaultLoginPage(final boolean loginError, final HttpSession session, final Model model) throws CMSItemNotFoundException { final LoginForm loginForm = new LoginForm(); model.addAttribute(loginForm);// ww w. jav a 2s . c o m model.addAttribute(new RegisterForm()); model.addAttribute(new GuestForm()); final String username = (String) session.getAttribute(SPRING_SECURITY_LAST_USERNAME); if (username != null) { session.removeAttribute(SPRING_SECURITY_LAST_USERNAME); } loginForm.setJ_username(username); storeCmsPageInModel(model, getCmsPage()); setUpMetaDataForContentPage(model, (ContentPageModel) getCmsPage()); model.addAttribute(ThirdPartyConstants.SeoRobots.META_ROBOTS, ThirdPartyConstants.SeoRobots.INDEX_NOFOLLOW); final Breadcrumb loginBreadcrumbEntry = new Breadcrumb("#", getMessageSource().getMessage( "header.link.login", null, "header.link.login", getI18nService().getCurrentLocale()), null); model.addAttribute("breadcrumbs", Collections.singletonList(loginBreadcrumbEntry)); if (loginError) { model.addAttribute("loginError", Boolean.valueOf(loginError)); GlobalMessages.addErrorMessage(model, "login.error.account.not.found.title"); } return getView(); }
From source file:org.training.storefront.controllers.pages.AbstractLoginPageController.java
protected String getDefaultLoginPage(final boolean loginError, final HttpSession session, final Model model) throws CMSItemNotFoundException { final LoginForm loginForm = new LoginForm(); model.addAttribute(loginForm);// w w w.ja v a 2 s . co m model.addAttribute(new RegisterForm()); model.addAttribute(new GuestForm()); final String username = (String) session.getAttribute(SPRING_SECURITY_LAST_USERNAME); if (username != null) { session.removeAttribute(SPRING_SECURITY_LAST_USERNAME); } loginForm.setJ_username(username); storeCmsPageInModel(model, getCmsPage()); setUpMetaDataForContentPage(model, (ContentPageModel) getCmsPage()); model.addAttribute("metaRobots", "index,no-follow"); final Breadcrumb loginBreadcrumbEntry = new Breadcrumb("#", getMessageSource().getMessage("header.link.login", null, getI18nService().getCurrentLocale()), null); model.addAttribute("breadcrumbs", Collections.singletonList(loginBreadcrumbEntry)); if (loginError) { model.addAttribute("loginError", Boolean.valueOf(loginError)); GlobalMessages.addErrorMessage(model, "login.error.account.not.found.title"); } return getView(); }
From source file:com.esd.ps.LoginController.java
/** * ?//from ww w . j a v a 2 s .c om * * @return */ @RequestMapping(value = "/quit", method = RequestMethod.GET) public ModelAndView quitGet(HttpSession session, HttpServletRequest request) { session.removeAttribute(Constants.USER_ID); session.removeAttribute(Constants.USER_LVL); session.removeAttribute("typeCount"); session.removeAttribute(Constants.USER_TYPE); session.removeAttribute(Constants.ADD_USER_ID); session.removeAttribute("aduiting"); session.removeAttribute("aduited"); session.removeAttribute("salary"); session.removeAttribute("uploading"); // try { // ServletContext servletContext = request.getSession().getServletContext(); // if (servletContext.getAttribute(session.getAttribute(Constants.USER_NAME).toString()) != null) { // servletContext.removeAttribute(session.getAttribute(Constants.USER_NAME).toString()); // } // } catch (NullPointerException n) { // return new ModelAndView(Constants.REDIRECT + Constants.COLON + Constants.LOGIN); // } session.removeAttribute(Constants.USER_NAME); return new ModelAndView(Constants.REDIRECT + Constants.COLON + Constants.LOGIN); }