Package com.databricks.jdbc.dbclient.impl.common

## Class ClientConfigurator

- java.lang.Object
- - com.databricks.jdbc.dbclient.impl.common.ClientConfigurator

    public class ClientConfigurator
    extends Object

This class is responsible for configuring the Databricks config based on the connection context. The databricks config is then used to create the SDK or Thrift client.

### Constructor Summary

Constructors
`ClientConfigurator​(IDatabricksConnectionContext connectionContext)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static String` `convertNonProxyHostConfigToBeSystemPropertyCompliant​(String nonProxyHosts)` Currently, the ODBC driver takes in nonProxyHosts as a comma separated list of suffix of non-proxy hosts i.e. suffix1|suffix2|suffix3.
`int` `findAvailablePort​(List<Integer> initialPorts)` Finds the first available port from the provided list of ports.
`com.databricks.sdk.core.DatabricksConfig` `getDatabricksConfig()`
`static Path` `getTokenCachePath​(String host, String clientId, List<String> scopes)` Returns the path for the token cache file based on host, client ID, and scopes.
`com.databricks.sdk.WorkspaceClient` `getWorkspaceClient()`
`void` `resetAccessTokenInConfig​(String newAccessToken)`
`void` `setupAccessTokenConfig()` Setup the PAT authentication settings in the databricks config.
`void` `setupAuthConfig()` Setup the workspace authentication settings in the databricks config.
`void` `setupM2MConfig()` Setup the OAuth M2M authentication settings in the databricks config.
`void` `setupOAuthAccessTokenConfig()`
`void` `setupOAuthConfig()` Setup the OAuth authentication settings in the databricks config.
`void` `setupProxyConfig​(com.databricks.sdk.core.commons.CommonsHttpClient.Builder httpClientBuilder)` Setup proxy settings in the databricks config.
`void` `setupU2MConfig()` Setup the OAuth U2M authentication settings in the databricks config.
`void` `setupU2MRefreshConfig()` Setup the OAuth U2M refresh token authentication settings in the databricks config.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### ClientConfigurator

    public ClientConfigurator​(IDatabricksConnectionContext connectionContext)
                       throws DatabricksSSLException

Throws:
  `DatabricksSSLException`

### Method Detail

#### getTokenCachePath

    public static Path getTokenCachePath​(String host,
                                         String clientId,
                                         List<String> scopes)

Returns the path for the token cache file based on host, client ID, and scopes. This creates a unique cache path using a hash of these parameters.

Parameters:
  `host` - The host URL
  `clientId` - The OAuth client ID
  `scopes` - The OAuth scopes
Returns:
  The path for the token cache file

#### setupProxyConfig

    public void setupProxyConfig​(com.databricks.sdk.core.commons.CommonsHttpClient.Builder httpClientBuilder)

Setup proxy settings in the databricks config.

#### getWorkspaceClient

    public com.databricks.sdk.WorkspaceClient getWorkspaceClient()

#### setupAuthConfig

    public void setupAuthConfig()

Setup the workspace authentication settings in the databricks config.

#### setupOAuthConfig

    public void setupOAuthConfig()
                          throws DatabricksParsingException

Setup the OAuth authentication settings in the databricks config.

Throws:
  `DatabricksParsingException`

#### setupU2MConfig

    public void setupU2MConfig()
                        throws DatabricksParsingException

Setup the OAuth U2M authentication settings in the databricks config.

Throws:
  `DatabricksParsingException`

#### findAvailablePort

    public int findAvailablePort​(List<Integer> initialPorts)

Finds the first available port from the provided list of ports. If a single port is provided, it tries incremental ports (port, port+1, port+2, etc.) If multiple ports are provided, it tries each port in the list.

Parameters:
  `initialPorts` - List of ports to try
Returns:
  The first available port
Throws:
  `com.databricks.sdk.core.DatabricksException` - if no available port is found

#### setupAccessTokenConfig

    public void setupAccessTokenConfig()
                                throws DatabricksParsingException

Setup the PAT authentication settings in the databricks config.

Throws:
  `DatabricksParsingException`

#### setupOAuthAccessTokenConfig

    public void setupOAuthAccessTokenConfig()
                                     throws DatabricksParsingException

Throws:
  `DatabricksParsingException`

#### resetAccessTokenInConfig

    public void resetAccessTokenInConfig​(String newAccessToken)

#### setupU2MRefreshConfig

    public void setupU2MRefreshConfig()
                               throws DatabricksParsingException

Setup the OAuth U2M refresh token authentication settings in the databricks config.

Throws:
  `DatabricksParsingException`

#### setupM2MConfig

    public void setupM2MConfig()
                        throws DatabricksParsingException

Setup the OAuth M2M authentication settings in the databricks config.

Throws:
  `DatabricksParsingException`

#### convertNonProxyHostConfigToBeSystemPropertyCompliant

    public static String convertNonProxyHostConfigToBeSystemPropertyCompliant​(String nonProxyHosts)

Currently, the ODBC driver takes in nonProxyHosts as a comma separated list of suffix of non-proxy hosts i.e. suffix1|suffix2|suffix3. Whereas, the SDK takes in nonProxyHosts as a list of patterns separated by '|'. This pattern conforms to the system property format in the Java Proxy Guide.

Parameters:
  `nonProxyHosts` - Comma separated list of suffix of non-proxy hosts
Returns:
  nonProxyHosts in system property compliant format from Java Proxy Guide

#### getDatabricksConfig

    public com.databricks.sdk.core.DatabricksConfig getDatabricksConfig()