Package io.camunda.client.impl.oauth
Class OAuthCredentialsProvider
java.lang.Object
io.camunda.client.impl.oauth.OAuthCredentialsProvider
- All Implemented Interfaces:
CredentialsProvider
@ThreadSafe
public final class OAuthCredentialsProvider
extends Object
implements CredentialsProvider
This class is thread-safe in terms of the next: 1. If you are trying to modify headers of your
request from the several threads there would be sequential calls to the cache 2. If the cache
hasn't a valid token and you are calling from several threads there would be just one call to the
Auth server
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.camunda.client.CredentialsProvider
CredentialsProvider.CredentialsApplier, CredentialsProvider.StatusCode -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an access token to the Authorization header of a gRPC call.booleanbooleanshouldRetryRequest(CredentialsProvider.StatusCode statusCode) Returns true if the request should be retried — meaning the token was refreshed (either by this thread or a concurrent one) and a retry with the new token is worthwhile.
-
Method Details
-
isClientAssertionEnabled
public boolean isClientAssertionEnabled() -
applyCredentials
Adds an access token to the Authorization header of a gRPC call.- Specified by:
applyCredentialsin interfaceCredentialsProvider- Parameters:
applier- where to add the credentials headers- Throws:
IOException
-
shouldRetryRequest
Returns true if the request should be retried — meaning the token was refreshed (either by this thread or a concurrent one) and a retry with the new token is worthwhile. Returns false if the failure was not an auth error, or if the freshly fetched credentials are identical to the cached ones (indicating the 401 was not caused by a stale token). Delegates toOAuthCredentialsCache.forceRefreshIfChanged(java.lang.String, io.camunda.client.impl.util.SupplierWithIO<io.camunda.client.impl.CamundaClientCredentials>)which is synchronized on the same monitor asOAuthCredentialsCache.computeIfMissingOrInvalid(java.lang.String, io.camunda.client.impl.util.SupplierWithIO<io.camunda.client.impl.CamundaClientCredentials>), ensuring that concurrent 401 retries coalesce into a single token refresh call.- Specified by:
shouldRetryRequestin interfaceCredentialsProvider- Parameters:
statusCode- the response code for the failure
-