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.datatorrent.lib.io.fs.S3BlockReader.java

License:Apache License

@Override
public void setup(Context.OperatorContext context) {
    super.setup(context);
    s3Client = new AmazonS3Client(new BasicAWSCredentials(accessKey, secretAccessKey));
    ((S3BlockReaderContext) readerContext).setBucketName(bucketName);
    ((S3BlockReaderContext) readerContext).setS3Client(s3Client);
}

From source file:com.davidgildeh.hadoop.input.simpledb.SimpleDBDAO.java

License:Apache License

/**
 * Default Constructor, initialises SimpleDB Client
 * //from   ww w  . ja  v a 2  s. c  om
 * @param jobConf   Hadoop Job Configuration
 */
public SimpleDBDAO(JobConf jobConf) {

    // Load Configuration
    String awsAccessKey = jobConf.get(SIMPLEDB_AWS_ACCESSKEY);
    String awsSecretKey = jobConf.get(SIMPLEDB_AWS_SECRETKEY);
    // Default to US-EAST Region
    String simpleDBRegion = jobConf.get(SIMPLEDB_AWS_REGION, "sdb.amazonaws.com");
    sdb_domain = jobConf.get(SIMPLEDB_DOMAIN);
    whereQuery = jobConf.get(SIMPLEDB_WHERE_QUERY, null);

    // Initialise SimpleDB Client  
    sdb = new AmazonSimpleDBClient(new BasicAWSCredentials(awsAccessKey, awsSecretKey));
    sdb.setEndpoint(simpleDBRegion);
}

From source file:com.davidsoergel.s3napback.S3ops.java

License:Apache License

public static void main(String[] argv) {
    int chunkSize = 25000000; // default 25 MB

    // hacky positional arguments, whatever
    String keyfileName = argv[0];
    String command = argv[1];/*  w  w w . j a  v a2s.c om*/
    String bucket = argv[2];
    String filename = argv[3];

    if (argv.length > 4) {
        chunkSize = new Integer(argv[3]);
    }

    Properties props = new Properties();
    try {
        props.load(new FileInputStream(keyfileName));
    } catch (FileNotFoundException e) {
        logger.error("Error", e);
    } catch (IOException e) {
        logger.error("Error", e);
    }
    String accessKey = props.getProperty("key");
    String secretKey = props.getProperty("secret");

    AWSCredentials myCredentials = new BasicAWSCredentials(accessKey, secretKey);
    StreamingTransferManager tx = new StreamingTransferManager(myCredentials);

    try {
        if (command.equals("upload")) {
            upload(tx, bucket, filename, chunkSize);
        } else if (command.equals("download")) {
            download(tx, bucket, filename);
        } else if (command.equals("delete")) {
            delete(tx, bucket, filename);
        } else if (command.equals("list")) {
            list(tx, bucket);
        } else {
            logger.error("Unknown command: " + command);
        }
    } catch (InterruptedException e) {
        logger.error("Error", e);
        System.exit(1);
    } catch (IOException e) {
        logger.error("Error", e);
        System.exit(1);
    }
    tx.shutdownNow();
}

From source file:com.dell.doradus.db.dynamodb.DynamoDBService.java

License:Apache License

private AWSCredentials getCredentials() {
    String awsProfile = getParamString("aws_profile");
    if (!Utils.isEmpty(awsProfile)) {
        m_logger.info("Using AWS profile: {}", awsProfile);
        ProfileCredentialsProvider credsProvider = null;
        String awsCredentialsFile = getParamString("aws_credentials_file");
        if (!Utils.isEmpty(awsCredentialsFile)) {
            credsProvider = new ProfileCredentialsProvider(awsCredentialsFile, awsProfile);
        } else {// w  w w .  j  a  va 2 s  . c  o m
            credsProvider = new ProfileCredentialsProvider(awsProfile);
        }
        return credsProvider.getCredentials();
    }

    String awsAccessKey = getParamString("aws_access_key");
    Utils.require(!Utils.isEmpty(awsAccessKey),
            "Either 'aws_profile' or 'aws_access_key' must be defined for tenant: " + m_tenant.getName());
    String awsSecretKey = getParamString("aws_secret_key");
    Utils.require(!Utils.isEmpty(awsSecretKey),
            "'aws_secret_key' must be defined when 'aws_access_key' is defined. "
                    + "'aws_profile' is preferred over aws_access_key/aws_secret_key. Tenant: "
                    + m_tenant.getName());
    return new BasicAWSCredentials(awsAccessKey, awsSecretKey);
}

