Package io.deephaven.server.session
Class SessionService
java.lang.Object
io.deephaven.server.session.SessionService
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Implementations of error transformer give the server one last chance to convert errors to useful messages before responding to gRPC users.static class
static final class
-
Constructor Summary
ConstructorDescriptionSessionService
(Scheduler scheduler, SessionState.Factory sessionFactory, long tokenExpireMs, Map<String, AuthenticationRequestHandler> authRequestHandlers, Set<SessionListener> sessionListeners) -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.void
void
closeSession
(SessionState session) Reduces the liveness of the session.@NotNull SessionState
Lookup a session via the SessionServiceGrpcImpl.SESSION_CONTEXT_KEY.long
@Nullable SessionState
Lookup a session via the SessionServiceGrpcImpl.SESSION_CONTEXT_KEY.getSessionForAuthToken
(String token) Lookup a session by token.getSessionForToken
(UUID token) Lookup a session by token.newSession
(AuthContext authContext) Create a new session object for the provided auth context.void
refreshToken
(SessionState session) If enough time has passed since the last token run, rotate to a new token and reset the expiration deadline.
-
Constructor Details
-
SessionService
@Inject public SessionService(Scheduler scheduler, SessionState.Factory sessionFactory, @Named("session.tokenExpireMs") long tokenExpireMs, Map<String, AuthenticationRequestHandler> authRequestHandlers, Set<SessionListener> sessionListeners)
-
-
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 toresponseObserver
- the observer to notify
-
newSession
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
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
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
Lookup a session by token.- Parameters:
token
- the session secret to look for- Returns:
- the session or null if the session is invalid
-
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
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
Reduces the liveness of the session.- Parameters:
session
- the session to close
-
closeAllSessions
public void closeAllSessions()
-