List of usage examples for com.amazonaws.auth BasicAWSCredentials BasicAWSCredentials
public BasicAWSCredentials(String accessKey, String secretKey)
From source file:com.ge.predix.sample.blobstore.connector.spring.BlobstoreServiceConnectorCreator.java
License:Apache License
/** * Creates the BlobStore context using S3Client * * @param serviceInfo Object Store Service Info Object * @param serviceConnectorConfig Cloud Foundry Service Connector Configuration * * @return BlobstoreService Instance of the ObjectStore Service *//*w w w. j a v a 2 s . com*/ @Override public BlobstoreService create(BlobstoreServiceInfo serviceInfo, ServiceConnectorConfig serviceConnectorConfig) { log.info("create() invoked with serviceInfo? = " + (serviceInfo == null)); ClientConfiguration config = new ClientConfiguration(); config.setProtocol(Protocol.HTTPS); S3ClientOptions options = new S3ClientOptions(); config.setSignerOverride("S3SignerType"); BasicAWSCredentials creds = new BasicAWSCredentials(serviceInfo.getObjectStoreAccessKey(), serviceInfo.getObjectStoreSecretKey()); AmazonS3Client s3Client = new AmazonS3Client(creds, config); s3Client.setEndpoint(serviceInfo.getUrl()); s3Client.setS3ClientOptions(options); try { // Remove the Credentials from the Object Store URL URL url = new URL(serviceInfo.getUrl()); String urlWithoutCredentials = url.getProtocol() + "://" + url.getHost(); // Return BlobstoreService return new BlobstoreService(s3Client, serviceInfo.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); } }
From source file:com.ge.predix.solsvc.blobstore.bootstrap.BlobstoreClientImpl.java
License:Apache License
/** * -/*from w ww. j a v a2 s.c o m*/ */ @PostConstruct public void init() { ClientConfiguration config = new ClientConfiguration(); config.setProtocol(Protocol.HTTPS); if (this.blobstoreConfig.getProxyHost() != null && !"".equals(this.blobstoreConfig.getProxyHost())) { //$NON-NLS-1$ this.log.info("Connnecting with proxy"); //$NON-NLS-1$ if (this.blobstoreConfig.getProxyHost() != null) { config.withProxyHost(this.blobstoreConfig.getProxyHost()); } if (this.blobstoreConfig.getProxyPort() != null) { config.withProxyPort(Integer.parseInt(this.blobstoreConfig.getProxyPort())); } } BasicAWSCredentials creds = new BasicAWSCredentials(this.blobstoreConfig.getAccessKey(), this.blobstoreConfig.getAccessKey()); this.s3Client = new AmazonS3Client(creds, config); this.s3Client.setEndpoint(this.blobstoreConfig.getUrl()); }
From source file:com.gendevs.bedrock.appengine.service.storage.StorageProvider.java
License:Apache License
private void initalizeS3() { AWSCredentials credentials = new BasicAWSCredentials(StorageConstants.ACCESS_KEY, StorageConstants.SECRET_KEY); if (s3Client == null) { s3Client = new AmazonS3Client(credentials); s3Client.setRegion(region);// w w w .ja v a 2 s. c o m s3Client.setEndpoint("s3-us-west-2.amazonaws.com"); } manager = new TransferManager(credentials); }
From source file:com.github.abhinavmishra14.aws.glacier.service.impl.GlacierArchiveServiceImpl.java
License:Open Source License
/** * The Constructor.<br/>/* w w w . jav a2 s .c o m*/ * This Constructor will return glacier client using accessKey and secretKey.<br/> * Additionally it will set the given endPoint for performing upload operation over vault.<br/> * Default endpoint will be always: "https://glacier.us-east-1.amazonaws.com/" * SSL Certificate checking will be disabled based on provided flag. * * @param accessKey the access key * @param secretKey the secret key * @param disableCertCheck the disable cert check * @param endpoint the endpoint */ public GlacierArchiveServiceImpl(final String accessKey, final String secretKey, final boolean disableCertCheck, final String endpoint) { super(); AWSUtil.notNull(accessKey, ERR_MSG_ACCESSKEY); AWSUtil.notNull(secretKey, ERR_MSG_SECRETKEY); if (LOGGER.isDebugEnabled()) { LOGGER.debug("GlacierArchiveServiceImpl is initializing using keys.."); } final AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); final AWSCredentialsProvider credentialsProvider = new StaticCredentialsProvider(credentials); glacierClient = new AmazonGlacierClient(credentialsProvider); sqsClient = new AmazonSQSClient(credentialsProvider); snsClient = new AmazonSNSClient(credentialsProvider); if (disableCertCheck) { System.setProperty(DISABLE_CERT_PARAM, TRUE);//Disable cert check } if (StringUtils.isNotBlank(endpoint)) { glacierClient.setEndpoint(endpoint); } }
From source file:com.github.abhinavmishra14.aws.glacier.service.impl.GlacierVaultServiceImpl.java
License:Open Source License
/** * The Constructor.<br/>// w w w.j av a 2s . c om * This Constructor will return glacier client using accessKey and secretKey.<br/> * Additionally it will set the given endPoint for performing operations over vault.<br/> * Default endpoint will be always: "https://glacier.us-east-1.amazonaws.com/" * SSL Certificate checking will be disabled based on provided flag. * * @param accessKey the access key * @param secretKey the secret key * @param disableCertCheck the disable cert check * @param endpoint the endpoint */ public GlacierVaultServiceImpl(final String accessKey, final String secretKey, final boolean disableCertCheck, final String endpoint) { super(); AWSUtil.notNull(accessKey, ERR_MSG_ACCESSKEY); AWSUtil.notNull(secretKey, ERR_MSG_SECRETKEY); if (LOGGER.isDebugEnabled()) { LOGGER.debug("GlacierVaultServiceImpl is initializing using keys.."); } final AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); final AWSCredentialsProvider credentialsProvider = new StaticCredentialsProvider(credentials); glacierClient = new AmazonGlacierClient(credentialsProvider); if (disableCertCheck) { System.setProperty(DISABLE_CERT_PARAM, TRUE);//Disable cert check } if (StringUtils.isNotBlank(endpoint)) { glacierClient.setEndpoint(endpoint); } }
From source file:com.github.abhinavmishra14.aws.s3.service.impl.AwsS3IamServiceImpl.java
License:Open Source License
/** * Inits the service.//from w w w . ja va2 s. com */ private void initService() { AWSUtil.notNull(accessKey, AWSUtilConstants.ERR_MSG_ACCESSKEY); AWSUtil.notNull(secretKey, AWSUtilConstants.ERR_MSG_SECRETKEY); // credentials object identifying user for authentication // user must have AWSConnector and AmazonS3FullAccess for // this example to work if (LOGGER.isDebugEnabled()) { LOGGER.debug("AwsS3IamService is initializing using keys.."); } final AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); // create a client connection based on credentials s3client = new AmazonS3Client(credentials); }
From source file:com.github.lbroudoux.elasticsearch.river.s3.connector.S3Connector.java
License:Apache License
/** * Connect to the specified bucket using previously given accesskey and secretkey. * @param bucketName Name of the bucket to connect to * @param pathPrefix Prefix that will be later used for filtering documents * @throws AmazonS3Exception when access or secret keys are wrong or bucket does not exists *//*from www .j a v a2 s . c o m*/ public void connectUserBucket(String bucketName, String pathPrefix) throws AmazonS3Exception { this.bucketName = bucketName; this.pathPrefix = pathPrefix; AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); s3Client = new AmazonS3Client(credentials); // Getting location seems odd as we don't use it later and doesBucketExists() seems // more appropriate... However, this later returns true even for non existing buckets ! s3Client.getBucketLocation(bucketName); }
From source file:com.github.rholder.esthree.Main.java
License:Apache License
public void parseGlobalCli(String... args) { command = createCli().parse(args);//from w w w .ja v a 2s .c om command.commandMetadata = MetadataLoader.loadCommand(command.getClass()); command.output = new PrintStream(new BufferedOutputStream(System.out)); // override if keys are specified if (command.accessKey != null || command.secretKey != null) { command.amazonS3Client = new AmazonS3Client( new BasicAWSCredentials(command.accessKey, command.secretKey)); } else { command.amazonS3Client = new AmazonS3Client(); } // override S3 endpoint if specified if (command.endpoint != null) { command.amazonS3Client.setEndpoint(command.endpoint); } }
From source file:com.github.sdmcraft.slingdynamo.demo.App.java
License:Open Source License
/** * Inits the./* w w w.j a v a 2 s . c o m*/ */ public static void init() { Scanner reader = new Scanner(System.in); System.out.println("Enter access key:"); accessKey = reader.next(); System.out.println("Enter secret access key:"); secretAccessKey = reader.next(); System.out.println("Access Key:" + accessKey); System.out.println("Secret access Key:" + secretAccessKey); reader.close(); AWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretAccessKey); dynamoDB = new AmazonDynamoDBClient(awsCredentials); Region usWest2 = Region.getRegion(Regions.US_WEST_2); dynamoDB.setRegion(usWest2); }
From source file:com.github.sporcina.mule.modules.DynamoDBConnector.java
License:Open Source License
/** * Creates a DynamoDB client using the security values passed in * * @param accessKey/* w ww . j av a 2s . c om*/ * the access key provided to you through your Amazon AWS account * @param secretKey * the secret key provided to you through your Amazon AWS account * * @throws ConnectionException */ private void createDynamoDBClient(String accessKey, String secretKey) throws ConnectionException { try { AWSCredentials credentialsProvider = new BasicAWSCredentials(accessKey, secretKey); setDynamoDBClient(new AmazonDynamoDBClient(credentialsProvider)); } catch (Exception e) { throw new ConnectionException(ConnectionExceptionCode.UNKNOWN, null, e.getMessage(), e); } }