This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 0fb0cbe Add AccessSubject (#10041)
0fb0cbe is described below
commit 0fb0cbe22bbbb2e5417f35bd7d4c893de4861564
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Apr 12 13:39:20 2021 +0800
Add AccessSubject (#10041)
---
.../{ => model}/privilege/PrivilegeType.java | 2 +-
.../privilege/ShardingSpherePrivileges.java | 53 ++++++++++++----------
.../privilege/admin/AdministrativePrivileges.java | 4 +-
.../privilege/database/DatabasePrivileges.java | 4 +-
.../privilege/database/SchemaPrivileges.java | 4 +-
.../privilege/database/TablePrivileges.java | 4 +-
.../subject/AccessSubject.java} | 30 ++----------
.../subject/impl/SchemaAccessSubject.java} | 26 ++---------
.../subject/impl/TableAccessSubject.java} | 28 +++---------
.../authority/spi/AuthorityProvideAlgorithm.java | 2 +-
.../authority/checker/AuthorityChecker.java | 4 +-
.../natived/NativeAuthorityProviderAlgorithm.java | 2 +-
.../natived/loader/StoragePrivilegeBuilder.java | 2 +-
.../natived/loader/StoragePrivilegeLoader.java | 2 +-
.../natived/loader/StoragePrivilegeMerger.java | 6 +--
.../loader/dialect/MySQLPrivilegeLoader.java | 8 ++--
.../loader/dialect/OraclePrivilegeLoader.java | 8 ++--
.../loader/dialect/PostgreSQLPrivilegeLoader.java | 8 ++--
.../authority/rule/AuthorityRule.java | 2 +-
.../authority/merge/PrivilegeMergeTest.java | 8 ++--
.../loader/dialect/MySQLPrivilegeLoaderTest.java | 4 +-
.../loader/dialect/OraclePrivilegeLoaderTest.java | 6 +--
.../dialect/PostgreSQLPrivilegeLoaderTest.java | 6 +--
.../auth/PostgreSQLAuthenticationEngineTest.java | 2 +-
24 files changed, 88 insertions(+), 137 deletions(-)
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/PrivilegeType.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/PrivilegeType.java
similarity index 96%
rename from
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/PrivilegeType.java
rename to
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/PrivilegeType.java
index ec2e542..7e7a11d 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/PrivilegeType.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/PrivilegeType.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.privilege;
+package org.apache.shardingsphere.authority.model.privilege;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/ShardingSpherePrivileges.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/ShardingSpherePrivileges.java
similarity index 64%
rename from
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/ShardingSpherePrivileges.java
rename to
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/ShardingSpherePrivileges.java
index 1e3b595..8cdb300 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/ShardingSpherePrivileges.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/ShardingSpherePrivileges.java
@@ -15,12 +15,15 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.privilege;
+package org.apache.shardingsphere.authority.model.privilege;
import lombok.EqualsAndHashCode;
import lombok.Getter;
-import
org.apache.shardingsphere.authority.privilege.admin.AdministrativePrivileges;
-import
org.apache.shardingsphere.authority.privilege.database.DatabasePrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.admin.AdministrativePrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.database.DatabasePrivileges;
+import org.apache.shardingsphere.authority.model.subject.AccessSubject;
+import
org.apache.shardingsphere.authority.model.subject.impl.SchemaAccessSubject;
+import
org.apache.shardingsphere.authority.model.subject.impl.TableAccessSubject;
import java.util.Collection;
@@ -43,6 +46,17 @@ public final class ShardingSpherePrivileges {
}
/**
+ * Has privilege for login and use db.
+ *
+ * @param schema schema
+ * @return has or not
+ */
+ public boolean hasPrivileges(final String schema) {
+ return
administrativePrivileges.getPrivileges().contains(PrivilegeType.SUPER)
+ || !databasePrivileges.getGlobalPrivileges().isEmpty() ||
databasePrivileges.getSpecificPrivileges().containsKey(schema);
+ }
+
+ /**
* Has privileges.
*
* @param privileges privileges
@@ -55,34 +69,25 @@ public final class ShardingSpherePrivileges {
/**
* Has privileges.
*
- * @param schema schema
+ * @param accessSubject access subject
* @param privileges privileges
* @return has privileges or not
*/
- public boolean hasPrivileges(final String schema, final
Collection<PrivilegeType> privileges) {
- return hasPrivileges(privileges) ||
databasePrivileges.hasPrivileges(schema, privileges);
+ public boolean hasPrivileges(final AccessSubject accessSubject, final
Collection<PrivilegeType> privileges) {
+ if (accessSubject instanceof SchemaAccessSubject) {
+ return hasPrivileges(((SchemaAccessSubject)
accessSubject).getSchema(), privileges);
+ }
+ if (accessSubject instanceof TableAccessSubject) {
+ return hasPrivileges(((TableAccessSubject)
accessSubject).getSchema(), ((TableAccessSubject) accessSubject).getTable(),
privileges);
+ }
+ throw new
UnsupportedOperationException(accessSubject.getClass().getCanonicalName());
}
- /**
- * Has privilege for login and use db.
- *
- * @param schema schema
- * @return has or not
- */
- public boolean hasPrivileges(final String schema) {
- return
administrativePrivileges.getPrivileges().contains(PrivilegeType.SUPER)
- || !databasePrivileges.getGlobalPrivileges().isEmpty() ||
databasePrivileges.getSpecificPrivileges().containsKey(schema);
+ private boolean hasPrivileges(final String schema, final
Collection<PrivilegeType> privileges) {
+ return hasPrivileges(privileges) ||
databasePrivileges.hasPrivileges(schema, privileges);
}
- /**
- * Has privileges.
- *
- * @param schema schema
- * @param table table
- * @param privileges privileges
- * @return has privileges or not
- */
- public boolean hasPrivileges(final String schema, final String table,
final Collection<PrivilegeType> privileges) {
+ private boolean hasPrivileges(final String schema, final String table,
final Collection<PrivilegeType> privileges) {
return hasPrivileges(privileges) ||
databasePrivileges.hasPrivileges(schema, table, privileges);
}
}
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/admin/AdministrativePrivileges.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/admin/AdministrativePrivileges.java
similarity index 91%
rename from
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/admin/AdministrativePrivileges.java
rename to
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/admin/AdministrativePrivileges.java
index baed134..2efbb0e 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/admin/AdministrativePrivileges.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/admin/AdministrativePrivileges.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.privilege.admin;
+package org.apache.shardingsphere.authority.model.privilege.admin;
import lombok.EqualsAndHashCode;
import lombok.Getter;
-import org.apache.shardingsphere.authority.privilege.PrivilegeType;
+import org.apache.shardingsphere.authority.model.privilege.PrivilegeType;
import java.util.Collection;
import java.util.concurrent.CopyOnWriteArraySet;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/database/DatabasePrivileges.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/database/DatabasePrivileges.java
similarity index 95%
rename from
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/database/DatabasePrivileges.java
rename to
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/database/DatabasePrivileges.java
index 87a2825..a65fa22 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/database/DatabasePrivileges.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/database/DatabasePrivileges.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.privilege.database;
+package org.apache.shardingsphere.authority.model.privilege.database;
import lombok.EqualsAndHashCode;
import lombok.Getter;
-import org.apache.shardingsphere.authority.privilege.PrivilegeType;
+import org.apache.shardingsphere.authority.model.privilege.PrivilegeType;
import java.util.Collection;
import java.util.Map;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/database/SchemaPrivileges.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/database/SchemaPrivileges.java
similarity index 94%
rename from
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/database/SchemaPrivileges.java
rename to
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/database/SchemaPrivileges.java
index 7bd53d0..db2c89c 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/database/SchemaPrivileges.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/database/SchemaPrivileges.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.privilege.database;
+package org.apache.shardingsphere.authority.model.privilege.database;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.authority.privilege.PrivilegeType;
+import org.apache.shardingsphere.authority.model.privilege.PrivilegeType;
import java.util.Collection;
import java.util.Map;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/database/TablePrivileges.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/database/TablePrivileges.java
similarity index 90%
copy from
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/database/TablePrivileges.java
copy to
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/database/TablePrivileges.java
index b186c5a..a0428df 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/database/TablePrivileges.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/database/TablePrivileges.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.privilege.database;
+package org.apache.shardingsphere.authority.model.privilege.database;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.authority.privilege.PrivilegeType;
+import org.apache.shardingsphere.authority.model.privilege.PrivilegeType;
import java.util.Collection;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/database/TablePrivileges.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/subject/AccessSubject.java
similarity index 52%
copy from
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/database/TablePrivileges.java
copy to
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/subject/AccessSubject.java
index b186c5a..f2df100 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/database/TablePrivileges.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/subject/AccessSubject.java
@@ -15,34 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.privilege.database;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.authority.privilege.PrivilegeType;
-
-import java.util.Collection;
+package org.apache.shardingsphere.authority.model.subject;
/**
- * Table privileges.
+ * Access subject.
*/
-@RequiredArgsConstructor
-@EqualsAndHashCode
-@Getter
-public final class TablePrivileges {
-
- private final String tableName;
-
- private final Collection<PrivilegeType> privileges;
-
- /**
- * Has privileges.
- *
- * @param privileges privileges
- * @return has privileges or not
- */
- public boolean hasPrivileges(final Collection<PrivilegeType> privileges) {
- return this.privileges.containsAll(privileges);
- }
+public interface AccessSubject {
}
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/database/TablePrivileges.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/subject/impl/SchemaAccessSubject.java
similarity index 59%
copy from
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/database/TablePrivileges.java
copy to
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/subject/impl/SchemaAccessSubject.java
index b186c5a..dbd6437 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/database/TablePrivileges.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/subject/impl/SchemaAccessSubject.java
@@ -15,34 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.privilege.database;
+package org.apache.shardingsphere.authority.model.subject.impl;
-import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.authority.privilege.PrivilegeType;
-
-import java.util.Collection;
+import org.apache.shardingsphere.authority.model.subject.AccessSubject;
/**
- * Table privileges.
+ * Schema access subject.
*/
@RequiredArgsConstructor
-@EqualsAndHashCode
@Getter
-public final class TablePrivileges {
-
- private final String tableName;
-
- private final Collection<PrivilegeType> privileges;
+public final class SchemaAccessSubject implements AccessSubject {
- /**
- * Has privileges.
- *
- * @param privileges privileges
- * @return has privileges or not
- */
- public boolean hasPrivileges(final Collection<PrivilegeType> privileges) {
- return this.privileges.containsAll(privileges);
- }
+ private final String schema;
}
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/database/TablePrivileges.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/subject/impl/TableAccessSubject.java
similarity index 59%
rename from
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/database/TablePrivileges.java
rename to
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/subject/impl/TableAccessSubject.java
index b186c5a..193acf6 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/privilege/database/TablePrivileges.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/subject/impl/TableAccessSubject.java
@@ -15,34 +15,20 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.privilege.database;
+package org.apache.shardingsphere.authority.model.subject.impl;
-import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.authority.privilege.PrivilegeType;
-
-import java.util.Collection;
+import org.apache.shardingsphere.authority.model.subject.AccessSubject;
/**
- * Table privileges.
+ * Table access subject.
*/
@RequiredArgsConstructor
-@EqualsAndHashCode
@Getter
-public final class TablePrivileges {
-
- private final String tableName;
+public final class TableAccessSubject implements AccessSubject {
- private final Collection<PrivilegeType> privileges;
-
- /**
- * Has privileges.
- *
- * @param privileges privileges
- * @return has privileges or not
- */
- public boolean hasPrivileges(final Collection<PrivilegeType> privileges) {
- return this.privileges.containsAll(privileges);
- }
+ private final String schema;
+
+ private final String table;
}
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/spi/AuthorityProvideAlgorithm.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/spi/AuthorityProvideAlgorithm.java
index 3c8d63c..907a451 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/spi/AuthorityProvideAlgorithm.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/spi/AuthorityProvideAlgorithm.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.authority.spi;
-import org.apache.shardingsphere.authority.privilege.ShardingSpherePrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.ShardingSpherePrivileges;
import
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithm;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/checker/AuthorityChecker.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/checker/AuthorityChecker.java
index 7c7c27e..1c52d64 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/checker/AuthorityChecker.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/checker/AuthorityChecker.java
@@ -18,8 +18,8 @@
package org.apache.shardingsphere.authority.checker;
import org.apache.shardingsphere.authority.constant.AuthorityOrder;
-import org.apache.shardingsphere.authority.privilege.PrivilegeType;
-import org.apache.shardingsphere.authority.privilege.ShardingSpherePrivileges;
+import org.apache.shardingsphere.authority.model.privilege.PrivilegeType;
+import
org.apache.shardingsphere.authority.model.privilege.ShardingSpherePrivileges;
import org.apache.shardingsphere.authority.rule.AuthorityRule;
import org.apache.shardingsphere.infra.executor.check.SQLCheckResult;
import org.apache.shardingsphere.infra.executor.check.SQLChecker;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/NativeAuthorityProviderAlgorithm.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/NativeAuthorityProviderAlgorithm.java
index d204d03..d398a32 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/NativeAuthorityProviderAlgorithm.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/NativeAuthorityProviderAlgorithm.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.authority.provider.natived;
-import org.apache.shardingsphere.authority.privilege.ShardingSpherePrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.ShardingSpherePrivileges;
import
org.apache.shardingsphere.authority.provider.natived.loader.StoragePrivilegeBuilder;
import org.apache.shardingsphere.authority.spi.AuthorityProvideAlgorithm;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/StoragePrivilegeBuilder.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/StoragePrivilegeBuilder.java
index 4ef7a18..9b9a47d 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/StoragePrivilegeBuilder.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/StoragePrivilegeBuilder.java
@@ -20,7 +20,7 @@ package
org.apache.shardingsphere.authority.provider.natived.loader;
import com.google.common.base.Preconditions;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.authority.privilege.ShardingSpherePrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.ShardingSpherePrivileges;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.exception.ShardingSphereException;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/StoragePrivilegeLoader.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/StoragePrivilegeLoader.java
index 6342b6f..be9e7a4 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/StoragePrivilegeLoader.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/StoragePrivilegeLoader.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.authority.provider.natived.loader;
-import org.apache.shardingsphere.authority.privilege.ShardingSpherePrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.ShardingSpherePrivileges;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.spi.typed.TypedSPI;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/StoragePrivilegeMerger.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/StoragePrivilegeMerger.java
index 6d14ead..db8e096 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/StoragePrivilegeMerger.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/StoragePrivilegeMerger.java
@@ -19,9 +19,9 @@ package
org.apache.shardingsphere.authority.provider.natived.loader;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.authority.privilege.ShardingSpherePrivileges;
-import org.apache.shardingsphere.authority.privilege.database.SchemaPrivileges;
-import org.apache.shardingsphere.authority.privilege.database.TablePrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.ShardingSpherePrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.database.SchemaPrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.database.TablePrivileges;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.type.DataNodeContainedRule;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/MySQLPrivilegeLoader.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/MySQLPrivilegeLoader.java
index f6979b6..02eb856 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/MySQLPrivilegeLoader.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/MySQLPrivilegeLoader.java
@@ -17,11 +17,11 @@
package org.apache.shardingsphere.authority.provider.natived.loader.dialect;
-import org.apache.shardingsphere.authority.privilege.database.SchemaPrivileges;
-import org.apache.shardingsphere.authority.privilege.database.TablePrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.database.SchemaPrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.database.TablePrivileges;
import
org.apache.shardingsphere.authority.provider.natived.loader.StoragePrivilegeLoader;
-import org.apache.shardingsphere.authority.privilege.PrivilegeType;
-import org.apache.shardingsphere.authority.privilege.ShardingSpherePrivileges;
+import org.apache.shardingsphere.authority.model.privilege.PrivilegeType;
+import
org.apache.shardingsphere.authority.model.privilege.ShardingSpherePrivileges;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/OraclePrivilegeLoader.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/OraclePrivilegeLoader.java
index 56cdb21..7eea670 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/OraclePrivilegeLoader.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/OraclePrivilegeLoader.java
@@ -18,10 +18,10 @@
package org.apache.shardingsphere.authority.provider.natived.loader.dialect;
import
org.apache.shardingsphere.authority.provider.natived.loader.StoragePrivilegeLoader;
-import org.apache.shardingsphere.authority.privilege.PrivilegeType;
-import org.apache.shardingsphere.authority.privilege.ShardingSpherePrivileges;
-import org.apache.shardingsphere.authority.privilege.database.SchemaPrivileges;
-import org.apache.shardingsphere.authority.privilege.database.TablePrivileges;
+import org.apache.shardingsphere.authority.model.privilege.PrivilegeType;
+import
org.apache.shardingsphere.authority.model.privilege.ShardingSpherePrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.database.SchemaPrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.database.TablePrivileges;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/PostgreSQLPrivilegeLoader.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/PostgreSQLPrivilegeLoader.java
index 8aafc74..8b3e654 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/PostgreSQLPrivilegeLoader.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/PostgreSQLPrivilegeLoader.java
@@ -17,11 +17,11 @@
package org.apache.shardingsphere.authority.provider.natived.loader.dialect;
-import org.apache.shardingsphere.authority.privilege.database.SchemaPrivileges;
-import org.apache.shardingsphere.authority.privilege.database.TablePrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.database.SchemaPrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.database.TablePrivileges;
import
org.apache.shardingsphere.authority.provider.natived.loader.StoragePrivilegeLoader;
-import org.apache.shardingsphere.authority.privilege.PrivilegeType;
-import org.apache.shardingsphere.authority.privilege.ShardingSpherePrivileges;
+import org.apache.shardingsphere.authority.model.privilege.PrivilegeType;
+import
org.apache.shardingsphere.authority.model.privilege.ShardingSpherePrivileges;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java
index 5f9fcdd..5c2031f 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.authority.rule;
import
org.apache.shardingsphere.authority.api.config.AuthorityRuleConfiguration;
-import org.apache.shardingsphere.authority.privilege.ShardingSpherePrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.ShardingSpherePrivileges;
import org.apache.shardingsphere.authority.spi.AuthorityProvideAlgorithm;
import
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmFactory;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/test/java/org/apache/shardingsphere/authority/merge/PrivilegeMergeTest.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/test/java/org/apache/shardingsphere/authority/merge/PrivilegeMergeTest.java
index 56de475..cfb897d 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/test/java/org/apache/shardingsphere/authority/merge/PrivilegeMergeTest.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/test/java/org/apache/shardingsphere/authority/merge/PrivilegeMergeTest.java
@@ -18,10 +18,10 @@
package org.apache.shardingsphere.authority.merge;
import
org.apache.shardingsphere.authority.provider.natived.loader.StoragePrivilegeMerger;
-import org.apache.shardingsphere.authority.privilege.PrivilegeType;
-import org.apache.shardingsphere.authority.privilege.ShardingSpherePrivileges;
-import org.apache.shardingsphere.authority.privilege.database.SchemaPrivileges;
-import org.apache.shardingsphere.authority.privilege.database.TablePrivileges;
+import org.apache.shardingsphere.authority.model.privilege.PrivilegeType;
+import
org.apache.shardingsphere.authority.model.privilege.ShardingSpherePrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.database.SchemaPrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.database.TablePrivileges;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.rule.type.DataNodeContainedRule;
import org.junit.Test;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/MySQLPrivilegeLoaderTest.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/MySQLPrivilegeLoaderTest.java
index ee9c7b6..83ae0bb 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/MySQLPrivilegeLoaderTest.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/MySQLPrivilegeLoaderTest.java
@@ -18,8 +18,8 @@
package org.apache.shardingsphere.authority.provider.natived.loader.dialect;
import
org.apache.shardingsphere.authority.provider.natived.loader.StoragePrivilegeLoader;
-import org.apache.shardingsphere.authority.privilege.PrivilegeType;
-import org.apache.shardingsphere.authority.privilege.ShardingSpherePrivileges;
+import org.apache.shardingsphere.authority.model.privilege.PrivilegeType;
+import
org.apache.shardingsphere.authority.model.privilege.ShardingSpherePrivileges;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.typed.TypedSPIRegistry;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/OraclePrivilegeLoaderTest.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/OraclePrivilegeLoaderTest.java
index 20d7a98..b379a5f 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/OraclePrivilegeLoaderTest.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/OraclePrivilegeLoaderTest.java
@@ -18,9 +18,9 @@
package org.apache.shardingsphere.authority.provider.natived.loader.dialect;
import
org.apache.shardingsphere.authority.provider.natived.loader.StoragePrivilegeLoader;
-import org.apache.shardingsphere.authority.privilege.PrivilegeType;
-import org.apache.shardingsphere.authority.privilege.ShardingSpherePrivileges;
-import org.apache.shardingsphere.authority.privilege.database.SchemaPrivileges;
+import org.apache.shardingsphere.authority.model.privilege.PrivilegeType;
+import
org.apache.shardingsphere.authority.model.privilege.ShardingSpherePrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.database.SchemaPrivileges;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.typed.TypedSPIRegistry;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/PostgreSQLPrivilegeLoaderTest.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/PostgreSQLPrivilegeLoaderTest.java
index 0bdffbd..34a947c 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/PostgreSQLPrivilegeLoaderTest.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/loader/dialect/PostgreSQLPrivilegeLoaderTest.java
@@ -17,9 +17,9 @@
package org.apache.shardingsphere.authority.provider.natived.loader.dialect;
-import org.apache.shardingsphere.authority.privilege.PrivilegeType;
-import org.apache.shardingsphere.authority.privilege.ShardingSpherePrivileges;
-import org.apache.shardingsphere.authority.privilege.database.SchemaPrivileges;
+import org.apache.shardingsphere.authority.model.privilege.PrivilegeType;
+import
org.apache.shardingsphere.authority.model.privilege.ShardingSpherePrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.database.SchemaPrivileges;
import
org.apache.shardingsphere.authority.provider.natived.loader.StoragePrivilegeLoader;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/auth/PostgreSQLAuthenticationEngineTest.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/auth/PostgreSQLAuthenticationEngineTest.java
index 4a6bd35..2cb34bb 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/auth/PostgreSQLAuthenticationEngineTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/auth/PostgreSQLAuthenticationEngineTest.java
@@ -27,7 +27,7 @@ import
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.bin
import
org.apache.shardingsphere.db.protocol.postgresql.packet.handshake.PostgreSQLAuthenticationMD5PasswordPacket;
import
org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
import
org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
-import org.apache.shardingsphere.authority.privilege.ShardingSpherePrivileges;
+import
org.apache.shardingsphere.authority.model.privilege.ShardingSpherePrivileges;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.frontend.auth.AuthenticationResult;