Example usage for javax.servlet.http HttpSessionBindingEvent getSession

List of usage examples for javax.servlet.http HttpSessionBindingEvent getSession

Introduction

In this page you can find the example usage for javax.servlet.http HttpSessionBindingEvent getSession.

Prototype

@Override
public HttpSession getSession() 

Source Link

Document

Return the session that changed.

Usage

From source file:com.gcrm.security.AuthenticationSuccessListener.java

public void attributeAdded(HttpSessionBindingEvent se) {
    String sessionName = se.getName();
    if (sessionName.equals("SPRING_SECURITY_CONTEXT")) {
        SecurityContext securityContext = (SecurityContext) se.getSession()
                .getAttribute("SPRING_SECURITY_CONTEXT");
        Authentication authentication = securityContext.getAuthentication();
        UserDetailsImpl userDetails = (UserDetailsImpl) authentication.getPrincipal();
        se.getSession().setAttribute(LOGIN_USER, userDetails.getUser());
    }/*w ww .  ja  v  a 2  s .  c o m*/
}

From source file:com.gcrm.security.AuthenticationSuccessListener.java

public void attributeReplaced(HttpSessionBindingEvent se) {
    String sessionName = se.getName();
    if (sessionName.equals("SPRING_SECURITY_CONTEXT")) {
        SecurityContext securityContext = (SecurityContext) se.getSession()
                .getAttribute("SPRING_SECURITY_CONTEXT");
        Authentication authentication = securityContext.getAuthentication();
        UserDetailsImpl userDetails = (UserDetailsImpl) authentication.getPrincipal();
        se.getSession().setAttribute(LOGIN_USER, userDetails.getUser());
    }// w ww.j av  a2  s  .  c  om
}

From source file:org.vaadin.spring.internal.UIStore.java

@Override
public void valueBound(HttpSessionBindingEvent event) {
    logger.debug("UIStore bound to HTTP session [{}]", event.getSession().getId());
}

From source file:org.vaadin.spring.internal.UIStore.java

@Override
public void valueUnbound(HttpSessionBindingEvent event) {
    logger.debug("UIStore unbound from HTTP session [{}]", event.getSession().getId());
}

From source file:com.twinsoft.convertigo.engine.requesters.HttpSessionListener.java

public void valueUnbound(HttpSessionBindingEvent event) {
    try {/* w  w w.jav  a  2 s .  c  o m*/
        Engine.logContext.debug("HTTP session stopping...");
        HttpSession httpSession = event.getSession();
        String httpSessionID = httpSession.getId();

        if (Engine.theApp != null)
            Engine.theApp.contextManager.removeAll(httpSessionID);
        removeSession(httpSessionID);

        Engine.logContext.debug("HTTP session stopped [" + httpSessionID + "]");
    } catch (Exception e) {
        Engine.logContext.error("Exception during unbinding HTTP session listener", e);
    }
}

From source file:com.twinsoft.convertigo.engine.requesters.HttpSessionListener.java

public void valueBound(HttpSessionBindingEvent event) {
    try {/*from  w w  w.j  a v  a 2 s  . c  o  m*/
        Engine.logContext.debug("HTTP session starting...");
        HttpSession httpSession = event.getSession();
        String httpSessionID = httpSession.getId();
        synchronized (httpSessions) {
            httpSessions.put(httpSessionID, httpSession);
        }
        Engine.logContext.debug("HTTP session started [" + httpSessionID + "]");

        if (Engine.isEngineMode()) {
            KeyManager.start(com.twinsoft.api.Session.EmulIDSE);
        }
    } catch (TASException e) {
        if (e.isOverflow()) {
            String line = dateFormat.format(new Date()) + "\t" + e.getCvMax() + "\t" + e.getCvCurrent() + "\n";
            try {
                FileUtils.write(new File(Engine.LOG_PATH + "/Session License exceeded.log"), line, "UTF-8",
                        true);
            } catch (IOException e1) {
                Engine.logContext.error("Failed to write the 'Session License exceeded.log' file", e1);
            }
        } else {
            event.getSession().setAttribute("__exception", e);
            HttpUtils.terminateSession(event.getSession());
        }
    } catch (Exception e) {
        Engine.logContext.error("Exception during binding HTTP session listener", e);
    }
}

From source file:com.github.javaplugs.jsf.ViewScope.java

/**
 * Seems like it called after our listeners was unbounded from http session.
 * Looks like view scope it destroyed. But should we call callback or not is a big question.
 *
 * @see HttpSessionBindingListener for more details
 *//* w  ww.j  a v  a  2s. c  om*/
