Example usage for com.amazonaws.auth BasicAWSCredentials BasicAWSCredentials

List of usage examples for com.amazonaws.auth BasicAWSCredentials BasicAWSCredentials

Introduction

In this page you can find the example usage for com.amazonaws.auth BasicAWSCredentials BasicAWSCredentials.

Prototype

public BasicAWSCredentials(String accessKey, String secretKey) 

Source Link

Document

Constructs a new BasicAWSCredentials object, with the specified AWS access key and AWS secret key.

Usage

From source file:com.eucalyptus.simpleworkflow.common.client.WorkflowClientStandalone.java

License:Open Source License

private AWSCredentialsProvider getCredentialsProvider() {
    AWSCredentialsProvider provider = null;
    if (this.credentialPropertyFile != null) {
        provider = new AWSCredentialsProvider() {
            private String accessKey = null;
            private String secretAccessKey = null;

            private void readProperty() throws FileNotFoundException, IOException {
                final FileInputStream stream = new FileInputStream(new File(credentialPropertyFile));
                try {
                    Properties credentialProperties = new Properties();
                    credentialProperties.load(stream);

                    if (credentialProperties.getProperty("accessKey") == null
                            || credentialProperties.getProperty("secretKey") == null) {
                        throw new IllegalArgumentException("The specified file (" + credentialPropertyFile
                                + ") doesn't contain the expected properties 'accessKey' "
                                + "and 'secretKey'.");
                    }/*from w w w .  jav  a  2  s. c  o  m*/
                    accessKey = credentialProperties.getProperty("accessKey");
                    secretAccessKey = credentialProperties.getProperty("secretKey");
                } finally {
                    try {
                        stream.close();
                    } catch (final IOException e) {
                    }
                }
            }

            @Override
            public AWSCredentials getCredentials() {
                if (this.accessKey == null || this.secretAccessKey == null) {
                    try {
                        readProperty();
                    } catch (final Exception ex) {
                        throw new RuntimeException("Failed to read credentials file", ex);
                    }
                }
                return new BasicAWSCredentials(accessKey, secretAccessKey);
            }

            @Override
            public void refresh() {
                this.accessKey = null;
            }
        };
    } else {
        provider = new InstanceProfileCredentialsProvider();
    }

    return provider;
}

From source file:com.example.rafa.myapplication.AmazonClientManager.java

License:Open Source License

private void initClients() {
    /****credentials***/
    BasicAWSCredentials credentials = new BasicAWSCredentials("AKIAIFAXGBW3HDEGKF2Q",
            "AIaVirpRfFkwAyuqN38OviapQTGAZnVOPtB1Pg6G");
    ddb = new AmazonDynamoDBClient(credentials);

    // Amazon Database
    ddb.setRegion(Region.getRegion(Regions.US_EAST_1));

    // Local Database
    //ddb.setEndpoint("http://192.168.0.19:8000");
}

From source file:com.exorath.service.lastserver.dynamodb.LocalDynamoDBCreationRule.java

License:Apache License

