Class SessionService

java.lang.Object
io.deephaven.server.session.SessionService

@Singleton public class SessionService extends Object
  • Constructor Details

  • Method Details

    • onShutdown

      public void onShutdown()
    • addTerminationListener

      public void addTerminationListener(SessionState session, io.grpc.stub.StreamObserver<TerminationNotificationResponse> responseObserver)
      Add a listener who receives a single notification when this process is exiting and yet able to communicate with the observer.
      Parameters:
      session - the session the observer belongs to
      responseObserver - the observer to notify
    • newSession

      public SessionState newSession(AuthContext authContext)
      Create a new session object for the provided auth context.
      Parameters:
      authContext - the auth context of the session
      Returns:
      a new session independent of all other existing sessions
    • refreshToken

      public SessionService.TokenExpiration refreshToken(SessionState session)
      If enough time has passed since the last token run, rotate to a new token and reset the expiration deadline.
      Parameters:
      session - the session to run
      Returns:
      the most recent token expiration
    • getExpirationDelayMs

      public long getExpirationDelayMs()
      Returns:
      the configured token duration in milliseconds
    • getSessionForAuthToken

      public SessionState getSessionForAuthToken(String token) throws AuthenticationException
      Lookup a session by token. Creates a new session if it's a basic auth and it passes.
      Parameters:
      token - the Authentication header to service
      Returns:
      the session or null if the session is invalid
      Throws:
      AuthenticationException
    • getSessionForToken

      public SessionState getSessionForToken(UUID token)
      Lookup a session by token.
      Parameters:
      token - the session secret to look for
      Returns:
      the session or null if the session is invalid
    • getCurrentSession

      @NotNull public @NotNull SessionState getCurrentSession()
      Lookup a session via the SessionServiceGrpcImpl.SESSION_CONTEXT_KEY. This method is only valid in the context of the original calling gRPC thread.
      Returns:
      the session attached to this gRPC request
      Throws:
      io.grpc.StatusRuntimeException - if thread is not attached to a session or if the session is expired/closed
    • getOptionalSession

      @Nullable public @Nullable SessionState getOptionalSession()
      Lookup a session via the SessionServiceGrpcImpl.SESSION_CONTEXT_KEY. This method is only valid in the context of the original calling gRPC thread.
      Returns:
      the session attached to this gRPC request; null if no session is established
    • closeSession

      public void closeSession(SessionState session)
      Reduces the liveness of the session.
      Parameters:
      session - the session to close
    • closeAllSessions

      public void closeAllSessions()