List of usage examples for com.vaadin.server VaadinSession getForSession
@Deprecated public static VaadinSession getForSession(VaadinService service, WrappedSession underlyingSession)
From source file:org.vaadin.spring.security.internal.SecurityContextVaadinRequestListener.java
License:Apache License
@Override public void onRequestStart(VaadinRequest request, VaadinResponse response) { final WrappedSession wrappedSession = request.getWrappedSession(false); VaadinSession session = null;/*from w w w .j a v a 2 s . c om*/ if (wrappedSession != null) { session = VaadinSession.getForSession(request.getService(), wrappedSession); } SecurityContextHolder.clearContext(); if (session != null) { logger.debug("Loading security context from VaadinSession {}", session); SecurityContext securityContext; session.lock(); try { securityContext = (SecurityContext) session.getAttribute(SECURITY_CONTEXT_SESSION_ATTRIBUTE); } finally { session.unlock(); } if (securityContext == null) { logger.debug("No security context found in VaadinSession {}", session); } else { logger.debug("Setting security context to {}", securityContext); SecurityContextHolder.setContext(securityContext); } } else { logger.debug("No VaadinSession available for retrieving the security context"); } }
From source file:org.vaadin.spring.security.managed.SecurityContextVaadinRequestListener.java
License:Apache License
@Override public void onRequestStart(VaadinRequest request, VaadinResponse response) { final WrappedSession wrappedSession = request.getWrappedSession(false); VaadinSession session = null;/*from w w w . j a va 2 s.c o m*/ if (wrappedSession != null) { session = VaadinSession.getForSession(request.getService(), wrappedSession); } SecurityContextHolder.clearContext(); if (session != null) { logger.trace("Loading security context from VaadinSession {}", session); SecurityContext securityContext; session.lock(); try { securityContext = (SecurityContext) session.getAttribute(SECURITY_CONTEXT_SESSION_ATTRIBUTE); } finally { session.unlock(); } if (securityContext == null) { logger.trace("No security context found in VaadinSession {}", session); } else { logger.trace("Setting security context to {}", securityContext); SecurityContextHolder.setContext(securityContext); } } else { logger.trace("No VaadinSession available for retrieving the security context"); } }