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:br.com.semanticwot.cd.conf.AmazonConfiguration.java

@Bean
@Profile("dev")/*ww  w . ja  v a 2  s .  c  o m*/
public AmazonS3Client s3Ninja() {
    AWSCredentials credentials = new BasicAWSCredentials("AKIAIOSFODNN7EXAMPLE",
            "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY");
    AmazonS3Client newClient = new AmazonS3Client(credentials, new ClientConfiguration());
    newClient.setS3ClientOptions(new S3ClientOptions().withPathStyleAccess(true));

    newClient.setEndpoint("http://localhost:9444/s3");
    return newClient;

}

From source file:br.com.semanticwot.cd.conf.AmazonConfiguration.java

@Bean
@Profile("prod")/*from   w ww  . jav a  2s. co  m*/
public AmazonS3Client s3Amazon() {
    AWSCredentials credentials = new BasicAWSCredentials("AKIAIOSFODNN7EXAMPLE",
            "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY");
    AmazonS3Client newClient = new AmazonS3Client(credentials, new ClientConfiguration());
    newClient.setS3ClientOptions(new S3ClientOptions().withPathStyleAccess(true));

    return newClient;

}

From source file:br.puc_rio.ele.lvc.interimage.common.udf.ROIStorage.java

License:Apache License

/**
  * Method invoked on every tuple during foreach evaluation.
  * @param input tuple<br>//ww  w. j  a v  a  2 s  .c om
  * first column is assumed to have the geometry<br>
  * second column is assumed to have the class name<br>
  * third column is assumed to have the output path
  * @exception java.io.IOException
  * @return true if successful, false otherwise
  */
@Override
public Boolean exec(Tuple input) throws IOException {
    if (input == null || input.size() < 3)
        return null;

    try {

        Object objGeometry = input.get(0);
        Geometry geometry = _geometryParser.parseGeometry(objGeometry);
        String className = DataType.toString(input.get(1));
        String path = DataType.toString(input.get(2));

        AWSCredentials credentials = new BasicAWSCredentials(_accessKey, _secretKey);
        AmazonS3 conn = new AmazonS3Client(credentials);
        conn.setEndpoint("https://s3.amazonaws.com");

        /*File temp = File.createTempFile(className, ".wkt");
                
         // Delete temp file when program exits.
         temp.deleteOnExit();
                     
         BufferedWriter out = new BufferedWriter(new FileWriter(temp));
         out.write(new WKTWriter().write(geometry));
         out.close();*/

        /*
                
        File temp = File.createTempFile(className, ".wkt.snappy");
                   
        temp.deleteOnExit();*/

        String geom = new WKTWriter().write(geometry);

        ByteArrayOutputStream out = new ByteArrayOutputStream();

        OutputStream snappyOut = new SnappyOutputStream(out);
        snappyOut.write(geom.getBytes());
        snappyOut.close();

        /*PutObjectRequest putObjectRequest = new PutObjectRequest(_bucket, path + className + ".wkt.snappy", temp);
        putObjectRequest.withCannedAcl(CannedAccessControlList.PublicRead); // public for all*/

        PutObjectRequest putObjectRequest = new PutObjectRequest(_bucket, path + className + ".wkts",
                new ByteArrayInputStream(out.toByteArray()), new ObjectMetadata());
        putObjectRequest.withCannedAcl(CannedAccessControlList.PublicRead); // public for all

        TransferManager tx = new TransferManager(credentials);
        tx.upload(putObjectRequest);

        return true;

    } catch (Exception e) {
        throw new IOException("Caught exception processing input row ", e);
    }
}

From source file:br.puc_rio.ele.lvc.interimage.core.datamanager.AWSSource.java

License:Apache License

 public AWSSource(String accessKey, String secretKey, String bucket) {
   _accessKey = accessKey;// www  .  j a va2  s .c o  m
   _secretKey = secretKey;
   _bucket = bucket;
      
   AWSCredentials credentials = new BasicAWSCredentials(_accessKey, _secretKey);
      
   ClientConfiguration conf = new ClientConfiguration();
      
   conf.setConnectionTimeout(0);
   conf.setSocketTimeout(0);
      
   AmazonS3 conn = new AmazonS3Client(credentials);
   conn.setEndpoint("https://s3.amazonaws.com");
      
   _manager = new TransferManager(conn);
            
}

From source file:br.puc_rio.ele.lvc.interimage.core.datamanager.AWSSource.java

License:Apache License

public AWSSource(String accessKey, String secretKey, String bucket) {
        _accessKey = accessKey;/*  w  w w. j  av a  2s .co m*/
        _secretKey = secretKey;
        _bucket = bucket;

        AWSCredentials credentials = new BasicAWSCredentials(_accessKey, _secretKey);

        ClientConfiguration conf = new ClientConfiguration();

        conf.setConnectionTimeout(0);
        conf.setSocketTimeout(0);

        AmazonS3 conn = new AmazonS3Client(credentials);
        conn.setEndpoint("https://s3.amazonaws.com");

        _manager = new TransferManager(conn);

    }

