Repository: kylin
Updated Branches:
refs/heads/2.0-rc 26f4133fc -> 97c18ef80
KYLIN-1442 make PasswordPlaceholderConfigurer work for both AES and BCrypt
Conflicts:
server/src/main/java/org/apache/kylin/rest/security/PasswordPlaceholderConfigurer.java
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/97c18ef8
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/97c18ef8
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/97c18ef8
Branch: refs/heads/2.0-rc
Commit: 97c18ef801d267cbf51cf96227b3e6379f261a0f
Parents: 26f4133
Author: shaofengshi <[email protected]>
Authored: Thu Feb 25 11:18:35 2016 +0800
Committer: shaofengshi <[email protected]>
Committed: Thu Feb 25 11:23:29 2016 +0800
----------------------------------------------------------------------
.../security/PasswordPlaceholderConfigurer.java | 34 ++++++++++++++++----
1 file changed, 27 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/97c18ef8/server/src/main/java/org/apache/kylin/rest/security/PasswordPlaceholderConfigurer.java
----------------------------------------------------------------------
diff --git
a/server/src/main/java/org/apache/kylin/rest/security/PasswordPlaceholderConfigurer.java
b/server/src/main/java/org/apache/kylin/rest/security/PasswordPlaceholderConfigurer.java
index b8ccbeb..0c4690f 100644
---
a/server/src/main/java/org/apache/kylin/rest/security/PasswordPlaceholderConfigurer.java
+++
b/server/src/main/java/org/apache/kylin/rest/security/PasswordPlaceholderConfigurer.java
@@ -18,11 +18,6 @@
package org.apache.kylin.rest.security;
-import java.util.Properties;
-
-import javax.crypto.Cipher;
-import javax.crypto.spec.SecretKeySpec;
-
import org.apache.commons.codec.binary.Base64;
import org.apache.kylin.common.KylinConfig;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
@@ -30,6 +25,10 @@ import org.springframework.core.io.InputStreamResource;
import org.springframework.core.io.Resource;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import javax.crypto.Cipher;
+import javax.crypto.spec.SecretKeySpec;
+import java.util.Properties;
+
/**
* @author xduo
*
@@ -75,9 +74,30 @@ public class PasswordPlaceholderConfigurer extends
PropertyPlaceholderConfigurer
return props.getProperty(placeholder);
}
}
+
+ private static void printUsage() {
+ System.out.println("Usage: java
org.apache.kylin.rest.security.PasswordPlaceholderConfigurer <EncryptMethod>
<your_password>");
+ System.out.println("EncryptMethod: AES or BCrypt");
+ }
public static void main(String[] args) {
- BCryptPasswordEncoder bCryptPasswordEncoder = new
BCryptPasswordEncoder();
- System.out.println(bCryptPasswordEncoder.encode("MODELER"));
+ if (args.length != 2) {
+ printUsage();
+ System.exit(1);
+ }
+
+ String encryptMethod = args[0];
+ String passwordTxt = args[1];
+ if ("AES".equalsIgnoreCase(encryptMethod)) {
+ System.out.println(encryptMethod + " encrypted password is: ");
+ System.out.println(encrypt(passwordTxt));
+ } else if ("BCrypt".equalsIgnoreCase(encryptMethod)) {
+ BCryptPasswordEncoder bCryptPasswordEncoder = new
BCryptPasswordEncoder();
+ System.out.println(encryptMethod + " encrypted password is: ");
+ System.out.println(bCryptPasswordEncoder.encode(passwordTxt));
+ } else {
+ printUsage();
+ System.exit(1);
+ }
}
}