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:net.webpasswordsafe.server.ServerSessionUtil.java
public static void initCsrfSession() { HttpSession session = getRequest().getSession(false); if (session.isNew() || (session.getAttribute(Constants.CSRF_TOKEN_KEY) == null)) { // either new session or old session without csrf token set, so set it session.setAttribute(Constants.CSRF_TOKEN_KEY, session.getId()); Cookie cookie = new Cookie(Constants.CSRF_TOKEN_KEY, session.getId()); cookie.setPath("".equals(getRequest().getContextPath()) ? "/" : getRequest().getContextPath()); getResponse().addCookie(cookie); }/*from w w w . j a v a 2 s. c om*/ }
From source file:edu.cornell.mannlib.vitro.webapp.beans.DisplayMessage.java
/** * Get the current message from the session, and remove it from the session * so it won't be displayed again.//from ww w .j av a2s. co m * * If there is no message, return the empty string. */ public static String getMessageAndClear(HttpSession session) { String message = NO_MESSAGE; if (session != null) { Object sessionMessage = session.getAttribute(ATTRIBUTE_NAME); if (sessionMessage != null) { if (sessionMessage instanceof String) { log.debug("Get message: '" + sessionMessage + "'"); message = (String) sessionMessage; } session.removeAttribute(ATTRIBUTE_NAME); } else { log.debug("Get no message."); } } return message; }
From source file:com.impetus.kundera.graphbrowser.IMDBUtils.java
public static IMDBService getIMDBService() { HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true); IMDBService imdbService = (IMDBService) session.getAttribute("imdb"); if (imdbService == null) { BeanFactory beanfactory = new ClassPathXmlApplicationContext("appContext.xml"); imdbService = (IMDBService) beanfactory.getBean("imdb"); // imdbService.init(); session.setAttribute("imdb", imdbService); }//from w ww . j av a 2s . co m return imdbService; }
From source file:cn.vlabs.umt.ui.UMTContext.java
public static LoginInfo getLoginInfo(HttpSession session) { if (session != null) { return killNull((LoginInfo) session.getAttribute(Attributes.LOGIN_INFO)); } else {//from w ww . j av a 2s . c o m return killNull(null); } }
From source file:com.quartz.monitor.util.Tools.java
public static QuartzInstance getQuartzInstance() { HttpServletRequest request = ServletActionContext.getRequest();// request HttpSession session = request.getSession();// requestsession String uuid = (String) session.getAttribute("configId"); Map<String, QuartzInstance> quartzInstanceMap = QuartzInstanceContainer.getQuartzInstanceMap(); if (quartzInstanceMap == null || quartzInstanceMap.size() == 0 || uuid == null || uuid.equals("")) { return null; }//from w w w . j a v a2 s . co m QuartzInstance instance = quartzInstanceMap.get(uuid); if (instance == null) { try { new InitAction().execute(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } instance = Tools.getQuartzInstance(); } return instance; }
From source file:com.daimler.spm.storefront.util.CSRFTokenManager.java
/** * Returns the CSRF token for the provided httpSession. * * @param httpSession/*from w w w . j a v a2 s .com*/ * @return the CSRF token */ public static String getTokenForSession(final HttpSession httpSession) { String sessionCsrfToken = null; synchronized (httpSession) { sessionCsrfToken = (String) httpSession.getAttribute(CSRF_TOKEN_SESSION_ATTRIBUTE); if (StringUtils.isBlank(sessionCsrfToken)) { sessionCsrfToken = generateToken(); httpSession.setAttribute(CSRF_TOKEN_SESSION_ATTRIBUTE, sessionCsrfToken); } } return sessionCsrfToken; }
From source file:com.brienwheeler.web.spring.security.SetUserInSessionInterceptor.java
public static User getCachedUser(HttpSession session, boolean throwOnFail) { ValidationUtils.assertNotNull(session, "session cannot be null"); User user = (User) session.getAttribute(SESSION_ATTR_USER); if ((user == null) && throwOnFail) throw new IllegalStateException("no cached user found in session"); return user;//from w w w. j a v a 2s.co m }
From source file:net.shibboleth.idp.oidc.util.OIDCUtils.java
/** * Gets session attribute.//from w w w. j a v a 2s . c o m * * @param request the request * @param parameter the parameter * @return the session attribute */ public static Object getSessionAttribute(final HttpServletRequest request, final String parameter) { final HttpSession session = request.getSession(); return session.getAttribute(parameter); }
From source file:edu.cornell.mannlib.vitro.webapp.controller.authenticate.LogoutRedirector.java
private static Set<String> getRestrictedPageUris(HttpServletRequest request) { HttpSession session = request.getSession(); @SuppressWarnings("unchecked") Set<String> restrictedPageUris = (Set<String>) session.getAttribute(ATTRIBUTE_RESTRICTED_PAGE_URIS); if (restrictedPageUris == null) { restrictedPageUris = new HashSet<String>(); session.setAttribute(ATTRIBUTE_RESTRICTED_PAGE_URIS, restrictedPageUris); }// w ww. j a v a 2 s . com return restrictedPageUris; }
From source file:be.fedict.eid.idp.sp.protocol.ws_federation.AuthenticationRequestServlet.java
/** * Used by the {@link AuthenticationResponseServlet} for validation of the * WS-Federation Response <tt>ctx</tt>. * // ww w .j av a 2s .com * @param httpSession * the HTTP Session * @return optional context sent along with the WS-Federation Authentication * Request */ public static String getContext(HttpSession httpSession) { return (String) httpSession.getAttribute(CONTEXT_SESSION_ATTRIBUTE); }