KYLIN-2535 minor, refactor some beans in acl service and user service


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/2b6a91f1
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/2b6a91f1
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/2b6a91f1

Branch: refs/heads/master
Commit: 2b6a91f14e791347f19bb1a7811c691fb1b6afb0
Parents: 0b51f7b
Author: FAN XIE <fx...@andrew.cmu.edu>
Authored: Tue May 2 13:33:47 2017 +0800
Committer: hongbin ma <m...@kyligence.io>
Committed: Tue May 2 13:33:47 2017 +0800

----------------------------------------------------------------------
 .../hbase/ITAclTableMigrationToolTest.java      |   9 +-
 .../org/apache/kylin/rest/service/AceInfo.java  |  55 +++++++++
 .../apache/kylin/rest/service/AclService.java   |  95 ---------------
 .../rest/service/AclTableMigrationTool.java     |  53 ++-------
 .../kylin/rest/service/DomainObjectInfo.java    |  52 ++++++++
 .../kylin/rest/service/LegacyAclService.java    | 118 ++-----------------
 .../kylin/rest/service/LegacyUserService.java   |  51 --------
 .../org/apache/kylin/rest/service/SidInfo.java  |  61 ++++++++++
 8 files changed, 199 insertions(+), 295 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/2b6a91f1/kylin-it/src/test/java/org/apache/kylin/storage/hbase/ITAclTableMigrationToolTest.java
----------------------------------------------------------------------
diff --git 
a/kylin-it/src/test/java/org/apache/kylin/storage/hbase/ITAclTableMigrationToolTest.java
 
b/kylin-it/src/test/java/org/apache/kylin/storage/hbase/ITAclTableMigrationToolTest.java
index 35535e5..65d5b52 100644
--- 
a/kylin-it/src/test/java/org/apache/kylin/storage/hbase/ITAclTableMigrationToolTest.java
+++ 
b/kylin-it/src/test/java/org/apache/kylin/storage/hbase/ITAclTableMigrationToolTest.java
@@ -45,6 +45,7 @@ import org.apache.kylin.rest.security.AclHBaseStorage;
 import org.apache.kylin.rest.service.AclService;
 import org.apache.kylin.rest.service.AclTableMigrationTool;
 import org.apache.kylin.rest.service.LegacyUserService;
+import org.apache.kylin.rest.service.UserGrantedAuthority;
 import org.apache.kylin.rest.service.UserService;
 import org.apache.kylin.rest.util.Serializer;
 import org.junit.After;