@Override
protected void before() throws Throwable {
    try {//  w  w  w. java  2  s . c o  m
        final String port = getAvailablePort();
        this.server = ServerRunner.createServerFromCommandLineArgs(new String[] { "-inMemory", "-port", port });
        server.start();
        amazonDynamoDB = new AmazonDynamoDBClient(new BasicAWSCredentials("access", "secret"));
        amazonDynamoDB.setEndpoint("http://localhost:" + port);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:com.facebook.presto.dynamodb.DynamodbConfig.java

License:Apache License

public AWSCredentialsProvider getCredentials() {
    if (accessKey == null && secretAccessKey == null) {
        return new InstanceProfileCredentialsProvider();
    }/*from   w ww  .  ja v a2 s  .c om*/
    return new StaticCredentialsProvider(new BasicAWSCredentials(getAccessKey(), getSecretAccessKey()));
}

From source file:com.facebook.presto.hive.PrestoS3FileSystem.java

License:Apache License

private static AWSCredentials getAwsCredentials(URI uri, Configuration conf) {
    S3Credentials credentials = new S3Credentials();
    credentials.initialize(uri, conf);/*from   www.j  av  a2 s .com*/
    return new BasicAWSCredentials(credentials.getAccessKey(), credentials.getSecretAccessKey());
}

From source file:com.facebook.presto.hive.s3.PrestoS3ClientFactory.java

License:Apache License

private static Optional<AWSCredentials> getAwsCredentials(Configuration conf) {
    String accessKey = conf.get(S3_ACCESS_KEY);
    String secretKey = conf.get(S3_SECRET_KEY);

    if (isNullOrEmpty(accessKey) || isNullOrEmpty(secretKey)) {
        return Optional.empty();
    }/*from  w w  w  .ja  v a2 s  . c  o  m*/
    return Optional.of(new BasicAWSCredentials(accessKey, secretKey));
}

From source file:com.facebook.presto.hive.s3.PrestoS3FileSystem.java

License:Apache License

private static Optional<AWSCredentials> getAwsCredentials(URI uri, Configuration conf) {
    String accessKey = conf.get(S3_ACCESS_KEY);
    String secretKey = conf.get(S3_SECRET_KEY);

    String userInfo = uri.getUserInfo();
    if (userInfo != null) {
        int index = userInfo.indexOf(':');
        if (index < 0) {
            accessKey = userInfo;/*w w  w.  ja  v a  2  s  .c o  m*/
        } else {
            accessKey = userInfo.substring(0, index);
            secretKey = userInfo.substring(index + 1);
        }
    }

    if (isNullOrEmpty(accessKey) || isNullOrEmpty(secretKey)) {
        return Optional.empty();
    }
    return Optional.of(new BasicAWSCredentials(accessKey, secretKey));
}

From source file:com.fivepebbles.ProcessAWS.java

License:MIT License

ProcessAWS(String keyId, String secKey) {
    this.myCredentials = new BasicAWSCredentials(keyId, secKey);
    this.s3client = new AmazonS3Client(myCredentials);
}

From source file:com.formkiq.core.service.AssetServiceS3Default.java

License:Apache License

/**
 * @return {@link AmazonS3}//from   w  ww . j a v a 2  s  .c om
 */
private AmazonS3 getS3Connection() {

    if (this.s3client == null) {
        AWSCredentials credentials = new BasicAWSCredentials(this.s3AccessKey, this.s3AccessSecret);
        this.s3client = AmazonS3ClientBuilder.standard()
                .withCredentials(new AWSStaticCredentialsProvider(credentials)).withRegion(Regions.US_WEST_2) // TODO create aws.properties
                .build();
    }

    return this.s3client;
}

From source file:com.ge.predix.sample.blobstore.config.LocalConfig.java

License:Apache License

@Bean
public BlobstoreService objectStoreService() {
    log.info("objectStoreService(): " + objectStoreProperties.getAccessKey()
            + objectStoreProperties.getSecretKey() + ", " + objectStoreProperties.getBucket());

    AmazonS3Client s3Client = new AmazonS3Client(new BasicAWSCredentials(objectStoreProperties.getAccessKey(),
            objectStoreProperties.getSecretKey()));
    s3Client.setEndpoint(objectStoreProperties.getUrl());

    try {/*from  www. j  av  a2s.  c om*/
        // Remove the Credentials from the Object Store URL
        URL url = new URL(objectStoreProperties.getUrl());
        String urlWithoutCredentials = url.getProtocol() + "://" + url.getHost();

        // Return BlobstoreService
        return new BlobstoreService(s3Client, objectStoreProperties.getBucket(), urlWithoutCredentials);
    } catch (MalformedURLException e) {
        log.error("create(): Couldnt parse the URL provided by VCAP_SERVICES. Exception = " + e.getMessage());
        throw new RuntimeException("Blobstore URL is Invalid", e);
    }
}