Class OAuthAccessTokenProvider
- All Implemented Interfaces:
AuthorizationProvider
An authorization provider that exchanges an application-supplied OAuth access token for a NoSQL login token through an OAuth-enabled proxy. The NoSQL login token is cached and used to authorize subsequent operations.
Applications implement getAccessToken() and remain responsible
for acquiring and maintaining OAuth tokens. By default, this provider calls
that method again and performs a new login shortly before the current NoSQL
login token expires. The server-returned expiration is bounded by both the
validated OAuth token expiration and the configured store session timeout.
Automatic re-login can be disabled with setAutoRenew(boolean).
OAuth access tokens and NoSQL login tokens are bearer credentials, so an HTTPS service endpoint is required.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a provider with automatic re-login enabled. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the provider, releasing resources such as a stored login token.voidInvalidate the cached NoSQL login token.Returns the endpoint of the authenticating entityReturns the logger, or null if not set.booleanReturns whether the login token is to be automatically renewed.setAutoRenew(boolean autoRenew) Sets the auto-renew state.setEndpoint(String endpoint) Sets the endpoint of the authenticating entitySets a Logger instance for this provider.setSslContext(io.netty.handler.ssl.SslContext sslCtx) Sets the SSL contextsetSslHandshakeTimeout(int timeoutMs) Sets the SSL handshake timeout in millisecondsMethods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AuthorizationProvider
forCloud, setRequiredHeaders, validateAuthString
-
Constructor Details
-
OAuthAccessTokenProvider
public OAuthAccessTokenProvider()Creates a provider with automatic re-login enabled.
-
-
Method Details
-
close
public void close()Closes the provider, releasing resources such as a stored login token.- Specified by:
closein interfaceAuthorizationProvider
-
flushCache
public void flushCache()Invalidate the cached NoSQL login token.- Specified by:
flushCachein interfaceAuthorizationProvider
-
getLogger
-
setLogger
Sets a Logger instance for this provider.- Parameters:
logger- the logger- Returns:
- this
-
getEndpoint
-
setEndpoint
Sets the endpoint of the authenticating entity- Parameters:
endpoint- the endpoint- Returns:
- this
- Throws:
IllegalArgumentException- if the endpoint is not correctly formatted
-
setSslContext
Sets the SSL context- Parameters:
sslCtx- the context- Returns:
- this
-
setSslHandshakeTimeout
Sets the SSL handshake timeout in milliseconds- Parameters:
timeoutMs- the timeout in milliseconds- Returns:
- this
-
isAutoRenew
public boolean isAutoRenew()Returns whether the login token is to be automatically renewed.- Returns:
- true if auto-renew is set
-
setAutoRenew
Sets the auto-renew state. If true, automatic renewal of the login token is enabled.- Parameters:
autoRenew- set to true to enable auto-renew- Returns:
- this
-