List of usage examples for com.amazonaws.auth BasicAWSCredentials BasicAWSCredentials
public BasicAWSCredentials(String accessKey, String secretKey)
From source file:com.erudika.para.iot.AWSIoTService.java
License:Apache License
protected AWSIotClient getClient() { if (iotClient != null) { return iotClient; }// w w w . j av a2s.co m Region region = Regions.getCurrentRegion(); region = region != null ? region : Region.getRegion(Regions.fromName(Config.AWS_REGION)); iotClient = new AWSIotClient(new BasicAWSCredentials(Config.AWS_ACCESSKEY, Config.AWS_SECRETKEY)) .withRegion(region); Para.addDestroyListener(new DestroyListener() { public void onDestroy() { shutdownClient(); } }); return iotClient; }
From source file:com.erudika.para.iot.AWSIoTService.java
License:Apache License
protected AWSIotDataClient getDataClient() { if (iotDataClient != null) { return iotDataClient; }// w w w. j a va 2 s. c o m Region region = Regions.getCurrentRegion(); region = region != null ? region : Region.getRegion(Regions.fromName(Config.AWS_REGION)); iotDataClient = new AWSIotDataClient(new BasicAWSCredentials(Config.AWS_ACCESSKEY, Config.AWS_SECRETKEY)) .withRegion(region); Para.addDestroyListener(new DestroyListener() { public void onDestroy() { shutdownDataClient(); } }); return iotDataClient; }
From source file:com.erudika.para.persistence.AWSDynamoUtils.java
License:Apache License
/** * Returns a client instance for AWS DynamoDB. * @return a client that talks to DynamoDB *//*w w w .ja v a 2 s.c o m*/ public static AmazonDynamoDBClient getClient() { if (ddbClient != null) { return ddbClient; } if (Config.IN_PRODUCTION) { Region region = Regions.getCurrentRegion(); region = region != null ? region : Region.getRegion(Regions.fromName(Config.AWS_REGION)); ddbClient = new AmazonDynamoDBClient( new BasicAWSCredentials(Config.AWS_ACCESSKEY, Config.AWS_SECRETKEY)).withRegion(region); } else { ddbClient = new AmazonDynamoDBClient(new BasicAWSCredentials("local", "null")) .withEndpoint(LOCAL_ENDPOINT); } if (!existsTable(Config.APP_NAME_NS)) { createTable(Config.APP_NAME_NS); } ddb = new DynamoDB(ddbClient); Para.addDestroyListener(new DestroyListener() { public void onDestroy() { shutdownClient(); } }); return ddbClient; }
From source file:com.erudika.para.queue.AWSQueueUtils.java
License:Apache License
/** * Returns a client instance for AWS SQS. * @return a client that talks to SQS/*ww w. j a v a 2 s. c om*/ */ public static AmazonSQSClient getClient() { if (sqsClient != null) { return sqsClient; } if (Config.IN_PRODUCTION) { Region region = Regions.getCurrentRegion(); region = region != null ? region : Region.getRegion(Regions.fromName(Config.AWS_REGION)); sqsClient = new AmazonSQSClient(new BasicAWSCredentials(Config.AWS_ACCESSKEY, Config.AWS_SECRETKEY)) .withRegion(region); } else { sqsClient = new AmazonSQSClient(new BasicAWSCredentials("x", "x")).withEndpoint(LOCAL_ENDPOINT); } Para.addDestroyListener(new DestroyListener() { public void onDestroy() { sqsClient.shutdown(); } }); return sqsClient; }
From source file:com.erudika.para.rest.Signer.java
License:Apache License
/** * Signs a request using AWS signature V4. * @param request the request instance//from w ww .jav a 2 s . c o m * @param accessKey the app's access key * @param secretKey the app's secret key */ public void sign(Request<?> request, String accessKey, String secretKey) { super.sign(request, new BasicAWSCredentials(accessKey, secretKey)); resetDate(); }
From source file:com.erudika.para.storage.AWSFileStore.java
License:Apache License
/** * Creates a new instance based on the bucket provided. * @param bucket the name of the S3 bucket *///from w w w . j av a 2 s. c om public AWSFileStore(String bucket) { this.bucket = bucket; this.awsCredentials = new BasicAWSCredentials(Config.AWS_ACCESSKEY, Config.AWS_SECRETKEY); Region region = Regions.getCurrentRegion(); region = region != null ? region : Region.getRegion(Regions.fromName(Config.AWS_REGION)); this.s3 = new AmazonS3Client(awsCredentials).withRegion(region); }
From source file:com.eucalyptus.blockstorage.SnapshotObjectOps.java
License:Open Source License
public SnapshotObjectOps() { try {// w w w. ja va2 s .c o m Account system = Accounts.lookupAccountByName(Account.SYSTEM_ACCOUNT); for (User user : system.getUsers()) { if (StorageProperties.BLOCKSTORAGE_ACCOUNT.equals(user.getName())) { List<AccessKey> keys = user.getKeys(); if (!keys.isEmpty()) { AccessKey key = keys.get(0); s3Client = new S3Client(new BasicAWSCredentials(key.getAccessKey(), key.getSecretKey()), false); s3Client.setUsePathStyle(true); s3Client.setS3Endpoint(StorageProperties.WALRUS_URL); } else { LOG.error( "Something went really wrong. Block storage account does not have an associated access key."); } } } } catch (Exception ex) { LOG.error(ex, ex); } }
From source file:com.eucalyptus.cloudformation.workflow.WorkflowClientManager.java
License:Open Source License
public static void start() throws Exception { final AmazonSimpleWorkflow simpleWorkflowClient; if (USE_AWS_SWF) { System.setProperty("com.amazonaws.sdk.disableCertChecking", "true"); final BasicAWSCredentials creds = new BasicAWSCredentials(AWS_ACCESS_KEY, AWS_SECRET_KEY); simpleWorkflowClient = new AmazonSimpleWorkflowClient(creds); simpleWorkflowClient.setRegion(Region.getRegion(Regions.US_EAST_1)); } else {/* ww w . j a va2 s .c o m*/ simpleWorkflowClient = Config.buildClient( CloudFormationAWSCredentialsProvider.CloudFormationUserSupplier.INSTANCE, SWF_CLIENT_CONFIG); } workflowClient = new WorkflowClient(CloudFormation.class, simpleWorkflowClient, SWF_DOMAIN, SWF_TASKLIST, SWF_WORKFLOW_WORKER_CONFIG, SWF_ACTIVITY_WORKER_CONFIG); workflowClient.start(); }
From source file:com.eucalyptus.objectstorage.providers.s3.S3ProviderClient.java
License:Open Source License
/** * Maps the request credentials to another set of credentials. This implementation maps * all Eucalyptus credentials to a single s3/backend credential. * /*from w ww. j a v a 2 s . co m*/ * @param requestUser The Eucalyptus user that generated the request * @return a BasicAWSCredentials object initialized with the credentials to use * @throws NoSuchElementException * @throws IllegalArgumentException */ protected BasicAWSCredentials mapCredentials(User requestUser) throws Exception { return new BasicAWSCredentials( ConfigurationCache.getConfiguration(S3ProviderConfiguration.class).getS3AccessKey(), ConfigurationCache.getConfiguration(S3ProviderConfiguration.class).getS3SecretKey()); }
From source file:com.eucalyptus.objectstorage.providers.walrus.WalrusProviderClient.java
License:Open Source License
/** * Walrus provider mapping maps all requests to the single ObjectStorage account used for interaction with Walrus */// www . jav a2s . c o m @Override protected BasicAWSCredentials mapCredentials(User requestUser) throws AuthException, IllegalArgumentException { List<AccessKey> eucaAdminKeys = systemAdmin.getKeys(); if (eucaAdminKeys != null && eucaAdminKeys.size() > 0) { return new BasicAWSCredentials(eucaAdminKeys.get(0).getAccessKey(), eucaAdminKeys.get(0).getSecretKey()); } else { LOG.error("No key found for user " + requestUser.getUserId() + " . Cannot map credentials for call to WalrusBackend backend for data operation"); throw new AuthException( "No access key found for backend call to WalrusBackend for UserId: " + requestUser.getUserId()); } }