VaadinSession implements HttpSessionBindingListener, Serializable { public String getCsrfToken() { return csrfToken; } VaadinSession(VaadinService service); @Override void valueBound(HttpSessionBindingEvent arg0); @Override void valueUnbound(HttpSessionBindingEvent event); WebBrowser getBrowser(); long getCumulativeRequestDuration(); void setLastRequestDuration(long time); long getLastRequestDuration(); void setLastRequestTimestamp(long timestamp); long getLastRequestTimestamp(); WrappedSession getSession(); static Collection<VaadinSession> getAllSessions(
            HttpSession httpSession); void setConfiguration(DeploymentConfiguration configuration); DeploymentConfiguration getConfiguration(); Locale getLocale(); void setLocale(Locale locale); ErrorHandler getErrorHandler(); void setErrorHandler(ErrorHandler errorHandler); void addRequestHandler(RequestHandler handler); void removeRequestHandler(RequestHandler handler); Collection<RequestHandler> getRequestHandlers(); static VaadinSession getCurrent(); static void setCurrent(VaadinSession session); Collection<UI> getUIs(); UI getUIById(int uiId); boolean hasLock(); void checkHasLock(String message); void checkHasLock(); void removeUI(UI ui); Lock getLockInstance(); void lock(); void unlock(); void setAttribute(String name, Object value); void setAttribute(Class<T> type, T value); Object getAttribute(String name); T getAttribute(Class<T> type); int getNextUIid(); void addUI(UI ui); VaadinService getService(); void close(); VaadinSessionState getState(); void accessSynchronously(Command command); Future<Void> access(Command command); Queue<FutureAccess> getPendingAccessQueue(); String getPushId(); void refreshTransients(WrappedSession wrappedSession,
            VaadinService vaadinService); StreamResourceRegistry getResourceRegistry(); String getCsrfToken(); @Deprecated
    static final String UI_PARAMETER; }
@Test public void csrfToken_different_sessions_shouldBeUnique() { String token1 = new VaadinSession(mockService).getCsrfToken(); String token2 = new VaadinSession(mockService).getCsrfToken(); Assert.assertNotEquals("Each session should have a unique CSRF token", token1, token2); }
@Test public void csrfToken_same_session_shouldBeSame() { VaadinSession vaadinSession = new VaadinSession(mockService); String token1 = vaadinSession.getCsrfToken(); String token2 = vaadinSession.getCsrfToken(); Assert.assertEquals( "getCsrfToken() should always return the same value for the same session", token1, token2); }