Example usage for org.springframework.security.web.session HttpSessionDestroyedEvent getSession

List of usage examples for org.springframework.security.web.session HttpSessionDestroyedEvent getSession

Introduction

In this page you can find the example usage for org.springframework.security.web.session HttpSessionDestroyedEvent getSession.

Prototype

public HttpSession getSession() 

Source Link

Usage

From source file:com.safasoft.treeweb.auth.CustomLogoutListener.java

@Override
public void onApplicationEvent(HttpSessionDestroyedEvent e) {
    //set logout time
    HttpSession session = e.getSession();
    if (session != null) {
        Object obj = session.getAttribute("logParentId");
        if (obj != null) {
            int logParentId = (Integer) obj;
            FfLogFocusService flfService = new SessionUtil<FfLogFocusService>()
                    .getAppContext("ffLogFocusService");
            FfLogFocus logFocus = flfService.getById(logParentId);
            DataConverter dc = new DataConverter();
            dc.setConverter(new Date(), "dd-MMM-yyyy kk:mm:ss");
            logFocus.setLogoutTime(dc.getConverter());
            flfService.save(logFocus);//w ww. j  a va2  s .  c  o  m
        }
    }
}

From source file:com.gs.config.SessionExpirationFilter.java

@Override
public void onApplicationEvent(HttpSessionDestroyedEvent event) {
    List<org.springframework.security.core.context.SecurityContext> lstSecurityContext = event
            .getSecurityContexts();//from  w ww  . j  a  v  a2s  . c  o  m
    UserDetails ud;
    for (org.springframework.security.core.context.SecurityContext securityContext : lstSecurityContext) {
        ud = (UserDetails) securityContext.getAuthentication().getPrincipal();
        System.out.println("SESIN DESTRUIDA: " + ud.toString());

        HttpSession httpSession = event.getSession();
        //            long createdTime = httpSession.getCreationTime();
        long lastAccessedTime = httpSession.getLastAccessedTime();
        int maxInactiveTime = httpSession.getMaxInactiveInterval();
        long currentTime = System.currentTimeMillis();

        //            System.out.println("Session Id :"+httpSession.getId() );
        //            System.out.println("Created Time : " + createdTime);
        //            System.out.println("Last Accessed Time : " + lastAccessedTime);
        //            System.out.println("Current Time : " + currentTime);
        boolean possibleSessionTimeout = (currentTime - lastAccessedTime) >= (maxInactiveTime * 1000);
        if (possibleSessionTimeout) {
            //Se realiza la peticin al Node JS
            //                requestNodeJS.sendRequestWithUsernameAndMethod(ud.getUsername(), "/session-close");
        }
        //            System.out.println("Possbile Timeout : " + possibleSessionTimeout);
    }
}

From source file:com.cruz.sec.config.SessionExpirationFilter.java

@Override
public void onApplicationEvent(HttpSessionDestroyedEvent event) {
    List<org.springframework.security.core.context.SecurityContext> lstSecurityContext = event
            .getSecurityContexts();//from www.  j  av a2 s  .  c o m
    UserDetails ud;
    for (org.springframework.security.core.context.SecurityContext securityContext : lstSecurityContext) {
        ud = (UserDetails) securityContext.getAuthentication().getPrincipal();
        System.out.println("OBJECTO SESION DESTRUIDO: " + ud.toString());

        HttpSession httpSession = event.getSession();
        //            long createdTime = httpSession.getCreationTime();
        long lastAccessedTime = httpSession.getLastAccessedTime();
        int maxInactiveTime = httpSession.getMaxInactiveInterval();
        long currentTime = System.currentTimeMillis();

        //            System.out.println("Session Id :"+httpSession.getId() );
        //            System.out.println("Created Time : " + createdTime);
        //            System.out.println("Last Accessed Time : " + lastAccessedTime);
        //            System.out.println("Current Time : " + currentTime);
        boolean possibleSessionTimeout = (currentTime - lastAccessedTime) >= (maxInactiveTime * 1000);
        if (possibleSessionTimeout) {
            System.out.println("SESIN CERRADA POR INACTIVIDAD");
            //Se realiza la peticin al Node JS
            //                requestNodeJS.sendRequestWithUsernameAndMethod(ud.getUsername(), "/session-close");
        }
    }
}

From source file:org.broadleafcommerce.core.web.order.SessionOrderLockManager.java

@Override
public void onApplicationEvent(HttpSessionDestroyedEvent event) {
    ReentrantLock lock = SESSION_LOCKS.remove(event.getSession().getId());
    if (lock != null && LOG.isDebugEnabled()) {
        LOG.debug("Destroyed lock due to session invalidation: " + lock.toString());
    }/*ww w . ja v  a  2 s .c  om*/
}