Module org.neo4j.driver
Class ExpirationBasedAuthTokenManager
java.lang.Object
org.neo4j.driver.internal.security.ExpirationBasedAuthTokenManager
- All Implemented Interfaces:
AuthTokenManager
-
Constructor Summary
ConstructorDescriptionExpirationBasedAuthTokenManager
(Supplier<CompletionStage<AuthTokenAndExpiration>> freshTokenSupplier, Set<Class<? extends SecurityException>> retryableExceptionClasses, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptiongetToken()
Returns aCompletionStage
for a validAuthToken
.boolean
handleSecurityException
(AuthToken authToken, SecurityException exception) HandlesSecurityException
that is created based on the server's security error response by determining if the given error may be resolved upon nextAuthTokenManager.getToken()
invokation.
-
Constructor Details
-
ExpirationBasedAuthTokenManager
public ExpirationBasedAuthTokenManager(Supplier<CompletionStage<AuthTokenAndExpiration>> freshTokenSupplier, Set<Class<? extends SecurityException>> retryableExceptionClasses, Clock clock)
-
-
Method Details
-
getToken
Description copied from interface:AuthTokenManager
Returns aCompletionStage
for a validAuthToken
.Driver invokes this method often to check if token has changed.
Failures will surface via the driver API, like
Session.beginTransaction()
method and others.- Specified by:
getToken
in interfaceAuthTokenManager
- Returns:
- a stage for a valid token, must not be
null
or complete withnull
- See Also:
-
handleSecurityException
Description copied from interface:AuthTokenManager
HandlesSecurityException
that is created based on the server's security error response by determining if the given error may be resolved upon nextAuthTokenManager.getToken()
invokation.If this method returns
true
, the driver wraps the originalSecurityException
inSecurityRetryableException
. The managed transaction API (likeSession.executeRead(TransactionCallback)
, etc.) automatically retries its unit of work if no other condition is violated, while the other query execution APIs surface this error for external handling.If this method returns
false
, the original error remains unchanged.This method must not throw exceptions.
- Specified by:
handleSecurityException
in interfaceAuthTokenManager
- Parameters:
authToken
- the current tokenexception
- the security exception- Returns:
true
if the exception should be marked as retryable orfalse
if it should remain unchanged
-