List of usage examples for com.amazonaws.auth DefaultAWSCredentialsProviderChain DefaultAWSCredentialsProviderChain
public DefaultAWSCredentialsProviderChain()
From source file:com.denismo.aws.iam.LDAPIAMPoller.java
License:Apache License
public LDAPIAMPoller(DirectoryService directoryService) throws LdapException { this.directory = directoryService; credentials = new DefaultAWSCredentialsProviderChain(); try {/*from w w w. ja v a 2 s . co m*/ credentials.getCredentials(); // throws } catch (AmazonClientException ex) { LOG.error("AWS credentials error", ex); throw new LdapException("Unable to initialze AWS poller - cannot retrieve valid credentials"); } utils = new ApacheDSUtils(directory); runner = new Runner(directory); LOG.info("IAMPoller created"); }
From source file:com.denismo.aws.iam.UIDAllocator.java
License:Apache License
public UIDAllocator(AWSCredentialsProvider credentials, String space) throws LdapException { this.table = "IAM" + space; client = new AmazonDynamoDBClient( new AWSCredentialsProviderChain(new DefaultAWSCredentialsProviderChain(), credentials)); client.setEndpoint("dynamodb.ap-southeast-2.amazonaws.com"); createTable();// w w w.j ava 2 s . co m }
From source file:com.digitalpebble.stormcrawler.aws.s3.AbstractS3CacheBolt.java
License:Apache License
/** Returns an S3 client given the configuration **/ public static AmazonS3Client getS3Client(Map conf) { AWSCredentialsProvider provider = new DefaultAWSCredentialsProviderChain(); AWSCredentials credentials = provider.getCredentials(); ClientConfiguration config = new ClientConfiguration(); AmazonS3Client client = new AmazonS3Client(credentials, config); String regionName = ConfUtils.getString(conf, REGION); if (StringUtils.isNotBlank(regionName)) { client.setRegion(RegionUtils.getRegion(regionName)); }/*from w w w .ja v a2 s. c o m*/ String endpoint = ConfUtils.getString(conf, ENDPOINT); if (StringUtils.isNotBlank(endpoint)) { client.setEndpoint(endpoint); } return client; }
From source file:com.dtolabs.rundeck.plugin.resources.ec2.InstanceToNodeMapper.java
License:Apache License
/** * Perform the query asynchronously and return the set of instances * */// w w w . j a v a2 s . c om public Future<INodeSet> performQueryAsync() { final AmazonEC2AsyncClient ec2; if (null != credentials) { ec2 = new AmazonEC2AsyncClient(credentials, clientConfiguration, executorService); } else { ec2 = new AmazonEC2AsyncClient(new DefaultAWSCredentialsProviderChain(), clientConfiguration, executorService); } if (null != getEndpoint()) { ec2.setEndpoint(getEndpoint()); } final ArrayList<Filter> filters = buildFilters(); final Future<DescribeInstancesResult> describeInstancesRequest = ec2 .describeInstancesAsync(new DescribeInstancesRequest().withFilters(filters)); return new Future<INodeSet>() { public boolean cancel(boolean b) { return describeInstancesRequest.cancel(b); } public boolean isCancelled() { return describeInstancesRequest.isCancelled(); } public boolean isDone() { return describeInstancesRequest.isDone(); } public INodeSet get() throws InterruptedException, ExecutionException { DescribeInstancesResult describeInstancesResult = describeInstancesRequest.get(); final NodeSetImpl nodeSet = new NodeSetImpl(); final Set<Instance> instances = examineResult(describeInstancesResult); mapInstances(nodeSet, instances); return nodeSet; } public INodeSet get(final long l, final TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException { DescribeInstancesResult describeInstancesResult = describeInstancesRequest.get(l, timeUnit); final NodeSetImpl nodeSet = new NodeSetImpl(); final Set<Instance> instances = examineResult(describeInstancesResult); mapInstances(nodeSet, instances); return nodeSet; } }; }
From source file:com.epam.dlab.auth.modules.AwsSecurityServiceModule.java
License:Apache License
@Provides @Singleton public AWSCredentialsProvider defaultAWSCredentialsProviderChain() { return new DefaultAWSCredentialsProviderChain(); }
From source file:com.facebook.presto.kinesis.KinesisClientManager.java
License:Apache License
@Inject KinesisClientManager(@Named("connectorId") String connectorId, KinesisConnectorConfig kinesisConnectorConfig) { log.info("Creating new client for Consuner"); if (kinesisConnectorConfig.getAccessKey() == null || kinesisConnectorConfig.getSecretKey() == null) { this.kinesisAwsCredentials = null; this.client = new AmazonKinesisClient(new DefaultAWSCredentialsProviderChain()); this.dynamoDBClient = new AmazonDynamoDBClient(new DefaultAWSCredentialsProviderChain()); } else {//from w ww. ja v a2 s . co m this.kinesisAwsCredentials = new KinesisAwsCredentials(kinesisConnectorConfig.getAccessKey(), kinesisConnectorConfig.getSecretKey()); this.client = new AmazonKinesisClient(this.kinesisAwsCredentials); this.dynamoDBClient = new AmazonDynamoDBClient(this.kinesisAwsCredentials); } this.client.setEndpoint("kinesis." + kinesisConnectorConfig.getAwsRegion() + ".amazonaws.com"); this.dynamoDBClient.setEndpoint("dynamodb." + kinesisConnectorConfig.getAwsRegion() + ".amazonaws.com"); }
From source file:com.github.gregwhitaker.awspolly.example.PollyModule.java
License:Apache License
@Override protected void configure() { bind(AmazonPollyAsyncClient.class) .toInstance(new AmazonPollyAsyncClient(new DefaultAWSCredentialsProviderChain())); bind(PollyReadHandler.class); bind(PollyVoicesHandler.class); }
From source file:com.github.gregwhitaker.sns.Consumer.java
License:Apache License
public Consumer(String name, String queueArn) { this.name = name; this.queueArn = queueArn; this.sqsClient = new AmazonSQSClient(new DefaultAWSCredentialsProviderChain()); this.sqsClient.setRegion(Region.getRegion(Regions.US_WEST_2)); }
From source file:com.github.gregwhitaker.sns.Producer.java
License:Apache License
public Producer(String name, String topicArn) { this.name = name; this.topicArn = topicArn; this.snsClient = new AmazonSNSClient(new DefaultAWSCredentialsProviderChain()); this.snsClient.setRegion(Region.getRegion(Regions.US_WEST_2)); }
From source file:com.github.jramos.snowplow.RedshiftSink.java
License:Apache License
public RedshiftSink(String pathToConfigFile) { InputStream configStream = null; properties = new Properties(); try {//from ww w .j a v a 2 s. c o m File configFile = new File(pathToConfigFile); if (!configFile.exists()) { throw new IOException(); } configStream = new FileInputStream(configFile); properties.load(configStream); properties.forEach((key, value) -> { String resolvedValue = resolveEnvVars(value.toString()); properties.setProperty(key.toString(), resolvedValue); }); } catch (IOException ioe) { String msg = "Could not load properties file " + pathToConfigFile; LOG.error(msg, ioe); throw new IllegalStateException(msg, ioe); } finally { if (configStream != null) { try { configStream.close(); } catch (IOException ioe) { } } } AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain(); this.config = new RedshiftSinkConfiguration(properties, credentialsProvider); super.initialize(config); }