Package org.apache.gravitino.credential
Interface CredentialProvider
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
CredentialProviderDelegator
An interface for providing credentials to access external systems.
Implementations of this interface are discovered using Java's ServiceLoader.
To prevent class loading issues and unnecessary dependency bloat, all implementations must be
lightweight. Any logic that requires heavy external dependencies (e.g., cloud SDKs) should be
isolated in a separate CredentialGenerator class and loaded reflectively at runtime. The
CredentialProviderDelegator provides a convenient base class for this pattern.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the type of credential, it should be identical in Gravitino.getCredential(CredentialContext context) Gets a credential based on the provided context information.default Optional<Credential>getCredentialOptional(CredentialContext context) Gets a credential based on the provided context information.voidinitialize(Map<String, String> properties) Initializes the credential provider with catalog properties.default booleansupportsScheme(String scheme) Checks whether this provider supports generating credentials for the given URI scheme.
-
Method Details
-
initialize
Initializes the credential provider with catalog properties.- Parameters:
properties- catalog properties that can be used to configure the provider. The specific properties required vary by implementation.
-
credentialType
String credentialType()Returns the type of credential, it should be identical in Gravitino.- Returns:
- A string identifying the type of credentials.
-
supportsScheme
Checks whether this provider supports generating credentials for the given URI scheme.By default, it returns
true. Path-based credential flows should only use providers that explicitly declare supported schemes.- Parameters:
scheme- The URI scheme (e.g.s3,s3a,gs,abfs).- Returns:
- True if the provider supports the scheme.
-
getCredential
Gets a credential based on the provided context information.- Parameters:
context- A context object providing necessary information for retrieving credentials.- Returns:
- A
Credentialobject containing the authentication information needed to access a system or resource.nullwill be returned if no credential is available.
-
getCredentialOptional
Gets a credential based on the provided context information.- Parameters:
context- A context object providing necessary information for retrieving credentials.- Returns:
- An
Optionalcontaining theCredentialwith the authentication information needed to access a system or resource, orOptional.empty()if no credential is available.
-