public class KubernetesServiceAccountTokenFile extends Object implements KubernetesJwtSupplier
A file containing a token for a pod's service account is automatically mounted at
/var/run/secrets/kubernetes.io/serviceaccount/token
.
KubernetesJwtSupplier
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_KUBERNETES_SERVICE_ACCOUNT_TOKEN_FILE
Default path to the service account token file.
|
Constructor and Description |
---|
KubernetesServiceAccountTokenFile()
Create a new
KubernetesServiceAccountTokenFile pointing to the
DEFAULT_KUBERNETES_SERVICE_ACCOUNT_TOKEN_FILE . |
KubernetesServiceAccountTokenFile(File file)
Create a new
KubernetesServiceAccountTokenFile
KubernetesServiceAccountTokenFile from a File handle. |
KubernetesServiceAccountTokenFile(Resource resource)
Create a new
KubernetesServiceAccountTokenFile
KubernetesServiceAccountTokenFile from a Resource handle. |
KubernetesServiceAccountTokenFile(String path)
|
Modifier and Type | Method and Description |
---|---|
String |
get()
Get a JWT for Kubernetes authentication.
|
protected static byte[] |
readToken(Resource resource)
Read the token from
Resource . |
public static final String DEFAULT_KUBERNETES_SERVICE_ACCOUNT_TOKEN_FILE
public KubernetesServiceAccountTokenFile()
KubernetesServiceAccountTokenFile
pointing to the
DEFAULT_KUBERNETES_SERVICE_ACCOUNT_TOKEN_FILE
. Construction fails with an
exception if the file does not exist.IllegalArgumentException
- if the
DEFAULT_KUBERNETES_SERVICE_ACCOUNT_TOKEN_FILE
does not exist.public KubernetesServiceAccountTokenFile(String path)
path
- path to the service account token file.IllegalArgumentException
- if thepath
does not exist.public KubernetesServiceAccountTokenFile(File file)
KubernetesServiceAccountTokenFile
KubernetesServiceAccountTokenFile
from a File
handle.file
- path to the service account token file.IllegalArgumentException
- if thepath
does not exist.public KubernetesServiceAccountTokenFile(Resource resource)
KubernetesServiceAccountTokenFile
KubernetesServiceAccountTokenFile
from a Resource
handle.resource
- resource pointing to the service account token file.IllegalArgumentException
- if thepath
does not exist.public String get()
KubernetesJwtSupplier
get
in interface Supplier<String>
get
in interface KubernetesJwtSupplier
protected static byte[] readToken(Resource resource) throws IOException
Resource
.resource
- the resource to read from, must not be null.IOException
- in case of I/O errors.Copyright © 2016–2019 Pivotal Software, Inc.. All rights reserved.