Package org.apache.iceberg.rest.auth
Class OAuth2Util.AuthSession
java.lang.Object
org.apache.iceberg.rest.auth.OAuth2Util.AuthSession
- All Implemented Interfaces:
AutoCloseable
,AuthSession
- Enclosing class:
- OAuth2Util
Class to handle authorization headers and token refresh.
-
Field Summary
Fields inherited from interface org.apache.iceberg.rest.auth.AuthSession
EMPTY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionauthenticate
(HTTPRequest request) Authenticates the given request and returns a new request with the necessary authentication.void
close()
Closes the session and releases any resources.config()
static OAuth2Util.AuthSession
empty()
A newOAuth2Util.AuthSession
with empty headers.static OAuth2Util.AuthSession
fromAccessToken
(RESTClient client, ScheduledExecutorService executor, String token, Long defaultExpiresAtMillis, OAuth2Util.AuthSession parent) static OAuth2Util.AuthSession
fromCredential
(RESTClient client, ScheduledExecutorService executor, String credential, OAuth2Util.AuthSession parent) static OAuth2Util.AuthSession
fromTokenExchange
(RESTClient client, ScheduledExecutorService executor, String token, String tokenType, OAuth2Util.AuthSession parent) static OAuth2Util.AuthSession
fromTokenResponse
(RESTClient client, ScheduledExecutorService executor, OAuthTokenResponse response, long startTimeMillis, OAuth2Util.AuthSession parent) headers()
refresh
(RESTClient client) Attempt to refresh the session token using the token exchange flow.scope()
void
token()
-
Constructor Details
-
AuthSession
-
-
Method Details
-
authenticate
Description copied from interface:AuthSession
Authenticates the given request and returns a new request with the necessary authentication.- Specified by:
authenticate
in interfaceAuthSession
-
headers
-
token
-
tokenType
-
expiresAtMillis
-
scope
-
stopRefreshing
public void stopRefreshing() -
close
public void close()Description copied from interface:AuthSession
Closes the session and releases any resources. This method is called when the session is no longer needed. Note that since sessions may be cached, this method may not be called immediately after the session is no longer needed, but rather when the session is evicted from the cache, or the cache itself is closed.- Specified by:
close
in interfaceAuthSession
- Specified by:
close
in interfaceAutoCloseable
-
credential
-
oauth2ServerUri
-
optionalOAuthParams
-
config
-
empty
A newOAuth2Util.AuthSession
with empty headers.- Returns:
- A new
OAuth2Util.AuthSession
with empty headers.
-
refresh
Attempt to refresh the session token using the token exchange flow.- Parameters:
client
- a RESTClient- Returns:
- interval to wait before calling refresh again, or null if no refresh is needed
-
fromAccessToken
public static OAuth2Util.AuthSession fromAccessToken(RESTClient client, ScheduledExecutorService executor, String token, Long defaultExpiresAtMillis, OAuth2Util.AuthSession parent) -
fromCredential
public static OAuth2Util.AuthSession fromCredential(RESTClient client, ScheduledExecutorService executor, String credential, OAuth2Util.AuthSession parent) -
fromTokenResponse
public static OAuth2Util.AuthSession fromTokenResponse(RESTClient client, ScheduledExecutorService executor, OAuthTokenResponse response, long startTimeMillis, OAuth2Util.AuthSession parent) -
fromTokenExchange
public static OAuth2Util.AuthSession fromTokenExchange(RESTClient client, ScheduledExecutorService executor, String token, String tokenType, OAuth2Util.AuthSession parent)
-