Module org.neo4j.driver
Class ExpirationBasedAuthTokenManager
java.lang.Object
org.neo4j.driver.internal.security.ExpirationBasedAuthTokenManager
- All Implemented Interfaces:
AuthTokenManager
-
Constructor Summary
ConstructorsConstructorDescriptionExpirationBasedAuthTokenManager(Supplier<CompletionStage<AuthTokenAndExpiration>> freshTokenSupplier, Set<Class<? extends SecurityException>> retryableExceptionClasses, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptiongetToken()Returns aCompletionStagefor a validAuthToken.booleanhandleSecurityException(AuthToken authToken, SecurityException exception) HandlesSecurityExceptionthat 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:AuthTokenManagerReturns aCompletionStagefor 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:
getTokenin interfaceAuthTokenManager- Returns:
- a stage for a valid token, must not be
nullor complete withnull - See Also:
-
handleSecurityException
Description copied from interface:AuthTokenManagerHandlesSecurityExceptionthat 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 originalSecurityExceptioninSecurityRetryableException. 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:
handleSecurityExceptionin interfaceAuthTokenManager- Parameters:
authToken- the current tokenexception- the security exception- Returns:
trueif the exception should be marked as retryable orfalseif it should remain unchanged
-