Package net.snowflake.client.core

## Class SessionUtil

- java.lang.Object
- - net.snowflake.client.core.SessionUtil

    public class SessionUtil
    extends Object

Low level session util

### Field Summary

Fields
`static String` `CLIENT_CONSERVATIVE_MEMORY_ADJUST_STEP`
`static String` `CLIENT_ENABLE_CONSERVATIVE_MEMORY_USAGE`
`static String` `CLIENT_ENABLE_CONSERVATIVE_MEMORY_USAGE_JVM`
`static String` `CLIENT_ENABLE_LOG_INFO_STATEMENT_PARAMETERS`
`static String` `CLIENT_MEMORY_LIMIT`
`static String` `CLIENT_MEMORY_LIMIT_JVM`
`static String` `CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX`
`static String` `CLIENT_METADATA_USE_SESSION_DATABASE`
`static String` `CLIENT_PREFETCH_THREADS`
`static String` `CLIENT_PREFETCH_THREADS_JVM`
`static String` `CLIENT_RESULT_CHUNK_SIZE`
`static String` `CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY`
`static String` `CLIENT_SFSQL`
`static String` `CLIENT_VALIDATE_DEFAULT_PARAMETERS`
`static long` `DEFAULT_CLIENT_MEMORY_LIMIT`
`static int` `DEFAULT_CLIENT_PREFETCH_THREADS`
`static String` `ENABLE_STAGE_S3_PRIVATELINK_FOR_US_EAST_1`
`static String` `JDBC_CHUNK_DOWNLOADER_MAX_RETRY`
`static String` `JDBC_ENABLE_PUT_GET`
`static Map<String,​String>` `JVM_PARAMS_TO_PARAMS`
`static int` `MAX_CLIENT_CHUNK_SIZE`
`static int` `MIN_CLIENT_CHUNK_SIZE`
`static String` `OCSP_FAIL_OPEN_JVM`
`static String` `QUERY_CONTEXT_CACHE_SIZE`
`static String` `SF_HEADER_AUTHORIZATION` Deprecated.
`static String` `SF_HEADER_CLIENT_APP_ID`
`static String` `SF_HEADER_CLIENT_APP_VERSION`
`static String` `SF_PATH_AUTHENTICATOR_REQUEST`
`static String` `SF_PATH_CONSOLE_LOGIN_REQUEST`
`static String` `SF_QUERY_SESSION_DELETE`

### Constructor Summary

Constructors
`SessionUtil()`

### Method Summary

All Methods Static Methods Concrete Methods Deprecated Methods
`static void` `deleteIdTokenCache​(String host, String user)` Delete the id token cache
`static void` `deleteMfaTokenCache​(String host, String user)` Delete the mfa token cache
`static void` `deleteOAuthAccessTokenCache​(String host, String user)` Delete the Oauth access token cache
`static void` `deleteOAuthRefreshTokenCache​(String host, String user)` Delete the Oauth refresh token cache
`static String` `generateJWTToken​(PrivateKey privateKey, String privateKeyFile, String privateKeyFilePwd, String accountName, String userName)` Deprecated.
`static String` `generateJWTToken​(PrivateKey privateKey, String privateKeyFile, String privateKeyBase64, String privateKeyPwd, String accountName, String userName)` Helper function to generate a JWT token
`static Map<String,​Object>` `getCommonParams​(com.fasterxml.jackson.databind.JsonNode paramsNode)` Helper function to parse a JsonNode from a GS response containing CommonParameters, emitting an EnumMap of parameters
`static boolean` `isNewRetryStrategyRequest​(org.apache.http.client.methods.HttpRequestBase request)` Helper method to check if the request path is a login/auth request to use for retry strategy.
`static void` `resetOCSPUrlIfNecessary​(String serverUrl)` Set OCSP cache server.

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

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

### Field Detail

#### SF_PATH_AUTHENTICATOR_REQUEST

    public static final String SF_PATH_AUTHENTICATOR_REQUEST

See Also:
  Constant Field Values

