/** * Closes those UIs in the given session for which {@link #isUIActive} * yields false. * * @since 7.0.0 */ private void closeInactiveUIs(VaadinSession session) { final String sessionId = session.getSession().getId(); for (final UI ui : session.getUIs()) { if (!isUIActive(ui) && !ui.isClosing()) { ui.accessSynchronously(() -> { getLogger().log(Level.FINE, "Closing inactive UI #{0} in session {1}", new Object[] { ui.getUIId(), sessionId }); ui.close(); }); } } }
/** * Performs the actual read of the VaadinSession from the underlying HTTP * session after sanity checks have been performed. * <p> * Called by {@link #loadSession(WrappedSession)}. * * @param wrappedSession * the underlying HTTP session * @since 7.6 * @return the VaadinSession or null if no session was found */ protected VaadinSession readFromHttpSession(WrappedSession wrappedSession) { return (VaadinSession) wrappedSession .getAttribute(getSessionAttributeName()); }
/** * Associates the given lock with this service and the given wrapped * session. This method should not be called more than once when the lock is * initialized for the session. * * @see #getSessionLock(WrappedSession) * @param wrappedSession * The wrapped session the lock is associated with * @param lock * The lock object */ private void setSessionLock(WrappedSession wrappedSession, Lock lock) { if (wrappedSession == null) { throw new IllegalArgumentException( "Can't set a lock for a null session"); } Object currentSessionLock = wrappedSession .getAttribute(getLockAttributeName()); assert (currentSessionLock == null || currentSessionLock == lock) : "Changing the lock for a session is not allowed"; wrappedSession.setAttribute(getLockAttributeName(), lock); }
Set<String> attributeNames = oldSession.getAttributeNames(); Map<String, Object> attrs = new HashMap<>(attributeNames.size() * 2); for (String name : attributeNames) { Object value = oldSession.getAttribute(name); if (value instanceof VaadinSession) { oldSession.invalidate(); newSession.setAttribute(name, value);
@Override public Collection<Object> values() { LinkedList<Object> out = new LinkedList<>(); for (String name : instance.getAttributeNames()) { out.add(instance.getAttribute(name)); } return out; }
/** * Performs the actual write of the VaadinSession to the underlying HTTP * session after sanity checks have been performed. * <p> * Called by {@link #storeSession(VaadinSession, WrappedSession)} * * @since 7.6 * @param wrappedSession * the underlying HTTP session * @param session * the VaadinSession to store */ protected void writeToHttpSession(WrappedSession wrappedSession, VaadinSession session) { wrappedSession.setAttribute(getSessionAttributeName(), session); }
attributesToSpare.add(serviceName + ".lock"); attributesToSpare.add(VaadinSession.class.getName() + "." + serviceName); for (String s : currentRequest.getWrappedSession().getAttributeNames()) { if (!attributesToSpare.contains(s)) { LOGGER.trace("Removing attribute {} from session", s); session.removeAttribute(s); LOGGER.debug("Reinitializing the session {}", session.getId()); VaadinService.reinitializeSession(currentRequest); LOGGER.debug("Session reinitialized, new ID is {}", VaadinService.getCurrentRequest().getWrappedSession().getId()); } else { LOGGER
@Override public void exectuteAction() { IkasanAuthentication ikasanAuthentication = (IkasanAuthentication)VaadinService.getCurrentRequest().getWrappedSession() .getAttribute(DashboardSessionValueConstants.USER); VaadinService.getCurrentRequest().getWrappedSession() .setAttribute(DashboardSessionValueConstants.USER, null); this.visibilityGroup.setVisible(); this.editableGroup.setEditable(false); layout.removeComponent(this.logOutButton); layout.addComponent(this.setupButton, 3, 0); layout.setComponentAlignment(this.setupButton, Alignment.MIDDLE_RIGHT); this.layout.removeComponent(userLabel); VaadinSession vSession = VaadinSession.getCurrent(); WrappedSession httpSession = vSession.getSession(); this.navigationPanel.reset(); //Invalidate HttpSession httpSession.invalidate(); vSession.close(); systemEventService.logSystemEvent(SystemEventConstants.DASHBOARD_LOGOUT_CONSTANTS, "User logging out: " + ikasanAuthentication.getName(), ikasanAuthentication.getName()); //Redirect the user to the login/default Page Page.getCurrent().setLocation("/ikasan-dashboard"); }
/** * Reads the error attributes from current session.<p> */ private void readErrorAttributes() { WrappedSession session = getSession().getSession(); m_requestedPage = (String)session.getAttribute(PATH); m_throwable = (Throwable)session.getAttribute(THROWABLE); // remove the attributes after read to keep the session clean session.removeAttribute(THROWABLE); session.removeAttribute(PATH); } }
public static void setUser(AnnisUser user) { if (user == null) { VaadinSession.getCurrent().getSession().removeAttribute( AnnisBaseUI.USER_KEY); } else { VaadinSession.getCurrent().getSession().setAttribute(AnnisBaseUI.USER_KEY, user); } }
/** * Performs the actual removal of the VaadinSession from the underlying HTTP * session after sanity checks have been performed. * * @since 7.6 * @param wrappedSession * the underlying HTTP session */ protected void removeFromHttpSession(WrappedSession wrappedSession) { wrappedSession.removeAttribute(getSessionAttributeName()); }
/** * Returns the number of seconds that must pass without a valid UIDL request * being received for the given session before the session is closed, even * though heartbeat requests are received. This is a lower bound; it might * take longer to close an inactive session. * <p> * Returns a negative number if there is no timeout. In this case heartbeat * requests suffice to keep the session alive, but it will still eventually * expire in the regular manner if there are no requests at all (see * {@link WrappedSession#getMaxInactiveInterval()}). * * @see DeploymentConfiguration#isCloseIdleSessions() * @see #getHeartbeatTimeout() * * @since 7.0.0 * * @return The UIDL request timeout in seconds, or a negative number if * timeout never occurs. */ private int getUidlRequestTimeout(VaadinSession session) { return getDeploymentConfiguration().isCloseIdleSessions() ? session.getSession().getMaxInactiveInterval() : -1; }
public void logout(UI ui) { close(); VaadinService.getCurrentRequest().getWrappedSession().invalidate(); ui.close(); String contextPath = VaadinService.getCurrentRequest().getContextPath(); ui.getPage().setLocation(contextPath); }
wrappedSession.setMaxInactiveInterval(webConfig.getHttpSessionExpirationTimeoutSec()); httpSession, wrappedSession.getMaxInactiveInterval());
@Override public Set<String> keys() { return instance.getAttributeNames(); }
Set<String> attributeNames = oldSession.getAttributeNames(); HashMap<String, Object> attrs = new HashMap<>( attributeNames.size() * 2); for (String name : attributeNames) { Object value = oldSession.getAttribute(name); if (value instanceof VaadinSession) { oldSession.invalidate(); String name = entry.getKey(); Object value = entry.getValue(); newSession.setAttribute(name, value);
@Override public void setProperty(String key, Object value) { instance.setAttribute(key, value); }
attributesToSpare.add(serviceName + ".lock"); attributesToSpare.add(VaadinSession.class.getName() + "." + serviceName); for (String s : currentRequest.getWrappedSession().getAttributeNames()) { if (!attributesToSpare.contains(s)) { LOGGER.trace("Removing attribute {} from session", s); session.removeAttribute(s); LOGGER.debug("Reinitializing the session {}", session.getId()); VaadinService.reinitializeSession(currentRequest); LOGGER.debug("Session reinitialized, new ID is {}", VaadinService.getCurrentRequest().getWrappedSession().getId()); } else { LOGGER
@Override public Set<java.util.Map.Entry<String, Object>> entrySet() { HashSet<Map.Entry<String, Object>> out = new HashSet<>(); for (String name : instance.getAttributeNames()) { out.add(new MapEntry<String,Object>( name, instance.getAttribute(name)) ); } return out; }
@Override public void removeProperty(String key) { instance.removeAttribute(key); }