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 2018/09/19 01:44:48 UTC

[kylin] branch master updated: KYLIN-3531 Save uppercase of usernames to metadata

This is an automated email from the ASF dual-hosted git repository.

shaofengshi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git


The following commit(s) were added to refs/heads/master by this push:
     new 5413975  KYLIN-3531 Save uppercase of usernames to metadata
5413975 is described below

commit 5413975a94ea41ba17cd5e02359038d7a7affb45
Author: Yichen Zhou <zh...@gmail.com>
AuthorDate: Tue Sep 18 14:40:39 2018 +0800

    KYLIN-3531 Save uppercase of usernames to metadata
---
 .../main/java/org/apache/kylin/rest/security/KylinUserManager.java    | 4 +++-
 .../src/main/java/org/apache/kylin/rest/service/KylinUserService.java | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/server-base/src/main/java/org/apache/kylin/rest/security/KylinUserManager.java b/server-base/src/main/java/org/apache/kylin/rest/security/KylinUserManager.java
index c4b457d..acbc008 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/security/KylinUserManager.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/security/KylinUserManager.java
@@ -25,6 +25,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
+import java.util.Locale;
 
 import org.apache.kylin.common.KylinConfig;
 import org.apache.kylin.common.persistence.ResourceStore;
@@ -119,6 +120,7 @@ public class KylinUserManager {
             if (exist != null) {
                 user.setLastModified(exist.getLastModified());
             }
+            user.setUsername(user.getUsername().toUpperCase(Locale.ROOT));
             crud.save(user);
         } catch (IOException e) {
             throw new RuntimeException("Can not update user.", e);
@@ -127,7 +129,7 @@ public class KylinUserManager {
 
     public void delete(String username) {
         try (AutoReadWriteLock.AutoLock l = lock.lockForWrite()) {
-            crud.delete(username);
+            crud.delete(username.toUpperCase(Locale.ROOT));
         } catch (IOException e) {
             throw new RuntimeException("Can not delete user.", e);
         }
diff --git a/server-base/src/main/java/org/apache/kylin/rest/service/KylinUserService.java b/server-base/src/main/java/org/apache/kylin/rest/service/KylinUserService.java
index 8571aec..eea8cd7 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/service/KylinUserService.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/service/KylinUserService.java
@@ -90,7 +90,7 @@ public class KylinUserService implements UserService {
 
     @Override
     public void deleteUser(String userName) {
-        if (userName.equals(SUPER_ADMIN)) {
+        if (userName.equalsIgnoreCase(SUPER_ADMIN)) {
             throw new InternalErrorException("User " + userName + " is not allowed to be deleted.");
         }