#### SF_PATH_CONSOLE_LOGIN_REQUEST

    public static final String SF_PATH_CONSOLE_LOGIN_REQUEST

See Also:
  Constant Field Values

#### SF_QUERY_SESSION_DELETE

    public static final String SF_QUERY_SESSION_DELETE

See Also:
  Constant Field Values

#### SF_HEADER_AUTHORIZATION

    @Deprecated
    public static final String SF_HEADER_AUTHORIZATION

Deprecated.

See Also:
  Constant Field Values

#### JDBC_CHUNK_DOWNLOADER_MAX_RETRY

    public static final String JDBC_CHUNK_DOWNLOADER_MAX_RETRY

See Also:
  Constant Field Values

#### CLIENT_RESULT_CHUNK_SIZE

    public static final String CLIENT_RESULT_CHUNK_SIZE

See Also:
  Constant Field Values

#### CLIENT_MEMORY_LIMIT_JVM

    public static final String CLIENT_MEMORY_LIMIT_JVM

See Also:
  Constant Field Values

#### CLIENT_MEMORY_LIMIT

    public static final String CLIENT_MEMORY_LIMIT

See Also:
  Constant Field Values

#### QUERY_CONTEXT_CACHE_SIZE

    public static final String QUERY_CONTEXT_CACHE_SIZE

See Also:
  Constant Field Values

#### JDBC_ENABLE_PUT_GET

    public static final String JDBC_ENABLE_PUT_GET

See Also:
  Constant Field Values

#### CLIENT_PREFETCH_THREADS_JVM

    public static final String CLIENT_PREFETCH_THREADS_JVM

See Also:
  Constant Field Values

#### CLIENT_PREFETCH_THREADS

    public static final String CLIENT_PREFETCH_THREADS

See Also:
  Constant Field Values

#### CLIENT_ENABLE_CONSERVATIVE_MEMORY_USAGE_JVM

    public static final String CLIENT_ENABLE_CONSERVATIVE_MEMORY_USAGE_JVM

See Also:
  Constant Field Values

#### CLIENT_ENABLE_CONSERVATIVE_MEMORY_USAGE

    public static final String CLIENT_ENABLE_CONSERVATIVE_MEMORY_USAGE

See Also:
  Constant Field Values

#### CLIENT_CONSERVATIVE_MEMORY_ADJUST_STEP

    public static final String CLIENT_CONSERVATIVE_MEMORY_ADJUST_STEP

See Also:
  Constant Field Values

#### OCSP_FAIL_OPEN_JVM

    public static final String OCSP_FAIL_OPEN_JVM

See Also:
  Constant Field Values

#### CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY

    public static final String CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY

See Also:
  Constant Field Values

#### CLIENT_SFSQL

    public static final String CLIENT_SFSQL

See Also:
  Constant Field Values

#### CLIENT_VALIDATE_DEFAULT_PARAMETERS

    public static final String CLIENT_VALIDATE_DEFAULT_PARAMETERS

See Also:
  Constant Field Values

#### CLIENT_ENABLE_LOG_INFO_STATEMENT_PARAMETERS

    public static final String CLIENT_ENABLE_LOG_INFO_STATEMENT_PARAMETERS

See Also:
  Constant Field Values

#### CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX

    public static final String CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX

See Also:
  Constant Field Values

#### CLIENT_METADATA_USE_SESSION_DATABASE

    public static final String CLIENT_METADATA_USE_SESSION_DATABASE

See Also:
  Constant Field Values

#### ENABLE_STAGE_S3_PRIVATELINK_FOR_US_EAST_1

    public static final String ENABLE_STAGE_S3_PRIVATELINK_FOR_US_EAST_1

See Also:
  Constant Field Values

#### SF_HEADER_CLIENT_APP_ID

    public static final String SF_HEADER_CLIENT_APP_ID

See Also:
  Constant Field Values

#### SF_HEADER_CLIENT_APP_VERSION

    public static final String SF_HEADER_CLIENT_APP_VERSION

