List of usage examples for javax.servlet.http HttpSession getAttribute
public Object getAttribute(String name);
null
if no object is bound under the name. From source file:com.orig.gls.web.category.Categoryw.java
public static void handleMaintainCategory(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(false); session.setAttribute("catadded", false); session.setAttribute("catexists", false); if ((String) session.getAttribute("uname") != null) { String function = request.getParameter("function"); String categorytype = request.getParameter("categorytype"); String categorycode = request.getParameter("categorycode"); String categoryvalue = request.getParameter("categoryvalue"); switch (function) { case "ADD": if (!Category.categoryExists(categorycode, categorytype)) { Category.addCategories(Bank.getBankId(), categorycode, categorytype, categoryvalue, new Date(), (String) session.getAttribute("uname"), new Date(), (String) session.getAttribute("uname")); session.setAttribute("catadded", true); session.setAttribute("content_page", "categories/mCategories_a.jsp"); } else { session.setAttribute("catexists", true); session.setAttribute("content_page", "categories/mCategories_b.jsp"); }/*from w ww . j a va 2s . co m*/ break; } } else { session.setAttribute("content_page", "sessionexp.jsp"); } response.sendRedirect("index.jsp"); }
From source file:be.fedict.eid.applet.service.impl.AuthenticationChallenge.java
/** * Generates a challenge and stores it in the given HTTP session for later * consumption.//w w w . java2 s. c om * * @param session * @return the challenge. */ public static byte[] generateChallenge(HttpSession session) { AuthenticationChallenge authenticationChallenge = new AuthenticationChallenge(); if (null != session.getAttribute(AUTHN_CHALLENGE_SESSION_ATTRIBUTE)) { LOG.warn("overwriting a previous authentication challenge"); } session.setAttribute(AUTHN_CHALLENGE_SESSION_ATTRIBUTE, authenticationChallenge); byte[] challenge = authenticationChallenge.getChallenge(); return challenge; }
From source file:be.fedict.eid.applet.service.impl.AuthenticationChallenge.java
/** * Gives back the authentication challenge. This challenge is checked for * freshness and can be consumed only once. * /*from w w w .j a v a2 s. c o m*/ * @param session * @param maxMaturity * @return */ public static byte[] getAuthnChallenge(HttpSession session, Long maxMaturity) { AuthenticationChallenge authenticationChallenge = (AuthenticationChallenge) session .getAttribute(AUTHN_CHALLENGE_SESSION_ATTRIBUTE); if (null == authenticationChallenge) { throw new SecurityException("no challenge in session"); } session.removeAttribute(AUTHN_CHALLENGE_SESSION_ATTRIBUTE); Date now = new Date(); if (null == maxMaturity) { maxMaturity = DEFAULT_MAX_MATURITY; } long dt = now.getTime() - authenticationChallenge.getTimestamp().getTime(); if (dt > maxMaturity) { throw new SecurityException("maximum challenge maturity reached"); } byte[] challenge = authenticationChallenge.getChallenge(); return challenge; }
From source file:com.swdouglass.joid.consumer.OpenIdFilter.java
public static String getCurrentUser(HttpSession session) { ensureFilterConfiguredProperly();//from w ww. j a va 2 s .com String openid = (String) session.getAttribute(OpenIdFilter.OPENID_ATTRIBUTE); if (openid != null) { return openid; } // TODO: THIS COOKIE THING CAN'T WORK BECAUSE SOMEONE COULD FAKE IT, NEEDS AN AUTH TOKEN ALONG WITH IT return openid; }
From source file:gov.nih.nci.cma.web.ajax.RegHelper.java
public static String pReg(String ln, String fn, String em, String in, String ca, String ph, String de) { //look @ the captcha JSONObject jso = new JSONObject(); String status = "pass"; String msg = ""; WebContext webContext = WebContextFactory.get(); HttpSession session = webContext.getSession(); String k = session.getAttribute(nl.captcha.servlet.Constants.SIMPLE_CAPCHA_SESSION_KEY) != null ? (String) session.getAttribute(nl.captcha.servlet.Constants.SIMPLE_CAPCHA_SESSION_KEY) : null;//from www.ja v a2 s .c o m if (k != null && k.equals(ca.trim())) { try { //need to clean the generalFeedback field, also put this in the props as a template MailProps mp = new MailProps(); //make sure its only 1 email em = em.replace(",", "").replace(";", ""); //send the mail to APP support /* String fdbk = fn + " " + ln + " is requesting an account for the CMA Application. \n\n"; fdbk += "Their email is: " + em + " \n"; fdbk += "Their institution is: " + in + " \n"; fdbk += "\n\nThis is an automated email sent from the CMA Application.\n"; */ //String fdbk = System.getProperty("cma.register.template.support"); Map propsMap = (Map) ConfigurationHolder.getFlatConfig(); String fdbk = (String) propsMap.get("cma.register.template.support"); fdbk = fdbk.replace("{last_name}", (ln != null) ? ln : "None"); fdbk = fdbk.replace("{first_name}", (fn != null) ? fn : "None"); fdbk = fdbk.replace("{email}", (em != null) ? em : "None"); fdbk = fdbk.replace("{phone}", (ph != null) ? ph : "None"); fdbk = fdbk.replace("{department}", (de != null) ? de : "None"); fdbk = fdbk.replace("{institution}", (in != null) ? in : "None"); mp.setBody(fdbk); //the fields below should be in a props file mp.setSmtp((String) propsMap.get("cma.feedback.mailSMPT")); mp.setSubject((String) propsMap.get("cma.register.mailSubject.support")); mp.setMailTo((String) propsMap.get("cma.register.mailTo.support")); mp.setMailFrom((String) propsMap.get("cma.feedback.mailFrom")); Mail.sendMail(mp); //send the mail to the user mp = new MailProps(); fdbk = (String) propsMap.get("cma.register.template.user"); fdbk = fdbk.replace("{last_name}", (ln != null) ? ln : "None"); fdbk = fdbk.replace("{first_name}", (fn != null) ? fn : "None"); /* fdbk = "Dear " + fn + " " + ln + ",\n Thanks for registering for access to the CMA Application. You will receive your official account information via email shortly. Please contact ncicb@pop.nci.nih.gov for further assistance.\n"; fdbk += "\n\nSincerely,\n-The CMA Team"; */ mp.setBody(fdbk); mp.setSmtp((String) propsMap.get("cma.feedback.mailSMPT")); mp.setSubject((String) propsMap.get("cma.register.mailSubject.user")); mp.setMailTo(em.trim()); mp.setMailFrom((String) propsMap.get("cma.feedback.mailFrom")); Mail.sendMail(mp); } catch (ValidationException e) { logger.error("mail did not send from regHelper"); logger.error(e); status = "failed"; msg = "SEND_FAILED"; } catch (Exception e) { logger.error("mail did not send from regHelper"); logger.error(e); status = "failed"; msg = "SEND_FAILED_GENERIC"; } } else { status = "fail"; msg = "BAD_CAPTCHA"; } jso.put("status", status); jso.put("msg", msg); if (status.equals("pass")) { // Uncomment the two lines below to enable login after registration (more steps are needed). // Should change the login parameters too //jso.put("un", "RBTuser"); //jso.put("ps", "RBTpass"); } return jso.toString(); }
From source file:com.bluexml.side.Framework.alfresco.shareLanguagePicker.CustomDispatcherServlet.java
public static void setLanguageFromLayoutParam(HttpServletRequest req) { String urlLang = req.getParameter("shareLang"); HttpSession currentSession = req.getSession(); String sessionLang = (String) currentSession.getAttribute("shareLang"); //1st option: Select the url param shareLang if (urlLang != null) { I18NUtil.setLocale(I18NUtil.parseLocale(urlLang)); currentSession.setAttribute("shareLang", urlLang); } else if (sessionLang != null) { I18NUtil.setLocale(I18NUtil.parseLocale(sessionLang)); } else {// w w w .j a v a2s .c o m // set language locale from browser header String acceptLang = req.getHeader("Accept-Language"); if (acceptLang != null && acceptLang.length() != 0) { StringTokenizer t = new StringTokenizer(acceptLang, ",; "); // get language and convert to java locale format String language = t.nextToken().replace('-', '_'); I18NUtil.setLocale(I18NUtil.parseLocale(language)); } } }
From source file:com.tn.exam.util.web.springside.Struts2Utils.java
/** * ?HttpSessionAttribute.//from w ww .ja v a2 s. c o m */ public static Object getSessionAttribute(String name) { HttpSession session = getSession(false); return (session != null ? session.getAttribute(name) : null); }
From source file:edu.cornell.mannlib.vedit.beans.LoginStatusBean.java
/** * Get the bean from this session, or a dummy bean if the user is not logged * in. Never returns null.//from w w w . ja va 2s.c o m */ public static LoginStatusBean getBean(HttpSession session) { if (session == null) { return DUMMY_BEAN; } Object o = session.getAttribute(ATTRIBUTE_NAME); if (o == null) { return DUMMY_BEAN; } if (!(o instanceof LoginStatusBean)) { log.warn("Tried to get login status bean, but found an instance of " + o.getClass().getName() + ": " + o); return DUMMY_BEAN; } return (LoginStatusBean) o; }
From source file:com.ixcode.framework.model.lookup.LookupHandler.java
public static LookupContext getLookupContext(HttpSession session) { if (session.getAttribute(SESSION_ATTR_LOOKUP_CONTEXT) == null) { throw new IllegalStateException( "Could not locate attribute '" + SESSION_ATTR_LOOKUP_CONTEXT + "' in session"); }//from w ww . j a v a2 s . c om return (LookupContext) session.getAttribute(SESSION_ATTR_LOOKUP_CONTEXT); }
From source file:com.orangeleap.common.security.CasUtil.java
public static Authentication getAuthenticationToken() { HttpServletRequest request = OrangeLeapRequestLocal.getRequest(); if (request == null) return null; HttpSession session = request.getSession(); if (session == null) return null; SecurityContextImpl si = (SecurityContextImpl) session .getAttribute(HttpSessionContextIntegrationFilter.SPRING_SECURITY_CONTEXT_KEY); if (si == null) return null; return si.getAuthentication(); }