Package org.apache.gravitino.client
Class OAuth2TokenProvider
java.lang.Object
org.apache.gravitino.client.OAuth2TokenProvider
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
DefaultOAuth2TokenProvider
OAuth2TokenProvider will request the access token from the authorization server and then provide
the access token for every request.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classOAuth2TokenProvider.OAuth2TokenProviderBuilder<SELF extends org.apache.gravitino.client.OAuth2TokenProvider.Builder<SELF,T>, T extends OAuth2TokenProvider> Builder interface for creating instances ofOAuth2TokenProvider. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HTTPClientThe HTTP client used to request the access token from the authorization server. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the OAuth2TokenProvider and releases any underlying resources.protected abstract StringGet the access token from the authorization server.byte[]Acquire the data of token for authentication.booleanJudge whether AuthDataProvider can provide token data.
-
Field Details
-
client
The HTTP client used to request the access token from the authorization server.
-
-
Constructor Details
-
OAuth2TokenProvider
public OAuth2TokenProvider()
-
-
Method Details
-
hasTokenData
public boolean hasTokenData()Judge whether AuthDataProvider can provide token data.- Returns:
- true if the AuthDataProvider can provide token data otherwise false.
-
getTokenData
public byte[] getTokenData()Acquire the data of token for authentication. The client will set the token data as HTTP header Authorization directly. So the return value should ensure token data contain the token header (eg: Bearer, Basic) if necessary.- Returns:
- the token data is used for authentication.
-
close
Closes the OAuth2TokenProvider and releases any underlying resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getAccessToken
Get the access token from the authorization server.- Returns:
- The access token.
-