List of usage examples for javax.servlet.http HttpSession removeAttribute
public void removeAttribute(String name);
From source file:com.mnt.base.web.DigestAuthenticator.java
public static boolean authenticate(HttpServletRequest req, HttpServletResponse resp) { boolean result = false; HttpSession session = req.getSession(); if (session != null) { result = session.getAttribute(AUTHENTICATED_FLAG_KEY) != null; if (!result) { session.setMaxInactiveInterval(60); Map<String, Object> authInfoMap = CommonUtil.uncheckedMapCast(session.getAttribute(AUTH_INFO_MAP)); if (authInfoMap == null) { authInfoMap = new HashMap<String, Object>(); session.setAttribute(AUTH_INFO_MAP, authInfoMap); }/* w w w.j a v a2s. co m*/ String authentication = req.getHeader("Authorization"); if (CommonUtil.isEmpty(authentication) || !authentication.startsWith("Digest ")) { postAuthRequired(req, resp, authInfoMap); } else { result = authenticate(req.getMethod(), authentication, authInfoMap); if (result) { if (authProvider != null) { try { authProvider.authenticated(authUser.get(), true); } catch (Exception e) { log.error("error while invoke the authProvider.authenticated: " + authUser.get(), e); } } session.setAttribute(AUTHENTICATED_FLAG_KEY, true); session.removeAttribute(AUTH_INFO_MAP); authInfoMap.clear(); authInfoMap = null; session.setMaxInactiveInterval(1800); } else { authProvider.authenticated(authUser.get(), false); authInfoMap.clear(); postAuthRequired(req, resp, authInfoMap); } } } } else { System.err.println("Just support session available authentication."); } return result; }
From source file:org.motechproject.server.omod.web.controller.DemoEnrollController.java
@RequestMapping(method = RequestMethod.POST) public String submitForm(@ModelAttribute("enrollpatient") WebPatient webPatient, Errors errors, ModelMap model, SessionStatus status, HttpSession session) { log.debug("Enroll Demo Patient"); ValidationUtils.rejectIfEmpty(errors, "motechId", "motechmodule.motechId.required"); Patient patient = null;/*from w w w.j a v a 2 s . co m*/ if (webPatient.getMotechId() != null) { patient = openmrsBean.getPatientByMotechId(webPatient.getMotechId().toString()); if (patient == null) { errors.rejectValue("motechId", "motechmodule.motechId.notexist"); } } if (!Boolean.TRUE.equals(webPatient.getConsent())) { errors.rejectValue("consent", "motechmodule.consent.required"); } if (!errors.hasErrors()) { registrarBean.demoEnrollPatient(patient); model.addAttribute("successMsg", "motechmodule.Demo.Patient.enroll.success"); status.setComplete(); session.removeAttribute("demoLastMotechId"); return "redirect:/module/motechmodule/demo-success.htm"; } return "/module/motechmodule/demo-enrollpatient"; }
From source file:cn.vlabs.umt.ui.servlet.login.LocalLogin.java
protected boolean checkValidateCode(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); //??//from w w w .ja v a 2s . com String requireValid = (String) session.getAttribute(LocalLogin.REQUIRED_VALID); if (requireValid != null) { String savedCode = (String) session.getAttribute(Attributes.VALID_CODE); String validCode = request.getParameter("ValidCode"); if (!StringUtils.equals(savedCode, validCode)) { request.setAttribute("WrongValidCode", "true"); request.setAttribute("showValidCode", "true"); if (!CommonUtils.isNull(validCode)) { request.setAttribute("lastErrorValidCode", "error"); } else { request.setAttribute("lastErrorValidCode", "required"); } request.setAttribute("username", request.getParameter("username")); doForward("/login.jsp", request, response); session.removeAttribute(Attributes.VALID_CODE); return false; } } return true; }
From source file:com.jsmartframework.web.manager.FilterControl.java
private void addAjaxHeaders(HttpServletRequest httpRequest, HttpServletResponseWrapper response) { // Case redirect via ajax, place tag with path to be handled by java script String ajaxPath = (String) httpRequest.getAttribute(REQUEST_REDIRECT_PATH_AJAX_ATTR); if (ajaxPath != null) { Boolean newWindow = (Boolean) httpRequest.getAttribute(REQUEST_REDIRECT_WINDOW_PATH_AJAX_ATTR); if (Boolean.TRUE.equals(newWindow)) { response.addHeader("New-Window-Ajax", ajaxPath); } else {/*from w w w . j a v a 2s .c o m*/ response.addHeader("Redirect-Ajax", ajaxPath); } } // Case session reset, place tag to force java script reset the page HttpSession session = httpRequest.getSession(); synchronized (session) { if (session.getAttribute(SESSION_RESET_ATTR) != null) { if (ajaxPath == null && WebContext.isAjaxRequest()) { response.addHeader("Reset-Ajax", "Session"); } session.removeAttribute(SESSION_RESET_ATTR); } } }
From source file:jp.terasoluna.fw.web.struts.actions.ActionEx.java
/** * ZbV?AGlobals.ERROR_KEYL?[// w w w . ja v a 2s . co m * ActionMessages?A?xi[?s?B * * @param session ZbV * @param errors G?[?bZ?[W? */ protected void addErrors(HttpSession session, ActionMessages errors) { if (session == null) { return; } if (errors == null) { return; } // ZbVG?[?bZ?[W??A?V??? ActionMessages sessionErrors = (ActionMessages) session.getAttribute(Globals.ERROR_KEY); if (sessionErrors == null) { sessionErrors = new ActionMessages(); } // ?G?[ sessionErrors.add(errors); // ?AG?[?bZ?[W????AZbVSG?[?bZ?[W??? if (sessionErrors.isEmpty()) { session.removeAttribute(Globals.ERROR_KEY); return; } // ZbVG?[?bZ?[W session.setAttribute(Globals.ERROR_KEY, sessionErrors); }
From source file:com.idega.block.form.presentation.FormViewer.java
protected void shutdown(WebAdapter webAdapter, HttpSession session, String key) { // attempt to shutdown processor if (webAdapter != null) { try {/* ww w. jav a2 s . co m*/ webAdapter.shutdown(); } catch (XFormsException xfe) { xfe.printStackTrace(); } } // remove xformssession from httpsession if (key != null) { session.removeAttribute(key); } setSessionKey(null); // redirect to error page (after encoding session id if required) // response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/" // + request.getSession().getServletContext().getInitParameter("error.page"))); }
From source file:jp.terasoluna.fw.web.struts.actions.ActionEx.java
/** * ZbV?AGlobals.MESSAGE_KEYL?[//from ww w . j a va 2 s.com * ActionMessages?A?xi[?s?B * * @param session ZbV * @param messages ?bZ?[W? */ protected void addMessages(HttpSession session, ActionMessages messages) { if (session == null) { return; } if (messages == null) { return; } // ZbV?bZ?[W??A?V??? ActionMessages sessionMessages = (ActionMessages) session.getAttribute(Globals.MESSAGE_KEY); if (sessionMessages == null) { sessionMessages = new ActionMessages(); } // ??bZ?[W sessionMessages.add(messages); // ?A?bZ?[W????AZbVS?bZ?[W??? if (sessionMessages.isEmpty()) { session.removeAttribute(Globals.MESSAGE_KEY); return; } // ZbV?bZ?[W session.setAttribute(Globals.MESSAGE_KEY, sessionMessages); }
From source file:com.virtusa.akura.student.controller.RejoinSuspendedStudentController.java
/** * Initializes the reference data that is to be previewed on the UI. * /* w w w .j a v a 2 s . co m*/ * @param request - an object of HttpServletRequest * @param student - an instance of Student * @param model - a HashMap that contains information of the suspended student 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_STUDENT_SUSPEND_DETAILS_HTM) public final String viewSuspendedStudentDetails(final ModelMap model, final HttpSession session, final HttpServletRequest request, @ModelAttribute(STUDENT) final Student student) throws AkuraAppException { String studentId = request.getParameter(SELECTED_STUDENT_ID); String studentIdAttribute = (String) session.getAttribute(SELECTED_STUDENT_ID); String message = request.getParameter(MESSAGE); if (studentId == null && studentIdAttribute != null) { studentId = studentIdAttribute; session.removeAttribute(SELECTED_STUDENT_ID); if (message != null) { model.addAttribute(MESSAGE, message); request.removeAttribute(MESSAGE); } } setSuspendedStudentList(model, studentId); SuspendStudent suspendStudent = new SuspendStudent(); model.addAttribute(SUSPEND_STUDENT, suspendStudent); return VIEW_GET_SUSPENDED_STUDENT_REJOIN; }
From source file:fr.paris.lutece.plugins.workflow.modules.fillingdirectory.web.FillingDirectoryTaskComponent.java
/** * {@inheritDoc}//w w w . j av a2 s . c o m */ @Override public String getDisplayTaskForm(int nIdResource, String strResourceType, HttpServletRequest request, Locale locale, ITask task) { Map<String, Object> model = new HashMap<String, Object>(); Plugin pluginDirectory = PluginService.getPlugin(DirectoryPlugin.PLUGIN_NAME); if (strResourceType.equals(Record.WORKFLOW_RESOURCE_TYPE)) { Plugin plugin = PluginService.getPlugin(FillingDirectoryPlugin.PLUGIN_NAME); TaskFillingDirectoryConfig config = _taskFillingDirectoryConfigService.findByPrimaryKey(task.getId()); Record record = RecordHome.findByPrimaryKey(nIdResource, pluginDirectory); IEntry entry = null; if ((config != null) && !(config.isUsedTaskEntry() || config.isUsedUser())) { EntryFilter entryFilter = new EntryFilter(); entryFilter.setPosition(config.getPositionEntryDirectory()); entryFilter.setIdDirectory(record.getDirectory().getIdDirectory()); List<IEntry> entryList = EntryHome.getEntryList(entryFilter, pluginDirectory); if ((entryList != null) && !entryList.isEmpty()) { entry = EntryHome.findByPrimaryKey(entryList.get(0).getIdEntry(), pluginDirectory); /** * Map of <idEntry, RecordFields> * 1) The user has uploaded/deleted a file * - The updated map is stored in the session * 2) The user has not uploaded/delete a file * - The map is filled with the data from the database * - The asynchronous uploaded files map is reinitialized */ Map<String, List<RecordField>> mapRecordFields = null; /** 1) Case when the user has uploaded a file, the the map is stored in the session */ HttpSession session = request.getSession(); String strUploadAction = DirectoryAsynchronousUploadHandler.getHandler() .getUploadAction(request); if (StringUtils.isBlank(strUploadAction)) { // IMPORTANT : Remove the map from the session if the button upload is not pushed session.removeAttribute(DirectoryUtils.SESSION_DIRECTORY_TASKS_SUBMITTED_RECORD_FIELDS); } else { mapRecordFields = (Map<String, List<RecordField>>) session .getAttribute(DirectoryUtils.SESSION_DIRECTORY_TASKS_SUBMITTED_RECORD_FIELDS); } /** 2) The user has not uploaded/delete a file */ if (mapRecordFields == null) { mapRecordFields = new HashMap<String, List<RecordField>>(); // Reinit the asynchronous uploaded files map DirectoryAsynchronousUploadHandler.getHandler().reinitMap(request, mapRecordFields, plugin); } model.put(MARK_MAP_ID_ENTRY_LIST_RECORD_FIELD, mapRecordFields); model.put(MARK_ENTRY_DIRECTORY, entry); model.put(MARK_LOCALE, locale); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_TASK_FILLING_DIRECTORY_FORM, locale, model); return template.getHtml(); } } } return DirectoryUtils.EMPTY_STRING; }
From source file:org.traccar.web.server.model.DataServiceImpl.java
private void setSessionUser(User user) { HttpSession session = getThreadLocalRequest().getSession(); if (user != null) { session.setAttribute(ATTRIBUTE_USER, user); } else {//from w w w .j a v a 2 s . co m session.removeAttribute(ATTRIBUTE_USER); } }