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
TypeDescription
String

CLOUD_SQL_INSTANCE_PROPERTY

public static final String CLOUD_SQL_INSTANCE_PROPERTY
Field Value
TypeDescription
String

CLOUD_SQL_TARGET_PRINCIPAL_PROPERTY

public static final String CLOUD_SQL_TARGET_PRINCIPAL_PROPERTY
Field Value
TypeDescription
String

DEFAULT_IP_TYPES

public static final String DEFAULT_IP_TYPES
Field Value
TypeDescription
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
TypeDescription
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
NameDescription
artifactIdString

connect(Properties props)

public static Socket connect(Properties props)

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

Parameter
NameDescription
propsProperties
Returns
TypeDescription
Socket
Exceptions
TypeDescription
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
NameDescription
propsProperties

Properties used to configure the connection.

unixPathSuffixString

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

Returns
TypeDescription
Socket

the newly created Socket.

Exceptions
TypeDescription
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
NameDescription
csqlInstanceNameString
ipTypesString
targetPrincipalString
delegatesList<String>
Returns
TypeDescription
String
Exceptions
TypeDescription
IOException

getInstance()

public static synchronized CoreSocketFactory getInstance()

Returns the CoreSocketFactory singleton.

Returns
TypeDescription
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
NameDescription
csqlInstanceNameString
enableIamAuthboolean
targetPrincipalString
delegatesList<String>
Returns
TypeDescription
com.google.cloud.sql.core.SslData
Exceptions
TypeDescription
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
NameDescription
applicationNameString