You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2020/04/28 08:35:34 UTC
[kylin] branch 3.0.x updated: KYLIN-4438 fix bug: null password may
cause RuntimeException when starting up
This is an automated email from the ASF dual-hosted git repository.
shaofengshi pushed a commit to branch 3.0.x
in repository https://gitbox.apache.org/repos/asf/kylin.git
The following commit(s) were added to refs/heads/3.0.x by this push:
new f4de7ab KYLIN-4438 fix bug: null password may cause RuntimeException when starting up
f4de7ab is described below
commit f4de7ab4cac24071f0bda34a870b765ffb8e50a8
Author: Congling Xia <xi...@xiaomi.com>
AuthorDate: Tue Mar 17 16:15:05 2020 +0800
KYLIN-4438 fix bug: null password may cause RuntimeException when starting up
---
.../src/main/java/org/apache/kylin/common/util/EncryptUtil.java | 6 ++++++
.../src/test/java/org/apache/kylin/common/util/EncryptUtilTest.java | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/core-common/src/main/java/org/apache/kylin/common/util/EncryptUtil.java b/core-common/src/main/java/org/apache/kylin/common/util/EncryptUtil.java
index deb54d4..c714eb2 100644
--- a/core-common/src/main/java/org/apache/kylin/common/util/EncryptUtil.java
+++ b/core-common/src/main/java/org/apache/kylin/common/util/EncryptUtil.java
@@ -32,6 +32,9 @@ public class EncryptUtil {
0x65, 0x79 };
public static String encrypt(String strToEncrypt) {
+ if (strToEncrypt == null) {
+ return null;
+ }
try {
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
final SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
@@ -45,6 +48,9 @@ public class EncryptUtil {
}
public static String decrypt(String strToDecrypt) {
+ if (strToDecrypt == null) {
+ return null;
+ }
try {
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
final SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
diff --git a/core-common/src/test/java/org/apache/kylin/common/util/EncryptUtilTest.java b/core-common/src/test/java/org/apache/kylin/common/util/EncryptUtilTest.java
index bc1c3e7..f559229 100644
--- a/core-common/src/test/java/org/apache/kylin/common/util/EncryptUtilTest.java
+++ b/core-common/src/test/java/org/apache/kylin/common/util/EncryptUtilTest.java
@@ -30,5 +30,11 @@ public class EncryptUtilTest {
Assert.assertEquals("4stv/RRleOtvie/8SLHmXA==", result);
}
+ @Test
+ public void testNullInput() {
+ Assert.assertNull(EncryptUtil.encrypt(null));
+ Assert.assertNull(EncryptUtil.decrypt(null));
+ }
+
}