Package com.volcengine.auth
Class EcsRoleCredentialProvider
- java.lang.Object
-
- com.volcengine.auth.EcsRoleCredentialProvider
-
- All Implemented Interfaces:
Provider
public class EcsRoleCredentialProvider extends Object implements Provider
Provider that fetches temporary credentials from the ECS IMDS.Follows the
ProviderCQS contract:isExpired()/retrieve()are pure reads.refresh()is the only method that mutates state.
Intended to be wrapped in a
CredentialProvider, which serializes refresh through aReadWriteLockand guarantees theisExpired → refresh → retrievesequence. Direct use (without wrapping) is not a supported mode.
-
-
Constructor Summary
Constructors Constructor Description EcsRoleCredentialProvider(String roleName)EcsRoleCredentialProvider(String roleName, int connectTimeoutMs, int readTimeoutMs, int maxRetries, int retryIntervalMs, int expireBufferSeconds)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static EcsRoleCredentialProvidercreate(String roleName)static booleanisDisabledByEnv()Returns true whenVOLCENGINE_ECS_METADATA_DISABLED=trueis set.booleanisExpired()voidrefresh()CredentialValueretrieve()voidsetConnectTimeoutMs(int connectTimeoutMs)voidsetExpireBufferSeconds(int expireBufferSeconds)voidsetMaxRetries(int maxRetries)voidsetReadTimeoutMs(int readTimeoutMs)voidsetRetryIntervalMs(int retryIntervalMs)
-
-
-
Method Detail
-
isDisabledByEnv
public static boolean isDisabledByEnv()
Returns true whenVOLCENGINE_ECS_METADATA_DISABLED=trueis set. Used byDefaultCredentialProviderto skip adding the IMDS step to the chain, and by the constructor to fail fast on directnew.
-
create
public static EcsRoleCredentialProvider create(String roleName)
-
setConnectTimeoutMs
public void setConnectTimeoutMs(int connectTimeoutMs)
-
setReadTimeoutMs
public void setReadTimeoutMs(int readTimeoutMs)
-
setMaxRetries
public void setMaxRetries(int maxRetries)
-
setRetryIntervalMs
public void setRetryIntervalMs(int retryIntervalMs)
-
setExpireBufferSeconds
public void setExpireBufferSeconds(int expireBufferSeconds)
-
refresh
public void refresh() throws ApiException- Specified by:
refreshin interfaceProvider- Throws:
ApiException
-
retrieve
public CredentialValue retrieve() throws ApiException
- Specified by:
retrievein interfaceProvider- Throws:
ApiException
-
-