private void storeCredentialsInS3(String passphrase, String password) {
if (!validPassphraseInputs(passphrase, password)) {
return;
}
final AWSCredentials awsCredentials =
AWSCredentialsDialog.showDialog(ownerFrame,
(loginMode == LOGIN_MODE_LOCAL_FOLDER), hyperlinkListener);
if (awsCredentials == null) {
return;
}
final String[] bucketName = new String[1];
final String[] credentialObjectKey = new String[1];
try {
bucketName[0] = generateBucketNameFromPassphrase(passphrase);
credentialObjectKey[0] = generateObjectKeyFromPassphrase(passphrase, password);
} catch (Exception e) {
String message = "Unable to generate bucket name or object key";
log.error(message, e);
ErrorDialog.showDialog(this, hyperlinkListener, message, e);
return;
}
final ByteArrayInputStream[] bais = new ByteArrayInputStream[1];
try {
// Convert AWS Credentials into a readable input stream.
String algorithm = myProperties.getStringProperty("crypto.algorithm", "PBEWithMD5AndDES");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
awsCredentials.save(password, baos, algorithm);
bais[0] = new ByteArrayInputStream(baos.toByteArray());
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
String message = "Unable to encrypt your AWS Credentials";