Class FileExternalTokenProvider
- All Implemented Interfaces:
ExternalTokenProvider
This is the ordinary shape of workload identity on a platform that already solves it: a projected service-account token on Kubernetes, a sidecar's output, an agent that refreshes a credential on a timer. Something else owns minting and refreshing; the SDK's job is to read the current contents at the moment it needs them.
Re-read on every mint, never cached
The file is the source of truth precisely because an external agent rewrites it. A provider that read it once would hold a token that expires while a perfectly fresh one sits on disk - and the resulting failure looks like a revoked credential rather than a stale read.
The path comes from configuration and from nothing else
It is fixed when this provider is constructed and cannot be changed afterwards. Nothing the server returns reaches it. That is not incidental: a path a response could steer would let whoever controls the response choose which of the caller's files gets read and posted.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondescribe()A short operator-facing description of WHERE the token comes from - a path, a command name, an issuer - for diagnostics.Produces the current external token.kind()Which of the configured source kinds this provider is, ornullfor a consumer-supplied provider that is none of them.path()The file this provider reads.toString()The path is the diagnostic an operator needs and is not itself a secret.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface co.ankatech.ankasecure.sdk.auth.ExternalTokenProvider
close, invalidate
-
Constructor Details
-
FileExternalTokenProvider
- Parameters:
path- the file holding the external token; captured as an absolute path at construction- Throws:
NullPointerException- ifpathisnull
-
-
Method Details
-
fetchExternalToken
Description copied from interface:ExternalTokenProviderProduces the current external token.How current it is belongs to the implementation, and the two answers are both correct for their case. A provider that READS an out-of-band token re-reads on every call, because something else refreshes it and a copy held here is a copy that expires without anyone noticing. A provider that OBTAINS the token itself knows the lifetime its issuer stated for it, so it may reuse one inside that lifetime - and when the issuer states no lifetime, it falls back to fetching per call rather than guessing one.
- Specified by:
fetchExternalTokenin interfaceExternalTokenProvider- Returns:
- the token; the caller takes ownership and closes it
-
kind
Description copied from interface:ExternalTokenProviderWhich of the configured source kinds this provider is, ornullfor a consumer-supplied provider that is none of them.- Specified by:
kindin interfaceExternalTokenProvider- Returns:
- the kind, or
nullwhen the provider is the consumer's own
-
describe
Description copied from interface:ExternalTokenProviderA short operator-facing description of WHERE the token comes from - a path, a command name, an issuer - for diagnostics. It must never contain the token.- Specified by:
describein interfaceExternalTokenProvider- Returns:
- the description; never
null
-
toString
The path is the diagnostic an operator needs and is not itself a secret. -
path
The file this provider reads. Exposed so a containment check can assert that the path a running SDK actually uses is the configured one.- Returns:
- the absolute path; never
null
-