use of com.amazonaws.auth.AWSCredentials in project nifi by apache.
the class TestCredentialsProviderFactory method testAnonymousCredentials.
@Test
public void testAnonymousCredentials() throws Throwable {
final TestRunner runner = TestRunners.newTestRunner(MockAWSProcessor.class);
runner.setProperty(CredentialPropertyDescriptors.USE_ANONYMOUS_CREDENTIALS, "true");
runner.assertValid();
Map<PropertyDescriptor, String> properties = runner.getProcessContext().getProperties();
final CredentialsProviderFactory factory = new CredentialsProviderFactory();
final AWSCredentialsProvider credentialsProvider = factory.getCredentialsProvider(properties);
Assert.assertNotNull(credentialsProvider);
final AWSCredentials creds = credentialsProvider.getCredentials();
assertEquals("credentials should be equal", AnonymousAWSCredentials.class, creds.getClass());
}
use of com.amazonaws.auth.AWSCredentials 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);
}
}
}
use of com.amazonaws.auth.AWSCredentials in project jointware by isdream.
the class EC2Main method main.
/**
* @param args
*/
public static void main(String[] args) {
AWSCredentials ac = new BasicAWSCredentials(ACCESS_KEY_ID, ACCESS_KEY_SECRET);
AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(ac);
AmazonEC2 ec2 = AmazonEC2ClientBuilder.standard().withRegion(Regions.AP_NORTHEAST_1).withCredentials(credentialsProvider).build();
System.out.println(ec2.getClass().getName());
// for (com.amazonaws.services.ec2.model.Region region : ec2.describeRegions().getRegions()) {
// System.out.println(region.getRegionName());
// }
}
use of com.amazonaws.auth.AWSCredentials in project flink by apache.
the class AWSUtilTest method testGetCredentialsProviderNamedProfile.
@Test
public void testGetCredentialsProviderNamedProfile() {
Properties testConfig = new Properties();
testConfig.setProperty(AWS_CREDENTIALS_PROVIDER, "PROFILE");
testConfig.setProperty(AWSConfigConstants.profileName(AWS_CREDENTIALS_PROVIDER), "foo");
testConfig.setProperty(AWSConfigConstants.profilePath(AWS_CREDENTIALS_PROVIDER), "src/test/resources/profile");
AWSCredentialsProvider credentialsProvider = AWSUtil.getCredentialsProvider(testConfig);
assertTrue(credentialsProvider instanceof ProfileCredentialsProvider);
AWSCredentials credentials = credentialsProvider.getCredentials();
assertEquals("22222222222222222222", credentials.getAWSAccessKeyId());
assertEquals("wJalrXUtnFEMI/K7MDENG/bPxRfiCY2222222222", credentials.getAWSSecretKey());
}
use of com.amazonaws.auth.AWSCredentials in project aws-doc-sdk-examples by awsdocs.
the class DiscoverInstances method main.
public static void main(String[] args) {
final String USAGE = "\n" + "To run this example, supply the Namespacename , ServiceName of aws cloud map!\n" + "\n" + "Ex: DiscoverInstances <namespace-name> <service-name> \n";
if (args.length < 2) {
System.out.println(USAGE);
System.exit(1);
}
String namespace_name = args[0];
String service_name = args[1];
AWSCredentials credentials = null;
try {
credentials = new EnvironmentVariableCredentialsProvider().getCredentials();
} catch (Exception e) {
throw new AmazonClientException("Cannot Load Credentials");
}
System.out.format("Instances in AWS cloud map %s:\n", namespace_name);
AWSServiceDiscovery client = AWSServiceDiscoveryClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(credentials)).withRegion(System.getenv("AWS_REGION")).build();
DiscoverInstancesRequest request = new DiscoverInstancesRequest();
request.setNamespaceName(namespace_name);
request.setServiceName(service_name);
DiscoverInstancesResult result = client.discoverInstances(request);
System.out.println(result.toString());
}
Aggregations