org.apache.catalina.SessionEvent Java Examples

The following examples show how to use org.apache.catalina.SessionEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SingleSignOnListener.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public void sessionEvent(SessionEvent event) {
    if (!Session.SESSION_DESTROYED_EVENT.equals(event.getType())) {
        return;
    }

    Session session = event.getSession();
    Manager manager = session.getManager();
    if (manager == null) {
        return;
    }
    Context context = manager.getContext();
    Authenticator authenticator = context.getAuthenticator();
    if (!(authenticator instanceof AuthenticatorBase)) {
        return;
    }
    SingleSignOn sso = ((AuthenticatorBase) authenticator).sso;
    if (sso == null) {
        return;
    }
    sso.sessionDestroyed(ssoId, session);
}
 
Example #2
Source File: SingleSignOnListener.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
public void sessionEvent(SessionEvent event) {
    if (!Session.SESSION_DESTROYED_EVENT.equals(event.getType())) {
        return;
    }

    Session session = event.getSession();
    Manager manager = session.getManager();
    if (manager == null) {
        return;
    }
    Context context = (Context) manager.getContainer();
    if (context == null) {
        return;
    }
    Authenticator authenticator = context.getAuthenticator();
    if (!(authenticator instanceof AuthenticatorBase)) {
        return;
    }
    SingleSignOn sso = ((AuthenticatorBase) authenticator).sso;
    if (sso == null) {
        return;
    }
    sso.sessionDestroyed(ssoId, session);
}
 
Example #3
Source File: SingleSignOnListener.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public void sessionEvent(SessionEvent event) {
    if (!Session.SESSION_DESTROYED_EVENT.equals(event.getType())) {
        return;
    }

    Session session = event.getSession();
    Manager manager = session.getManager();
    if (manager == null) {
        return;
    }
    Context context = (Context) manager.getContainer();
    Authenticator authenticator = context.getAuthenticator();
    if (!(authenticator instanceof AuthenticatorBase)) {
        return;
    }
    SingleSignOn sso = ((AuthenticatorBase) authenticator).sso;
    if (sso == null) {
        return;
    }
    sso.sessionDestroyed(ssoId, session);
}
 
Example #4
Source File: RedissonSessionManager.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Override
public Session createSession(String sessionId) {
    Session session = super.createSession(sessionId);
    
    if (broadcastSessionEvents) {
        getTopic().publish(new SessionCreatedMessage(getNodeId(), session.getId()));
        session.addSessionListener(new SessionListener() {
            @Override
            public void sessionEvent(SessionEvent event) {
                if (event.getType() == Session.SESSION_DESTROYED_EVENT) {
                    getTopic().publish(new SessionDestroyedMessage(getNodeId(), session.getId()));
                }
            }
        });
    }
    return session;
}
 
Example #5
Source File: RedissonSessionManager.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Override
public Session createSession(String sessionId) {
    Session session = super.createSession(sessionId);
    
    if (broadcastSessionEvents) {
        getTopic().publish(new SessionCreatedMessage(getNodeId(), session.getId()));
        session.addSessionListener(new SessionListener() {
            @Override
            public void sessionEvent(SessionEvent event) {
                if (event.getType() == Session.SESSION_DESTROYED_EVENT) {
                    getTopic().publish(new SessionDestroyedMessage(getNodeId(), session.getId()));
                }
            }
        });
    }
    return session;
}
 
Example #6
Source File: RedissonSessionManager.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Override
public Session createSession(String sessionId) {
    Session session = super.createSession(sessionId);
    
    if (broadcastSessionEvents) {
        getTopic().publish(new SessionCreatedMessage(getNodeId(), session.getId()));
        session.addSessionListener(new SessionListener() {
            @Override
            public void sessionEvent(SessionEvent event) {
                if (event.getType() == Session.SESSION_DESTROYED_EVENT) {
                    getTopic().publish(new SessionDestroyedMessage(getNodeId(), session.getId()));
                }
            }
        });
    }
    return session;
}
 
Example #7
Source File: StandardSession.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Notify all session event listeners that a particular event has
 * occurred for this Session.  The default implementation performs
 * this notification synchronously using the calling thread.
 *
 * @param type Event type
 * @param data Event data
 */
public void fireSessionEvent(String type, Object data) {
    if (listeners.size() < 1)
        return;
    SessionEvent event = new SessionEvent(this, type, data);
    SessionListener list[] = new SessionListener[0];
    synchronized (listeners) {
        list = listeners.toArray(list);
    }

    for (int i = 0; i < list.length; i++){
        (list[i]).sessionEvent(event);
    }

}
 
Example #8
Source File: StandardSession.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Notify all session event listeners that a particular event has
 * occurred for this Session.  The default implementation performs
 * this notification synchronously using the calling thread.
 *
 * @param type Event type
 * @param data Event data
 */
public void fireSessionEvent(String type, Object data) {
    if (listeners.size() < 1)
        return;
    SessionEvent event = new SessionEvent(this, type, data);
    SessionListener list[] = new SessionListener[0];
    synchronized (listeners) {
        list = listeners.toArray(list);
    }

    for (int i = 0; i < list.length; i++){
        (list[i]).sessionEvent(event);
    }

}
 
Example #9
Source File: StandardSession.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Notify all session event listeners that a particular event has
 * occurred for this Session.  The default implementation performs
 * this notification synchronously using the calling thread.
 *
 * @param type Event type
 * @param data Event data
 */
public void fireSessionEvent(String type, Object data) {
    if (listeners.size() < 1)
        return;
    SessionEvent event = new SessionEvent(this, type, data);
    SessionListener list[] = new SessionListener[0];
    synchronized (listeners) {
        list = listeners.toArray(list);
    }

    for (int i = 0; i < list.length; i++){
        (list[i]).sessionEvent(event);
    }

}
 
Example #10
Source File: CatalinaUserSessionManagement.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public void sessionEvent(SessionEvent event) {
    // We only care about session destroyed events
    if (!Session.SESSION_DESTROYED_EVENT.equals(event.getType()))
        return;

    // Look up the single session id associated with this session (if any)
    Session session = event.getSession();
    log.debugf("Session %s destroyed", session.getId());

    GenericPrincipal principal = (GenericPrincipal) session.getPrincipal();
    if (principal == null) return;
    session.setPrincipal(null);
    session.setAuthType(null);
}