public class X509FederationClient extends Object implements FederationClient, ProvidesConfigurableRefresh
This class gets a security token from the auth service by signing the request with a PKI issued leaf certificate, passing along a temporary public key that is bounded to the the security token, and the leaf certificate.
Modifier and Type | Class and Description |
---|---|
static class |
X509FederationClient.SecurityToken |
static class |
X509FederationClient.X509FederationRequest
Class is immutable.
|
Constructor and Description |
---|
X509FederationClient(String federationEndpoint,
String tenancyId,
X509CertificateSupplier leafCertificateSupplier,
SessionKeySupplier sessionKeySupplier,
Set<X509CertificateSupplier> intermediateCertificateSuppliers,
ClientConfigurator clientConfigurator,
List<ClientConfigurator> additionalClientConfigurators,
CircuitBreakerConfiguration circuitBreakerConfig)
Same as
#X509FederationClient(String, String, X509CertificateSupplier,
SessionKeySupplier, Set, ClientConfigurator, List, String) but with ‘purpose’ set to DEFAULT_PURPOSE . |
X509FederationClient(String federationEndpoint,
String tenancyId,
X509CertificateSupplier leafCertificateSupplier,
SessionKeySupplier sessionKeySupplier,
Set<X509CertificateSupplier> intermediateCertificateSuppliers,
ClientConfigurator clientConfigurator,
List<ClientConfigurator> additionalClientConfigurators,
CircuitBreakerConfiguration circuitBreakerConfig,
String purpose)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
X509CertificateSupplier |
getLeafCertificateSupplier() |
String |
getSecurityToken()
Gets a security token.
|
String |
getStringClaim(String key)
Return a claim embedded in the security token
|
String |
getTenancyId() |
String |
refreshAndGetSecurityToken()
Gets a security token from the federation endpoint.
|
String |
refreshAndGetSecurityTokenIfExpiringWithin(Duration time)
Gets a security token from the federation endpoint if the security token expires within the
provided duration.
|
String |
refreshAndGetSecurityTokenIfExpiringWithin(Duration time,
boolean refreshKeys)
Gets a security token from the federation endpoint if the security token expires within the
provided duration and allows to enable/disable refresh of keys.
|
public X509FederationClient(String federationEndpoint, String tenancyId, X509CertificateSupplier leafCertificateSupplier, SessionKeySupplier sessionKeySupplier, Set<X509CertificateSupplier> intermediateCertificateSuppliers, ClientConfigurator clientConfigurator, List<ClientConfigurator> additionalClientConfigurators, CircuitBreakerConfiguration circuitBreakerConfig)
Same as #X509FederationClient(String, String, X509CertificateSupplier,
SessionKeySupplier, Set, ClientConfigurator, List, String)
but with ‘purpose’ set to DEFAULT_PURPOSE
.
public X509FederationClient(String federationEndpoint, String tenancyId, X509CertificateSupplier leafCertificateSupplier, SessionKeySupplier sessionKeySupplier, Set<X509CertificateSupplier> intermediateCertificateSuppliers, ClientConfigurator clientConfigurator, List<ClientConfigurator> additionalClientConfigurators, CircuitBreakerConfiguration circuitBreakerConfig, String purpose)
The constructor.
federationEndpoint
- the auth service endpoint.tenancyId
- the tenancy id, to construct the key idleafCertificateSupplier
- the leaf certificate, used to identify the callersessionKeySupplier
- the temporary public key, whose corresponding private key will be
used to sign actual API callsintermediateCertificateSuppliers
- intermediate certificates, if there are any (else
null)clientConfigurator
- client configurator used to configure the federation rest client,
if any (else null)additionalClientConfigurators
- Additional client configurators to be run after the
primary configurator.purpose
- The purpose that will be configured for each request.public String getSecurityToken()
Gets a security token. If there is already a valid token cached, it will be returned. Else this will make a call to the auth service to get a new token, using the provided suppliers.
This method is thread-safe.
getSecurityToken
in interface FederationClient
BmcException
- If there is any issue with getting a token from the auth serverIllegalArgumentException
- if there is a problem with the key/certificate supplierspublic String getStringClaim(String key)
Return a claim embedded in the security token
getStringClaim
in interface FederationClient
key
- the name of the claimpublic String refreshAndGetSecurityToken()
FederationClient
Gets a security token from the federation endpoint. This will always retreive a new token from the federation endpoint and does not use a cached token.
refreshAndGetSecurityToken
in interface FederationClient
public String refreshAndGetSecurityTokenIfExpiringWithin(Duration time)
ProvidesConfigurableRefresh
Gets a security token from the federation endpoint if the security token expires within the provided duration. This will always retrieve a new token from the federation endpoint and does not use a cached token.
refreshAndGetSecurityTokenIfExpiringWithin
in interface ProvidesConfigurableRefresh
time
- the duration to checkpublic String refreshAndGetSecurityTokenIfExpiringWithin(Duration time, boolean refreshKeys)
ProvidesConfigurableRefresh
Gets a security token from the federation endpoint if the security token expires within the provided duration and allows to enable/disable refresh of keys. This will always retrieve a new token from the federation endpoint and does not use a cached token.
refreshAndGetSecurityTokenIfExpiringWithin
in interface ProvidesConfigurableRefresh
time
- the duration to checkrefreshKeys
- boolean value to enable/disable refresh of keyspublic X509CertificateSupplier getLeafCertificateSupplier()
public String getTenancyId()
Copyright © 2016–2024. All rights reserved.