public class DefaultClientBuilder extends Object implements ClientBuilder
The default ClientBuilder implementation. This looks for configuration files
 in the following locations and order of precedence (last one wins).
DEFAULT_CLIENT_API_TOKEN_PROPERTY_NAME, DEFAULT_CLIENT_AUTHENTICATION_SCHEME_PROPERTY_NAME, DEFAULT_CLIENT_AUTHORIZATION_MODE_PROPERTY_NAME, DEFAULT_CLIENT_CACHE_CACHES_PROPERTY_NAME, DEFAULT_CLIENT_CACHE_ENABLED_PROPERTY_NAME, DEFAULT_CLIENT_CACHE_TTI_PROPERTY_NAME, DEFAULT_CLIENT_CACHE_TTL_PROPERTY_NAME, DEFAULT_CLIENT_CONNECTION_TIMEOUT_PROPERTY_NAME, DEFAULT_CLIENT_ID_PROPERTY_NAME, DEFAULT_CLIENT_KID_PROPERTY_NAME, DEFAULT_CLIENT_OAUTH2_ACCESS_TOKEN_PROPERTY_NAME, DEFAULT_CLIENT_ORG_URL_PROPERTY_NAME, DEFAULT_CLIENT_PRIVATE_KEY_PROPERTY_NAME, DEFAULT_CLIENT_PROXY_HOST_PROPERTY_NAME, DEFAULT_CLIENT_PROXY_PASSWORD_PROPERTY_NAME, DEFAULT_CLIENT_PROXY_PORT_PROPERTY_NAME, DEFAULT_CLIENT_PROXY_USERNAME_PROPERTY_NAME, DEFAULT_CLIENT_REQUEST_TIMEOUT_PROPERTY_NAME, DEFAULT_CLIENT_RETRY_MAX_ATTEMPTS_PROPERTY_NAME, DEFAULT_CLIENT_SCOPES_PROPERTY_NAME, DEFAULT_CLIENT_TESTING_DISABLE_HTTPS_CHECK_PROPERTY_NAME| Constructor and Description | 
|---|
| DefaultClientBuilder() | 
| Modifier and Type | Method and Description | 
|---|---|
| ApiClient | build()Constructs a new  ApiClientinstance based on the ClientBuilder's current configuration state. | 
| protected org.apache.hc.client5.http.impl.classic.HttpClientBuilder | createHttpClientBuilder(ClientConfiguration clientConfig)Override to customize the client, allowing one to add additional interceptors. | 
| protected org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder | createHttpClientConnectionManagerBuilder(ClientConfiguration clientConfig)Override to customize the connection manager, allowing the increase of max connections | 
| protected org.apache.hc.client5.http.config.RequestConfig.Builder | createHttpRequestConfigBuilder(ClientConfiguration clientConfig)Override to customize the request config | 
| ClientConfiguration | getClientConfiguration() | 
| ClientBuilder | setAuthorizationMode(AuthorizationMode authorizationMode)Overrides the default (very secure)
 Okta SSWS Digest
 Authentication Scheme used to authenticate every request sent to the Okta API server. | 
| ClientBuilder | setCacheManager(CacheManager cacheManager)Sets the  CacheManagerthat should be used to cache Okta REST resources, reducing round-trips to the
 Okta API server and enhancing application performance. | 
| ClientBuilder | setClientCredentials(ClientCredentials clientCredentials)Allows specifying an  ApiKeyinstance directly instead of relying on the
 default location + override/fallback behavior defined in thedocumentation above. | 
| ClientBuilder | setClientId(String clientId)Allows specifying the client ID instead of relying on the default location + override/fallback behavior defined
 in the  documentation above. | 