From source file:com.dell.doradus.db.s3.DynamoDBService2.java

License:Apache License

public DynamoDBService2(Tenant tenant) {
    super(tenant);

    String accessKey = getParamString("ddb-access-key");
    String secretKey = getParamString("ddb-secret-key");
    String endpoint = getParamString("ddb-endpoint");
    m_readCapacityUnits = getParamInt("ddb-read-capacity-units", 1);
    m_writeCapacityUnits = getParamInt("ddb-write-capacity-units", 1);

    BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey);
    m_client = new AmazonDynamoDBClient(awsCredentials);
    m_client.setEndpoint(endpoint);/*from ww w.  jav  a2s.c o  m*/
    // try to connect to check the connection
    m_client.listTables();

    m_logger.info("Started DynamoDB service. Endpoint: {}, read/write capacity units for new namespaces: {}/{}",
            new Object[] { endpoint, m_readCapacityUnits, m_writeCapacityUnits });
}

From source file:com.denismo.aws.iam.IAMPasswordValidator.java

License:Apache License

public boolean verifyIAMPassword(Entry user, String pw)
        throws LdapInvalidAttributeValueException, LdapAuthenticationException {
    boolean role = false;
    AWSCredentials creds;//from  www .  j  a v  a 2 s . co m
    if (isRole(user)) {
        role = true;
        String[] parts = pw.split("\\|");
        if (parts == null || parts.length < 3)
            throw new LdapAuthenticationException();
        creds = new BasicSessionCredentials(parts[0], parts[1], parts[2]);
    } else {
        creds = new BasicAWSCredentials(user.get("accessKey").getString(), pw);
    }
    LOG.debug("Verifying {} {} with accessKey <hidden> and secretKey <hidden>", role ? "role" : "user",
            user.get("uid").getString());
    AmazonIdentityManagementClient client = new AmazonIdentityManagementClient(creds);
    try {
        client.getAccountSummary();
    } catch (AmazonClientException e) {
        System.err.println(e.getMessage());
        return false;
    } finally {
        client.shutdown();
    }
    return true;
}

From source file:com.denismo.aws.iam.IAMSecretKeyValidator.java

License:Apache License

@Override
public boolean verifyIAMPassword(Entry user, String pw)
        throws LdapInvalidAttributeValueException, LdapAuthenticationException {
    boolean role = false;
    AWSCredentials creds;/*from w  ww .  j a va  2  s . com*/
    if (isRole(user)) {
        role = true;
        String[] parts = pw.split("\\|");
        if (parts == null || parts.length < 3)
            throw new LdapAuthenticationException();
        creds = new BasicSessionCredentials(parts[0], parts[1], parts[2]);
    } else {
        creds = new BasicAWSCredentials(user.get("accessKey").getString(), pw);
    }
    LOG.debug("Verifying {} {} with accessKey <hidden> and secretKey <hidden>", role ? "role" : "user",
            user.get("uid").getString());
    AmazonIdentityManagementClient client = new AmazonIdentityManagementClient(creds);
    try {
        client.getAccountSummary();
    } catch (AmazonClientException e) {
        System.err.println(e.getMessage());
        return false;
    } finally {
        client.shutdown();
    }
    return true;
}

From source file:com.devnexus.ting.core.service.integration.AmazonSesSender.java

License:Apache License

@Autowired
public AmazonSesSender(AmazonSettings amazonSettings) {
    final AWSCredentials awsCredentials = new BasicAWSCredentials(amazonSettings.getAwsAccessKeyId(),
            amazonSettings.getAwsSecretKey());
    client = new AmazonSimpleEmailServiceClient(awsCredentials);
}

From source file:com.digitaslbi.helios.mock.utils.ConnectionHelper.java

public static AmazonS3 connect() {
    loadProperties();/*from w  w w  . j av a2 s.c o m*/
    BasicAWSCredentials awsCreds = new BasicAWSCredentials(
            prop.getProperty(MocksConstants.AWS_ACCESS_KEY_ID.getValue()),
            prop.getProperty(MocksConstants.AWS_SECRET_ACCESS_KEY.getValue()));
    s3Client = new AmazonS3Client(awsCreds);
    return s3Client;
}

From source file:com.digitaslbi.helios.utils.S3Helper.java

public static AmazonS3 connect() {
    BasicAWSCredentials awsCreds = new BasicAWSCredentials(S3Properties.getInstance().getAwsAccessKeyId(),
            S3Properties.getInstance().getAwsSecretAccessKey());
    s3Client = new AmazonS3Client(awsCreds);

    return s3Client;
}