Refine search
/** * Return the best available mutex for the given session: * that is, an object to synchronize on for the given session. * <p>Returns the session mutex attribute if available; usually, * this means that the HttpSessionMutexListener needs to be defined * in {@code web.xml}. Falls back to the Session reference itself * if no mutex attribute found. * <p>The session mutex is guaranteed to be the same object during * the entire lifetime of the session, available under the key defined * by the {@code SESSION_MUTEX_ATTRIBUTE} constant. It serves as a * safe reference to synchronize on for locking on the current session. * <p>In many cases, the Session reference itself is a safe mutex * as well, since it will always be the same object reference for the * same active logical session. However, this is not guaranteed across * different servlet containers; the only 100% safe way is a session mutex. * @param fc the FacesContext to find the session mutex for * @return the mutex object (never {@code null}) * @see org.springframework.web.util.WebUtils#SESSION_MUTEX_ATTRIBUTE * @see org.springframework.web.util.HttpSessionMutexListener */ @Nullable public static Object getSessionMutex(FacesContext fc) { Assert.notNull(fc, "FacesContext must not be null"); ExternalContext ec = fc.getExternalContext(); Object mutex = ec.getSessionMap().get(WebUtils.SESSION_MUTEX_ATTRIBUTE); if (mutex == null) { mutex = ec.getSession(true); } return mutex; }
/** * @see Faces#getSession(boolean) */ public static HttpSession getSession(FacesContext context, boolean create) { return (HttpSession) context.getExternalContext().getSession(create); }
public static boolean isSessionInvalid(FacesContext context) { final ExternalContext externalContext = context.getExternalContext(); //if session invalid or expired block other resource handlers from running return externalContext.getSession(false) == null; }
/** * Return the best available mutex for the given session: * that is, an object to synchronize on for the given session. * <p>Returns the session mutex attribute if available; usually, * this means that the HttpSessionMutexListener needs to be defined * in {@code web.xml}. Falls back to the Session reference itself * if no mutex attribute found. * <p>The session mutex is guaranteed to be the same object during * the entire lifetime of the session, available under the key defined * by the {@code SESSION_MUTEX_ATTRIBUTE} constant. It serves as a * safe reference to synchronize on for locking on the current session. * <p>In many cases, the Session reference itself is a safe mutex * as well, since it will always be the same object reference for the * same active logical session. However, this is not guaranteed across * different servlet containers; the only 100% safe way is a session mutex. * @param fc the FacesContext to find the session mutex for * @return the mutex object (never {@code null}) * @see org.springframework.web.util.WebUtils#SESSION_MUTEX_ATTRIBUTE * @see org.springframework.web.util.HttpSessionMutexListener */ @Nullable public static Object getSessionMutex(FacesContext fc) { Assert.notNull(fc, "FacesContext must not be null"); ExternalContext ec = fc.getExternalContext(); Object mutex = ec.getSessionMap().get(WebUtils.SESSION_MUTEX_ATTRIBUTE); if (mutex == null) { mutex = ec.getSession(true); } return mutex; }
@Override public Object getSession(FacesContext facesContext, boolean create) { ExternalContext externalContext = facesContext.getExternalContext(); return externalContext.getSession(create); }
public void handle(String name, Object bean, FacesContext context) { synchronized (context.getExternalContext().getSession(true)) { context.getExternalContext().getSessionMap().put(name, bean); } }
/** * @see Faces#getSession(boolean) */ public static HttpSession getSession(FacesContext context, boolean create) { return (HttpSession) context.getExternalContext().getSession(create); }
@Override public void handle(String name, Object bean, FacesContext context) { synchronized (context.getExternalContext().getSession(true)) { context.getExternalContext().getSessionMap().put(name, bean); } }
/** * Gets the session identifier. * * @return the identifier. */ public static String getSessionId() { FacesContext context = FacesContext.getCurrentInstance(); HttpSession session = (HttpSession) context.getExternalContext().getSession(false); return session.getId(); } }
@Override public void handle(String name, Object bean, FacesContext context) { synchronized (context.getExternalContext().getSession(true)) { context.getExternalContext().getSessionMap().put(name, bean); } }
/** * Gets the session identifier. * * @return the identifier. */ public static String getSessionId() { FacesContext context = FacesContext.getCurrentInstance(); HttpSession session = (HttpSession) context.getExternalContext().getSession(false); return session.getId(); } }
protected boolean checkSessionState(FacesContext context) { return context.getExternalContext().getSession(false) == null || (context.getExternalContext().getSessionMap().get( REDEPLOYED_PORTLET) == null); }
/** * @see org.sakaiproject.section.api.facade.managers.Authn#getUserUid() */ public String getUserUid(Object request) { HttpSession session = null; if(request == null) { session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true); } else { session = ((HttpServletRequest)request).getSession(); } return (String)session.getAttribute(USER_NAME); }
public String getCryptographicallyStrongTokenFromSession(FacesContext context) { String result = (String) context.getExternalContext().getSessionMap().get(TOKEN_NAME); if (null == result) { context.getExternalContext().getSession(true); } result = (String) context.getExternalContext().getSessionMap().get(TOKEN_NAME); return result; }
public long getCreationTime() { Object sess = facesContext.getExternalContext().getSession(true); Class clazz = sess.getClass(); long val = -1; try { Method meth = clazz.getMethod("getCreationTime"); val = (Long)meth.invoke(sess); } catch (Exception e) { log.log(Level.WARNING, "could not get creation time from PortletSession ", e); } return val; }
public String getCryptographicallyStrongTokenFromSession(FacesContext context) { String result = (String) context.getExternalContext().getSessionMap().get(TOKEN_NAME); if (null == result) { context.getExternalContext().getSession(true); } result = (String) context.getExternalContext().getSessionMap().get(TOKEN_NAME); return result; }
public long getLastAccessedTime() { Object sess = facesContext.getExternalContext().getSession(true); Class clazz = sess.getClass(); long val = -1; try { Method meth = clazz.getMethod("getLastAccessedTime"); val = (Long)meth.invoke(sess); } catch (Exception e) { log.log(Level.WARNING, "could not get last accessed time from PortletSession ", e); } return val; }
public String getCryptographicallyStrongTokenFromSession(FacesContext context) { String result = (String) context.getExternalContext().getSessionMap().get(TOKEN_NAME); if (null == result) { context.getExternalContext().getSession(true); } result = (String) context.getExternalContext().getSessionMap().get(TOKEN_NAME); return result; }
public boolean isNew() { Object sess = facesContext.getExternalContext().getSession(true); Class clazz = sess.getClass(); boolean val = false; try { Method meth = clazz.getMethod("isNew"); val = (Boolean)meth.invoke(sess); } catch (Exception e) { log.log(Level.WARNING, "could not get isNew from PortletSession ", e); } return val; }
private Cache getSessionScopeCache(FacesContext context) { Map<String, Object> sessionMap = context.getExternalContext().getSessionMap(); if (!sessionMap.containsKey(DEFAULT_CACHE_PARAM_NAME)) { Object session = context.getExternalContext().getSession(true); synchronized (session) { if (!sessionMap.containsKey(DEFAULT_CACHE_PARAM_NAME)) { sessionMap.put(DEFAULT_CACHE_PARAM_NAME, createCache(sessionDefaultTimeToLive, sessionMaxCapacity)); } } } return (Cache) sessionMap.get(DEFAULT_CACHE_PARAM_NAME); }