/** * 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()); }
Map<String, Object> attrs = new HashMap<>(attributeNames.size() * 2); for (String name : attributeNames) { Object value = oldSession.getAttribute(name); if (value instanceof VaadinSession) {
/** * Gets the lock instance used to lock the VaadinSession associated with the * given wrapped session. * <p> * This method uses the wrapped session instead of VaadinSession to be able * to lock even before the VaadinSession has been initialized. * </p> * * @param wrappedSession * The wrapped session * @return A lock instance used for locking access to the wrapped session */ protected Lock getSessionLock(WrappedSession wrappedSession) { Object lock = wrappedSession.getAttribute(getLockAttributeName()); if (lock instanceof ReentrantLock) { return (ReentrantLock) lock; } if (lock == null) { return null; } throw new RuntimeException( "Something else than a ReentrantLock was stored in the " + getLockAttributeName() + " in the session"); }
@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; }
/** * 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); }
wrappedSession.getAttribute(getLockAttributeName()); } catch (IllegalStateException e) { lock.unlock();
@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 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); }
/** * 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); } }
@Override protected void init(VaadinRequest request) { ReplayEvent replayEvent = (ReplayEvent)VaadinService.getCurrentRequest().getWrappedSession().getAttribute("replayEvent"); ReplayService replayService = (ReplayService)VaadinService.getCurrentRequest().getWrappedSession().getAttribute("replayService"); PlatformConfigurationService platformConfigurationService = (PlatformConfigurationService)VaadinService.getCurrentRequest().getWrappedSession().getAttribute("platformConfigurationService"); TopologyService topologyService = (TopologyService)VaadinService.getCurrentRequest().getWrappedSession().getAttribute("topologyService"); ReplayEventViewPanel panel = new ReplayEventViewPanel(replayEvent, replayService, platformConfigurationService, topologyService); this.setContent(panel); }
@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; } }
@Override protected void init(VaadinRequest request) { String errorUri = request.getParameter("errorUri"); ErrorReportingService errorReportingService = (ErrorReportingService)VaadinService.getCurrentRequest().getWrappedSession().getAttribute("errorReportService"); ErrorReportingManagementService errorReportingManagementService = (ErrorReportingManagementService)VaadinService.getCurrentRequest().getWrappedSession().getAttribute("errorReportManagementService"); ActionedErrorOccurrenceViewPanel panel = new ActionedErrorOccurrenceViewPanel(errorUri, errorReportingManagementService, errorReportingService); this.setContent(panel); }
public static ZoneId extractUserTimeZoneIdOrNull(){ if(VaadinSession.getCurrent() != null && VaadinSession.getCurrent().getSession() !=null){ return (ZoneId) VaadinSession.getCurrent().getSession().getAttribute(CentralizedDateTimeFormat.SESSION_PROPERTY_TIMEZONE_ID); } return null; } }
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 access this page!", Type.ERROR_MESSAGE); } } });
public static ZoneId extractUserTimeZoneIdOrNull(final UI ui) { // Verify if a ui is provided, still attached and has a session if (ui != null && ui.isAttached() && ui.getSession() != null && ui.getSession().getSession() != null) { // Only the wrapped session has the attribute set, the VaadinSession does not! return (ZoneId) ui.getSession().getSession().getAttribute(CentralizedDateTimeFormat.SESSION_PROPERTY_TIMEZONE_ID); } return null; } }
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()); } });