Class DefaultZtsClient
java.lang.Object
com.yahoo.vespa.athenz.client.common.ClientBase
com.yahoo.vespa.athenz.client.zts.DefaultZtsClient
- All Implemented Interfaces:
ZtsClient
,AutoCloseable
Default implementation of
ZtsClient
- Author:
- bjorncs, mortent
-
Nested Class Summary
Nested classes/interfaces inherited from class com.yahoo.vespa.athenz.client.common.ClientBase
ClientBase.ClientExceptionFactory
-
Field Summary
Fields inherited from class com.yahoo.vespa.athenz.client.common.ClientBase
logger
-
Constructor Summary
ModifierConstructorDescriptionprotected
DefaultZtsClient
(URI ztsUrl, Supplier<SSLContext> sslContextSupplier, HostnameVerifier hostnameVerifier, ErrorHandler errorHandler) -
Method Summary
Modifier and TypeMethodDescriptiongetAccessToken
(AthenzDomain domain, List<AthenzIdentity> proxyPrincipals) Fetch an access token for the target domaingetAccessToken
(List<AthenzRole> athenzRole) Fetch an access token for the target rolesgetAwsTemporaryCredentials
(AthenzDomain athenzDomain, AwsRole awsRole, Duration duration, String externalId) Get aws temporary credentialsgetRoleCertificate
(AthenzRole role, com.yahoo.security.Pkcs10Csr csr) Fetch role certificate for the target domain and rolegetRoleCertificate
(AthenzRole role, com.yahoo.security.Pkcs10Csr csr, Duration expiry) Fetch role certificate for the target domain and rolegetRoleToken
(AthenzDomain domain, Duration expiry) Fetch a role token for the target domaingetRoleToken
(AthenzRole athenzRole, Duration expiry) Fetch a role token for the target rolegetServiceIdentity
(AthenzIdentity identity, String keyId, com.yahoo.security.Pkcs10Csr csr) Get service identitygetServiceIdentity
(AthenzIdentity identity, String keyId, com.yahoo.security.Pkcs10Csr csr, Optional<NToken> nToken) getServiceIdentity
(AthenzIdentity identity, String keyId, KeyPair keyPair, String dnsSuffix) Get service identitygetTenantDomains
(AthenzIdentity providerIdentity, AthenzIdentity userIdentity, String roleName) For a given provider, get a list of tenant domains that the user is a member ofboolean
hasAccess
(AthenzResourceName resource, String action, AthenzIdentity identity) Check access to resource for a given principalrefreshInstance
(AthenzIdentity providerIdentity, AthenzIdentity instanceIdentity, String instanceId, com.yahoo.security.Pkcs10Csr csr) Refresh an existing instanceregisterInstance
(AthenzIdentity providerIdentity, AthenzIdentity instanceIdentity, String attestationData, com.yahoo.security.Pkcs10Csr csr) Register an instance using the specified provider.Methods inherited from class com.yahoo.vespa.athenz.client.common.ClientBase
close, execute, readEntity, toJsonStringEntity
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.yahoo.vespa.athenz.client.zts.ZtsClient
close, getAccessToken, getAwsTemporaryCredentials, getAwsTemporaryCredentials, getRoleToken, getRoleToken
-
Constructor Details
-
DefaultZtsClient
protected DefaultZtsClient(URI ztsUrl, Supplier<SSLContext> sslContextSupplier, HostnameVerifier hostnameVerifier, ErrorHandler errorHandler)
-
-
Method Details
-
registerInstance
public InstanceIdentity registerInstance(AthenzIdentity providerIdentity, AthenzIdentity instanceIdentity, String attestationData, com.yahoo.security.Pkcs10Csr csr) Description copied from interface:ZtsClient
Register an instance using the specified provider.- Specified by:
registerInstance
in interfaceZtsClient
attestationData
- The signed identity documented serialized to a string.- Returns:
- A x509 certificate + service token (optional)
-
refreshInstance
public InstanceIdentity refreshInstance(AthenzIdentity providerIdentity, AthenzIdentity instanceIdentity, String instanceId, com.yahoo.security.Pkcs10Csr csr) Description copied from interface:ZtsClient
Refresh an existing instance- Specified by:
refreshInstance
in interfaceZtsClient
- Returns:
- A x509 certificate + service token (optional)
-
getServiceIdentity
public Identity getServiceIdentity(AthenzIdentity identity, String keyId, com.yahoo.security.Pkcs10Csr csr) Description copied from interface:ZtsClient
Get service identity- Specified by:
getServiceIdentity
in interfaceZtsClient
- Returns:
- A x509 certificate with CA certificates
-
getServiceIdentity
public Identity getServiceIdentity(AthenzIdentity identity, String keyId, com.yahoo.security.Pkcs10Csr csr, Optional<NToken> nToken) -
getServiceIdentity
public Identity getServiceIdentity(AthenzIdentity identity, String keyId, KeyPair keyPair, String dnsSuffix) Description copied from interface:ZtsClient
Get service identity- Specified by:
getServiceIdentity
in interfaceZtsClient
- Returns:
- A x509 certificate with CA certificates
-
getRoleToken
Description copied from interface:ZtsClient
Fetch a role token for the target domain- Specified by:
getRoleToken
in interfaceZtsClient
- Parameters:
domain
- Target domainexpiry
- Token expiry- Returns:
- A role token
-
getRoleToken
Description copied from interface:ZtsClient
Fetch a role token for the target role- Specified by:
getRoleToken
in interfaceZtsClient
- Parameters:
athenzRole
- Target roleexpiry
- Token expiry- Returns:
- A role token
-
getAccessToken
Description copied from interface:ZtsClient
Fetch an access token for the target domain- Specified by:
getAccessToken
in interfaceZtsClient
- Parameters:
domain
- Target domainproxyPrincipals
- List of principals to allow proxying token- Returns:
- An Athenz access token
-
getAccessToken
Description copied from interface:ZtsClient
Fetch an access token for the target roles- Specified by:
getAccessToken
in interfaceZtsClient
- Parameters:
athenzRole
- List of athenz roles to get access token for- Returns:
- An Athenz access token
-
getRoleCertificate
public X509Certificate getRoleCertificate(AthenzRole role, com.yahoo.security.Pkcs10Csr csr, Duration expiry) Description copied from interface:ZtsClient
Fetch role certificate for the target domain and role- Specified by:
getRoleCertificate
in interfaceZtsClient
- Parameters:
role
- Target rolecsr
- Certificate signing request matching roleexpiry
- Certificate expiry- Returns:
- A role certificate
-
getRoleCertificate
Description copied from interface:ZtsClient
Fetch role certificate for the target domain and role- Specified by:
getRoleCertificate
in interfaceZtsClient
- Parameters:
role
- Target rolecsr
- Certificate signing request matching role- Returns:
- A role certificate
-
getTenantDomains
public List<AthenzDomain> getTenantDomains(AthenzIdentity providerIdentity, AthenzIdentity userIdentity, String roleName) Description copied from interface:ZtsClient
For a given provider, get a list of tenant domains that the user is a member of- Specified by:
getTenantDomains
in interfaceZtsClient
- Parameters:
providerIdentity
- Provider identityuserIdentity
- User identityroleName
- Role name- Returns:
- List of domains
-
getAwsTemporaryCredentials
public AwsTemporaryCredentials getAwsTemporaryCredentials(AthenzDomain athenzDomain, AwsRole awsRole, Duration duration, String externalId) Description copied from interface:ZtsClient
Get aws temporary credentials- Specified by:
getAwsTemporaryCredentials
in interfaceZtsClient
awsRole
- AWS role to get credentials forduration
- Duration for which the credentials should be valid, ornull
to use defaultexternalId
- External Id to get credentials, ornull
if not required- Returns:
- AWS temporary credentials
-
hasAccess
Description copied from interface:ZtsClient
Check access to resource for a given principal
-