Package com.okta.authn.sdk.client
Interface AuthenticationClientBuilder
-
- All Known Implementing Classes:
DefaultAuthenticationClientBuilder
public interface AuthenticationClientBuilder
A Builder design pattern used to constructAuthenticationClient
instances.The
AuthenticationClientBuilder
is used to construct AuthenticationClient instances with Okta credentials, Proxy and Cache configuration. Understanding caching is extremely important when creating a AuthenticationClient instance, so please ensure you read the Caching section below.Usage
The simplest usage is to just call the
build()
method, for example:AuthenticationClient client =
AuthenticationClients
.builder().build()
;This will:
- Automatically attempt to find your organization URL value in a number of default/conventional locations and then use the discovered values. Without any other configuration, the following locations will be each be checked, in order:
- The environment variable
OKTA_CLIENT_ORGURL
. If this values is present, they override any previously discovered value. - A yaml file that exists at the file path
~/.okta/okta.yml
or root of the classpath/okta.yml
. If this file exists and any values are present, the values override any previously discovered value. - The system properties
okta.client.orgUrl
. If this value is present, it will override any previously discovered values.
Explicit API Key Configuration
The above default configuration searching heuristics may not be suitable to your needs. In that case, you will likely need to explicitly configure the builder. For example:
AuthenticationClient client =
AuthenticationClients
.builder() .setOrgUrl("https://example.okta.com") .build();- Since:
- 0.1.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_CLIENT_AUTHENTICATION_SCHEME_PROPERTY_NAME
static java.lang.String
DEFAULT_CLIENT_CONNECTION_TIMEOUT_PROPERTY_NAME
static java.lang.String
DEFAULT_CLIENT_ORG_URL_PROPERTY_NAME
static java.lang.String
DEFAULT_CLIENT_PROXY_HOST_PROPERTY_NAME
static java.lang.String
DEFAULT_CLIENT_PROXY_PASSWORD_PROPERTY_NAME
static java.lang.String
DEFAULT_CLIENT_PROXY_PORT_PROPERTY_NAME
static java.lang.String
DEFAULT_CLIENT_PROXY_USERNAME_PROPERTY_NAME
static java.lang.String
DEFAULT_CLIENT_REQUEST_TIMEOUT_PROPERTY_NAME
static java.lang.String
DEFAULT_CLIENT_RETRY_MAX_ATTEMPTS_PROPERTY_NAME
static java.lang.String
DEFAULT_CLIENT_TESTING_DISABLE_HTTPS_CHECK_PROPERTY_NAME
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description AuthenticationClient
build()
Constructs a newAuthenticationClient
instance based on the AuthenticationClientBuilder's current configuration state.AuthenticationClientBuilder
setConnectionTimeout(int timeout)
Sets both the timeout until a connection is established and the socket timeout (i.e.AuthenticationClientBuilder
setOrgUrl(java.lang.String baseUrl)
Sets the base URL of the Okta REST API to use.AuthenticationClientBuilder
setProxy(com.okta.commons.http.config.Proxy proxy)
Sets the HTTP proxy to be used when communicating with the Okta API server.AuthenticationClientBuilder
setRetryMaxAttempts(int maxAttempts)
Sets the maximum number of attempts to retrying before giving up.AuthenticationClientBuilder
setRetryMaxElapsed(int maxElapsed)
Sets the maximum number of milliseconds to wait when retrying before giving up.
-
-
-
Field Detail
-
DEFAULT_CLIENT_ORG_URL_PROPERTY_NAME
static final java.lang.String DEFAULT_CLIENT_ORG_URL_PROPERTY_NAME
- See Also:
- Constant Field Values
-
DEFAULT_CLIENT_CONNECTION_TIMEOUT_PROPERTY_NAME
static final java.lang.String DEFAULT_CLIENT_CONNECTION_TIMEOUT_PROPERTY_NAME
- See Also:
- Constant Field Values
-
DEFAULT_CLIENT_AUTHENTICATION_SCHEME_PROPERTY_NAME
static final java.lang.String DEFAULT_CLIENT_AUTHENTICATION_SCHEME_PROPERTY_NAME
- See Also:
- Constant Field Values
-
DEFAULT_CLIENT_PROXY_PORT_PROPERTY_NAME
static final java.lang.String DEFAULT_CLIENT_PROXY_PORT_PROPERTY_NAME
- See Also:
- Constant Field Values
-
DEFAULT_CLIENT_PROXY_HOST_PROPERTY_NAME
static final java.lang.String DEFAULT_CLIENT_PROXY_HOST_PROPERTY_NAME
- See Also:
- Constant Field Values
-
DEFAULT_CLIENT_PROXY_USERNAME_PROPERTY_NAME
static final java.lang.String DEFAULT_CLIENT_PROXY_USERNAME_PROPERTY_NAME
- See Also:
- Constant Field Values
-
DEFAULT_CLIENT_PROXY_PASSWORD_PROPERTY_NAME
static final java.lang.String DEFAULT_CLIENT_PROXY_PASSWORD_PROPERTY_NAME
- See Also:
- Constant Field Values
-
DEFAULT_CLIENT_REQUEST_TIMEOUT_PROPERTY_NAME
static final java.lang.String DEFAULT_CLIENT_REQUEST_TIMEOUT_PROPERTY_NAME
- See Also:
- Constant Field Values
-
DEFAULT_CLIENT_RETRY_MAX_ATTEMPTS_PROPERTY_NAME
static final java.lang.String DEFAULT_CLIENT_RETRY_MAX_ATTEMPTS_PROPERTY_NAME
- See Also:
- Constant Field Values
-
DEFAULT_CLIENT_TESTING_DISABLE_HTTPS_CHECK_PROPERTY_NAME
static final java.lang.String DEFAULT_CLIENT_TESTING_DISABLE_HTTPS_CHECK_PROPERTY_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
setProxy
AuthenticationClientBuilder setProxy(com.okta.commons.http.config.Proxy proxy)
Sets the HTTP proxy to be used when communicating with the Okta API server. For example:Proxy proxy = new Proxy("whatever.domain.com", 443); AuthenticationClient client =
AuthenticationClients
.builder().setProxy(proxy).build();- Parameters:
proxy
- theProxy
you need to use.- Returns:
- the AuthenticationClientBuilder instance for method chaining.
-
setConnectionTimeout
AuthenticationClientBuilder setConnectionTimeout(int timeout)
Sets both the timeout until a connection is established and the socket timeout (i.e. a maximum period of inactivity between two consecutive data packets). A timeout value of zero is interpreted as an infinite timeout.- Parameters:
timeout
- connection and socket timeout in seconds- Returns:
- the AuthenticationClientBuilder instance for method chaining
-
setOrgUrl
AuthenticationClientBuilder setOrgUrl(java.lang.String baseUrl)
Sets the base URL of the Okta REST API to use.- Parameters:
baseUrl
- the base URL of the Okta REST API to use.- Returns:
- the AuthenticationClientBuilder instance for method chaining
-
setRetryMaxElapsed
AuthenticationClientBuilder setRetryMaxElapsed(int maxElapsed)
Sets the maximum number of milliseconds to wait when retrying before giving up.- Parameters:
maxElapsed
- retry max elapsed duration in milliseconds- Returns:
- the ClientBuilder instance for method chaining
-
setRetryMaxAttempts
AuthenticationClientBuilder setRetryMaxAttempts(int maxAttempts)
Sets the maximum number of attempts to retrying before giving up.- Parameters:
maxAttempts
- retry max attempts- Returns:
- the ClientBuilder instance for method chaining
-
build
AuthenticationClient build()
Constructs a newAuthenticationClient
instance based on the AuthenticationClientBuilder's current configuration state.- Returns:
- a new
AuthenticationClient
instance based on the AuthenticationClientBuilder's current configuration state.
-
-