| ClientBuilder | setConnectionTimeout(int timeout)Sets both the timeout until a connection is established and the socket timeout (i.e. | 
| ClientBuilder | setKid(String kid)Allows specifying the Key ID (kid) instead of relying on the YAML config. | 
| ClientBuilder | setOAuth2AccessToken(String oAuth2AccessToken)Allows specifying the user obtained OAuth2 access token to be used by the SDK. | 
| ClientBuilder | setOrgUrl(String baseUrl)Sets the base URL of the Okta REST API to use. | 
| ClientBuilder | setPrivateKey(InputStream privateKeyStream)Allows specifying the private key (PEM file) path (for private key jwt authentication) directly instead
 of relying on the default location + override/fallback behavior defined
 in the  documentation above. | 
| ClientBuilder | setPrivateKey(Path privateKeyPath)Allows specifying the private key (PEM file) path (for private key jwt authentication) directly instead
 of relying on the default location + override/fallback behavior defined
 in the  documentation above. | 
| ClientBuilder | setPrivateKey(PrivateKey privateKey)Allows specifying the private key (PEM file) path (for private key jwt authentication) directly instead
 of relying on the default location + override/fallback behavior defined
 in the  documentation above. | 
| ClientBuilder | setPrivateKey(String privateKey)Allows specifying the private key (PEM file) path (for private key jwt authentication) directly instead
 of relying on the default location + override/fallback behavior defined
 in the  documentation above. | 
| ClientBuilder | setProxy(com.okta.commons.http.config.Proxy proxy)Sets the HTTP proxy to be used when communicating with the Okta API server. | 
| ClientBuilder | setRetryMaxAttempts(int maxAttempts)Sets the maximum number of attempts to retrying before giving up. | 
| ClientBuilder | setRetryMaxElapsed(int maxElapsed)Sets the maximum number of seconds to wait when retrying before giving up. | 
| ClientBuilder | setScopes(Set<String> scopes)Allows specifying a list of scopes directly instead of relying on the
 default location + override/fallback behavior defined in the  documentation above. | 
public ClientBuilder setProxy(com.okta.commons.http.config.Proxy proxy)
ClientBuilder
 Proxy proxy = new Proxy("whatever.domain.com", 443);
 Client client = Clients.builder().setProxy(proxy).build();
 setProxy in interface ClientBuilderproxy - the Proxy you need to use.public ClientBuilder setCacheManager(CacheManager cacheManager)
ClientBuilderCacheManager that should be used to cache Okta REST resources, reducing round-trips to the
 Okta API server and enhancing application performance.
 Single JVM Applications
 If your application runs on a single JVM-based applications, the
 CacheManagerBuilder should be sufficient for your needs. You
 create a CacheManagerBuilder by using the Caches utility class,
 for example:
 import static com.okta.sdk.cache.Caches.*;
 ...
 ApiClient client = Clients.builder()...
     .setCacheManager(
         newCacheManager()
         .withDefaultTimeToLive(1, TimeUnit.DAYS) //general default
         .withDefaultTimeToIdle(2, TimeUnit.HOURS) //general default
         .withCache(forResource(User.class) //User-specific cache settings
             .withTimeToLive(1, TimeUnit.HOURS)
             .withTimeToIdle(30, TimeUnit.MINUTES))
         .withCache(forResource(Group.class) //Group-specific cache settings
             .withTimeToLive(2, TimeUnit.HOURS))
         .build() //build the CacheManager
     )
     .build(); //build the Client
 
 The above TTL and TTI times are just examples showing API usage - the times themselves are not recommendations. Choose TTL and TTI times based on your application requirements.
Multi-JVM / Clustered ApplicationsThe default CacheManager instances returned by the
 CacheManagerBuilder might not be sufficient for a
 multi-instance application that runs on multiple JVMs and/or hosts/servers, as there could be cache-coherency
 problems across the JVMs.  See the CacheManagerBuilder
 JavaDoc for additional information.
In these multi-JVM environments, you will likely want to create a simple CacheManager implementation that wraps your distributed Caching API/product of choice and then plug that implementation in to the Okta SDK via this method. Hazelcast is one known cluster-safe caching product, and the Okta SDK has out-of-the-box support for this as an extension module. See the top-level class JavaDoc for a Hazelcast configuration example.
setCacheManager in interface ClientBuildercacheManager - the CacheManager that should be used to cache Okta REST resources, reducing
                     round-trips to the Okta API server and enhancing application performance.public ClientBuilder setConnectionTimeout(int timeout)
ClientBuildersetConnectionTimeout in interface ClientBuildertimeout - connection and socket timeout in secondspublic ClientBuilder setClientCredentials(ClientCredentials clientCredentials)
ClientBuilderApiKey instance directly instead of relying on the
 default location + override/fallback behavior defined in the documentation above.
 Currently, you should use a com.okta.sdk.impl.api.TokenClientCredentials (if you are NOT using an okta.yaml file)setClientCredentials in interface ClientBuilderclientCredentials - the token to use to authenticate requests to the Okta API server.public ClientBuilder setRetryMaxElapsed(int maxElapsed)
ClientBuildersetRetryMaxElapsed in interface ClientBuildermaxElapsed - retry max elapsed duration in secondspublic ClientBuilder setRetryMaxAttempts(int maxAttempts)
ClientBuildersetRetryMaxAttempts in interface ClientBuildermaxAttempts - retry max attemptspublic ApiClient build()
ClientBuilderApiClient instance based on the ClientBuilder's current configuration state.build in interface ClientBuilderApiClient instance based on the ClientBuilder's current configuration state.protected org.apache.hc.client5.http.impl.classic.HttpClientBuilder createHttpClientBuilder(ClientConfiguration clientConfig)
clientConfig - the current ClientConfigurationHttpClientBuilder initialized with default configurationprotected org.apache.hc.client5.http.config.RequestConfig.Builder createHttpRequestConfigBuilder(ClientConfiguration clientConfig)
clientConfig - the current clientConfigRequestConfig.Builder initialized with default configurationprotected org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder createHttpClientConnectionManagerBuilder(ClientConfiguration clientConfig)
clientConfig - the current clientConfigPoolingHttpClientConnectionManagerBuilder initialized with default configurationpublic ClientBuilder setOrgUrl(String baseUrl)
ClientBuilderhttps://api.okta.com/v1 - the most common use case for Okta's public SaaS cloud.
 Customers using Okta's Enterprise HA cloud might need to configure this to be
 https://enterprise.okta.io/v1 for example.
setOrgUrl in interface ClientBuilderbaseUrl - the base URL of the Okta REST API to use.public ClientBuilder setAuthorizationMode(AuthorizationMode authorizationMode)
ClientBuilder
 Client client = Clients.builder()...
    // setApiKey, etc...
    .setAuthorizationMode(AuthorizationMode.SSWS) //set the SSWS authentication mode
    .build(); //build the Client
 setAuthorizationMode in interface ClientBuilderauthorizationMode - mode of authorization for requests to the Okta API server.public ClientBuilder setScopes(Set<String> scopes)
ClientBuilderdocumentation above.setScopes in interface ClientBuilderscopes - set of scopes for which the client requests access.public ClientBuilder setPrivateKey(String privateKey)
ClientBuilderdocumentation above.setPrivateKey in interface ClientBuilderprivateKey - either the fully qualified string path to the private key PEM file (or)
                   the full PEM payload content.public ClientBuilder setPrivateKey(Path privateKeyPath)
ClientBuilderdocumentation above.setPrivateKey in interface ClientBuilderprivateKeyPath - representing the path to private key PEM file.public ClientBuilder setPrivateKey(InputStream privateKeyStream)
ClientBuilderdocumentation above.setPrivateKey in interface ClientBuilderprivateKeyStream - representing an InputStream with private key PEM file content.public ClientBuilder setPrivateKey(PrivateKey privateKey)
ClientBuilderdocumentation above.setPrivateKey in interface ClientBuilderprivateKey - the PrivateKey instance.public ClientBuilder setClientId(String clientId)
ClientBuilderdocumentation above.setClientId in interface ClientBuilderclientId - string representing the client ID.public ClientBuilder setOAuth2AccessToken(String oAuth2AccessToken)
ClientBuildersetOAuth2AccessToken in interface ClientBuilderoAuth2AccessToken - the token string.public ClientBuilder setKid(String kid)
ClientBuildersetKid in interface ClientBuilderkid - string representing the Key ID.public ClientConfiguration getClientConfiguration()
Copyright © 2017–2023 Okta. All rights reserved.