@@ -70,7 +71,7 @@ public class ITAclTableMigrationToolTest extends 
HBaseMetadataTestCase {
 
     private TableName userTable = TableName.valueOf(STORE_WITH_OLD_TABLE + 
AclHBaseStorage.USER_TABLE_NAME);
 
-    private Serializer<LegacyUserService.UserGrantedAuthority[]> ugaSerializer 
= new 
Serializer<LegacyUserService.UserGrantedAuthority[]>(LegacyUserService.UserGrantedAuthority[].class);
+    private Serializer<UserGrantedAuthority[]> ugaSerializer = new 
Serializer<UserGrantedAuthority[]>(UserGrantedAuthority[].class);
 
     private AclTableMigrationTool aclTableMigrationJob;
 
@@ -192,13 +193,13 @@ public class ITAclTableMigrationToolTest extends 
HBaseMetadataTestCase {
         if (authorities == null)
             authorities = Collections.emptyList();
 
-        LegacyUserService.UserGrantedAuthority[] serializing = new 
LegacyUserService.UserGrantedAuthority[authorities.size() + 1];
+        UserGrantedAuthority[] serializing = new 
UserGrantedAuthority[authorities.size() + 1];
 
         // password is stored as the [0] authority
-        serializing[0] = new 
LegacyUserService.UserGrantedAuthority(LegacyUserService.PWD_PREFIX + 
"password");
+        serializing[0] = new UserGrantedAuthority(LegacyUserService.PWD_PREFIX 
+ "password");
         int i = 1;
         for (GrantedAuthority a : authorities) {
-            serializing[i++] = new 
LegacyUserService.UserGrantedAuthority(a.getAuthority());
+            serializing[i++] = new UserGrantedAuthority(a.getAuthority());
         }
 
         byte[] value = ugaSerializer.serialize(serializing);

http://git-wip-us.apache.org/repos/asf/kylin/blob/2b6a91f1/server-base/src/main/java/org/apache/kylin/rest/service/AceInfo.java
----------------------------------------------------------------------
diff --git 
a/server-base/src/main/java/org/apache/kylin/rest/service/AceInfo.java 
b/server-base/src/main/java/org/apache/kylin/rest/service/AceInfo.java
new file mode 100644
index 0000000..0be1019
--- /dev/null
+++ b/server-base/src/main/java/org/apache/kylin/rest/service/AceInfo.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.kylin.rest.service;
+
+import org.springframework.security.acls.model.AccessControlEntry;
+
+/**
+ * Created by xiefan on 17-5-2.
+ */
+class AceInfo {
+    private SidInfo sidInfo;
+    private int permissionMask;
+
+    public AceInfo() {
+    }
+
+    public AceInfo(AccessControlEntry ace) {
+        super();
+        this.sidInfo = new SidInfo(ace.getSid());
+        this.permissionMask = ace.getPermission().getMask();
+    }
+
+    public SidInfo getSidInfo() {
+        return sidInfo;
+    }
+
+    public void setSidInfo(SidInfo sidInfo) {
+        this.sidInfo = sidInfo;
+    }
+
+    public int getPermissionMask() {
+        return permissionMask;
+    }
+
+    public void setPermissionMask(int permissionMask) {
+        this.permissionMask = permissionMask;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/kylin/blob/2b6a91f1/server-base/src/main/java/org/apache/kylin/rest/service/AclService.java
----------------------------------------------------------------------
diff --git 
a/server-base/src/main/java/org/apache/kylin/rest/service/AclService.java 
b/server-base/src/main/java/org/apache/kylin/rest/service/AclService.java
index 63b155b..097dd92 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/service/AclService.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/service/AclService.java
@@ -409,98 +409,3 @@ class AclRecord extends RootPersistentEntity {
 
 }
 
-class DomainObjectInfo {
-    private String id;
-    private String type;
-
-    public DomainObjectInfo() {
-    }
-
-    public DomainObjectInfo(ObjectIdentity oid) {
-        super();
-        this.id = (String) oid.getIdentifier();
-        this.type = oid.getType();
-    }
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-}
-
-class SidInfo {
-    private String sid;
-    private boolean isPrincipal;
-
-    public SidInfo() {
-    }
-
-    public SidInfo(Sid sid) {
-        if (sid instanceof PrincipalSid) {
-            this.sid = ((PrincipalSid) sid).getPrincipal();
-            this.isPrincipal = true;
-        } else if (sid instanceof GrantedAuthoritySid) {
-            this.sid = ((GrantedAuthoritySid) sid).getGrantedAuthority();
-            this.isPrincipal = false;
-        }
-    }
-
-    public String getSid() {
-        return sid;
-    }
-
-    public void setSid(String sid) {
-        this.sid = sid;
-    }
-
-    public boolean isPrincipal() {
-        return isPrincipal;
-    }
-
-    public void setPrincipal(boolean isPrincipal) {
-        this.isPrincipal = isPrincipal;
-    }
-
-}
-
-class AceInfo {
-    private SidInfo sidInfo;
-    private int permissionMask;
-
-    public AceInfo() {
-    }
-
-    public AceInfo(AccessControlEntry ace) {
-        super();
-        this.sidInfo = new SidInfo(ace.getSid());
-        this.permissionMask = ace.getPermission().getMask();
-    }
-
-    public SidInfo getSidInfo() {
-        return sidInfo;
-    }
-
-    public void setSidInfo(SidInfo sidInfo) {
-        this.sidInfo = sidInfo;
-    }
-
-    public int getPermissionMask() {
-        return permissionMask;
-    }
-
-    public void setPermissionMask(int permissionMask) {
-        this.permissionMask = permissionMask;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/kylin/blob/2b6a91f1/server-base/src/main/java/org/apache/kylin/rest/service/AclTableMigrationTool.java
----------------------------------------------------------------------
diff --git 
a/server-base/src/main/java/org/apache/kylin/rest/service/AclTableMigrationTool.java
 
b/server-base/src/main/java/org/apache/kylin/rest/service/AclTableMigrationTool.java
index da017b3..d88ca74 100644
--- 
a/server-base/src/main/java/org/apache/kylin/rest/service/AclTableMigrationTool.java
+++ 
b/server-base/src/main/java/org/apache/kylin/rest/service/AclTableMigrationTool.java
@@ -52,13 +52,13 @@ import com.fasterxml.jackson.databind.JsonMappingException;
 
 public class AclTableMigrationTool {
 
-    private static final Serializer<LegacyAclService.SidInfo> sidSerializer = 
new Serializer<LegacyAclService.SidInfo>(LegacyAclService.SidInfo.class);
+    private static final Serializer<SidInfo> sidSerializer = new 
Serializer<SidInfo>(SidInfo.class);
 
-    private static final Serializer<LegacyAclService.DomainObjectInfo> 
domainObjSerializer = new 
Serializer<LegacyAclService.DomainObjectInfo>(LegacyAclService.DomainObjectInfo.class);
+    private static final Serializer<DomainObjectInfo> domainObjSerializer = 
new Serializer<DomainObjectInfo>(DomainObjectInfo.class);
 
-    private static final Serializer<LegacyAclService.AceInfo> aceSerializer = 
new Serializer<LegacyAclService.AceInfo>(LegacyAclService.AceInfo.class);
+    private static final Serializer<AceInfo> aceSerializer = new 
Serializer<AceInfo>(AceInfo.class);
 
-    private static final Serializer<LegacyUserService.UserGrantedAuthority[]> 
ugaSerializer = new 
Serializer<LegacyUserService.UserGrantedAuthority[]>(LegacyUserService.UserGrantedAuthority[].class);
+    private static final Serializer<UserGrantedAuthority[]> ugaSerializer = 
new Serializer<UserGrantedAuthority[]>(UserGrantedAuthority[].class);
 
     public static final String MIGRATE_OK_PREFIX = AclService.DIR_PREFIX + 
"MIGRATE_OK_";
 
@@ -198,8 +198,8 @@ public class AclTableMigrationTool {
     }
 
     private DomainObjectInfo getParentDomainObjectInfoFromRs(Result result) 
throws IOException {
-        LegacyAclService.DomainObjectInfo parentInfo = 
domainObjSerializer.deserialize(result.getValue(Bytes.toBytes(AclHBaseStorage.ACL_INFO_FAMILY),
 Bytes.toBytes(LegacyAclService.ACL_INFO_FAMILY_PARENT_COLUMN)));
-        return convert(parentInfo);
+        DomainObjectInfo parentInfo = 
domainObjSerializer.deserialize(result.getValue(Bytes.toBytes(AclHBaseStorage.ACL_INFO_FAMILY),
 Bytes.toBytes(LegacyAclService.ACL_INFO_FAMILY_PARENT_COLUMN)));
+        return parentInfo;
     }
 
     private boolean getInheriting(Result result) {
@@ -208,8 +208,8 @@ public class AclTableMigrationTool {
     }
 
     private SidInfo getOwnerSidInfo(Result result) throws IOException {
-        LegacyAclService.SidInfo owner = 
sidSerializer.deserialize(result.getValue(Bytes.toBytes(AclHBaseStorage.ACL_INFO_FAMILY),
 Bytes.toBytes(LegacyAclService.ACL_INFO_FAMILY_OWNER_COLUMN)));
-        return convert(owner);
+        SidInfo owner = 
sidSerializer.deserialize(result.getValue(Bytes.toBytes(AclHBaseStorage.ACL_INFO_FAMILY),
 Bytes.toBytes(LegacyAclService.ACL_INFO_FAMILY_OWNER_COLUMN)));
+        return owner;
     }
 
     private Map<String, AceInfo> getAllAceInfo(Result result) throws 
IOException {
@@ -217,41 +217,14 @@ public class AclTableMigrationTool {
         NavigableMap<byte[], byte[]> familyMap = 
result.getFamilyMap(Bytes.toBytes(AclHBaseStorage.ACL_ACES_FAMILY));
         for (Map.Entry<byte[], byte[]> entry : familyMap.entrySet()) {
             String sid = String.valueOf(entry.getKey());
-            LegacyAclService.AceInfo aceInfo = 
aceSerializer.deserialize(familyMap.get(entry.getValue()));
+            AceInfo aceInfo = 
aceSerializer.deserialize(familyMap.get(entry.getValue()));
             if (null != aceInfo) {
-                allAceInfoMap.put(sid, convert(aceInfo));
+                allAceInfoMap.put(sid, aceInfo);
             }
         }
         return allAceInfoMap;
     }
 
-    private DomainObjectInfo convert(LegacyAclService.DomainObjectInfo 
oldInfo) {
-        if (oldInfo == null)
-            return null;
-        DomainObjectInfo newInfo = new DomainObjectInfo();
-        newInfo.setId(String.valueOf(oldInfo.getId()));
-        newInfo.setType(oldInfo.getType());
-        return newInfo;
-    }
-
-    private SidInfo convert(LegacyAclService.SidInfo oldInfo) {
-        if (oldInfo == null)
-            return null;
-        SidInfo newInfo = new SidInfo();
-        newInfo.setPrincipal(oldInfo.isPrincipal());
-        newInfo.setSid(oldInfo.getSid());
-        return newInfo;
-    }
-
-    private AceInfo convert(LegacyAclService.AceInfo oldInfo) {
-        if (oldInfo == null)
-            return null;
-        AceInfo newInfo = new AceInfo();
-        newInfo.setPermissionMask(oldInfo.getPermissionMask());
-        newInfo.setSidInfo(convert(oldInfo.getSidInfo()));
-        return newInfo;
-    }
-
     private UserInfo convert(User user) {
         if (user == null)
             return null;
@@ -273,10 +246,10 @@ public class AclTableMigrationTool {
         String username = Bytes.toString(result.getRow());
 
         byte[] valueBytes = 
result.getValue(Bytes.toBytes(AclHBaseStorage.USER_AUTHORITY_FAMILY), 
Bytes.toBytes(AclHBaseStorage.USER_AUTHORITY_COLUMN));
-        LegacyUserService.UserGrantedAuthority[] deserialized = 
ugaSerializer.deserialize(valueBytes);
+        UserGrantedAuthority[] deserialized = 
ugaSerializer.deserialize(valueBytes);
 
         String password = "";
-        List<LegacyUserService.UserGrantedAuthority> authorities = 
Collections.emptyList();
+        List<UserGrantedAuthority> authorities = Collections.emptyList();
 
         // password is stored at [0] of authorities for backward compatibility
         if (deserialized != null) {
@@ -288,7 +261,7 @@ public class AclTableMigrationTool {
             }
         }
         List<String> authoritiesStr = new ArrayList<>();
-        for (LegacyUserService.UserGrantedAuthority auth : authorities) {
+        for (UserGrantedAuthority auth : authorities) {
             if (auth != null) {
                 authoritiesStr.add(auth.getAuthority());
             }

http://git-wip-us.apache.org/repos/asf/kylin/blob/2b6a91f1/server-base/src/main/java/org/apache/kylin/rest/service/DomainObjectInfo.java
----------------------------------------------------------------------
diff --git 
a/server-base/src/main/java/org/apache/kylin/rest/service/DomainObjectInfo.java 
b/server-base/src/main/java/org/apache/kylin/rest/service/DomainObjectInfo.java
new file mode 100644
index 0000000..f07a65e
--- /dev/null
+++ 
b/server-base/src/main/java/org/apache/kylin/rest/service/DomainObjectInfo.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.kylin.rest.service;
+
+import org.springframework.security.acls.model.ObjectIdentity;
+
+
+class DomainObjectInfo {
+    private String id;
+    private String type;
+
+    public DomainObjectInfo() {
+    }
+
+    public DomainObjectInfo(ObjectIdentity oid) {
+        super();
+        this.id = (String) oid.getIdentifier();
+        this.type = oid.getType();
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+}

http://git-wip-us.apache.org/repos/asf/kylin/blob/2b6a91f1/server-base/src/main/java/org/apache/kylin/rest/service/LegacyAclService.java
----------------------------------------------------------------------
diff --git 
a/server-base/src/main/java/org/apache/kylin/rest/service/LegacyAclService.java 
b/server-base/src/main/java/org/apache/kylin/rest/service/LegacyAclService.java
index abd0268..8ab6ebe 100644
--- 
a/server-base/src/main/java/org/apache/kylin/rest/service/LegacyAclService.java
+++ 
b/server-base/src/main/java/org/apache/kylin/rest/service/LegacyAclService.java
@@ -18,8 +18,17 @@
 
 package org.apache.kylin.rest.service;
 
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.NavigableMap;
+
+import javax.annotation.PostConstruct;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.Get;
@@ -59,16 +68,8 @@ import 
org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.util.FieldUtils;
 import org.springframework.util.Assert;
 
-import javax.annotation.PostConstruct;
-import java.io.IOException;
-import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.NavigableMap;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
 
 /**
  * @author xduo
@@ -363,98 +364,5 @@ public class LegacyAclService implements MutableAclService 
{
         }
     }
 
-    protected static class DomainObjectInfo {
-        private String id;
-        private String type;
-
-        public DomainObjectInfo() {
-        }
-
-        public DomainObjectInfo(ObjectIdentity oid) {
-            super();
-            this.id = (String) oid.getIdentifier();
-            this.type = oid.getType();
-        }
-
-        public Serializable getId() {
-            return id;
-        }
-
-        public void setId(String id) {
-            this.id = id;
-        }
-
-        public String getType() {
-            return type;
-        }
-
-        public void setType(String type) {
-            this.type = type;
-        }
-    }
-
-    protected static class SidInfo {
-        private String sid;
-        private boolean isPrincipal;
-
-        public SidInfo() {
-        }
-
-        public SidInfo(Sid sid) {
-            if (sid instanceof PrincipalSid) {
-                this.sid = ((PrincipalSid) sid).getPrincipal();
-                this.isPrincipal = true;
-            } else if (sid instanceof GrantedAuthoritySid) {
-                this.sid = ((GrantedAuthoritySid) sid).getGrantedAuthority();
-                this.isPrincipal = false;
-            }
-        }
-
-        public String getSid() {
-            return sid;
-        }
-
-        public void setSid(String sid) {
-            this.sid = sid;
-        }
-
-        public boolean isPrincipal() {
-            return isPrincipal;
-        }
-
-        public void setPrincipal(boolean isPrincipal) {
-            this.isPrincipal = isPrincipal;
-        }
-    }
-
-    protected static class AceInfo {
-        private SidInfo sidInfo;
-        private int permissionMask;
-
-        public AceInfo() {
-        }
-
-        public AceInfo(AccessControlEntry ace) {
-            super();
-            this.sidInfo = new SidInfo(ace.getSid());
-            this.permissionMask = ace.getPermission().getMask();
-        }
-
-        public SidInfo getSidInfo() {
-            return sidInfo;
-        }
-
-        public void setSidInfo(SidInfo sidInfo) {
-            this.sidInfo = sidInfo;
-        }
-
-        public int getPermissionMask() {
-            return permissionMask;
-        }
-
-        public void setPermissionMask(int permissionMask) {
-            this.permissionMask = permissionMask;
-        }
-    }
 
 }

http://git-wip-us.apache.org/repos/asf/kylin/blob/2b6a91f1/server-base/src/main/java/org/apache/kylin/rest/service/LegacyUserService.java
----------------------------------------------------------------------
diff --git 
a/server-base/src/main/java/org/apache/kylin/rest/service/LegacyUserService.java
 
b/server-base/src/main/java/org/apache/kylin/rest/service/LegacyUserService.java
index 6f0455e..b8f3700 100644
--- 
a/server-base/src/main/java/org/apache/kylin/rest/service/LegacyUserService.java
+++ 
b/server-base/src/main/java/org/apache/kylin/rest/service/LegacyUserService.java
@@ -234,55 +234,4 @@ public class LegacyUserService implements 
UserDetailsManager {
         return all;
     }
 
-    public static class UserGrantedAuthority implements GrantedAuthority {
-        private static final long serialVersionUID = -5128905636841891058L;
-        private String authority;
-
-        public UserGrantedAuthority() {
-        }
-
-        public UserGrantedAuthority(String authority) {
-            setAuthority(authority);
-        }
-
-        @Override
-        public String getAuthority() {
-            return authority;
-        }
-
-        public void setAuthority(String authority) {
-            this.authority = authority;
-        }
-
-        @Override
-        public int hashCode() {
-            final int prime = 31;
-            int result = 1;
-            result = prime * result + ((authority == null) ? 0 : 
authority.hashCode());
-            return result;
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj)
-                return true;
-            if (obj == null)
-                return false;
-            if (getClass() != obj.getClass())
-                return false;
-            UserGrantedAuthority other = (UserGrantedAuthority) obj;
-            if (authority == null) {
-                if (other.authority != null)
-                    return false;
-            } else if (!authority.equals(other.authority))
-                return false;
-            return true;
-        }
-
-        @Override
-        public String toString() {
-            return authority;
-        }
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/kylin/blob/2b6a91f1/server-base/src/main/java/org/apache/kylin/rest/service/SidInfo.java
----------------------------------------------------------------------
diff --git 
a/server-base/src/main/java/org/apache/kylin/rest/service/SidInfo.java 
b/server-base/src/main/java/org/apache/kylin/rest/service/SidInfo.java
new file mode 100644
index 0000000..0a89449
--- /dev/null
+++ b/server-base/src/main/java/org/apache/kylin/rest/service/SidInfo.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.kylin.rest.service;
+
+import org.springframework.security.acls.domain.GrantedAuthoritySid;
+import org.springframework.security.acls.domain.PrincipalSid;
+import org.springframework.security.acls.model.Sid;
+
+/**
+ * Created by xiefan on 17-5-2.
+ */
+class SidInfo {
+    private String sid;
+    private boolean isPrincipal;
+
+    public SidInfo() {
+    }
+
+    public SidInfo(Sid sid) {
+        if (sid instanceof PrincipalSid) {
+            this.sid = ((PrincipalSid) sid).getPrincipal();
+            this.isPrincipal = true;
+        } else if (sid instanceof GrantedAuthoritySid) {
+            this.sid = ((GrantedAuthoritySid) sid).getGrantedAuthority();
+            this.isPrincipal = false;
+        }
+    }
+
+    public String getSid() {
+        return sid;
+    }
+
+    public void setSid(String sid) {
+        this.sid = sid;
+    }
+
+    public boolean isPrincipal() {
+        return isPrincipal;
+    }
+
+    public void setPrincipal(boolean isPrincipal) {
+        this.isPrincipal = isPrincipal;
+    }
+
+}

Reply via email to