From source file:br.unb.bionimbuz.storage.bucket.methods.CloudMethodsAmazonGoogle.java

@Override
public void StorageAuth(StorageProvider sp) throws Exception {

    switch (sp) {

    case AMAZON: {

        byte[] encoded = Files.readAllBytes(Paths.get(authFolder + "AwsCredentials.txt"));
        String fileContent = new String(encoded, Charset.defaultCharset());
        //System.out.println("AuthString: " + fileContent);
        String accessKeyID, accessKey;
        int delimiter = fileContent.indexOf(':');
        accessKeyID = fileContent.substring(0, delimiter);
        accessKey = fileContent.substring(delimiter + 1);
        AWSCredentials credentials = new BasicAWSCredentials(accessKeyID, accessKey);
        s3client = new AmazonS3Client(credentials);

        break;//from   w w w  .  j av  a2 s  .c om
    }
    case GOOGLE: {

        String command = gcloudFolder + "gcloud auth activate-service-account --key-file=" + authFolder
                + "GoogleCredentials.json";
        ExecCommand(command);

        break;
    }
    default: {
        throw new Exception("Provedor incorreto!");
    }
    }
}

From source file:br.unb.cic.bionimbuz.elasticity.AmazonMonitoring.java

License:Open Source License

public AmazonCloudWatchClient client(final String awsAccessKey, final String awsSecretKey) {
    final AmazonCloudWatchClient client = new AmazonCloudWatchClient(
            new BasicAWSCredentials(awsAccessKey, awsSecretKey));
    client.setEndpoint("monitoring.sa-east-1.amazonaws.com");
    return client;
}

From source file:br.unb.cic.bionimbuz.services.storage.bucket.methods.CloudMethodsAmazonGoogle.java

@Override
public void StorageAuth(StorageProvider sp) throws Exception {

    switch (sp) {

    case AMAZON: {
        // InputStream is = null;
        // is = new FileInputStream(keyAmazon);
        // PropertiesCredentials credentials = new PropertiesCredentials(is);
        final byte[] encoded = Files.readAllBytes(Paths.get(keyAmazon));
        final String fileContent = new String(encoded, Charset.defaultCharset());
        System.out.println("AuthString: " + fileContent);
        String accessKeyID, accessKey;
        final int delimiter = fileContent.indexOf(':');
        accessKeyID = fileContent.substring(0, delimiter);
        accessKey = fileContent.substring(delimiter + 1);
        final AWSCredentials credentials = new BasicAWSCredentials(accessKeyID, accessKey);
        s3client = new AmazonS3Client(credentials);

        break;/*from w  ww.j  a  v a 2 s  .co m*/
    }
    case GOOGLE: {

        final String command = gcloudFolder + "gcloud auth activate-service-account --key-file=" + keyGoogle;
        ExecCommand(command);

        break;
    }
    default: {
        throw new Exception("Provedor incorreto!");
    }
    }
}

From source file:br.unb.cic.bionimbuz.storage.bucket.methods.CloudMethodsAmazonGoogle.java

@Override
public void StorageAuth(StorageProvider sp) throws Exception {

    switch (sp) {

    case AMAZON: {

        byte[] encoded = Files.readAllBytes(Paths.get(authFolder + "accesskey.txt"));
        String fileContent = new String(encoded, Charset.defaultCharset());
        //System.out.println("AuthString: " + fileContent);
        String accessKeyID, accessKey;
        int delimiter = fileContent.indexOf(':');
        accessKeyID = fileContent.substring(0, delimiter);
        accessKey = fileContent.substring(delimiter + 1);
        AWSCredentials credentials = new BasicAWSCredentials(accessKeyID, accessKey);
        s3client = new AmazonS3Client(credentials);

        break;//from  w ww  .jav a2s  .  com
    }
    case GOOGLE: {

        String command = gcloudFolder + "gcloud auth activate-service-account --key-file=" + authFolder
                + "cred.json";
        ExecCommand(command);

        break;
    }
    default: {
        throw new Exception("Provedor incorreto!");
    }
    }
}

From source file:c3.ops.priam.defaultimpl.ClearCredential.java

License:Apache License

public AWSCredentialsProvider getAwsCredentialProvider() {
    return new AWSCredentialsProvider() {
        public AWSCredentials getCredentials() {
            return new BasicAWSCredentials(AWS_ACCESS_ID, AWS_KEY);
        }//  ww w .  ja  va2  s .  com

        public void refresh() {
            // NOP
        }
    };
}