use of org.talend.components.simplefileio.s3.S3DatastoreProperties in project components by Talend.
the class S3TestResource method createS3DatastoreProperties.
/**
* @return An S3DatastoreProperties with all of the defaults, but filled with security credentials from the system
* environment.
*/
public S3DatastoreProperties createS3DatastoreProperties() {
S3DatastoreProperties properties = new S3DatastoreProperties(null);
properties.init();
String s3AccessKey = System.getProperty("s3.accesskey");
String s3SecretKey = System.getProperty("s3.secretkey");
// If we are running in an environment without specified keys, then don't use them.
if (StringUtils.isEmpty(s3AccessKey) || StringUtils.isEmpty(s3SecretKey)) {
properties.specifyCredentials.setValue(false);
} else {
properties.accessKey.setValue(System.getProperty("s3.accesskey"));
properties.secretKey.setValue(System.getProperty("s3.secretkey"));
}
return properties;
}
use of org.talend.components.simplefileio.s3.S3DatastoreProperties in project components by Talend.
the class S3Connection method createClient.
public static AmazonS3 createClient(S3OutputProperties properties) {
S3DatasetProperties data_set = properties.getDatasetProperties();
S3DatastoreProperties data_store = properties.getDatasetProperties().getDatastoreProperties();
com.amazonaws.auth.AWSCredentials credentials = new com.amazonaws.auth.BasicAWSCredentials(data_store.accessKey.getValue(), data_store.secretKey.getValue());
Region region = RegionUtils.getRegion(data_set.region.getValue().getValue());
Boolean clientSideEnc = data_set.encryptDataInMotion.getValue();
AmazonS3 conn = null;
if (clientSideEnc != null && clientSideEnc) {
String kms_cmk = data_set.kmsForDataInMotion.getValue();
KMSEncryptionMaterialsProvider encryptionMaterialsProvider = new KMSEncryptionMaterialsProvider(kms_cmk);
conn = new AmazonS3EncryptionClient(credentials, encryptionMaterialsProvider, new CryptoConfiguration().withAwsKmsRegion(region));
} else {
AWSCredentialsProvider basicCredentialsProvider = new StaticCredentialsProvider(credentials);
conn = new AmazonS3Client(basicCredentialsProvider);
}
conn.setRegion(region);
return conn;
}
use of org.talend.components.simplefileio.s3.S3DatastoreProperties in project components by Talend.
the class PropertiesPreparer method createS3OtuputProperties.
public static S3OutputProperties createS3OtuputProperties() {
S3OutputProperties properties = new S3OutputProperties("s3output");
S3DatasetProperties dataset = new S3DatasetProperties("dataset");
S3DatastoreProperties datastore = new S3DatastoreProperties("datastore");
properties.setDatasetProperties(dataset);
dataset.setDatastoreProperties(datastore);
datastore.accessKey.setValue(accessKey);
datastore.secretKey.setValue(secretkey);
dataset.region.setValue(S3Region.valueOf(region));
dataset.bucket.setValue(bucket);
dataset.kmsForDataInMotion.setValue(ssekmskey);
dataset.kmsForDataAtRest.setValue(csekmskey);
dataset.object.setValue(objectkey);
return properties;
}
use of org.talend.components.simplefileio.s3.S3DatastoreProperties in project components by Talend.
the class S3SourceOrSinkTestIT method validate_fail.
@Test
public void validate_fail() {
S3OutputProperties properties = PropertiesPreparer.createS3OtuputProperties();
S3DatastoreProperties datastore = properties.getDatasetProperties().getDatastoreProperties();
datastore.secretKey.setValue("wrongone");
runtime.initialize(null, properties);
ValidationResult result = runtime.validate(null);
org.junit.Assert.assertEquals(result.getMessage(), ValidationResult.Result.ERROR, result.getStatus());
}
use of org.talend.components.simplefileio.s3.S3DatastoreProperties in project components by Talend.
the class S3OutputPropertiesTest method setup.
@Before
public void setup() {
properties = new S3OutputProperties("test");
S3DatastoreProperties datastoreProperties = new S3DatastoreProperties("test");
datastoreProperties.init();
S3DatasetProperties datasetProperties = new S3DatasetProperties("test");
datasetProperties.init();
datasetProperties.setDatastoreProperties(datastoreProperties);
properties.setDatasetProperties(datasetProperties);
properties.init();
}
Aggregations