Class CoreSocketFactory (1.14.1)

public final class CoreSocketFactory

Factory responsible for obtaining an ephemeral certificate, if necessary, and establishing a secure connecting to a Cloud SQL instance.

This class should not be used directly, but only through the JDBC driver specific SocketFactory implementations.

The API of this class is subject to change without notice.

Inheritance

java.lang.Object > CoreSocketFactory

Static Fields

CLOUD_SQL_DELEGATES_PROPERTY

public static final String CLOUD_SQL_DELEGATES_PROPERTY
Field Value
Type Description
String

CLOUD_SQL_INSTANCE_PROPERTY

public static final String CLOUD_SQL_INSTANCE_PROPERTY
Field Value
Type Description
String

CLOUD_SQL_TARGET_PRINCIPAL_PROPERTY

public static final String CLOUD_SQL_TARGET_PRINCIPAL_PROPERTY
Field Value
Type Description
String

DEFAULT_IP_TYPES

public static final String DEFAULT_IP_TYPES
Field Value
Type Description
String

USER_TOKEN_PROPERTY_NAME (deprecated)

public static final String USER_TOKEN_PROPERTY_NAME

Deprecated. Use #setApplicationName(String) to set the application name programmatically.

Property used to set the application name for the underlying SQLAdmin client.

Field Value
Type Description
String

Static Methods

addArtifactId(String artifactId)

public static void addArtifactId(String artifactId)

Internal use only: Sets the default string which is appended to the SQLAdmin API client User-Agent header.

This is used by the specific database connector socket factory implementations to append their database name to the user agent.

Parameter
Name Description
artifactId String

connect(Properties props)

public static Socket connect(Properties props)

Creates a socket representing a connection to a Cloud SQL instance.

Parameter
Name Description
props Properties
Returns
Type Description
Socket
Exceptions
Type Description
IOException
InterruptedException

connect(Properties props, String unixPathSuffix)

public static Socket connect(Properties props, String unixPathSuffix)

Creates a socket representing a connection to a Cloud SQL instance.

Depending on the given properties, it may return either a SSL Socket or a Unix Socket.

Parameters
Name Description
props Properties

Properties used to configure the connection.

unixPathSuffix String

suffix to add the the Unix socket path. Unused if null.

Returns
Type Description
Socket

the newly created Socket.

Exceptions
Type Description
IOException

if error occurs during socket creation.

InterruptedException

if error occurs during socket creation.

getHostIp(String csqlInstanceName, String ipTypes, String targetPrincipal, List<String> delegates)

public static String getHostIp(String csqlInstanceName, String ipTypes, String targetPrincipal, List<String> delegates)

Returns preferred ip address that can be used to establish Cloud SQL connection.

Parameters
Name Description
csqlInstanceName String
ipTypes String
targetPrincipal String
delegates List<String>
Returns
Type Description
String
Exceptions
Type Description
IOException

getInstance()

public static synchronized CoreSocketFactory getInstance()

Returns the CoreSocketFactory singleton.

Returns
Type Description
CoreSocketFactory

getSslData(String csqlInstanceName, boolean enableIamAuth, String targetPrincipal, List<String> delegates)

public static SslData getSslData(String csqlInstanceName, boolean enableIamAuth, String targetPrincipal, List<String> delegates)

Returns data that can be used to establish Cloud SQL SSL connection.

Parameters
Name Description
csqlInstanceName String
enableIamAuth boolean
targetPrincipal String
delegates List<String>
Returns
Type Description
com.google.cloud.sql.core.SslData
Exceptions
Type Description
IOException

setApplicationName(String applicationName)

public static void setApplicationName(String applicationName)

Adds an external application name to the user agent string for tracking. This is known to be used by the spring-cloud-gcp project.

Parameter
Name Description
applicationName String