@Override
public void valueUnbound(HttpSessionBindingEvent event) {
    logger.trace("Session event unbound " + event.getName());
    final Set<ViewScopeViewMapListener> listeners;
    synchronized (sessionToListeners) {
        if (sessionToListeners.containsKey(event.getSession())) {
            listeners = sessionToListeners.get(event.getSession());
            sessionToListeners.remove(event.getSession());
        } else {
            listeners = null;
        }
    }
    if (listeners != null) {
        // I just hope that JSF context already done this job
        for (ViewScopeViewMapListener listener : listeners) {
            // As long as our callbacks can run only once - this is not such big deal
            listener.doCallback();
        }
    }
}

From source file:de.zib.gndms.kit.monitor.GroovyMonitor.java

public synchronized void valueUnbound(HttpSessionBindingEvent event) {
    if (event.getSession() == session) {
        session = null;//from  www.  ja v a2s. c  o  m
        final GroovyMoniServer theSerer = getMoniServer();
        theSerer.getBindingFactory().destroyBinding(theSerer, getShell().getContext());
        runMode = RunMode.CLOSE;
        notifyAll();
    }
}

From source file:de.zib.gndms.kit.monitor.GroovyMonitor.java

public synchronized void valueBound(HttpSessionBindingEvent event) {
    setSession(event.getSession());
}

From source file:com.adito.security.DefaultLogonController.java

public void initialiseSession(HttpSession session, User user) throws UserDatabaseException {
    if (log.isInfoEnabled())
        log.info("Initialising session " + session.getId() + " with user "
                + (user == null ? "[none]" : user.getPrincipalName()));
    PropertyProfile profile = (PropertyProfile) session.getAttribute(Constants.SELECTED_PROFILE);
    session.setAttribute(Constants.USER, user);
    String logonInfo = MessageResources.getMessageResources("com.adito.navigation.ApplicationResources")
            .getMessage("footer.info", user.getPrincipalName(),
                    SimpleDateFormat.getDateTimeInstance().format(new Date()));
    session.setAttribute(Constants.LOGON_INFO, logonInfo);
    try {//  w ww  .j ava  2 s  .c o  m
        List profiles = ResourceUtil.filterResources(user, ProfilesFactory.getInstance()
                .getPropertyProfiles(user.getPrincipalName(), true, user.getRealm().getResourceId()), true);
        session.setAttribute(Constants.PROFILES, profiles);
        if (profiles.size() == 0) {
            throw new UserDatabaseException("You do not have permission to use any profiles.");
        }
        String startupProfile = Property.getProperty(new UserAttributeKey(user, User.USER_STARTUP_PROFILE));
        if (profiles.size() < 2) {
            profile = (PropertyProfile) profiles.get(0);
        } else if (!startupProfile.equals(ProfilesListDataSource.SELECT_ON_LOGIN)) {
            int profileId = Integer.parseInt(startupProfile);
            profile = null;
            for (Iterator i = profiles.iterator(); i.hasNext();) {
                PropertyProfile p = (PropertyProfile) i.next();
                if (profileId == p.getResourceId()) {
                    profile = p;
                    break;
                }
            }
            if (profile == null) {
                profile = ProfilesFactory.getInstance().getPropertyProfile(null, "Default",
                        UserDatabaseManager.getInstance().getDefaultUserDatabase().getRealm().getResourceId());
            }
        }
        if (profile != null) {
            if (log.isInfoEnabled())
                log.info("Switching user " + user.getPrincipalName() + " to profile "
                        + profile.getResourceName());
            session.setAttribute(Constants.SELECTED_PROFILE, profile);
        }
    } catch (Exception e) {
        throw new UserDatabaseException("Failed to initialise profiles.", e);
    }
    final String logonTicket = (String) session.getAttribute(Constants.LOGON_TICKET);
    session.setAttribute(Constants.LOGOFF_HOOK, new HttpSessionBindingListener() {
        public void valueBound(HttpSessionBindingEvent evt) {
        }

        public void valueUnbound(HttpSessionBindingEvent evt) {
            if (log.isDebugEnabled())
                log.debug("Session unbound");
            // We should should only log off completely if no other
            // session has
            // the logon ticket
            SessionInfo currentTicketSessionInfo = ((SessionInfo) logons.get(logonTicket));
            if (currentTicketSessionInfo == null
                    || evt.getSession().getId().equals(currentTicketSessionInfo.getHttpSession().getId())) {
                if (log.isDebugEnabled())
                    log.debug("Session (" + evt.getSession().getId()
                            + ") unbound is the current session for ticket " + logonTicket
                            + " so a logoff will be performed.");
                logoff(logonTicket);
            } else {
                if (log.isDebugEnabled())
                    log.debug("Session unbound is NOT the current session, ignoring.");
            }
        }
    });
    if (log.isDebugEnabled())
        log.debug("Using profile: " + (profile == null ? "DEFAULT" : profile.getResourceName()) + ")");
    session.removeAttribute(Constants.SESSION_LOCKED);

    resetSessionTimeout(user, profile, session);
}