use of com.amazonaws.auth.PropertiesFileCredentialsProvider in project beam by apache.
the class AwsSerializableUtilsTest method testPropertiesFileCredentialsProviderSerialization.
@Test
public void testPropertiesFileCredentialsProviderSerialization() {
AWSCredentialsProvider credentialsProvider = new PropertiesFileCredentialsProvider("AwsCredentials.properties");
String expectedSerializedProvider = "{\"@type\":\"PropertiesFileCredentialsProvider\",\"credentialsFilePath\":\"AwsCredentials.properties\"}";
String serializedProvider = serialize(credentialsProvider);
assertEquals(expectedSerializedProvider, serializedProvider);
assertEquals(expectedSerializedProvider, serialize(deserialize(serializedProvider)));
}
use of com.amazonaws.auth.PropertiesFileCredentialsProvider in project cas by apereo.
the class ChainingAWSCredentialsProvider method getInstance.
/**
* Gets instance.
*
* @param credentialAccessKey the credential access key
* @param credentialSecretKey the credential secret key
* @param credentialPropertiesFile the credential properties file
* @param profilePath the profile path
* @param profileName the profile name
* @return the instance
*/
public static AWSCredentialsProvider getInstance(final String credentialAccessKey, final String credentialSecretKey, final Resource credentialPropertiesFile, final String profilePath, final String profileName) {
LOGGER.debug("Attempting to locate AWS credentials...");
final List<AWSCredentialsProvider> chain = new ArrayList<>();
chain.add(new InstanceProfileCredentialsProvider(false));
if (credentialPropertiesFile != null) {
try {
final File f = credentialPropertiesFile.getFile();
chain.add(new PropertiesFileCredentialsProvider(f.getCanonicalPath()));
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
if (StringUtils.isNotBlank(profilePath) && StringUtils.isNotBlank(profileName)) {
chain.add(new ProfileCredentialsProvider(profilePath, profileName));
}
chain.add(new SystemPropertiesCredentialsProvider());
chain.add(new EnvironmentVariableCredentialsProvider());
chain.add(new ClasspathPropertiesFileCredentialsProvider("awscredentials.properties"));
if (StringUtils.isNotBlank(credentialAccessKey) && StringUtils.isNotBlank(credentialSecretKey)) {
final BasicAWSCredentials credentials = new BasicAWSCredentials(credentialAccessKey, credentialSecretKey);
chain.add(new AWSStaticCredentialsProvider(credentials));
}
LOGGER.debug("AWS chained credential providers are configured as [{}]", chain);
return new ChainingAWSCredentialsProvider(chain);
}
use of com.amazonaws.auth.PropertiesFileCredentialsProvider in project beam by apache.
the class AwsModuleTest method testPropertiesFileCredentialsProviderSerializationDeserialization.
@Test
public void testPropertiesFileCredentialsProviderSerializationDeserialization() throws Exception {
String credentialsFilePath = "/path/to/file";
AWSCredentialsProvider credentialsProvider = new PropertiesFileCredentialsProvider(credentialsFilePath);
String serializedCredentialsProvider = serialize(credentialsProvider);
AWSCredentialsProvider deserializedCredentialsProvider = deserializeCredentialsProvider(serializedCredentialsProvider);
assertEquals(credentialsProvider.getClass(), deserializedCredentialsProvider.getClass());
assertEquals(credentialsFilePath, readField(deserializedCredentialsProvider, "credentialsFilePath", true));
}
use of com.amazonaws.auth.PropertiesFileCredentialsProvider in project beam by apache.
the class AwsModuleTest method testPropertiesFileCredentialsProviderSerializationDeserialization.
@Test
public void testPropertiesFileCredentialsProviderSerializationDeserialization() throws Exception {
String credentialsFilePath = "/path/to/file";
PropertiesFileCredentialsProvider credentialsProvider = new PropertiesFileCredentialsProvider(credentialsFilePath);
String serializedCredentialsProvider = objectMapper.writeValueAsString(credentialsProvider);
AWSCredentialsProvider deserializedCredentialsProvider = objectMapper.readValue(serializedCredentialsProvider, AWSCredentialsProvider.class);
assertEquals(credentialsProvider.getClass(), deserializedCredentialsProvider.getClass());
assertEquals(credentialsFilePath, readField(deserializedCredentialsProvider, "credentialsFilePath", true));
}
Aggregations