com.google.cloud.sql.CredentialFactory Java Examples

The following examples show how to use com.google.cloud.sql.CredentialFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GcpCloudSqlAutoConfiguration.java    From spring-cloud-gcp with Apache License 2.0 6 votes vote down vote up
private void setSystemProperties(File credentialsLocationFile) {
	// This should happen if the Spring resource isn't in the filesystem, but a URL,
	// classpath file, etc.
	if (credentialsLocationFile == null) {
		LOGGER.info("The private key of the Google Cloud SQL credential must "
				+ "be in a file on the filesystem.");
		return;
	}

	System.setProperty(SqlCredentialFactory.CREDENTIAL_LOCATION_PROPERTY_NAME,
			credentialsLocationFile.getAbsolutePath());

	// If there are specified credentials, tell sockets factory to use them.
	System.setProperty(CredentialFactory.CREDENTIAL_FACTORY_PROPERTY,
			SqlCredentialFactory.class.getName());
}
 
Example #2
Source File: GcpCloudSqlAutoConfiguration.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
private void setCredentialsEncodedKeyProperty(GcpCloudSqlProperties gcpCloudSqlProperties) {
	Credentials credentials = gcpCloudSqlProperties.getCredentials();

	if (credentials.getEncodedKey() == null) {
		LOGGER.info("SQL properties contain no encoded key. Can't set credentials.");
		return;
	}

	System.setProperty(SqlCredentialFactory.CREDENTIAL_ENCODED_KEY_PROPERTY_NAME,
			credentials.getEncodedKey());

	System.setProperty(CredentialFactory.CREDENTIAL_FACTORY_PROPERTY,
			SqlCredentialFactory.class.getName());
}
 
Example #3
Source File: CloudSqlCredentialSupplier.java    From nomulus with Apache License 2.0 4 votes vote down vote up
/** Initialize the supplier with given credential json and scopes. */
public static void setupCredentialSupplier(Credential credential) {
  System.setProperty(
      CredentialFactory.CREDENTIAL_FACTORY_PROPERTY, CloudSqlCredentialSupplier.class.getName());
  CloudSqlCredentialSupplier.credential = credential;
}