/** * Retrieves the wrapped session for the request. * * @param request * The request for which to retrieve a session * @param requestCanCreateSession * true to create a new session if one currently does not exist * @return The retrieved (or created) wrapped session * @throws SessionExpiredException * If the request is not associated to a session and new session * creation is not allowed */ private WrappedSession getWrappedSession(VaadinRequest request, boolean requestCanCreateSession) throws SessionExpiredException { final WrappedSession session = request .getWrappedSession(requestCanCreateSession); if (session == null) { throw new SessionExpiredException(); } return session; }
/** * Finds the {@link UI} that belongs to the provided request. This is * generally only supported for UIDL requests as other request types are not * related to any particular UI or have the UI information encoded in a * non-standard way. The returned UI is also set as the current UI ( * {@link UI#setCurrent(UI)}). * * @param request * the request for which a UI is desired * @return the UI belonging to the request or null if no UI is found * */ public UI findUI(VaadinRequest request) { // getForSession asserts that the lock is held VaadinSession session = loadSession(request.getWrappedSession()); // Get UI id from the request String uiIdString = request.getParameter(UIConstants.UI_ID_PARAMETER); UI ui = null; if (uiIdString != null && session != null) { int uiId = Integer.parseInt(uiIdString); ui = session.getUIById(uiId); } UI.setCurrent(ui); return ui; }
WrappedSession oldSession = request.getWrappedSession(); WrappedSession newSession = request.getWrappedSession();
boolean requestCanCreateSession) throws SessionExpiredException, ServiceException { assert ((ReentrantLock) getSessionLock(request.getWrappedSession())) .isHeldByCurrentThread() : "Session has not been locked by this thread"; closeSession(session, request.getWrappedSession(false)); return null; } else if (restartApplication) { closeSession(session, request.getWrappedSession(false)); return createAndRegisterSession(request); } else {
/** * Creates and registers a new VaadinSession for this service. Assumes * proper locking has been taken care of by the caller. * * * @param request * The request which triggered session creation. * @return A new VaadinSession instance * @throws ServiceException */ private VaadinSession createAndRegisterSession(VaadinRequest request) throws ServiceException { assert ((ReentrantLock) getSessionLock(request.getWrappedSession())) .isHeldByCurrentThread() : "Session has not been locked by this thread"; VaadinSession session = createVaadinSession(request); VaadinSession.setCurrent(session); storeSession(session, request.getWrappedSession()); // Initial WebBrowser data comes from the request session.getBrowser().updateRequestDetails(request); // Initial locale comes from the request Locale locale = request.getLocale(); session.setLocale(locale); session.setConfiguration(getDeploymentConfiguration()); session.setCommunicationManager( new LegacyCommunicationManager(session)); ServletPortletHelper.initDefaultUIProvider(session, this); onVaadinSessionStarted(request, session); return session; }
public static UserDetails getCurrentUser() { final SecurityContext context = (SecurityContext) VaadinService.getCurrentRequest().getWrappedSession() .getAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY); return (UserDetails) context.getAuthentication().getPrincipal(); }
public static UserDetails getCurrentUser() { final SecurityContext context = (SecurityContext) VaadinService.getCurrentRequest().getWrappedSession() .getAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY); return (UserDetails) context.getAuthentication().getPrincipal(); }
protected boolean isLinkHandlerRequest(VaadinRequest request) { WrappedSession wrappedSession = request.getWrappedSession(); if (wrappedSession == null) { return false; } String action = (String) wrappedSession.getAttribute(LAST_REQUEST_ACTION_ATTR); return webConfig.getLinkHandlerActions().contains(action); }
public void buttonClick(ClickEvent event) { VaadinService.getCurrentRequest().getWrappedSession().setAttribute("replayService", replayService); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("platformConfigurationService", platformConfigurationService); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("topologyService", topologyService); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("replayEvent", (ReplayEvent)replayEvent); } });
public void buttonClick(ClickEvent event) { VaadinService.getCurrentRequest().getWrappedSession().setAttribute("exclusionEvents", getResubmissionEvents()); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("topologyService", topologyService); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("errorReportingService", errorReportingService); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("errorReportingManagementService", errorReportingManagementService); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("exclusionManagementService", exclusionManagementService); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("container", container); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("action", ResubmitIgnoreStatusPanel.IGNORE); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("hospitalService", hospitalService); } });
public void buttonClick(ClickEvent event) { // todo add replay events VaadinService.getCurrentRequest().getWrappedSession().setAttribute("replayEvents", getReplayEvents()); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("replayService", replayService); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("topologyService",topologyService ); VaadinService.getCurrentRequest().getWrappedSession().setAttribute("platformConfigurationService", platformConfigurationService); } });
@SuppressWarnings("unchecked") @Override @Nullable public List<String> getUrls(String selectorId) { VaadinRequest vaadinRequest = VaadinService.getCurrentRequest(); if (vaadinRequest != null) return (List) vaadinRequest.getWrappedSession().getAttribute(getAttributeName(selectorId)); else { HttpSession httpSession = getHttpSession(); return httpSession != null ? (List<String>) httpSession.getAttribute(getAttributeName(selectorId)) : null; } }
/** * Opens the login target for a logged in user.<p> * * @param loginTarget the login target * @param isPublicPC the public PC flag */ public void openLoginTarget(String loginTarget, boolean isPublicPC) { // login was successful, remove login init data from session VaadinService.getCurrentRequest().getWrappedSession().removeAttribute(INIT_DATA_SESSION_ATTR); m_targetOpener.openTarget(loginTarget, isPublicPC); }
@Override public void setUrls(String selectorId, List<String> urls) { VaadinRequest vaadinRequest = VaadinService.getCurrentRequest(); if (vaadinRequest != null) vaadinRequest.getWrappedSession().setAttribute(getAttributeName(selectorId), urls); else { HttpSession httpSession = getHttpSession(); if (httpSession != null) { httpSession.setAttribute(getAttributeName(selectorId), urls); } } }
@Override public PermissionResolverDTO unpackPermissions() { WrappedSession session = VaadinService.getCurrentRequest().getWrappedSession(); String currentUser = (String)session.getAttribute(PermissionManager.USERNAME); @SuppressWarnings("unchecked") Set<String> currentPermissions = (Set<String>)session.getAttribute(PermissionManager.PERMISSIONS); return new PermissionResolverDTO(currentPermissions,currentUser); }
public void windowClose(CloseEvent e) { if((IkasanAuthentication)VaadinService.getCurrentRequest().getWrappedSession() .getAttribute(DashboardSessionValueConstants.USER) == null) { Notification.show("You cannot access this page!", Type.ERROR_MESSAGE); //Redirect the user to the login/default Page Page.getCurrent().setLocation("/ikasan-dashboard"); } } });
public void windowClose(CloseEvent e) { if((IkasanAuthentication)VaadinService.getCurrentRequest().getWrappedSession() .getAttribute(DashboardSessionValueConstants.USER) == null) { UI.getCurrent().getNavigator().navigateTo("landingView"); Notification.show("You cannot view this error!", Type.ERROR_MESSAGE); } } });
public void buttonClick(ClickEvent event) { roleTable.removeItem(role); principal.getRoles().remove(role); securityService.savePrincipal(principal); IkasanAuthentication ikasanAuthentication = (IkasanAuthentication)VaadinService.getCurrentRequest().getWrappedSession() .getAttribute(DashboardSessionValueConstants.USER); String action = "Role " + role.getName() + " removed by " + ikasanAuthentication.getName(); systemEventService.logSystemEvent(SystemEventConstants.DASHBOARD_USER_ROLE_CHANGED_CONSTANTS, action,principal.getName()); } });
@Override public VaadinApplicationContext create(OnmsServiceManager manager) { VaadinApplicationContextImpl context = new VaadinApplicationContextImpl(); context.setSessionId(request.getWrappedSession().getId()); context.setUiId(getUIId()); context.setUsername(request.getRemoteUser()); return context; } });
public void logout(UI ui) { close(); VaadinService.getCurrentRequest().getWrappedSession().invalidate(); ui.close(); String contextPath = VaadinService.getCurrentRequest().getContextPath(); ui.getPage().setLocation(contextPath); }