use of com.amazonaws.auth.BasicAWSCredentials in project cas by apereo.
the class DynamoDbServiceRegistryConfiguration method amazonDynamoDbClient.
@RefreshScope
@Bean
public AmazonDynamoDBClient amazonDynamoDbClient() {
try {
final DynamoDbServiceRegistryProperties dynamoDbProperties = casProperties.getServiceRegistry().getDynamoDb();
final ClientConfiguration cfg = new ClientConfiguration();
cfg.setConnectionTimeout(dynamoDbProperties.getConnectionTimeout());
cfg.setMaxConnections(dynamoDbProperties.getMaxConnections());
cfg.setRequestTimeout(dynamoDbProperties.getRequestTimeout());
cfg.setSocketTimeout(dynamoDbProperties.getSocketTimeout());
cfg.setUseGzip(dynamoDbProperties.isUseGzip());
cfg.setUseReaper(dynamoDbProperties.isUseReaper());
cfg.setUseThrottleRetries(dynamoDbProperties.isUseThrottleRetries());
cfg.setUseTcpKeepAlive(dynamoDbProperties.isUseTcpKeepAlive());
cfg.setProtocol(Protocol.valueOf(dynamoDbProperties.getProtocol().toUpperCase()));
cfg.setClientExecutionTimeout(dynamoDbProperties.getClientExecutionTimeout());
cfg.setCacheResponseMetadata(dynamoDbProperties.isCacheResponseMetadata());
if (StringUtils.isNotBlank(dynamoDbProperties.getLocalAddress())) {
cfg.setLocalAddress(InetAddress.getByName(dynamoDbProperties.getLocalAddress()));
}
AWSCredentials credentials = null;
if (dynamoDbProperties.getCredentialsPropertiesFile() != null) {
credentials = new PropertiesCredentials(dynamoDbProperties.getCredentialsPropertiesFile().getInputStream());
} else if (StringUtils.isNotBlank(dynamoDbProperties.getCredentialAccessKey()) && StringUtils.isNotBlank(dynamoDbProperties.getCredentialSecretKey())) {
credentials = new BasicAWSCredentials(dynamoDbProperties.getCredentialAccessKey(), dynamoDbProperties.getCredentialSecretKey());
}
final AmazonDynamoDBClient client;
if (credentials == null) {
client = new AmazonDynamoDBClient(cfg);
} else {
client = new AmazonDynamoDBClient(credentials, cfg);
}
if (StringUtils.isNotBlank(dynamoDbProperties.getEndpoint())) {
client.setEndpoint(dynamoDbProperties.getEndpoint());
}
if (StringUtils.isNotBlank(dynamoDbProperties.getRegion())) {
client.setRegion(Region.getRegion(Regions.valueOf(dynamoDbProperties.getRegion())));
}
if (StringUtils.isNotBlank(dynamoDbProperties.getRegionOverride())) {
client.setSignerRegionOverride(dynamoDbProperties.getRegionOverride());
}
if (StringUtils.isNotBlank(dynamoDbProperties.getServiceNameIntern())) {
client.setServiceNameIntern(dynamoDbProperties.getServiceNameIntern());
}
if (dynamoDbProperties.getTimeOffset() != 0) {
client.setTimeOffset(dynamoDbProperties.getTimeOffset());
}
return client;
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
use of com.amazonaws.auth.BasicAWSCredentials in project simplejpa by appoxy.
the class EntityManagerFactoryImpl method createClients.
private void createClients() {
AWSCredentials awsCredentials = null;
InputStream credentialsFile = getClass().getClassLoader().getResourceAsStream("AwsCredentials.properties");
if (credentialsFile != null) {
logger.info("Loading credentials from AwsCredentials.properties");
try {
awsCredentials = new PropertiesCredentials(credentialsFile);
} catch (IOException e) {
throw new PersistenceException("Failed loading credentials from AwsCredentials.properties.", e);
}
} else {
logger.info("Loading credentials from simplejpa.properties");
String awsAccessKey = (String) this.props.get(AWSACCESS_KEY_PROP_NAME);
String awsSecretKey = (String) this.props.get(AWSSECRET_KEY_PROP_NAME);
if (awsAccessKey == null || awsAccessKey.length() == 0) {
throw new PersistenceException("AWS Access Key not found. It is a required property.");
}
if (awsSecretKey == null || awsSecretKey.length() == 0) {
throw new PersistenceException("AWS Secret Key not found. It is a required property.");
}
awsCredentials = new BasicAWSCredentials(awsAccessKey, awsSecretKey);
}
this.simpleDbClient = new AmazonSimpleDBClient(awsCredentials, createConfiguration(sdbSecure));
this.simpleDbClient.setEndpoint(sdbEndpoint);
this.s3Client = new AmazonS3Client(awsCredentials, createConfiguration(s3Secure));
this.s3Client.setEndpoint(s3Endpoint);
}
use of com.amazonaws.auth.BasicAWSCredentials in project aws-iam-ldap-bridge by denismo.
the class IAMSecretKeyValidator method verifyIAMPassword.
@Override
public boolean verifyIAMPassword(Entry user, String pw) throws LdapInvalidAttributeValueException, LdapAuthenticationException {
boolean role = false;
AWSCredentials creds;
if (isRole(user)) {
role = true;
String[] parts = pw.split("\\|");
if (parts == null || parts.length < 3)
throw new LdapAuthenticationException();
creds = new BasicSessionCredentials(parts[0], parts[1], parts[2]);
} else {
creds = new BasicAWSCredentials(user.get("accessKey").getString(), pw);
}
LOG.debug("Verifying {} {} with accessKey <hidden> and secretKey <hidden>", role ? "role" : "user", user.get("uid").getString());
AmazonIdentityManagementClient client = new AmazonIdentityManagementClient(creds);
try {
client.getAccountSummary();
} catch (AmazonClientException e) {
System.err.println(e.getMessage());
return false;
} finally {
client.shutdown();
}
return true;
}
use of com.amazonaws.auth.BasicAWSCredentials in project elasticsearch by elastic.
the class AwsEc2ServiceImpl method buildCredentials.
protected static AWSCredentialsProvider buildCredentials(Logger logger, Settings settings) {
AWSCredentialsProvider credentials;
String key = CLOUD_EC2.KEY_SETTING.get(settings);
String secret = CLOUD_EC2.SECRET_SETTING.get(settings);
if (key.isEmpty() && secret.isEmpty()) {
logger.debug("Using either environment variables, system properties or instance profile credentials");
credentials = new DefaultAWSCredentialsProviderChain();
} else {
logger.debug("Using basic key/secret credentials");
credentials = new StaticCredentialsProvider(new BasicAWSCredentials(key, secret));
}
return credentials;
}
use of com.amazonaws.auth.BasicAWSCredentials in project camel by apache.
the class SnsEndpoint method createSNSClient.
/**
* Provide the possibility to override this method for an mock implementation
*
* @return AmazonSNSClient
*/
AmazonSNS createSNSClient() {
AmazonSNS client = null;
ClientConfiguration clientConfiguration = null;
boolean isClientConfigFound = false;
if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
clientConfiguration = new ClientConfiguration();
clientConfiguration.setProxyHost(configuration.getProxyHost());
clientConfiguration.setProxyPort(configuration.getProxyPort());
isClientConfigFound = true;
}
if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) {
AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
if (isClientConfigFound) {
client = new AmazonSNSClient(credentials, clientConfiguration);
} else {
client = new AmazonSNSClient(credentials);
}
} else {
if (isClientConfigFound) {
client = new AmazonSNSClient();
} else {
client = new AmazonSNSClient(clientConfiguration);
}
}
return client;
}
Aggregations