List of usage examples for com.amazonaws.auth BasicAWSCredentials BasicAWSCredentials
public BasicAWSCredentials(String accessKey, String secretKey)
From source file:com.github.trask.sandbox.mail.impl.AmazonMailService.java
License:Apache License
public AmazonMailService(String accessKey, String secretKey, ExecutorService executorService) { AWSCredentials emailCredentials = new BasicAWSCredentials(accessKey, secretKey); simpleEmailServiceAsync = new AmazonSimpleEmailServiceAsyncClient(emailCredentials, executorService); }
From source file:com.github.vatbub.awsvpnlauncher.Main.java
License:Apache License
private static void initAWSConnection() { AWSCredentials credentials = new BasicAWSCredentials(prefs.getPreference(Property.awsKey), prefs.getPreference(Property.awsSecret)); awsRegion = Regions.valueOf(prefs.getPreference(Property.awsRegion)); client = AmazonEC2ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(credentials)) .withRegion(awsRegion).build(); }
From source file:com.github.wuic.nut.s3.S3NutDao.java
License:Open Source License
/** * <p>/*from w ww . j a v a2s. c o m*/ * Initializes a new client based on the instance's credentials. * </p> * * @return the client */ public AmazonS3Client initClient() { return new AmazonS3Client(new BasicAWSCredentials(login, password)); }
From source file:com.grallandco.demos.DBWrite.java
License:Apache License
public static void main(String[] args) throws Exception { AmazonS3 s3;// w w w. jav a 2s .com if (args.length == 2) { String accessKey = args[0]; String secretKey = args[1]; s3 = new AmazonS3Client(new BasicAWSCredentials(accessKey, secretKey)); } StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); Properties props = new Properties(); //Properties outProps = new Properties(); // setProperties(); props.setProperty("bootstrap.servers", "localhost:9092"); props.setProperty("group.id", "zookeeper"); props.setProperty("auto.offset.reset", "latest"); //outProps.setProperty("bootstrap.servers", "localhost:9092"); String topic = "poe3"; //final Connection conn = r.connection().hostname("35.166.62.31").port(28015).connect(); //conn.use("poeapi"); //DataStream<String> stream = env.addSource(new FlinkKafkaConsumer09<String>(topic, new SimpleStringSchema(), props)); env.execute(); }
From source file:com.gst.infrastructure.documentmanagement.contentrepository.S3ContentRepository.java
License:Apache License
public S3ContentRepository(final String bucketName, final String secretKey, final String accessKey) { this.s3BucketName = bucketName; this.s3Client = new AmazonS3Client(new BasicAWSCredentials(accessKey, secretKey)); }
From source file:com.hangum.tadpole.aws.rds.commons.core.utils.AmazonRDSUtsils.java
License:Open Source License
/** * Get RDS to Tadpole UserDB data.// ww w. j av a 2s . c o m * * @param accessKey * @param secretKey * @param regionName * @return * @throws Exception */ public static List<AWSRDSUserDBDAO> getDBList(String accessKey, String secretKey, String regionName) throws Exception { List<AWSRDSUserDBDAO> returnDBList = new ArrayList<AWSRDSUserDBDAO>(); try { BasicAWSCredentials awsCredential = new BasicAWSCredentials(accessKey, secretKey); AmazonRDSClient rdsClient = new AmazonRDSClient(awsCredential); rdsClient.setRegion(RegionUtils.getRegion(regionName)); DescribeDBInstancesResult describeDBInstance = rdsClient.describeDBInstances(); List<DBInstance> listDBInstance = describeDBInstance.getDBInstances(); for (DBInstance rdsDbInstance : listDBInstance) { AWSRDSUserDBDAO rdsUserDB = new AWSRDSUserDBDAO(); // rds information rdsUserDB.setAccessKey(accessKey); rdsUserDB.setSecretKey(secretKey); rdsUserDB.setEndPoint(regionName); // ext information rdsUserDB.setExt1(rdsDbInstance.getDBInstanceClass()); rdsUserDB.setExt2(rdsDbInstance.getAvailabilityZone()); // db information String strDBMStype = rdsDbInstance.getEngine(); if (strDBMStype.startsWith("sqlserver")) { String strEngVer = rdsDbInstance.getEngineVersion(); // if(strEngVer.startsWith("11")) // else strDBMStype = "MSSQL_8_LE"; strDBMStype = DBDefine.MSSQL_DEFAULT.getDBToString(); } else if (strDBMStype.startsWith("oracle")) { strDBMStype = DBDefine.ORACLE_DEFAULT.getDBToString(); } rdsUserDB.setDbms_types(DBDefine.getDBDefine(strDBMStype).getDBToString()); rdsUserDB.setDisplay_name( rdsDbInstance.getDBInstanceIdentifier() + "." + rdsDbInstance.getAvailabilityZone()); rdsUserDB.setOperation_type(DBOperationType.DEVELOP.toString()); rdsUserDB.setDb(rdsDbInstance.getDBInstanceIdentifier());//getDBName()); rdsUserDB.setHost(rdsDbInstance.getEndpoint().getAddress()); rdsUserDB.setPort("" + rdsDbInstance.getEndpoint().getPort()); rdsUserDB.setLocale( rdsDbInstance.getCharacterSetName() == null ? "" : rdsDbInstance.getCharacterSetName()); rdsUserDB.setUsers(rdsDbInstance.getMasterUsername()); rdsUserDB.setPasswd(""); returnDBList.add(rdsUserDB); } } catch (Exception e) { throw e; } return returnDBList; }
From source file:com.haskins.cloudtrailviewer.core.EventLoader.java
License:Open Source License
/** * Loads events from S3//w w w.ja v a2 s . c o m * @param request Object containing request information */ public void loadEventsFromS3(final LoadFileRequest request) { SwingWorker worker = new SwingWorker<Void, Void>() { @Override public Void doInBackground() { int count = 0; List<AwsAccount> accounts = AccountDao.getAllAccounts(true); if (accounts.isEmpty()) { return null; } AwsAccount account = accounts.get(0); String key = account.getKey(); String secret = account.getSecret(); AWSCredentials credentials = new BasicAWSCredentials(key, secret); AmazonS3 s3Client = new AmazonS3Client(credentials); String bucketName = account.getBucket(); if (request.getFilter() == null) { CompositeFilter filters = new CompositeFilter(); filters.addFilter(new AllFilter()); request.setFilter(filters); } List<String> filenames = request.getFilenames(); int total = filenames.size(); for (String filename : filenames) { count++; for (EventLoaderListener l : listeners) { l.processingFile(count, total); } try (InputStream stream = loadEventFromS3(s3Client, bucketName, filename)) { processStream(stream, request.getFilter()); } catch (IOException ioe) { LOGGER.log(Level.WARNING, "Failed to load file : " + filename, ioe); } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed to load file : " + filename, e); } } for (EventLoaderListener l : listeners) { l.finishedLoading(); } return null; } }; worker.execute(); }
From source file:com.haskins.cloudtrailviewer.dialog.resourcedetail.detailpanels.AbstractDetail.java
License:Open Source License
AbstractDetail(ResourceDetailRequest detailRequest) { this.setLayout(new BorderLayout()); this.detailRequest = detailRequest; this.credentials = new BasicAWSCredentials(detailRequest.getAccount().getKey(), detailRequest.getAccount().getSecret()); primaryTableModel.addColumn("Property"); primaryTableModel.addColumn("Value"); tagsTableModel.addColumn("Key"); tagsTableModel.addColumn("Value"); }
From source file:com.haskins.cloudtrailviewer.dialog.s3filechooser.S3FileList.java
License:Open Source License
private AmazonS3 getS3Client() { AWSCredentials credentials = new BasicAWSCredentials(currentAccount.getKey(), currentAccount.getSecret()); return new AmazonS3Client(credentials); }
From source file:com.haskins.cloudtrailviewer.dialog.S3FileChooser.java
License:Open Source License
private void reloadContents() { loadingLabel.setVisible(true);/*from w w w. ja v a2s .c o m*/ this.s3ListModel.clear(); String bucketName = currentAccount.getBucket(); ListObjectsRequest listObjectsRequest = new ListObjectsRequest(); listObjectsRequest.setBucketName(bucketName); listObjectsRequest.setPrefix(prefix); listObjectsRequest.setDelimiter("/"); AWSCredentials credentials = new BasicAWSCredentials(currentAccount.getKey(), currentAccount.getSecret()); AmazonS3 s3Client = new AmazonS3Client(credentials); try { ObjectListing objectListing = s3Client.listObjects(listObjectsRequest); // Add .. if not at root if (prefix.trim().length() != 0) { S3ListModel model = new S3ListModel(MOVE_BACK, MOVE_BACK, S3ListModel.FILE_BACK); this.s3ListModel.addElement(model); } // these are directories List<String> directories = objectListing.getCommonPrefixes(); for (String directory : directories) { String dir = stripPrefix(directory); int lastSlash = dir.lastIndexOf("/"); String strippeDir = dir.substring(0, lastSlash); String alias = dir; if (isAccountNumber(strippeDir)) { if (aliasMap.containsKey(strippeDir)) { alias = aliasMap.get(strippeDir); } } S3ListModel model = new S3ListModel(dir, alias, S3ListModel.FILE_DIR); this.s3ListModel.addElement(model); } // these are files List<S3ObjectSummary> objectSummaries = objectListing.getObjectSummaries(); for (final S3ObjectSummary objectSummary : objectSummaries) { String file = stripPrefix(objectSummary.getKey()); S3ListModel model = new S3ListModel(file, file, S3ListModel.FILE_DOC); this.s3ListModel.addElement(model); } loadingLabel.setVisible(false); } catch (Exception e) { e.printStackTrace(); } }