Example usage for com.vaadin.server VaadinSession unlock

List of usage examples for com.vaadin.server VaadinSession unlock

Introduction

In this page you can find the example usage for com.vaadin.server VaadinSession unlock.

Prototype

public void unlock() 

Source Link

Document

Unlocks this session.

Usage

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;
    if (wrappedSession != null) {
        session = VaadinSession.getForSession(request.getService(), wrappedSession);
    }//from w ww . ja v a2  s .  c om

    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.internal.SecurityContextVaadinRequestListener.java

License:Apache License

@Override
public void onRequestEnd(VaadinRequest request, VaadinResponse response, VaadinSession session) {
    try {//from   ww  w  .j a va2s.  co  m
        if (session != null) {
            SecurityContext securityContext = SecurityContextHolder.getContext();
            logger.debug("Storing security context {} in VaadinSession {}", securityContext, session);
            session.lock();
            try {
                session.setAttribute(SECURITY_CONTEXT_SESSION_ATTRIBUTE, securityContext);
            } finally {
                session.unlock();
            }
        } else {
            logger.debug("No VaadinSession available for storing the security context");
        }
    } finally {
        logger.debug("Clearing security context");
        SecurityContextHolder.clearContext();
    }
}

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;
    if (wrappedSession != null) {
        session = VaadinSession.getForSession(request.getService(), wrappedSession);
    }//from ww  w  . j  a v a2  s.  com

    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");
    }
}

From source file:org.vaadin.spring.security.managed.SecurityContextVaadinRequestListener.java

License:Apache License

@Override
public void onRequestEnd(VaadinRequest request, VaadinResponse response, VaadinSession session) {
    try {// ww  w.j av  a 2 s  .  c  om
        if (session != null) {
            SecurityContext securityContext = SecurityContextHolder.getContext();
            logger.trace("Storing security context {} in VaadinSession {}", securityContext, session);
            session.lock();
            try {
                session.setAttribute(SECURITY_CONTEXT_SESSION_ATTRIBUTE, securityContext);
            } finally {
                session.unlock();
            }
        } else {
            logger.trace("No VaadinSession available for storing the security context");
        }
    } finally {
        logger.trace("Clearing security context");
        SecurityContextHolder.clearContext();
    }
}