/** Puts a ZK session to the cache. * You can retrieve the native session by {@link Session#getNativeSession}. * @param sess the ZK session. */ public void put(Session sess) { ((HttpSession) sess.getNativeSession()).setAttribute(Attributes.ZK_SESSION, sess); }
/** Removes the ZK session from the cache. */ public void remove(Session sess) { ((HttpSession) sess.getNativeSession()).removeAttribute(Attributes.ZK_SESSION); }
public void put(Session sess) { //ZK-1029: WebSphere portal's PortletSession also implements HttpSession, //so we have to check PortletSession first final Object navsess = sess.getNativeSession(); if (navsess instanceof PortletSession) ((PortletSession) navsess).setAttribute(Attributes.ZK_SESSION, sess, PortletSession.APPLICATION_SCOPE); else ((HttpSession) navsess).setAttribute(Attributes.ZK_SESSION, sess); }
public void remove(Session sess) { final Object navsess = sess.getNativeSession(); if (navsess instanceof PortletSession) ((PortletSession) navsess).removeAttribute(Attributes.ZK_SESSION, PortletSession.APPLICATION_SCOPE); else ((HttpSession) navsess).removeAttribute(Attributes.ZK_SESSION); } };
/** * Remove desktop security context on desktop cleanup. */ @Override public void onCleanup(Desktop desktop) { HttpSession session = (HttpSession) desktop.getSession().getNativeSession(); session.removeAttribute(getDesktopContextKey(desktop.getId())); }
/** * Given a desktop, returns Spring security context object. * * @param desktop The desktop whose security context is sought. * @return SecurityContext The Spring security context. */ public static SecurityContext getSecurityContext(Desktop desktop) { String key = getDesktopContextKey(desktop.getId()); HttpSession session = (HttpSession) desktop.getSession().getNativeSession(); return (SecurityContext) session.getAttribute(key); }
o = sess.getAttribute(Attributes.PREFERRED_FIRST_DAY_OF_WEEK); if (o == null) { final Object hsess = sess.getNativeSession(); if (hsess instanceof HttpSession) o = ((HttpSession) hsess).getServletContext()
public void patchRender(RequestInfo reqInfo, Page page, Writer result, Writer out) throws IOException { if (getDelay() >= 0) super.patchRender(reqInfo, page, result, out); PortletSession p = (PortletSession) reqInfo.getSession().getNativeSession(); out.write("<script>zk.afterMount(function () {" + "document.cookie = 'JSESSIONID=" + p.getId() + "; path=/'" + "});</script>"); }
/** * Force transfer of session-based security context to desktop. */ @Override public void onInit(Desktop desktop) { HttpSession session = (HttpSession) desktop.getSession().getNativeSession(); getSecurityContext(session, desktop.getId()); }
/** Returns the ZK session associated with the specified native session, * or null if not found. * * @param navsess the native session (never null). * If HTTP, it is HttpSession. If portlet, it is PortletSession. * @since 3.0.5 */ public static final Session getSession(WebApp wapp, Object navsess) { final SessionCache sc = ((WebAppCtrl) wapp).getSessionCache(); if (sc == null) return null; //bug 2668190: happens when destroying app in WebSphere 7 final Session sess = sc.get(navsess); if (sess != null && sess.getNativeSession() != navsess) ((SessionCtrl) sess).recover(navsess); return sess; }
public void attributeRemoved(HttpSessionBindingEvent evt) { final String name = evt.getName(); if (!shallIgnore(name)) { final Session sess = Sessions.getCurrent(false); if (sess instanceof SimpleSession && evt.getSession().equals(sess.getNativeSession())) ((SimpleSession) sess).getScopeListeners().notifyRemoved(name); } }
public void attributeAdded(HttpSessionBindingEvent evt) { final String name = evt.getName(); if (!shallIgnore(name)) { final Session sess = Sessions.getCurrent(false); if (sess instanceof SimpleSession && evt.getSession().equals(sess.getNativeSession())) ((SimpleSession) sess).getScopeListeners().notifyAdded(name, evt.getValue()); } }
public void attributeReplaced(HttpSessionBindingEvent evt) { final String name = evt.getName(); if (!shallIgnore(name)) { final Session sess = Sessions.getCurrent(false); if (sess instanceof SimpleSession && evt.getSession().equals(sess.getNativeSession())) ((SimpleSession) sess).getScopeListeners().notifyReplaced(name, evt.getValue()); } }
private static final Object setup(Object sess, ServletRequest request, ServletResponse response, String charset) { final Object[] old; if (request.getAttribute(ATTR_SETUP) != null) { //has been setup old = null; } else { final HttpSession hsess; if (sess instanceof Session) { final Session se = (Session) sess; //Invoke the request interceptors se.getWebApp().getConfiguration().invokeRequestInterceptors(se, request, response); hsess = (HttpSession) se.getNativeSession(); } else { hsess = (HttpSession) sess; } final Object ol = Charsets.setup(hsess, request, response, charset); //Charsets will handle PREFERRED_LOCALE //time zone final TimeZone tz = getTimeZone(hsess); final Object otz = TimeZones.setThreadLocal(tz); //date format info final DateFormatInfo dfinfo = getDateFormatInfo(hsess); final Object odi = DateFormats.setLocalFormatInfo(dfinfo); request.setAttribute(ATTR_SETUP, Boolean.TRUE); //mark as setup old = new Object[] { ol, otz, odi }; } if (sess instanceof Session) SessionsCtrl.setCurrent((Session) sess); return old; }