List of usage examples for javax.servlet.http HttpSession getId
public String getId();
From source file:edu.harvard.i2b2.fhir.server.ws.I2b2FhirWS.java
public Response generateFatalResponse(Exception e, HttpServletRequest request) { HttpSession session = request.getSession(); return Response .ok(FhirHelper.generateOperationOutcome(e.getMessage(), IssueTypeList.EXCEPTION, IssueSeverityList.FATAL)) .header("xreason", e.getMessage()).header("session_id", session.getId()).build(); }
From source file:net.lightbody.bmp.proxy.jetty.jetty.servlet.AbstractSessionManager.java
public Cookie getSessionCookie(HttpSession session, boolean requestIsSecure) { if (_handler.isUsingCookies()) { Cookie cookie = _handler.getSessionManager().getHttpOnly() ? new HttpOnlyCookie(SessionManager.__SessionCookie, session.getId()) : new Cookie(SessionManager.__SessionCookie, session.getId()); String domain = _handler.getServletContext().getInitParameter(SessionManager.__SessionDomain); String maxAge = _handler.getServletContext().getInitParameter(SessionManager.__MaxAge); String path = _handler.getServletContext().getInitParameter(SessionManager.__SessionPath); if (path == null) path = getCrossContextSessionIDs() ? "/" : _handler.getHttpContext().getContextPath(); if (path == null || path.length() == 0) path = "/"; if (domain != null) cookie.setDomain(domain);// w w w . j av a 2 s .c om if (maxAge != null) cookie.setMaxAge(Integer.parseInt(maxAge)); else cookie.setMaxAge(-1); cookie.setSecure(requestIsSecure && getSecureCookies()); cookie.setPath(path); return cookie; } return null; }
From source file:org.apache.struts.webapp.example2.SaveRegistrationAction.java
/** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). * Return an <code>ActionForward</code> instance describing where and how * control should be forwarded, or <code>null</code> if the response has * already been completed./*from w w w .j a v a 2 s . co m*/ * * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * * @exception Exception if the application business logic throws * an exception */ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Extract attributes and parameters we will need Locale locale = getLocale(request); MessageResources messages = getResources(request); HttpSession session = request.getSession(); RegistrationForm regform = (RegistrationForm) form; String action = regform.getAction(); if (action == null) { action = "Create"; } UserDatabase database = (UserDatabase) servlet.getServletContext().getAttribute(Constants.DATABASE_KEY); if (log.isDebugEnabled()) { log.debug("SaveRegistrationAction: Processing " + action + " action"); } // Is there a currently logged on user (unless creating)? User user = (User) session.getAttribute(Constants.USER_KEY); if (!"Create".equals(action) && (user == null)) { if (log.isTraceEnabled()) { log.trace(" User is not logged on in session " + session.getId()); } return (mapping.findForward("logon")); } // Was this transaction cancelled? if (isCancelled(request)) { if (log.isTraceEnabled()) { log.trace(" Transaction '" + action + "' was cancelled"); } session.removeAttribute(Constants.SUBSCRIPTION_KEY); return (mapping.findForward("failure")); } // Validate the transactional control token ActionErrors errors = new ActionErrors(); if (log.isTraceEnabled()) { log.trace(" Checking transactional control token"); } if (!isTokenValid(request)) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.transaction.token")); } resetToken(request); // Validate the request parameters specified by the user if (log.isTraceEnabled()) { log.trace(" Performing extra validations"); } String value = null; value = regform.getUsername(); if (("Create".equals(action)) && (database.findUser(value) != null)) { errors.add("username", new ActionError("error.username.unique", regform.getUsername())); } if ("Create".equals(action)) { value = regform.getPassword(); if ((value == null) || (value.length() < 1)) { errors.add("password", new ActionError("error.password.required")); } value = regform.getPassword2(); if ((value == null) || (value.length() < 1)) { errors.add("password2", new ActionError("error.password2.required")); } } // Report any errors we have discovered back to the original form if (!errors.isEmpty()) { saveErrors(request, errors); saveToken(request); return (mapping.getInputForward()); } // Update the user's persistent profile information try { if ("Create".equals(action)) { user = database.createUser(regform.getUsername()); } String oldPassword = user.getPassword(); PropertyUtils.copyProperties(user, regform); if ((regform.getPassword() == null) || (regform.getPassword().length() < 1)) { user.setPassword(oldPassword); } } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t == null) { t = e; } log.error("Registration.populate", t); throw new ServletException("Registration.populate", t); } catch (Throwable t) { log.error("Registration.populate", t); throw new ServletException("Subscription.populate", t); } try { database.save(); } catch (Exception e) { log.error("Database save", e); } // Log the user in if appropriate if ("Create".equals(action)) { session.setAttribute(Constants.USER_KEY, user); if (log.isTraceEnabled()) { log.trace(" User '" + user.getUsername() + "' logged on in session " + session.getId()); } } // Remove the obsolete form bean if (mapping.getAttribute() != null) { if ("request".equals(mapping.getScope())) request.removeAttribute(mapping.getAttribute()); else session.removeAttribute(mapping.getAttribute()); } // Forward control to the specified success URI if (log.isTraceEnabled()) { log.trace(" Forwarding to success page"); } return (mapping.findForward("success")); }
From source file:org.springframework.test.web.servlet.htmlunit.HtmlUnitRequestBuilderTests.java
@Test public void buildRequestSessionInvalidate() throws Exception { String sessionId = "session-id"; webRequest.setAdditionalHeader("Cookie", "JSESSIONID=" + sessionId); MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); HttpSession sessionToRemove = actualRequest.getSession(); sessionToRemove.invalidate();/*from w w w.j ava 2 s .co m*/ assertThat(sessions.containsKey(sessionToRemove.getId()), equalTo(false)); assertSingleSessionCookie("JSESSIONID=" + sessionToRemove.getId() + "; Expires=Thu, 01-Jan-1970 00:00:01 GMT; Path=/test; Domain=example.com"); webRequest.removeAdditionalHeader("Cookie"); requestBuilder = new HtmlUnitRequestBuilder(sessions, webClient, webRequest); actualRequest = requestBuilder.buildRequest(servletContext); assertThat(actualRequest.getSession().isNew(), equalTo(true)); assertThat(sessions.containsKey(sessionToRemove.getId()), equalTo(false)); }
From source file:gov.nih.nci.rembrandt.web.taglib.ClinicalPlotTag.java
public int doStartTag() { chart = null;/*from w ww . j a v a 2s . c o m*/ clinicalData.clear(); ServletRequest request = pageContext.getRequest(); HttpSession session = pageContext.getSession(); Object o = request.getAttribute(beanName); JspWriter out = pageContext.getOut(); ServletResponse response = pageContext.getResponse(); try { // //retrieve the Finding from cache and build the list of Clinical Data points //ClinicalFinding clinicalFinding = (ClinicalFinding)businessTierCache.getSessionFinding(session.getId(),taskId); ReportBean clincalReportBean = presentationTierCache.getReportBean(session.getId(), taskId); Resultant clinicalResultant = clincalReportBean.getResultant(); ResultsContainer resultsContainer = clinicalResultant.getResultsContainer(); SampleViewResultsContainer sampleViewContainer = null; if (resultsContainer instanceof DimensionalViewContainer) { DimensionalViewContainer dimensionalViewContainer = (DimensionalViewContainer) resultsContainer; sampleViewContainer = dimensionalViewContainer.getSampleViewResultsContainer(); } if (sampleViewContainer != null) { Collection<ClinicalFactorType> clinicalFactors = new ArrayList<ClinicalFactorType>(); clinicalFactors.add(ClinicalFactorType.AgeAtDx); //clinicalFactors.add(ClinicalFactorType.Survival); Collection<SampleResultset> samples = sampleViewContainer.getSampleResultsets(); if (samples != null) { int numDxvsKa = 0; int numDxvsSl = 0; for (SampleResultset rs : samples) { //String id = rs.getBiospecimen().getValueObject(); String id = rs.getSampleIDDE().getValueObject(); ClinicalDataPoint clinicalDataPoint = new ClinicalDataPoint(id); String diseaseName = rs.getDisease().getValueObject(); if (diseaseName != null) { clinicalDataPoint.setDiseaseName(diseaseName); } else { clinicalDataPoint.setDiseaseName(DiseaseType.NON_TUMOR.name()); } Long sl = rs.getSurvivalLength(); double survivalDays = -1.0; double survivalMonths = -1.0; if (sl != null) { survivalDays = sl.doubleValue(); survivalMonths = survivalDays / 30.0; //if ((survivalMonths > 0.0)&&(survivalMonths < 1000.0)) { clinicalDataPoint.setSurvival(survivalDays); //} } Long dxAge = rs.getAge(); if (dxAge != null) { clinicalDataPoint.setAgeAtDx(dxAge.doubleValue()); } KarnofskyClinicalEvalDE ka = rs.getKarnofskyClinicalEvalDE(); if (ka != null) { String kaStr = ka.getValueObject(); if (kaStr != null) { if (kaStr.contains("|")) { kaStr = kaStr.trim(); String[] kaStrArray = kaStr.split("\\|"); for (int i = 0; i < kaStrArray.length; i++) { if (i == 0) { //first score is baseline just use this for now //later we will need to use all score in a series for each patient double kaVal = Double.parseDouble(kaStrArray[i].trim()); clinicalDataPoint.setKarnofskyScore(kaVal); } } } else { double kaVal = Double.parseDouble(kaStr); clinicalDataPoint.setKarnofskyScore(kaVal); } } } if ((dxAge != null) && (ka != null)) { numDxvsKa++; } if ((dxAge != null) && (sl != null)) { numDxvsSl++; } // Object dx = rs.getAgeGroup(); // if(sl !=null && dx !=null){ // clinicalDataPoint.setSurvival(new Double(sl.toString())); // clinicalDataPoint.setAgeAtDx(new Double(dx.toString())); // } // Object ks = rs.getKarnofskyClinicalEvalDE(); // Object dx = rs.getAgeGroup(); // if(ks !=null && dx !=null){ // clinicalDataPoint.setNeurologicalAssessment(new Double(ks.toString())); // clinicalDataPoint.setAgeAtDx(new Double(dx.toString())); // } clinicalData.add(clinicalDataPoint); } } } System.out.println("Done creating points!"); //------------------------------------------------------------- //GET THE CLINICAL DATA AND POPULATE THE clinicalData list //Note the ClinicalFinding is currently an empty class //---------------------------------------------------------- //check the components to see which graph to get if (components.equalsIgnoreCase("SurvivalvsAgeAtDx")) { chart = (JFreeChart) CaIntegratorChartFactory.getClinicalGraph(clinicalData, ClinicalFactorType.SurvivalLength, "Survival Length (Months)", ClinicalFactorType.AgeAtDx, "Age At Diagnosis (Years)"); } if (components.equalsIgnoreCase("KarnofskyScorevsAgeAtDx")) { chart = (JFreeChart) CaIntegratorChartFactory.getClinicalGraph(clinicalData, ClinicalFactorType.KarnofskyAssessment, "Karnofsky Score", ClinicalFactorType.AgeAtDx, "Age At Diagnosis (Years)"); } RembrandtImageFileHandler imageHandler = new RembrandtImageFileHandler(session.getId(), "png", 600, 500); //The final complete path to be used by the webapplication String finalPath = imageHandler.getSessionTempFolder(); String finalURLpath = imageHandler.getFinalURLPath(); /* * Create the actual charts, writing it to the session temp folder */ ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); String mapName = imageHandler.createUniqueMapName(); ChartUtilities.writeChartAsPNG(new FileOutputStream(finalPath), chart, 600, 500, info); /* This is here to put the thread into a loop while it waits for the * image to be available. It has an unsophisticated timer but at * least it is something to avoid an endless loop. **/ boolean imageReady = false; int timeout = 1000; FileInputStream inputStream = null; while (!imageReady) { timeout--; try { inputStream = new FileInputStream(finalPath); inputStream.available(); imageReady = true; inputStream.close(); } catch (IOException ioe) { imageReady = false; if (inputStream != null) { inputStream.close(); } } if (timeout <= 1) { break; } } out.print(ImageMapUtil.getBoundingRectImageMapTag(mapName, false, info)); //finalURLpath = finalURLpath.replace("\\", "/"); finalURLpath = finalURLpath.replace("\\", "/"); long randomness = System.currentTimeMillis(); //prevent image caching out.print("<img id=\"geneChart\" alt=\"geneChart\" name=\"geneChart\" src=\"" + finalURLpath + "?" + randomness + "\" usemap=\"#" + mapName + "\" border=\"0\" />"); //out.print("<img id=\"geneChart\" name=\"geneChart\" src=\""+finalURLpath+"\" usemap=\"#"+mapName + "\" border=\"0\" />"); } catch (IOException e) { logger.error(e); } catch (Exception e) { logger.error(e); } catch (Throwable t) { logger.error(t); } return EVAL_BODY_INCLUDE; }
From source file:org.apache.struts.webapp.example.SaveRegistrationAction.java
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Extract attributes and parameters we will need HttpSession session = request.getSession(); RegistrationForm regform = (RegistrationForm) form; String action = regform.getAction(); if (action == null) { action = "Create"; }//ww w. j a v a2 s . c o m UserDatabase database = (UserDatabase) servlet.getServletContext().getAttribute(Constants.DATABASE_KEY); if (log.isDebugEnabled()) { log.debug("SaveRegistrationAction: Processing " + action + " action"); } // Is there a currently logged on user (unless creating)? User user = (User) session.getAttribute(Constants.USER_KEY); if (!"Create".equals(action) && (user == null)) { if (log.isTraceEnabled()) { log.trace(" User is not logged on in session " + session.getId()); } return (mapping.findForward("logon")); } // Was this transaction cancelled? if (isCancelled(request)) { if (log.isTraceEnabled()) { log.trace(" Transaction '" + action + "' was cancelled"); } session.removeAttribute(Constants.SUBSCRIPTION_KEY); return (mapping.findForward("success")); } // Validate the transactional control token ActionMessages errors = new ActionMessages(); if (log.isTraceEnabled()) { log.trace(" Checking transactional control token"); } if (!isTokenValid(request)) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.transaction.token")); } resetToken(request); // Validate the request parameters specified by the user if (log.isTraceEnabled()) { log.trace(" Performing extra validations"); } String value = null; value = regform.getUsername(); if (("Create".equals(action)) && (database.findUser(value) != null)) { errors.add("username", new ActionMessage("error.username.unique", regform.getUsername())); } if ("Create".equals(action)) { value = regform.getPassword(); if ((value == null) || (value.length() < 1)) { errors.add("password", new ActionMessage("error.password.required")); } value = regform.getPassword2(); if ((value == null) || (value.length() < 1)) { errors.add("password2", new ActionMessage("error.password2.required")); } } // Report any errors we have discovered back to the original form if (!errors.isEmpty()) { this.saveErrors(request, errors); this.saveToken(request); return (mapping.getInputForward()); } // Update the user's persistent profile information try { if ("Create".equals(action)) { user = database.createUser(regform.getUsername()); } String oldPassword = user.getPassword(); PropertyUtils.copyProperties(user, regform); if ((regform.getPassword() == null) || (regform.getPassword().length() < 1)) { user.setPassword(oldPassword); } } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t == null) { t = e; } log.error("Registration.populate", t); throw new ServletException("Registration.populate", t); } catch (Throwable t) { log.error("Registration.populate", t); throw new ServletException("Subscription.populate", t); } try { database.save(); } catch (Exception e) { log.error("Database save", e); } // Log the user in if appropriate if ("Create".equals(action)) { session.setAttribute(Constants.USER_KEY, user); if (log.isTraceEnabled()) { log.trace(" User '" + user.getUsername() + "' logged on in session " + session.getId()); } } // Remove the obsolete form bean if (mapping.getAttribute() != null) { if ("request".equals(mapping.getScope())) request.removeAttribute(mapping.getAttribute()); else session.removeAttribute(mapping.getAttribute()); } // Forward control to the specified success URI if (log.isTraceEnabled()) { log.trace(" Forwarding to success page"); } return (mapping.findForward("success")); }
From source file:org.springframework.test.web.servlet.htmlunit.HtmlUnitRequestBuilderTests.java
@Test public void buildRequestSession() throws Exception { MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); HttpSession newSession = actualRequest.getSession(); assertThat(newSession, notNullValue()); assertSingleSessionCookie("JSESSIONID=" + newSession.getId() + "; Path=/test; Domain=example.com"); webRequest.setAdditionalHeader("Cookie", "JSESSIONID=" + newSession.getId()); requestBuilder = new HtmlUnitRequestBuilder(sessions, webClient, webRequest); actualRequest = requestBuilder.buildRequest(servletContext); assertThat(actualRequest.getSession(), sameInstance(newSession)); }
From source file:gov.nih.nci.security.upt.actions.ProtectionGroupAction.java
public String setParentAssociation() throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = request.getSession(); UserProvisioningManager userProvisioningManager = (UserProvisioningManager) (request.getSession()) .getAttribute(DisplayConstants.USER_PROVISIONING_MANAGER); if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) { if (logProtectionGroup.isDebugEnabled()) logProtectionGroup.debug("||" + protectionGroupForm.getFormName() + "|setParentAssociation|Failure|No Session or User Object Forwarding to the Login Page||"); return ForwardConstants.LOGIN_PAGE; }/*from w w w . j a va2s. co m*/ UserInfoHelper.setUserInfo(((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId(), session.getId()); try { // TO-DO replace assignProtectionGroups with setOwners or such method String parentProtectionGroupId = null; if (protectionGroupForm.getParentAssociatedIds() != null && (protectionGroupForm.getParentAssociatedIds().length == 1)) { parentProtectionGroupId = protectionGroupForm.getParentAssociatedIds()[0]; } else { parentProtectionGroupId = null; } userProvisioningManager.assignParentProtectionGroup(parentProtectionGroupId, protectionGroupForm.getProtectionGroupId()); protectionGroupForm.setRequest(request); protectionGroupForm.buildDisplayForm(userProvisioningManager); addActionMessage("Association Update Successful"); } catch (CSException cse) { addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage())); if (logProtectionGroup.isDebugEnabled()) logProtectionGroup.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + protectionGroupForm.getFormName() + "|setParentAssociation|Failure|Error Loading Protection Group Association for the " + protectionGroupForm.getFormName() + " object|" + "|" + cse.getMessage()); } if (logProtectionGroup.isDebugEnabled()) logProtectionGroup.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + protectionGroupForm.getFormName() + "|setParentAssociation|Success|Success in Setting Parent Association for " + protectionGroupForm.getFormName() + " object|" + "|"); return ForwardConstants.SET_PARENT_ASSOCIATION_SUCCESS; }
From source file:com.liferay.portal.servlet.MainServlet.java
public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { if (!PortalInstances.matches()) { String html = ContentUtil.get("messages/en_US/init.html"); res.getOutputStream().print(html); return;/* ww w .java 2 s . c om*/ } if (ShutdownUtil.isShutdown()) { String html = ContentUtil.get("messages/en_US/shutdown.html"); res.getOutputStream().print(html); return; } req.setAttribute("dotcache", "no"); // Shared session HttpSession ses = req.getSession(); if (!GetterUtil.getBoolean(PropsUtil.get(PropsUtil.TCK_URL))) { String sharedSessionId = CookieUtil.get(req.getCookies(), CookieKeys.SHARED_SESSION_ID); _log.debug("Shared session id is " + sharedSessionId); if (sharedSessionId == null) { sharedSessionId = PwdGenerator.getPassword(PwdGenerator.KEY1 + PwdGenerator.KEY2, 12); Cookie sharedSessionIdCookie = new Cookie(CookieKeys.SHARED_SESSION_ID, sharedSessionId); sharedSessionIdCookie.setPath("/"); sharedSessionIdCookie.setMaxAge(86400); res.addCookie(sharedSessionIdCookie); _log.debug("Shared session id is " + sharedSessionId); } // if (ses.getAttribute(WebKeys.SHARED_SESSION_ID) == null) { ses.setAttribute(WebKeys.SHARED_SESSION_ID, sharedSessionId); // } HttpSession portalSes = (HttpSession) SharedSessionPool.get(sharedSessionId); if ((portalSes == null) || (ses != portalSes)) { if (portalSes == null) { _log.debug("No session exists in pool"); } else { _log.debug("Session " + portalSes.getId() + " in pool is old"); } _log.debug("Inserting current session " + ses.getId() + " in pool"); SharedSessionPool.put(sharedSessionId, ses); } } // Test CAS auto login /* * ses.setAttribute( * com.liferay.portal.auth.CASAutoLogin.CAS_FILTER_USER, * "liferay.com.1"); */ // CTX ServletContext ctx = getServletContext(); ServletContext portalCtx = ctx.getContext(PropsUtil.get(PropsUtil.PORTAL_CTX)); if (portalCtx == null) { portalCtx = ctx; } req.setAttribute(WebKeys.CTX, portalCtx); // CTX_PATH variable String ctxPath = (String) ctx.getAttribute(WebKeys.CTX_PATH); if (portalCtx.getAttribute(WebKeys.CTX_PATH) == null) { portalCtx.setAttribute(WebKeys.CTX_PATH, ctxPath); } if (ses.getAttribute(WebKeys.CTX_PATH) == null) { ses.setAttribute(WebKeys.CTX_PATH, ctxPath); } req.setAttribute(WebKeys.CTX_PATH, ctxPath); // CAPTCHA_PATH variable String captchaPath = (String) ctx.getAttribute(WebKeys.CAPTCHA_PATH); if (portalCtx.getAttribute(WebKeys.CAPTCHA_PATH) == null) { portalCtx.setAttribute(WebKeys.CAPTCHA_PATH, captchaPath); } if (ses.getAttribute(WebKeys.CAPTCHA_PATH) == null) { ses.setAttribute(WebKeys.CAPTCHA_PATH, captchaPath); } req.setAttribute(WebKeys.CAPTCHA_PATH, captchaPath); // IMAGE_PATH variable String imagePath = (String) ctx.getAttribute(WebKeys.IMAGE_PATH); if (portalCtx.getAttribute(WebKeys.IMAGE_PATH) == null) { portalCtx.setAttribute(WebKeys.IMAGE_PATH, imagePath); } if (ses.getAttribute(WebKeys.IMAGE_PATH) == null) { ses.setAttribute(WebKeys.IMAGE_PATH, imagePath); } req.setAttribute(WebKeys.IMAGE_PATH, imagePath); // WebKeys.COMPANY_ID variable String companyId = (String) ctx.getAttribute(WebKeys.COMPANY_ID); if (portalCtx.getAttribute(WebKeys.COMPANY_ID) == null) { portalCtx.setAttribute(WebKeys.COMPANY_ID, companyId); } if (ses.getAttribute(WebKeys.COMPANY_ID) == null) { ses.setAttribute(WebKeys.COMPANY_ID, companyId); } req.setAttribute(WebKeys.COMPANY_ID, companyId); // Portlet Request Processor PortletRequestProcessor portletReqProcessor = (PortletRequestProcessor) portalCtx .getAttribute(WebKeys.PORTLET_STRUTS_PROCESSOR); if (portletReqProcessor == null) { portletReqProcessor = new PortletRequestProcessor(this, getModuleConfig(req)); portalCtx.setAttribute(WebKeys.PORTLET_STRUTS_PROCESSOR, portletReqProcessor); } // Tiles definitions factory if (portalCtx.getAttribute(TilesUtilImpl.DEFINITIONS_FACTORY) == null) { portalCtx.setAttribute(TilesUtilImpl.DEFINITIONS_FACTORY, ctx.getAttribute(TilesUtilImpl.DEFINITIONS_FACTORY)); } // Set character encoding String strutsCharEncoding = PropsUtil.get(PropsUtil.STRUTS_CHAR_ENCODING); req.setCharacterEncoding(strutsCharEncoding); /* * if (!BrowserSniffer.is_wml(req)) { res.setContentType( * Constants.TEXT_HTML + "; charset=" + strutsCharEncoding); } */ // Determine content type String contentType = req.getHeader("Content-Type"); if ((contentType != null) && (contentType.startsWith("multipart/form-data"))) { req = new UploadServletRequest(req); } else if (ParamUtil.get(req, WebKeys.ENCRYPT, false)) { try { Company company = CompanyLocalManagerUtil.getCompany(companyId); req = new EncryptedServletRequest(req, company.getKeyObj()); } catch (Exception e) { } } // Current URL String completeURL = Http.getCompleteURL(req); if (completeURL.indexOf("j_security_check") != -1) { completeURL = ctxPath; } else { completeURL = completeURL.substring(completeURL.indexOf("://") + 3, completeURL.length()); completeURL = completeURL.substring(completeURL.indexOf("/"), completeURL.length()); } req.setAttribute(WebKeys.CURRENT_URL, completeURL); // Chat server // Login String userId = PortalUtil.getUserId(req); if ((userId != null)) { PrincipalThreadLocal.setName(userId); } if (userId == null) { try { User user = UserManagerUtil.getDefaultUser(companyId); if (ses.getAttribute(Globals.LOCALE_KEY) == null) ses.setAttribute(Globals.LOCALE_KEY, user.getLocale()); } catch (Exception e) { Logger.error(this, e.getMessage(), e); } } // Process pre service events try { EventsProcessor.process(PropsUtil.getArray(PropsUtil.SERVLET_SERVICE_EVENTS_PRE), req, res); } catch (Exception e) { Logger.error(this, e.getMessage(), e); req.setAttribute(PageContext.EXCEPTION, e); StrutsUtil.forward(PropsUtil.get(PropsUtil.SERVLET_SERVICE_EVENTS_PRE_ERROR_PAGE), portalCtx, req, res); } // Struts service callParentService(req, res); // Process post service events try { EventsProcessor.process(PropsUtil.getArray(PropsUtil.SERVLET_SERVICE_EVENTS_POST), req, res); } catch (Exception e) { Logger.error(this, e.getMessage(), e); } // Clear the principal associated with this thread PrincipalThreadLocal.setName(null); }
From source file:gov.nih.nci.security.upt.actions.CommonDoubleAssociationAction.java
public String setDoubleAssociation(BaseDoubleAssociationForm baseDoubleAssociationForm) throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = request.getSession(); if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) { if (logDoubleAssociation.isDebugEnabled()) logDoubleAssociation.debug("||" + baseDoubleAssociationForm.getFormName() + "|setDoubleAssociation|Failure|No Session or User Object Forwarding to the Login Page||"); return ForwardConstants.LOGIN_PAGE; }// w ww .j ava 2 s .c o m UserInfoHelper.setUserInfo(((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId(), session.getId()); try { UserProvisioningManager userProvisioningManager = (UserProvisioningManager) (request.getSession()) .getAttribute(DisplayConstants.USER_PROVISIONING_MANAGER); baseDoubleAssociationForm.setRequest(request); baseDoubleAssociationForm.buildDisplayForm(userProvisioningManager); baseDoubleAssociationForm.setDoubleAssociationObject(userProvisioningManager); addActionMessage("Association Update Successful"); } catch (CSException cse) { addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage())); if (logDoubleAssociation.isDebugEnabled()) logDoubleAssociation.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + baseDoubleAssociationForm.getFormName() + "|setDoubleAssociation|Failure|Error Setting Double Association for the " + baseDoubleAssociationForm.getFormName() + " object|" + "|" + cse.getMessage()); } if (logDoubleAssociation.isDebugEnabled()) logDoubleAssociation.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + baseDoubleAssociationForm.getFormName() + "|setDoubleAssociation|Success|Success in Setting Double Association for " + baseDoubleAssociationForm.getFormName() + " object|" + "|"); return ForwardConstants.SET_DOUBLEASSOCIATION_SUCCESS; }