See Also:
  Constant Field Values

#### DEFAULT_CLIENT_MEMORY_LIMIT

    public static long DEFAULT_CLIENT_MEMORY_LIMIT

#### DEFAULT_CLIENT_PREFETCH_THREADS

    public static int DEFAULT_CLIENT_PREFETCH_THREADS

#### MIN_CLIENT_CHUNK_SIZE

    public static int MIN_CLIENT_CHUNK_SIZE

#### MAX_CLIENT_CHUNK_SIZE

    public static int MAX_CLIENT_CHUNK_SIZE

#### JVM_PARAMS_TO_PARAMS

    public static Map<String,​String> JVM_PARAMS_TO_PARAMS

### Constructor Detail

#### SessionUtil

    public SessionUtil()

### Method Detail

#### deleteIdTokenCache

    public static void deleteIdTokenCache​(String host,
                                          String user)

Delete the id token cache

Parameters:
  `host` - The host string
  `user` - The user

#### deleteOAuthAccessTokenCache

    @SnowflakeJdbcInternalApi
    public static void deleteOAuthAccessTokenCache​(String host,
                                                   String user)

Delete the Oauth access token cache

Parameters:
  `host` - The host string
  `user` - The user

#### deleteOAuthRefreshTokenCache

    @SnowflakeJdbcInternalApi
    public static void deleteOAuthRefreshTokenCache​(String host,
                                                    String user)

Delete the Oauth refresh token cache

Parameters:
  `host` - The host string
  `user` - The user

#### deleteMfaTokenCache

    public static void deleteMfaTokenCache​(String host,
                                           String user)

Delete the mfa token cache

Parameters:
  `host` - The host string
  `user` - The user

#### getCommonParams

    public static Map<String,​Object> getCommonParams​(com.fasterxml.jackson.databind.JsonNode paramsNode)

Helper function to parse a JsonNode from a GS response containing CommonParameters, emitting an EnumMap of parameters

Parameters:
  `paramsNode` - parameters in JSON form
Returns:
  map object including key and value pairs

#### resetOCSPUrlIfNecessary

    public static void resetOCSPUrlIfNecessary​(String serverUrl)
                                        throws IOException

Set OCSP cache server. If the URL is for private link sets it to special cache server.

Parameters:
  `serverUrl` - The Snowflake URL includes protocol such as "https://"
Throws:
  `IOException` - If exception encountered

#### generateJWTToken

    public static String generateJWTToken​(PrivateKey privateKey,
                                          String privateKeyFile,
                                          String privateKeyBase64,
                                          String privateKeyPwd,
                                          String accountName,
                                          String userName)
                                   throws SFException

Helper function to generate a JWT token

Parameters:
  `privateKey` - private key
  `privateKeyFile` - path to private key file
  `privateKeyBase64` - base64 encoded content of the private key file
  `privateKeyPwd` - password for private key file or base64 encoded private key
  `accountName` - account name
  `userName` - user name
Returns:
  JWT token
Throws:
  `SFException` - if Snowflake error occurs

#### generateJWTToken

    @Deprecated
    public static String generateJWTToken​(PrivateKey privateKey,
                                          String privateKeyFile,
                                          String privateKeyFilePwd,
                                          String accountName,
                                          String userName)
                                   throws SFException

Deprecated.
Helper function to generate a JWT token. Use `generateJWTToken(PrivateKey, String, String, String, String, String)`

Parameters:
  `privateKey` - private key
  `privateKeyFile` - path to private key file
  `privateKeyFilePwd` - password for private key file
  `accountName` - account name
  `userName` - user name
Returns:
  JWT token
Throws:
  `SFException` - if Snowflake error occurs

#### isNewRetryStrategyRequest

    public static boolean isNewRetryStrategyRequest​(org.apache.http.client.methods.HttpRequestBase request)

Helper method to check if the request path is a login/auth request to use for retry strategy.

Parameters:
  `request` - the post request
Returns:
  true if this is a login/auth request, false otherwise