use of com.amazonaws.auth.BasicAWSCredentials in project android-simpl3r by jgilfelt.
the class UploadService method onCreate.
@Override
public void onCreate() {
super.onCreate();
s3Client = new AmazonS3Client(new BasicAWSCredentials(getString(R.string.s3_access_key), getString(R.string.s3_secret)));
nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
IntentFilter f = new IntentFilter();
f.addAction(UPLOAD_CANCELLED_ACTION);
registerReceiver(uploadCancelReceiver, f);
}
use of com.amazonaws.auth.BasicAWSCredentials in project openhab1-addons by openhab.
the class DynamoDBConfig method fromConfig.
/**
*
* @param config persistence service configuration
* @return DynamoDB configuration. Returns null in case of configuration errors
*/
public static DynamoDBConfig fromConfig(Map<String, Object> config) {
if (config == null || config.isEmpty()) {
logger.error("Configuration not provided! At least AWS region and credentials must be provided.");
return null;
}
try {
String regionName = (String) config.get("region");
if (isBlank(regionName)) {
invalidRegionLogHelp(regionName);
return null;
}
final Region region;
try {
region = Region.getRegion(Regions.fromName(regionName));
} catch (IllegalArgumentException e) {
invalidRegionLogHelp(regionName);
return null;
}
AWSCredentials credentials;
String accessKey = (String) config.get("accessKey");
String secretKey = (String) config.get("secretKey");
if (!isBlank(accessKey) && !isBlank(secretKey)) {
logger.debug("accessKey and secretKey specified. Using those.");
credentials = new BasicAWSCredentials(accessKey, secretKey);
} else {
logger.debug("accessKey and/or secretKey blank. Checking profilesConfigFile and profile.");
String profilesConfigFile = (String) config.get("profilesConfigFile");
String profile = (String) config.get("profile");
if (isBlank(profilesConfigFile) || isBlank(profile)) {
logger.error("Specify either 1) accessKey and secretKey; or 2) profilesConfigFile and " + "profile for providing AWS credentials");
return null;
}
credentials = new ProfilesConfigFile(profilesConfigFile).getCredentials(profile);
}
String table = (String) config.get("tablePrefix");
if (isBlank(table)) {
logger.debug("Using default table name {}", DEFAULT_TABLE_PREFIX);
table = DEFAULT_TABLE_PREFIX;
}
final boolean createTable;
String createTableParam = (String) config.get("createTable");
if (isBlank(createTableParam)) {
logger.debug("Creating table on demand: {}", DEFAULT_CREATE_TABLE_ON_DEMAND);
createTable = DEFAULT_CREATE_TABLE_ON_DEMAND;
} else {
createTable = Boolean.parseBoolean(createTableParam);
}
final long readCapacityUnits;
String readCapacityUnitsParam = (String) config.get("readCapacityUnits");
if (isBlank(readCapacityUnitsParam)) {
logger.debug("Read capacity units: {}", DEFAULT_READ_CAPACITY_UNITS);
readCapacityUnits = DEFAULT_READ_CAPACITY_UNITS;
} else {
readCapacityUnits = Long.parseLong(readCapacityUnitsParam);
}
final long writeCapacityUnits;
String writeCapacityUnitsParam = (String) config.get("writeCapacityUnits");
if (isBlank(writeCapacityUnitsParam)) {
logger.debug("Write capacity units: {}", DEFAULT_WRITE_CAPACITY_UNITS);
writeCapacityUnits = DEFAULT_WRITE_CAPACITY_UNITS;
} else {
writeCapacityUnits = Long.parseLong(writeCapacityUnitsParam);
}
return new DynamoDBConfig(region, credentials, table, createTable, readCapacityUnits, writeCapacityUnits);
} catch (Exception e) {
logger.error("Error with configuration", e);
return null;
}
}
use of com.amazonaws.auth.BasicAWSCredentials in project exhibitor by soabase.
the class S3ClientImpl method changeCredentials.
@Override
public void changeCredentials(S3Credential credential) {
RefCountedClient newRefCountedClient = (credential != null) ? new RefCountedClient(createClient(null, new BasicAWSCredentials(credential.getAccessKeyId(), credential.getSecretAccessKey()), null)) : new RefCountedClient(createClient(null, null, null));
RefCountedClient oldRefCountedClient = client.getAndSet(newRefCountedClient);
if (oldRefCountedClient != null) {
oldRefCountedClient.markForDelete();
}
}
use of com.amazonaws.auth.BasicAWSCredentials in project siena by mandubian.
the class SdbPersistenceManager method init.
public void init(Properties p) {
String awsAccessKeyId = p.getProperty("awsAccessKeyId");
String awsSecretAccessKey = p.getProperty("awsSecretAccessKey");
if (awsAccessKeyId == null || awsSecretAccessKey == null)
throw new SienaException("Both awsAccessKeyId and awsSecretAccessKey properties must be set");
prefix = p.getProperty("prefix");
if (prefix == null)
prefix = "";
sdb = new AmazonSimpleDBClient(new BasicAWSCredentials(awsAccessKeyId, awsSecretAccessKey));
}
use of com.amazonaws.auth.BasicAWSCredentials in project ORCID-Source by ORCID.
the class S3Utils method createBuckets.
//Create S3 buckets for a given prefix
public static void createBuckets(String bucketPrefix, String accessKey, String secretKey) {
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
AmazonS3 s3 = new AmazonS3Client(credentials);
String api12JsonPrefix = bucketPrefix + "-api-1-2-json-";
String api12XMLPrefix = bucketPrefix + "-api-1-2-xml-";
String api20JsonPrefix = bucketPrefix + "-api-2-0-json-";
String api20XMLPrefix = bucketPrefix + "-api-2-0-xml-";
for (int i = 0; i <= 10; i++) {
char lastCharacter = (i == 10 ? 'x' : Character.forDigit(i, 10));
if (!s3.doesBucketExist(api12JsonPrefix + lastCharacter)) {
s3.createBucket((api12JsonPrefix + lastCharacter), Region.EU_Ireland);
}
if (!s3.doesBucketExist(api12XMLPrefix + lastCharacter)) {
s3.createBucket((api12XMLPrefix + lastCharacter), Region.EU_Ireland);
}
if (!s3.doesBucketExist(api20JsonPrefix + lastCharacter)) {
s3.createBucket((api20JsonPrefix + lastCharacter), Region.EU_Ireland);
}
if (!s3.doesBucketExist(api20XMLPrefix + lastCharacter)) {
s3.createBucket((api20XMLPrefix + lastCharacter), Region.EU_Ireland);
}
}
}
Aggregations