org.keycloak.adapters.undertow

## Class UndertowUserSessionManagement

- java.lang.Object
- - org.keycloak.adapters.undertow.UndertowUserSessionManagement

- All Implemented Interfaces:
    io.undertow.server.session.SessionListener

      public class UndertowUserSessionManagement
      extends Object
      implements io.undertow.server.session.SessionListener

  Manages relationship to users and sessions so that forced admin logout can be implemented
  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `UndertowUserSessionManagement.UserSessions`

    - ### Nested classes/interfaces inherited from interface io.undertow.server.session.SessionListener

      `io.undertow.server.session.SessionListener.SessionDestroyedReason`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ConcurrentHashMap<String,UndertowUserSessionManagement.UserSessions>` | `keycloakSessionMap`
    `protected boolean` | `registered`
    `protected ConcurrentHashMap<String,UndertowUserSessionManagement.UserSessions>` | `userSessionMap`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `UndertowUserSessionManagement()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `attributeAdded(io.undertow.server.session.Session session, String name, Object value)`
    `void` | `attributeRemoved(io.undertow.server.session.Session session, String name, Object oldValue)`
    `void` | `attributeUpdated(io.undertow.server.session.Session session, String name, Object newValue, Object oldValue)`
    `int` | `getActiveSessions()`
    `Set<String>` | `getActiveUsers()`
    `Long` | `getUserLoginTime(String username)`
    `protected String` | `getUsernameFromSession(io.undertow.server.session.Session session)`
    `void` | `login(io.undertow.server.session.SessionManager manager, String sessionId, String username, String keycloakSessionId)`
    `void` | `logoutAll(io.undertow.server.session.SessionManager manager)`
    `void` | `logoutKeycloakSession(io.undertow.server.session.SessionManager manager, String keycloakSessionId)`
    `void` | `logoutUser(io.undertow.server.session.SessionManager manager, String user)`
    `void` | `sessionCreated(io.undertow.server.session.Session session, io.undertow.server.HttpServerExchange exchange)`
    `void` | `sessionDestroyed(io.undertow.server.session.Session session, io.undertow.server.HttpServerExchange exchange, io.undertow.server.session.SessionListener.SessionDestroyedReason reason)`
    `void` | `sessionIdChanged(io.undertow.server.session.Session session, String oldSessionId)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### userSessionMap

          protected ConcurrentHashMap<String,UndertowUserSessionManagement.UserSessions> userSessionMap

    - #### keycloakSessionMap

          protected ConcurrentHashMap<String,UndertowUserSessionManagement.UserSessions> keycloakSessionMap

    - #### registered

          protected volatile boolean registered

  - ### Constructor Detail

    - #### UndertowUserSessionManagement

          public UndertowUserSessionManagement()

  - ### Method Detail

    - #### getActiveSessions

          public int getActiveSessions()

    - #### getUserLoginTime

          public Long getUserLoginTime(String username)

      Parameters:
        `username` -
      Returns:
        null if user not logged in

    - #### getActiveUsers

          public Set<String> getActiveUsers()

    - #### login

          public void login(io.undertow.server.session.SessionManager manager,
                   String sessionId,
                   String username,
                   String keycloakSessionId)

    - #### logoutAll

          public void logoutAll(io.undertow.server.session.SessionManager manager)

    - #### logoutUser

          public void logoutUser(io.undertow.server.session.SessionManager manager,
                        String user)

    - #### logoutKeycloakSession

          public void logoutKeycloakSession(io.undertow.server.session.SessionManager manager,
                                   String keycloakSessionId)

    - #### sessionCreated

          public void sessionCreated(io.undertow.server.session.Session session,
                            io.undertow.server.HttpServerExchange exchange)

      Specified by:
        `sessionCreated` in interface `io.undertow.server.session.SessionListener`

    - #### sessionDestroyed

          public void sessionDestroyed(io.undertow.server.session.Session session,
                              io.undertow.server.HttpServerExchange exchange,
                              io.undertow.server.session.SessionListener.SessionDestroyedReason reason)

      Specified by:
        `sessionDestroyed` in interface `io.undertow.server.session.SessionListener`

    - #### getUsernameFromSession

          protected String getUsernameFromSession(io.undertow.server.session.Session session)

    - #### sessionIdChanged

          public void sessionIdChanged(io.undertow.server.session.Session session,
                              String oldSessionId)

      Specified by:
        `sessionIdChanged` in interface `io.undertow.server.session.SessionListener`

    - #### attributeAdded

          public void attributeAdded(io.undertow.server.session.Session session,
                            String name,
                            Object value)

      Specified by:
        `attributeAdded` in interface `io.undertow.server.session.SessionListener`

    - #### attributeUpdated

          public void attributeUpdated(io.undertow.server.session.Session session,
                              String name,
                              Object newValue,
                              Object oldValue)

      Specified by:
        `attributeUpdated` in interface `io.undertow.server.session.SessionListener`

    - #### attributeRemoved

          public void attributeRemoved(io.undertow.server.session.Session session,
                              String name,
                              Object oldValue)

      Specified by:
        `attributeRemoved` in interface `io.undertow.server.session.SessionListener`

Copyright © 2014. All Rights Reserved.