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 Constructor Description ClientConfigurator(IDatabricksConnectionContext connectionContext)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringconvertNonProxyHostConfigToBeSystemPropertyCompliant(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.intfindAvailablePort(List<Integer> initialPorts)Finds the first available port from the provided list of ports.com.databricks.sdk.core.DatabricksConfiggetDatabricksConfig()static PathgetTokenCachePath(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.WorkspaceClientgetWorkspaceClient()voidresetAccessTokenInConfig(String newAccessToken)voidsetupAccessTokenConfig()Setup the PAT authentication settings in the databricks config.voidsetupAuthConfig()Setup the workspace authentication settings in the databricks config.voidsetupM2MConfig()Setup the OAuth M2M authentication settings in the databricks config.voidsetupOAuthAccessTokenConfig()voidsetupOAuthConfig()Setup the OAuth authentication settings in the databricks config.voidsetupProxyConfig(com.databricks.sdk.core.commons.CommonsHttpClient.Builder httpClientBuilder)Setup proxy settings in the databricks config.voidsetupU2MConfig()Setup the OAuth U2M authentication settings in the databricks config.voidsetupU2MRefreshConfig()Setup the OAuth U2M refresh token authentication settings in the databricks config.
-
-
-
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 URLclientId- The OAuth client IDscopes- 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 DatabricksParsingExceptionSetup the OAuth authentication settings in the databricks config.- Throws:
DatabricksParsingException
-
setupU2MConfig
public void setupU2MConfig() throws DatabricksParsingExceptionSetup 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 DatabricksParsingExceptionSetup 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 DatabricksParsingExceptionSetup the OAuth U2M refresh token authentication settings in the databricks config.- Throws:
DatabricksParsingException
-
setupM2MConfig
public void setupM2MConfig() throws DatabricksParsingExceptionSetup 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()
-
-