List of usage examples for com.vaadin.server VaadinRequest getWrappedSession
public WrappedSession getWrappedSession(boolean allowSessionCreation);
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;/* ww w . j av a2 s .com*/ 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;//ww w . j a v a 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"); } }