Example usage for org.springframework.security.web.session HttpSessionCreatedEvent HttpSessionCreatedEvent

List of usage examples for org.springframework.security.web.session HttpSessionCreatedEvent HttpSessionCreatedEvent

Introduction

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

Prototype

public HttpSessionCreatedEvent(HttpSession session) 

Source Link

Usage

From source file:com.hazelcast.web.spring.SpringAwareWebFilter.java

@Override
protected HazelcastHttpSession createNewSession(HazelcastRequestWrapper requestWrapper,
        String existingSessionId) {
    HazelcastHttpSession session = super.createNewSession(requestWrapper, existingSessionId);
    ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
    if (appContext != null) {
        ensureSessionRegistryInitialized(appContext);
        if (sessionRegistry != null) {
            String originalSessionId = session.getOriginalSessionId();
            // If original session id is registered already, we don't need it.
            // So, we should remove it.
            sessionRegistry.removeSessionInformation(originalSessionId);
            // Publish event if this session is not registered
            if (!isSessionRegistered(session.getId())) {
                /**/* ww w. ja  va  2s.  co  m*/
                 * Publish an event to notify
                 * {@link org.springframework.security.core.session.SessionRegistry} instance.
                 * So Spring knows our Hazelcast session.
                 *
                 * If session is already exist
                 *      (
                 *          possibly added by
                 *          {@link org.springframework.security.web.session.HttpSessionEventPublisher} instance
                 *          which is defined in {@code web.xml} before
                 *          {@link com.hazelcast.web.SessionListener} to
                 *          {@link org.springframework.security.core.session.SessionRegistry}
                 *      ),
                 * it will be just updated.
                 */
                appContext.publishEvent(new HttpSessionCreatedEvent(session));

                LOGGER.finest(
                        "Published create session event for Spring for session with id " + session.getId());
            }
        }
    }
    return session;
}

From source file:org.springframework.security.web.session.HttpSessionEventPublisher.java

/**
 * Handles the HttpSessionEvent by publishing a {@link HttpSessionCreatedEvent} to the
 * application appContext.//from w ww.ja v  a  2  s.  co m
 *
 * @param event HttpSessionEvent passed in by the container
 */
public void sessionCreated(HttpSessionEvent event) {
    HttpSessionCreatedEvent e = new HttpSessionCreatedEvent(event.getSession());
    Log log = LogFactory.getLog(LOGGER_NAME);

    if (log.isDebugEnabled()) {
        log.debug("Publishing event: " + e);
    }

    getContext(event.getSession().getServletContext()).publishEvent(e);
}