Skip to content

Commit

Permalink
Merge pull request #3 from ing-bank/bug/read-secretkey-conf
Browse files Browse the repository at this point in the history
Allow read encrypted password
  • Loading branch information
kr7ysztof authored Jan 31, 2019
2 parents 3ba62df + 024ba6b commit ae80235
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<groupId>com.ing.ranger</groupId>
<artifactId>ranger-s3-plugin</artifactId>
<version>0.2</version>
<version>0.3</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -39,7 +39,7 @@
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
<version>11.0.2</version>
<scope>test</scope>

</dependency>
<dependency>
<groupId>org.apache.ranger</groupId>
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/ing/ranger/s3/client/S3Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.commons.logging.LogFactory;
import org.apache.ranger.authorization.hadoop.config.RangerConfiguration;
import org.apache.ranger.plugin.client.BaseClient;
import org.apache.ranger.plugin.util.PasswordUtils;

import java.util.HashMap;
import java.util.List;
Expand All @@ -56,14 +57,14 @@ private static void logError(String errorMessage) throws Exception {
public S3Client(Map<String, String> configs) throws Exception {
this.endpoint = configs.get("endpoint");
this.accessKey = configs.get("accesskey");
this.secretKey = configs.get("secretkey");
this.secretKey = PasswordUtils.decryptPassword(configs.get("password"));
this.awsRegion = RangerConfiguration.getInstance().get("airlock.s3.aws.region", "us-east-1");

if (this.endpoint == null || this.endpoint.isEmpty() || !this.endpoint.startsWith("http")) {
logError("Incorrect value found for configuration `endpoint`. Please provide url in format http://host:port");
}
if (this.accessKey == null || this.secretKey == null) {
logError("Required value not found. Please provide accessKey, secretKey and user uid");
logError("Required value not found. Please provide accessKey, secretKey");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void s3ClientConfEmptyAccessKey() throws Exception {

@Test(expected = Exception.class)
public void s3ClientConfEmptySecretKey() throws Exception {
configs.remove("secretkey");
configs.remove("password");
assertThat(new S3Client(configs));
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/ing/ranger/s3/client/TestsSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public void setUp() {
configs = new HashMap<String, String>();
configs.put("endpoint", "http://127.0.0.1:8010");
configs.put("accesskey", "accesskey");
configs.put("secretkey", "secretkey");
configs.put("password", "PBEWithMD5AndDES,tzL1AKl5uc4NKYaoQ4P3WLGIBFPXWPWdu1fRm9004jtQiV,f77aLYLo,1000,6IxJOOpoFsJXyLNjNf/M9Q==");
}
}

0 comments on commit ae80235

Please sign in to comment.