List of usage examples for javax.servlet.http HttpSession removeAttribute
public void removeAttribute(String name);
From source file:com.jsmartframework.web.manager.BeanHandler.java
private void finalizeWebBean(Object bean, HttpSession session) { if (bean != null) { executePreDestroy(bean);/*from ww w .j a va2 s.c o m*/ finalizeInjection(bean, session); WebBean webBean = bean.getClass().getAnnotation(WebBean.class); session.removeAttribute(HELPER.getClassName(webBean, bean.getClass())); } }
From source file:com.comcast.video.dawg.controller.park.ParkController.java
@SuppressWarnings("unchecked") @RequestMapping("/{token}*") public String userFront(@PathVariable String token, @RequestParam(required = false) String tag, @RequestParam(required = false) String q, @RequestParam(required = false) Integer page, @RequestParam(required = false) Integer size, @RequestParam(required = false) Boolean asc, @RequestParam(required = false) String[] sort, Model model, HttpSession session) throws CerealException { StringBuilder builder = new StringBuilder(); builder.append("Request=").append("token=").append(token).append(",q=").append(q).append(",tag=") .append(tag).append(",page=").append(page).append(",size=").append(size).append(",asc=").append(asc) .append(",sort=").append(sort); logger.info(builder.toString());// ww w .j a v a 2 s . co m if (isValid(token)) { token = clean(token); Map<String, Object>[] stbs = null; Map<String, Object>[] allDevices = null; Pageable pageable = null; if (null != sort) { if (0 == size) { size = 100; } Direction direction = asc ? Direction.ASC : Direction.DESC; Sort sorting = new Sort(direction, sort); pageable = new PageRequest(page, size, sorting); } if (null != tag) { if (null != q) { model.addAttribute("search", q); } stbs = service.findByCriteria(new TagCondition(tag, q).toCriteria(), pageable); } else if ((null != q) && (!q.trim().isEmpty())) { String[] keys = getKeys(q); stbs = service.findByKeys(keys, pageable); model.addAttribute("search", q); } else { Condition condition = (Condition) session.getAttribute("condition"); if (condition != null) { stbs = service.findByCriteria(condition.toCriteria(), pageable); session.removeAttribute("condition"); } else { stbs = service.findAll(pageable); model.addAttribute("search", ""); allDevices = stbs; } } Map<String, Object> requestParams = new HashMap<String, Object>(); requestParams.put("tag", tag); requestParams.put("q", q); requestParams.put("page", page); requestParams.put("size", size); requestParams.put("asc", asc); requestParams.put("sort", sort); String requestParamsJson = engine.writeToString(requestParams, Map.class); model.addAttribute("requestParams", requestParamsJson); Map<String, Object> devices = new HashMap<String, Object>(); Map<String, List<String>> deviceTags = new HashMap<String, List<String>>(); Object tagData = null; boolean anyReserved = false; for (Map<String, Object> stb : stbs) { if (stb.containsKey(MetaStb.MACADDRESS)) { String id = (String) stb.get(MetaStb.ID); devices.put(id, stb); tagData = stb.get(MetaStb.TAGS); if (tagData != null && (tagData instanceof List)) { deviceTags.put(id, (List<String>) tagData); } else { deviceTags.put(id, null); } String reserver = (String) stb.get(PersistableDevice.RESERVER); if ((token != null) && token.equals(reserver)) { anyReserved = true; } } } String deviceData = engine.writeToString(devices, Map.class); /** Get all the tags from other devices */ allDevices = allDevices == null ? service.findAll() : allDevices; Collection<String> otherTags = new HashSet<String>(); for (Map<String, Object> device : allDevices) { String id = (String) device.get(MetaStb.ID); if (!deviceTags.containsKey(id)) { tagData = device.get(MetaStb.TAGS); if (tagData != null && (tagData instanceof List)) { otherTags.addAll((List<String>) tagData); } } } model.addAttribute(LATEST_SEARCH_CONDITION_MODEL_ATTRIBUTE_NAME, returnAndRemoveLatestSearchCondition(session)); model.addAttribute(SEARCH_CONDITIONS_MODEL_ATTRIBUTE_NAME, getSearchConditions(session)); model.addAttribute("token", token); model.addAttribute("deviceData", deviceData); model.addAttribute("deviceTags", engine.writeToString(deviceTags)); model.addAttribute("otherTags", engine.writeToString(new ArrayList<String>(otherTags))); model.addAttribute("data", devices.values()); model.addAttribute("dawgShowUrl", config.getDawgShowUrl()); model.addAttribute("dawgPoundUrl", config.getDawgPoundUrl()); model.addAttribute("anyReserved", anyReserved); model.addAttribute("filterFields", SearchableField.values()); model.addAttribute("operators", Operator.values()); return "index"; } else { /** User login token is invalid, so redirects to login page */ return "login"; } }
From source file:com.virtusa.akura.student.controller.StudentDetailController.java
/** * handle GET requests for New Student Details Form. * /*from w ww .j a va2 s . c o m*/ * @param model - ModelMap * @param session - HttpSession * @param request - HttpServletRequest * @return the name of the view. * @throws AkuraAppException - AkuraAppException */ @RequestMapping(REQ_MAP_NEW_STUDENT_DETAIL) public String addNewStudentDetailForm(ModelMap model, HttpSession session, HttpServletRequest request) throws AkuraAppException { Student student = (Student) model.get(MODEL_ATT_STUDENT); if (request.getParameter(EVENT_VALUE) == null && student != null && student.getStudentId() > 0) { String strMessage = new ErrorMsgLoader().getErrorMessage(MESSAGE_STUDENT_PROFILE_CREATED); model.addAttribute(MODEL_ATT_MESSAGE, strMessage); } student = new Student(); student.setIsOldBoy(Boolean.FALSE); student.setStatusId(1); session.removeAttribute(STUDENT_ID); session.removeAttribute(MODEL_ATT_STUDENT); session.removeAttribute(STUDENT_GRADE); session.removeAttribute(STUDENT_CLASS); session.removeAttribute(STUDENT_GRADE_CLASS); model.addAttribute(MODEL_ATT_STUDENT, student); model.addAttribute(MODEL_ATT_STUDENT_ID_CHECK, Boolean.TRUE); model.addAttribute(MODEL_ATT_DEFAULT_IMAGE, RESOURCES_NO_PROFILE_IMAGE); return VIEW_GET_STUDENT_DETAIL_PAGE; }
From source file:com.someco.servlets.AuthenticationFilter.java
/** * Set the authenticated user./*from w ww. j av a 2 s . c o m*/ * * It does not check that the user exists at the moment. * * @param req * @param httpSess * @param userName */ private void setAuthenticatedUser(HttpServletRequest req, HttpSession httpSess, String userName) { // Set the authentication authComponent.setCurrentUser(userName); // Set up the user information UserTransaction tx = transactionService.getUserTransaction(); NodeRef homeSpaceRef = null; User user; try { tx.begin(); user = new User(userName, authService.getCurrentTicket(), personService.getPerson(userName)); homeSpaceRef = (NodeRef) nodeService.getProperty(personService.getPerson(userName), ContentModel.PROP_HOMEFOLDER); if (homeSpaceRef == null) { logger.warn("Home Folder is null for user '" + userName + "', using company_home."); homeSpaceRef = (NodeRef) nodeService.getRootNode(Repository.getStoreRef()); } user.setHomeSpaceId(homeSpaceRef.getId()); tx.commit(); } catch (Throwable ex) { logger.error(ex); try { tx.rollback(); } catch (Exception ex2) { logger.error("Failed to rollback transaction", ex2); } if (ex instanceof RuntimeException) { throw (RuntimeException) ex; } else { throw new RuntimeException("Failed to set authenticated user", ex); } } // Store the user httpSess.setAttribute(AuthenticationHelper.AUTHENTICATION_USER, user); httpSess.setAttribute(LoginBean.LOGIN_EXTERNAL_AUTH, Boolean.TRUE); // Set the current locale from the Accept-Lanaguage header if available Locale userLocale = parseAcceptLanguageHeader(req, m_languages); if (userLocale != null) { httpSess.setAttribute(LOCALE, userLocale); httpSess.removeAttribute(MESSAGE_BUNDLE); } // Set the locale using the session I18NUtil.setLocale(Application.getLanguage(httpSess)); }
From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractAuthenticationController.java
@RequestMapping(value = "/reset_password", method = RequestMethod.POST, params = "password") public String reset(@RequestParam(value = "password", required = true) final String password, HttpSession session) { logger.debug("###Entering in reset(password,session) method @POST"); final String username = (String) session.getAttribute(RESET_USER_KEY); final int maxFailCount = config .getIntValue(Names.com_citrix_cpbm_accountManagement_security_logins_lockThreshold); User user = privilegeService.runAsPortal(new PrivilegedAction<User>() { @Override//from w ww .j a va 2 s . c o m public User run() { User user = userService.getUserByParam("username", username, false); if (!config.getBooleanValue(Configuration.Names.com_citrix_cpbm_portal_directory_service_enabled)) { user.setClearPassword(password); } else if (config.getValue(Names.com_citrix_cpbm_directory_mode).equals("push")) { userService.updateUserPassword(password, user.getUuid()); } if (!user.isEnabled() || user.getFailedLoginAttempts() >= maxFailCount) { user.setFailedLoginAttempts(0); user.setEnabled(true); } return user; } }); // Looks out of place, but useful. if (user.getFailedLoginAttempts() >= config .getIntValue(Names.com_citrix_cpbm_accountManagement_security_logins_captchaThreshold)) { session.setAttribute(CaptchaAuthenticationFilter.CAPTCHA_REQUIRED, true); } session.removeAttribute(RESET_USER_KEY); logger.debug("###Exiting in reset(password,session) method @POST"); return "redirect:/portal/login"; }
From source file:com.nec.nsgui.action.cifs.CifsSetSpecialShareAction.java
private ActionForward displayForAdd(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { int group = NSActionUtil.getCurrentNodeNo(request); HttpSession session = request.getSession(); String exportGroup = NSActionUtil.getExportGroupPath(request); String domainName = (String) session.getAttribute(CifsActionConst.SESSION_DOMAIN_NAME); String computerName = (String) session.getAttribute(CifsActionConst.SESSION_COMPUTER_NAME); ShareOptionBean shareOptionBean = new ShareOptionBean(); shareOptionBean.setConnection("yes"); String[] directMp = CifsCmdHandler.getDirectMP(group, exportGroup, "all"); String[] hasSetedRealtimeScanmp = (String[]) session.getAttribute(SESSION_SPECIALSHARE_MP); if (hasSetedRealtimeScanmp == null) { hasSetedRealtimeScanmp = new String[] {}; }//w w w .ja v a 2 s. c o m List<String> dirForDisplay = new ArrayList<String>(); List<String> dirForOptionValues = new ArrayList<String>(); boolean hasUsed = false; if (directMp != null && directMp.length > 0 && !directMp[0].equals("")) { for (int i = 0; i < directMp.length; i++) { String directMpWhitoutFs = directMp[i].replaceAll("\\s*\\(.*\\)\\s*$", ""); hasUsed = false; for (int j = 0; j < hasSetedRealtimeScanmp.length; j++) { if (directMpWhitoutFs.equals(hasSetedRealtimeScanmp[j])) { hasUsed = true; break; } } if (!hasUsed) { dirForDisplay.add(directMp[i]); dirForOptionValues.add(directMpWhitoutFs); } } } NSActionUtil.setSessionAttribute(request, SESSION_AVAILABLEDIRFORSCAN, dirForDisplay); NSActionUtil.setSessionAttribute(request, SESSION_AVAILABLEDIRFORSCAN_OPTION_VALUES, dirForOptionValues); session.removeAttribute(SESSION_SPECIALSHARE_MP); String[] realtimeUserAndServer = CifsCmdHandler.getRealtimeScanUserAndServer(group, domainName, computerName); shareOptionBean.setValidUserForRealtimeScan(realtimeUserAndServer[0]); shareOptionBean.setAllowHostForRealtimeScan(realtimeUserAndServer[1]); String[] scheduleUserAndServer = CifsCmdHandler.getScheduleScanUserAndServer(group, domainName, computerName); shareOptionBean.setValidUserForScheduleScan(scheduleUserAndServer[0]); shareOptionBean.setAllowHostForScheduleScan(scheduleUserAndServer[1]); String[] privilegeUserForBackup = CifsCmdHandler.getPrivilegeUser(group, domainName, computerName, "backup"); if (privilegeUserForBackup != null && privilegeUserForBackup.length > 0 && !privilegeUserForBackup[0].equals("")) { NSActionUtil.setSessionAttribute(request, SESSION_ALLBACKUPUSER, privilegeUserForBackup); } shareOptionBean.setSharePurpose("realtime_scan"); ((DynaValidatorForm) form).set("shareOption", shareOptionBean); return mapping.findForward("displayPage"); }
From source file:com.skilrock.lms.web.accMgmt.common.RetailerPaymentSubmit.java
public String retailerPayment() throws Exception { HttpSession session = null; session = getRequest().getSession(); session.setAttribute("Receipt_Id", null); UserInfoBean userInfo;// w w w.jav a2 s.c o m try { if (totalAmount != cashAmnt) throw new LMSException(LMSErrors.RETAILER_PAYMENT_INVALIDATE_DATA_ERROR_CODE, LMSErrors.RETAILER_CASH_PAYMENT_INVALIDATE_DATA_ERROR_MESSAGE); userInfo = (UserInfoBean) session.getAttribute("USER_INFO"); logger.info("REQUEST_RETAILER_CASH_PAYMENT_SUBMIT-" + request.getAttribute("AUDIT_ID") + ":" + userInfo.getUserId()); int agentId = userInfo.getUserId(); String agentName = userInfo.getOrgName(); int userOrgID = userInfo.getUserOrgId(); RetailerPaymentSubmitHelper retailerPaymentHelper = new RetailerPaymentSubmitHelper(); String autoGeneRecieptNoAndId = retailerPaymentHelper.retailerCashPaySubmit(orgId, "RETAILER", totalAmount, agentId, userOrgID, userInfo.getUserType()); if (!autoGeneRecieptNoAndId.contains("#")) { addActionError(autoGeneRecieptNoAndId); retailerInfoMap = CommonMethods.getOrgInfoMap(userInfo.getUserOrgId(), "RETAILER"); return ERROR; } String[] autoGeneReceipt = autoGeneRecieptNoAndId.split("#"); String autoGeneRecieptNo = autoGeneReceipt[0]; int id = Integer.parseInt(autoGeneReceipt[1]); session.setAttribute("totalPay", totalAmount); //session.setAttribute("orgName", orgName); session.setAttribute("Receipt_Id", autoGeneRecieptNo); GraphReportHelper graphReportHelper = new GraphReportHelper(); graphReportHelper.createTextReportAgent(id, (String) session.getAttribute("ROOT_PATH"), userOrgID, agentName); session.removeAttribute("CASH"); } catch (LMSException le) { logger.info("RESPONSE_RETAILER_CASH_PAYMENT_SUBMIT-: ErrorCode:" + le.getErrorCode() + " ErrorMessage:" + le.getErrorMessage()); request.setAttribute("LMS_EXCEPTION", le.getErrorMessage()); return "applicationException"; } catch (Exception e) { logger.error("Exception", e); logger.info( "RESPONSE_RETAILER_CASH_PAYMENT_SUBMIT-: ErrorCode:" + LMSErrors.GENERAL_EXCEPTION_ERROR_CODE + " ErrorMessage:" + LMSErrors.GENERAL_EXCEPTION_ERROR_MESSAGE); request.setAttribute("LMS_EXCEPTION", LMSErrors.GENERAL_EXCEPTION_ERROR_MESSAGE); return "applicationException"; } return SUCCESS; }
From source file:com.tremolosecurity.idp.providers.OpenIDConnectIdP.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String action = (String) request.getAttribute(IDP.ACTION_NAME); UrlHolder holder = (UrlHolder) request.getAttribute(ProxyConstants.AUTOIDM_CFG); if (holder == null) { throw new ServletException("Holder is null"); }/*from w w w . j av a2 s.co m*/ AuthController ac = ((AuthController) request.getSession().getAttribute(ProxyConstants.AUTH_CTL)); if (action.equalsIgnoreCase(".well-known/openid-configuration")) { Gson gson = new GsonBuilder().setPrettyPrinting().create(); String json = gson.toJson(new OpenIDConnectConfig(this.idpName, request, mapper)); response.setContentType("application/json"); response.getWriter().print(json); AccessLog.log(AccessEvent.AzSuccess, holder.getApp(), (HttpServletRequest) request, ac.getAuthInfo(), "NONE"); return; } else if (action.equalsIgnoreCase("certs")) { try { X509Certificate cert = GlobalEntries.getGlobalEntries().getConfigManager() .getCertificate(this.jwtSigningKeyName); JsonWebKey jwk = JsonWebKey.Factory.newJwk(cert.getPublicKey()); String keyID = buildKID(cert); jwk.setKeyId(keyID); jwk.setUse("sig"); jwk.setAlgorithm("RS256"); response.setContentType("application/json"); response.getWriter().print(new JsonWebKeySet(jwk).toJson()); AccessLog.log(AccessEvent.AzSuccess, holder.getApp(), (HttpServletRequest) request, ac.getAuthInfo(), "NONE"); return; } catch (JoseException e) { throw new ServletException("Could not generate jwt", e); } } else if (action.equalsIgnoreCase("auth")) { String clientID = request.getParameter("client_id"); String responseCode = request.getParameter("response_type"); String scope = request.getParameter("scope"); String redirectURI = request.getParameter("redirect_uri"); String state = request.getParameter("state"); String nonce = request.getParameter("nonce"); OpenIDConnectTransaction transaction = new OpenIDConnectTransaction(); transaction.setClientID(clientID); transaction.setResponseCode(responseCode); transaction.setNonce(nonce); StringTokenizer toker = new StringTokenizer(scope, " ", false); while (toker.hasMoreTokens()) { String token = toker.nextToken(); transaction.getScope().add(token); } transaction.setRedirectURI(redirectURI); transaction.setState(state); OpenIDConnectTrust trust = trusts.get(clientID); if (trust == null) { StringBuffer b = new StringBuffer(); b.append(redirectURI).append("?error=unauthorized_client"); logger.warn("Trust '" + clientID + "' not found"); response.sendRedirect(b.toString()); return; } if (trust.isVerifyRedirect()) { if (!trust.getRedirectURI().equals(redirectURI)) { StringBuffer b = new StringBuffer(); b.append(trust.getRedirectURI()).append("?error=unauthorized_client"); logger.warn("Invalid redirect"); AccessLog.log(AccessEvent.AzFail, holder.getApp(), (HttpServletRequest) request, ac.getAuthInfo(), "NONE"); response.sendRedirect(b.toString()); return; } transaction.setRedirectURI(trust.getRedirectURI()); } else { transaction.setRedirectURI(redirectURI); } if (transaction.getScope().size() == 0 || !transaction.getScope().get(0).equals("openid")) { StringBuffer b = new StringBuffer(); b.append(transaction.getRedirectURI()).append("?error=invalid_scope"); logger.warn("First scope not openid"); AccessLog.log(AccessEvent.AzFail, holder.getApp(), (HttpServletRequest) request, ac.getAuthInfo(), "NONE"); response.sendRedirect(b.toString()); return; } else { //we don't need the openid scope anymore transaction.getScope().remove(0); } String authChain = trust.getAuthChain(); if (authChain == null) { StringBuffer b = new StringBuffer(); b.append("IdP does not have an authenticaiton chain configured"); throw new ServletException(b.toString()); } HttpSession session = request.getSession(); AuthInfo authData = ((AuthController) session.getAttribute(ProxyConstants.AUTH_CTL)).getAuthInfo(); AuthChainType act = holder.getConfig().getAuthChains().get(authChain); session.setAttribute(OpenIDConnectIdP.TRANSACTION_DATA, transaction); if (authData == null || !authData.isAuthComplete() && !(authData.getAuthLevel() < act.getLevel())) { nextAuth(request, response, session, false, act); } else { if (authData.getAuthLevel() < act.getLevel()) { //step up authentication, clear existing auth data session.removeAttribute(ProxyConstants.AUTH_CTL); holder.getConfig().createAnonUser(session); nextAuth(request, response, session, false, act); } else { StringBuffer b = genFinalURL(request); response.sendRedirect(b.toString()); //TODO if session already exists extend the life of the id_token } } } else if (action.contentEquals("completefed")) { this.completeFederation(request, response); } else if (action.equalsIgnoreCase("userinfo")) { try { processUserInfoRequest(request, response); } catch (JoseException | InvalidJwtException e) { throw new ServletException("Could not process userinfo request", e); } } }
From source file:de.jwi.jfm.Folder.java
private String pasteClipboard(HttpSession session) throws OutOfSyncException, IOException { ClipBoardContent clipBoardContent = (ClipBoardContent) session.getAttribute("clipBoardContent"); if (clipBoardContent == null) { return "nothing in clipboard"; }/*from w w w . j a va 2s.c o m*/ for (int i = 0; i < clipBoardContent.selectedfiles.length; i++) { File f = clipBoardContent.selectedfiles[i]; File f1 = f.getParentFile(); if (myFile.getCanonicalFile().equals(f1.getCanonicalFile())) { return "same folder"; } } for (int i = 0; i < clipBoardContent.selectedfiles.length; i++) { File f = clipBoardContent.selectedfiles[i]; if (clipBoardContent.contentType == ClipBoardContent.COPY_CONTENT) { if (f.isDirectory()) { FileUtils.copyDirectoryToDirectory(f, myFile); } else { FileUtils.copyFileToDirectory(f, myFile, true); } } if (clipBoardContent.contentType == ClipBoardContent.CUT_CONTENT) { if (f.isDirectory()) { FileUtils.moveDirectoryToDirectory(f, myFile, false); } else { FileUtils.moveFileToDirectory(f, myFile, false); } } if (clipBoardContent.contentType == ClipBoardContent.CUT_CONTENT) { session.removeAttribute("clipBoardContent"); } } return ""; }