List of usage examples for javax.servlet.http HttpSession setAttribute
public void setAttribute(String name, Object value);
From source file:org.wso2.carbon.ml.rest.api.LoginLogoutApiV10.java
/** * Login// w w w. ja v a2s. co m */ @POST @Path("/login") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public Response login() { //create session if not found HttpSession httpSession = httpServletRequest.getSession(); PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); String username = carbonContext.getUsername(); httpSession.setAttribute("userName", username); String tenantDomain = carbonContext.getTenantDomain(); httpSession.setAttribute("tenantDomain", tenantDomain); int tenantId = carbonContext.getTenantId(); httpSession.setAttribute("tenantId", tenantId); auditLog.info( String.format( "User [name] %s of tenant [id] %s [domain] %s is logged-in into WSO2 Machine Learner. " + "Granted session id is %s", username, tenantId, tenantDomain, httpSession.getId())); return Response.status(Response.Status.OK).entity("User logged in: " + username).build(); }
From source file:org.jasig.portal.security.provider.SamlAssertionFilter.java
public void doHttpFilter(HttpServletRequest req, HttpServletResponse res, FilterChain chain) throws IOException, ServletException { if (logger.isDebugEnabled()) { logger.debug("HTTP headers: [" + headersAsString(req) + "]"); }/*w w w . jav a2 s. c o m*/ final int assertionCount = this.getAssertionCount(req); String idp = null, assertion = null, signingKeys = null; if (assertionCount > 0) { idp = req.getHeader("Shib-Identity-Provider"); final String firstAssertionHeader = req.getHeader("Shib-Assertion-01"); if (idpPublicKeysSessionAttributeName != null) { signingKeys = req.getHeader("Meta-Signing-Keys"); } if (StringUtils.isNotEmpty(firstAssertionHeader)) { if (logger.isInfoEnabled()) { logger.info("Retrieving SAML assertion from the URL: " + firstAssertionHeader); } final HttpMethod method = new GetMethod(firstAssertionHeader); try { int result = this.httpClient.executeMethod(method); if (result >= HttpStatus.SC_OK && result < 300) { assertion = method.getResponseBodyAsString(); } else { logger.error("Unsupported HTTP result code when retrieving the SAML assertion: " + result); } } catch (Exception ex) { // There is nothing that can be done about this exception other than to log it // Exception must be caught and not rethrown to allow normal processing to continue logger.error("Exception caught when trying to retrieve SAML assertion.", ex); } finally { method.releaseConnection(); } } else { logger.error("SAML assertion URL not present, but the assertion count was " + assertionCount + "."); } } else { logger.warn("SAML assertion count not present or zero"); } // Start with processing the login. This way if the login process creates a new session, // the assertion will remain in the session to be picked up by SamlAssertionUserInfoService try { chain.doFilter(req, res); } finally { HttpSession session = req.getSession(); if (assertion != null) { session.setAttribute(samlAssertionSessionAttributeName, assertion); } if (idp != null) { session.setAttribute("IdP", idp); } if (signingKeys != null) { session.setAttribute(idpPublicKeysSessionAttributeName, signingKeys); } } }
From source file:org.openmrs.module.clinicalsummary.web.controller.evaluator.EvaluateCohortController.java
@RequestMapping(method = RequestMethod.POST) public String processForm( final @RequestParam(required = false, value = "patientIdentifiers") String patientIdentifiers, final @RequestParam(required = false, value = "locationId") String locationId, final @RequestParam(required = false, value = "obsStartDate") Date startDate, final @RequestParam(required = false, value = "obsEndDate") Date endDate, final HttpSession session) { int maxInactiveInterval = session.getMaxInactiveInterval(); session.setMaxInactiveInterval(-1);//from w ww . ja v a2s . c o m if (StringUtils.isBlank(locationId) && StringUtils.isBlank(patientIdentifiers)) { session.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "clinicalsummary.invalid.parameters"); } else { Cohort cohort = new Cohort(); if (StringUtils.isNotBlank(patientIdentifiers)) { String[] patientIdentifier = StringUtils.split(patientIdentifiers); cohort = Context.getPatientSetService().convertPatientIdentifier(Arrays.asList(patientIdentifier)); } else if (StringUtils.isNotBlank(locationId)) { Location location = Context.getLocationService().getLocation(NumberUtils.toInt(locationId, -1)); cohort = Context.getService(CoreService.class).getDateCreatedCohort(location, startDate, endDate); } SummaryCohortEvaluatorInstance instance = SummaryCohortEvaluatorInstance.getInstance(); instance.evaluate(cohort); } session.setMaxInactiveInterval(maxInactiveInterval); return "redirect:evaluateCohort.form"; }
From source file:wqm.web.server.controller.BaseWQMController.java
protected Station lockStation(HttpSession session, String stationAddress) throws IOException { Station _station = validateStation(session, stationAddress); if (!stationManager.lockStation(session, stationAddress)) { session.setAttribute(Messages.ERROR_MESSAGE, String.format("%s is currently being calibrated by somebody else.", _station.getDisplayName())); throw new RedirectException("."); }// w w w.j ava 2 s.co m return _station; }
From source file:net.anthonychaves.bookmarks.web.OpenIdController.java
@RequestMapping(method = RequestMethod.GET) public String discoverProvider(HttpSession session) throws Exception { List discoveries = manager.discover(discoveryTarget); DiscoveryInformation discovered = manager.associate(discoveries); session.setAttribute("discovered", discovered); AuthRequest authRequest = manager.authenticate(discovered, returnUrl); FetchRequest fetch = FetchRequest.createFetchRequest(); fetch.addAttribute("email", "http://axschema.org/contact/email", true); fetch.addAttribute("firstName", "http://axschema.org/namePerson/first", true); fetch.addAttribute("lastName", "http://axschema.org/namePerson/last", true); authRequest.addExtension(fetch);// w w w .ja v a 2 s .c om return "redirect:" + authRequest.getDestinationUrl(true); }
From source file:com.nec.nsgui.action.cifs.CifsSetShareAction.java
private void setSuccess(boolean isSetGlobalOption, HttpServletRequest request) { if (isSetGlobalOption) { HttpSession session = request.getSession(); session.setAttribute(SESSION_IS_SET_GLOBAL_DIRACCESS, "true"); } else {//from w w w .j av a 2s .co m NSActionUtil.setSuccess(request); } }
From source file:com.shared.rides.service.SignupUserService.java
public String uploadPicFile(MultipartFile file, HttpServletRequest request) { Random ran = new Random(); String fileName = ran.nextInt(999) + "_" + file.getOriginalFilename(); //Seteo el nuevo nombre de la imagen en la sesion para luego obtenerlo de nuevo a la hora de darle de alta al usuario HttpSession s = request.getSession(); s.setAttribute("picName", fileName); String pathFile = context.getInitParameter("img-upload"); return UploadFile.uploadFile(file, fileName, pathFile); }
From source file:com.skilrock.lms.web.scratchService.orderMgmt.common.RequestDetailAction.java
/** * //from w w w . j a v a 2 s . c o m * This method is used to get the details of the request by the BO Admin * * @return SUCCESS or ERROR throws LMSException */ @Override public String execute() throws Exception { List<OrderRequestBean> list = new ArrayList<OrderRequestBean>(); HttpSession session = getRequest().getSession(); session.setAttribute("SEARCH_RESULTS", null); session.setAttribute("SEARCH_AGENT", null); session.setAttribute("OrgId", null); RequestDetailHelper requestDetailHelper = new RequestDetailHelper(); // Order Id is coming from user end. session.setAttribute("OrgId", orderId); List searchResults = requestDetailHelper.searchResult(orderId); // Agent who have created the Order. List searchAgent = requestDetailHelper.searchAgent(orderId, name); if (searchAgent != null && searchAgent.size() > 0) { session.setAttribute("SEARCH_AGENT", searchAgent); // flag variable which is used for display the search result. setOrdersearchResultsAvailable("Yes"); } else { setOrdersearchResultsAvailable("No"); } if (searchResults != null && searchResults.size() > 0) { session.setAttribute("SEARCH_RESULTS", searchResults); setOrdersearchResultsAvailable("Yes"); } else { setOrdersearchResultsAvailable("No"); } return SUCCESS; }
From source file:com.skilrock.lms.web.scratchService.orderMgmt.common.RequestDetailAction.java
public String executeAgent() throws Exception { System.out.println("55555555555555555555555555555555555555555555555555555555555555555555"); // List<OrderRequestBean> list=new ArrayList<OrderRequestBean>(); HttpSession session = getRequest().getSession(); session.setAttribute("SEARCH_RESULTS", null); session.setAttribute("SEARCH_AGENT", null); session.setAttribute("OrgId", null); RequestDetailHelper requestDetailHelper = new RequestDetailHelper(); // Order Id is coming from user end. session.setAttribute("OrgId", orderId); UserInfoBean userBean = (UserInfoBean) session.getAttribute("USER_INFO"); List searchResults = requestDetailHelper.searchResultRetailer(orderId, userBean.getUserOrgId()); // Retailer who have created the Order. List searchAgent = requestDetailHelper.searchRetailer(orderId, name); if (searchAgent != null && searchAgent.size() > 0) { session.setAttribute("SEARCH_AGENT", searchAgent); // flag variable which is used for display the search result. setOrdersearchResultsAvailable("Yes"); } else {/* w w w .j a va 2s. c om*/ setOrdersearchResultsAvailable("No"); } if (searchResults != null && searchResults.size() > 0) { session.setAttribute("SEARCH_RESULTS", searchResults); setOrdersearchResultsAvailable("Yes"); } else { setOrdersearchResultsAvailable("No"); } return SUCCESS; }
From source file:org.appverse.web.framework.backend.test.util.frontfacade.mvc.tests.predefined.TestCsrfTokenRepository.java
@Override public void saveToken(CsrfToken token, HttpServletRequest request, HttpServletResponse response) { if (token == null) { HttpSession session = request.getSession(false); if (session != null) { session.removeAttribute(sessionAttributeName); }/*from w w w.jav a 2 s . co m*/ } else { HttpSession session = request.getSession(); session.setAttribute(sessionAttributeName, token); } }