List of usage examples for javax.servlet.http HttpSession removeAttribute
public void removeAttribute(String name);
From source file:cn.vlabs.umt.ui.servlet.AuthorizationCodeServlet.java
private void cleanSession(HttpServletRequest request) { HttpSession session = request.getSession(); session.removeAttribute("coremailSecureLogon"); }
From source file:com.att.api.immn.controller.DeleteSubscriptionController.java
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final HttpSession session = request.getSession(); JSONObject jresponse = new JSONObject(); try {//from w w w. jav a 2 s .com if (session.getAttribute("subscriptionId") == null) { throw new RESTException("You must first create a subscription."); } final OAuthToken token = this.getFileToken("notificationScope"); final String channelId = appConfig.getProperty("channelId"); final String subscriptionId = (String) session.getAttribute("subscriptionId"); final String fqdn = appConfig.getApiFQDN(); final WebhooksService srvc = new WebhooksService(fqdn, token); srvc.deleteNotificationSubscription(channelId, subscriptionId); session.removeAttribute("subscriptionId"); jresponse.put("success", true).put("text", "Subscription deleted."); } catch (RESTException re) { jresponse.put("success", false).put("text", re.getMessage()); } response.setContentType("text/html"); PrintWriter writer = response.getWriter(); writer.print(jresponse); writer.flush(); }
From source file:org.terasoluna.gfw.web.token.transaction.HttpSessionTransactionTokenStore.java
/** * removes old token name from session/*w w w. ja va 2 s . co m*/ * @param sessionAttributeNames set of token names * @param session HttpSession */ private void removeOldTokenName(Set<String> sessionAttributeNames, HttpSession session) { String oldestTokenName = null; TokenHolder oldestTokenHolder = new TokenHolder(null, Long.MAX_VALUE); for (String name : sessionAttributeNames) { TokenHolder tokenHolder = (TokenHolder) session.getAttribute(name); if (tokenHolder.getTimestamp() < oldestTokenHolder.getTimestamp()) { oldestTokenName = name; oldestTokenHolder = tokenHolder; } } session.removeAttribute(oldestTokenName); sessionAttributeNames.remove(oldestTokenName); }
From source file:com.manydesigns.portofino.actions.user.LoginAction.java
protected boolean validateCaptcha() { HttpServletRequest request = context.getRequest(); HttpSession session = request.getSession(); boolean valid = StringUtils.equalsIgnoreCase(request.getParameter("captchaText"), (String) session.getAttribute(CAPTCHA_SESSION_ATTRIBUTE)); session.removeAttribute(CAPTCHA_SESSION_ATTRIBUTE); captchaValidationFailed = !valid;/* www . j a va 2 s .co m*/ return valid; }
From source file:com.virtusa.akura.staff.controller.StaffPastServiceController.java
/** * Initializes the reference data that is to be previewed on the UI. * //from w ww . j a v a2 s. co m * @param request - an object of HttpServletRequest * @param staff - an instance of Staff * @param model - a HashMap that contains information of the Past staff service. * @param session - a session to pass values. * @return - name of the view which is redirected to * @throws AkuraAppException - The exception details that occurred when processing. */ @RequestMapping(value = ADMIN_MANAGE_VIEW_PAST_STAFF_SERVICE_HTM) public final String viewPastStaffService(final ModelMap model, final HttpSession session, final HttpServletRequest request, @ModelAttribute(STAFF) final Staff staff) throws AkuraAppException { String staffId = request.getParameter(SELECTED_STAFF_ID); String staffIdAttribute = (String) session.getAttribute(SELECTED_STAFF_ID); String message = request.getParameter(MESSAGE); if (staffId == null && staffIdAttribute != null) { staffId = staffIdAttribute; session.removeAttribute(SELECTED_STAFF_ID); if (message != null) { model.addAttribute(MESSAGE, message); request.removeAttribute(MESSAGE); } } setStaffPastServiceList(model, staffId); StaffPastService staffPastService = new StaffPastService(); model.addAttribute(STAFF_PAST_SERVICE, staffPastService); return VIEW_GET_PAST_STAFF_SERVICE; }
From source file:de.jwi.jfm.Folder.java
private String clearClipboard(HttpSession session) throws OutOfSyncException, IOException { session.removeAttribute("clipBoardContent"); return ""; }
From source file:de.berlios.jhelpdesk.web.ticket.TicketsViewController.java
@RequestMapping("/tickets/byFilter/{filterId}/list.html") public String processRequest(@PathVariable("filterId") Long filterId, @ModelAttribute("filter") TicketFilter filter, @RequestParam(value = "_formSent", defaultValue = "false", required = false) boolean formSent, @RequestParam(value = "cf", defaultValue = "false", required = false) boolean cf, ModelMap map, HttpServletRequest request, HttpSession session) throws Exception { User currentUser = (User) session.getAttribute("user"); Integer listSize = currentUser.getPreferedTicketsListSize(); TicketFilter currentFilter = null;/*from w w w . j a v a 2 s .c om*/ if (formSent) { // nowy filtr currentFilter = filter; session.setAttribute("currentFilter", currentFilter); map.addAttribute("requestURI", "?cf=true"); } else if (cf) { // filtr z sesji stronicowany currentFilter = (TicketFilter) session.getAttribute("currentFilter"); map.addAttribute("requestURI", "?cf=true"); } else { // po prostu danie GET session.removeAttribute("currentFilter"); TicketFilter dbFilter = ticketFilterDAO.getById(filterId); if (dbFilter != null && dbFilter.isOwnedBy(currentUser)) { currentFilter = dbFilter; } } if (currentFilter != null) { PagingParamsEncoder enc = new PagingParamsEncoder("ticketsIterator", "p_id", request, listSize); int offset = enc.getOffset(); List<Ticket> result = ticketDAO.getTicketsWithFilter(currentFilter, listSize, offset); Integer numOfTicketsWithFilter = ticketDAO.countTicketsWithFilter(currentFilter).intValue(); map.addAttribute("offset", offset); map.addAttribute("listSize", listSize); map.addAttribute("tickets", result); map.addAttribute("filter", currentFilter); map.addAttribute("ticketsListSize", numOfTicketsWithFilter); } else { map.addAttribute("message", "nie znaleziono filtra..."); } return TICKETS_LIST_VIEW; }
From source file:com.zte.gu.webtools.web.download.DownloadController.java
@RequestMapping(method = RequestMethod.GET) public void download(HttpSession session, HttpServletResponse response) { String filePath = (String) session.getAttribute("filePath"); String fileName = (String) session.getAttribute("fileName"); if (filePath != null) { response.reset();/*w w w. ja v a 2 s . com*/ response.setHeader("Content-Disposition", "attachment; filename=" + fileName); response.setContentType("application/octet-stream; charset=UTF-8"); InputStream in = null; try { in = new FileInputStream(filePath); IOUtils.copy(in, response.getOutputStream()); } catch (Exception e) { LoggerFactory.getLogger(DownloadController.class).warn("download error,", e); } finally { IOUtils.closeQuietly(in); session.removeAttribute("filePath"); session.removeAttribute("fileName"); } } }
From source file:de.ingrid.portal.portlets.myportal.MyPortalLoginPortlet.java
/** * @see org.apache.portals.bridges.velocity.GenericVelocityPortlet#processAction(javax.portlet.ActionRequest, * javax.portlet.ActionResponse)// ww w.j a va 2 s. c o m */ public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { LoginForm frm = (LoginForm) Utils.getActionForm(request, LoginForm.SESSION_KEY, LoginForm.class); frm.clearErrors(); String cmd = request.getParameter("cmd"); boolean isLoggedInExternally = request.getAttribute(Settings.USER_AUTH_INFO) != null; if (cmd != null && cmd.equals("doLogin")) { HttpSession session = ((RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV)) .getRequest().getSession(true); frm.populate(request); if (!frm.validate()) { return; } if (frm.getInput(LoginConstants.DESTINATION) != null) session.setAttribute(LoginConstants.DESTINATION, frm.getInput(LoginConstants.DESTINATION)); else session.removeAttribute(LoginConstants.DESTINATION); if (frm.getInput(LoginConstants.USERNAME) != null) session.setAttribute(LoginConstants.USERNAME, frm.getInput(LoginConstants.USERNAME)); else session.removeAttribute(LoginConstants.USERNAME); if (frm.getInput(LoginConstants.PASSWORD) != null) session.setAttribute(LoginConstants.PASSWORD, frm.getInput(LoginConstants.PASSWORD)); else session.removeAttribute(LoginConstants.PASSWORD); // signalize that the user is about to log in // see MyPortalOverviewPortlet::doView() session.setAttribute(Settings.SESSION_LOGIN_STARTED, "1"); response.sendRedirect( response.encodeURL(((RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV)) .getRequest().getContextPath() + "/login/redirector")); } else if (cmd != null && cmd.equals("doCreateProfile") && isLoggedInExternally) { PortalAdministration admin = (PortalAdministration) getPortletContext() .getAttribute(CommonPortletServices.CPS_PORTAL_ADMINISTRATION); List<String> roles = getInitialParameterFromOtherPortlet("roles"); List<String> groups = getInitialParameterFromOtherPortlet("groups"); List<String> rulesNames = getInitialParameterFromOtherPortlet("rulesNames"); List<String> rulesValues = getInitialParameterFromOtherPortlet("rulesValues"); Map<String, String> rules = new HashMap<String, String>(); for (int ix = 0; ix < ((rulesNames.size() < rulesValues.size()) ? rulesNames.size() : rulesValues.size()); ix++) { rules.put(rulesNames.get(ix), rulesValues.get(ix)); } Map<String, String> userAttributes = getUserAttributes(request); String username = (String) request.getAttribute(Settings.USER_AUTH_INFO); String password = RandomStringUtils.randomAlphanumeric(8); Boolean isAdminPortalUser = (Boolean) request.getAttribute(Settings.USER_AUTH_INFO_IS_ADMIN); // generate login id String confirmId = Utils .getMD5Hash(username.concat(password).concat(Long.toString(System.currentTimeMillis()))); userAttributes.put("user.custom.ingrid.user.confirmid", confirmId); // add admin-portal role if (isAdminPortalUser) { roles.add("user"); roles.add(IngridRole.ROLE_ADMIN_PORTAL); } try { log.debug("username: " + username + ", roles: " + roles + ", groups: " + groups + ", userAttr: " + userAttributes + ", rules: " + rules); admin.registerUser(username, password, roles, groups, userAttributes, rules, null); //UserManager userManager = (UserManager) getPortletContext().getAttribute(CommonPortletServices.CPS_USER_MANAGER_COMPONENT); //userManager.setPasswordEnabled(username, false); if (isAdminPortalUser) { addAdminSystemRole(username); } } catch (RegistrationException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } } else { Integer errorCode = (Integer) ((RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV)) .getSessionAttribute(LoginConstants.ERRORCODE); if (errorCode != null) { response.setRenderParameter("errorCode", errorCode.toString()); } else if (request.getUserPrincipal() == null) { response.setRenderParameter("errorCode", "login.error.principal.null"); } else { frm.clearErrors(); } } }
From source file:com.hihsoft.baseclass.web.controller.BaseController.java
/** * Session//from w w w . j a v a 2 s .com * @param request * @author Xiaojf * @since 2011-8-31 */ @SuppressWarnings("unchecked") public void clearSession(HttpServletRequest request) { HttpSession session = request.getSession(); Enumeration<String> attributeNames = session.getAttributeNames(); while (attributeNames.hasMoreElements()) { session.removeAttribute(attributeNames.nextElement()); } }