@Override public void sessionDestroy(SessionDestroyEvent event) { VaadinRequest request = VaadinService.getCurrentRequest(); HttpServletRequest httpRequest = request != null ? ((VaadinServletRequest) request).getHttpServletRequest() : null; getSecurityManager() .logout( new AuthorizationRequest( null, httpRequest, httpRequest != null ? httpRequest.getSession() : null)); }
/* (non-Javadoc) * @see com.mapping.configuration.ui.action.Action#exectuteAction() */ @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.loginButton, 2, 0); layout.addComponent(this.setupButton, 3, 0); layout.setComponentAlignment(this.setupButton, Alignment.MIDDLE_RIGHT); layout.setComponentAlignment(this.loginButton, 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"); }
void loadCookies() { Cookie[] cookies = VaadinService.getCurrentRequest().getCookies(); for (Cookie cookie : cookies) { if ("userLogin".equals(cookie.getName()) && cookie.getValue().isEmpty() == false) { this.userLogin = cookie.getValue(); } else if ("userPass".equals(cookie.getName()) && cookie.getValue().isEmpty() == false) { this.userPass = cookie.getValue(); } else if ("userId".equals(cookie.getName()) && cookie.getValue().isEmpty() == false) { this.userId = Integer.parseInt(cookie.getValue()); } } if (this.userId > 0 && this.userLogin.isEmpty() == false && this.userPass.isEmpty() == false) { this.logged = true; } }
@Override public void run(AtmosphereResource resource, UI ui) throws IOException { AtmosphereRequest req = resource.getRequest(); AtmospherePushConnection connection = getConnectionForUI(ui); assert connection != null : "Got push from the client " + "even though the connection does not seem to be " + "valid. This might happen if a HttpSession is " + "serialized and deserialized while the push " + "connection is kept open or if the UI has a " + "connection of unexpected type."; Reader reader = connection.receiveMessage(req.getReader()); if (reader == null) { // The whole message was not yet received return; } // Should be set up by caller VaadinRequest vaadinRequest = VaadinService.getCurrentRequest(); assert vaadinRequest != null; try { new ServerRpcHandler().handleRpc(ui, reader, vaadinRequest); connection.push(false); } catch (JSONException e) { getLogger().log(Level.SEVERE, "Error writing JSON to response", e); // Refresh on client side sendRefreshAndDisconnect(resource); } catch (InvalidUIDLSecurityKeyException e) { getLogger() .log( Level.WARNING, "Invalid security key received from {0}", resource.getRequest().getRemoteHost()); // Refresh on client side sendRefreshAndDisconnect(resource); } }