in core/src/main/java/com/google/cloud/sql/core/ConnectionConfig.java [78:137]
public static ConnectionConfig fromConnectionProperties(Properties props, String domainName) {
final String csqlInstanceName = props.getProperty(ConnectionConfig.CLOUD_SQL_INSTANCE_PROPERTY);
final String namedConnection =
props.getProperty(ConnectionConfig.CLOUD_SQL_NAMED_CONNECTOR_PROPERTY);
final String unixSocketPath = props.getProperty(ConnectionConfig.UNIX_SOCKET_PROPERTY);
final AuthType authType =
Boolean.parseBoolean(props.getProperty(ConnectionConfig.ENABLE_IAM_AUTH_PROPERTY))
? AuthType.IAM
: AuthType.PASSWORD;
final String targetPrincipal =
props.getProperty(ConnectionConfig.CLOUD_SQL_TARGET_PRINCIPAL_PROPERTY);
final String delegatesStr = props.getProperty(ConnectionConfig.CLOUD_SQL_DELEGATES_PROPERTY);
final List<String> delegates;
if (delegatesStr != null && !delegatesStr.isEmpty()) {
delegates = Arrays.asList(delegatesStr.split(","));
} else {
delegates = Collections.emptyList();
}
final List<IpType> ipTypes =
listIpTypes(
props.getProperty(
ConnectionConfig.IP_TYPES_PROPERTY, ConnectionConfig.DEFAULT_IP_TYPES));
final String adminRootUrl =
props.getProperty(ConnectionConfig.CLOUD_SQL_ADMIN_ROOT_URL_PROPERTY);
final String adminServicePath =
props.getProperty(ConnectionConfig.CLOUD_SQL_ADMIN_SERVICE_PATH_PROPERTY);
final String unixSocketPathSuffix =
props.getProperty(ConnectionConfig.UNIX_SOCKET_PATH_SUFFIX_PROPERTY);
final String googleCredentialsPath =
props.getProperty(ConnectionConfig.CLOUD_SQL_GOOGLE_CREDENTIALS_PATH);
final String adminQuotaProject =
props.getProperty(ConnectionConfig.CLOUD_SQL_ADMIN_QUOTA_PROJECT_PROPERTY);
final String universeDomain = props.getProperty(ConnectionConfig.CLOUD_SQL_UNIVERSE_DOMAIN);
final String refreshStrategyStr =
props.getProperty(ConnectionConfig.CLOUD_SQL_REFRESH_STRATEGY_PROPERTY);
final RefreshStrategy refreshStrategy =
"lazy".equalsIgnoreCase(refreshStrategyStr)
? RefreshStrategy.LAZY
: RefreshStrategy.BACKGROUND;
return new ConnectionConfig(
csqlInstanceName,
namedConnection,
unixSocketPath,
ipTypes,
authType,
unixSocketPathSuffix,
domainName,
new ConnectorConfig.Builder()
.withTargetPrincipal(targetPrincipal)
.withDelegates(delegates)
.withAdminRootUrl(adminRootUrl)
.withAdminServicePath(adminServicePath)
.withGoogleCredentialsPath(googleCredentialsPath)
.withAdminQuotaProject(adminQuotaProject)
.withUniverseDomain(universeDomain)
.withRefreshStrategy(refreshStrategy)
.build());
}