Package org.openhab.core.auth
Class UserSession
java.lang.Object
org.openhab.core.auth.UserSession
A persistent session for a
ManagedUser
, which holds a refresh token used by a client to get short-lived
access tokens for API requests authorization.- Author:
- Yannick Schaus - initial contribution
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets the ID of the client this session was created forGets the creation time of the session.Gets the time when the refresh token was last used to get a new access token.Gets the redirect URI which was used to perform the authorization flow.Gets the refresh token for the session.getScope()
Gets the scope requested when authorizing this session.Gets the ID of the session.boolean
Specifies whether this session is supported by a session cookie, to mitigate the impact of refresh token leakage.void
setLastRefreshTime
(Date lastRefreshTime) Sets the time when the refresh token was last used to get a new access token.void
setSessionCookie
(boolean sessionCookie) Sets the session cookie flag for this session.
-
Constructor Details
-
UserSession
public UserSession(String sessionId, String refreshToken, String clientId, String redirectUri, String scope) Constructs a new session.- Parameters:
sessionId
- a unique ID for the sessionrefreshToken
- the refresh token associated to the sessionclientId
- the client ID associated to the sessionredirectUri
- the callback URI provided when the client was authorized by the userscope
- the granted scope provided when the client was authorized by the user
-
-
Method Details
-
getSessionId
Gets the ID of the session.- Returns:
- the session ID
-
getRefreshToken
Gets the refresh token for the session.- Returns:
- the refresh token
-
getCreatedTime
Gets the creation time of the session.- Returns:
- the creation time
-
getLastRefreshTime
Gets the time when the refresh token was last used to get a new access token.- Returns:
- the last refresh time
-
setLastRefreshTime
Sets the time when the refresh token was last used to get a new access token.- Parameters:
lastRefreshTime
- the last refresh time
-
getScope
Gets the scope requested when authorizing this session.- Returns:
- the session scope
-
getClientId
Gets the ID of the client this session was created for- Returns:
- the client ID
-
getRedirectUri
Gets the redirect URI which was used to perform the authorization flow.- Returns:
- the redirect URI
-
hasSessionCookie
public boolean hasSessionCookie()Specifies whether this session is supported by a session cookie, to mitigate the impact of refresh token leakage.- Returns:
- whether or not a cookie has been set
-
setSessionCookie
public void setSessionCookie(boolean sessionCookie) Sets the session cookie flag for this session.- Parameters:
sessionCookie
- the cookie flag
-