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 32d52fc Use NativePrivileges to decouple privilege impl (#10042)
32d52fc is described below
commit 32d52fcfd692e1ea5ceb5c242097515d38aa367d
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Apr 12 14:57:44 2021 +0800
Use NativePrivileges to decouple privilege impl (#10042)
* Rename NativePrivileges
* Move NativePrivileges to shardingsphere-authority-common module
* Move subject impl to shardingsphere-authority-common module
---
.../model/{subject => }/AccessSubject.java | 2 +-
.../model/{privilege => }/PrivilegeType.java | 2 +-
...ivileges.java => ShardingSpherePrivileges.java} | 40 ++++++++++++--------
.../authority/spi/AuthorityProvideAlgorithm.java | 2 +-
.../authority/checker/AuthorityChecker.java | 4 +-
.../natived/NativeAuthorityProviderAlgorithm.java | 2 +-
.../natived/loader/StoragePrivilegeBuilder.java | 40 ++++++++++----------
.../natived/loader/StoragePrivilegeLoader.java | 4 +-
.../natived/loader/StoragePrivilegeMerger.java | 24 ++++++------
.../loader/dialect/MySQLPrivilegeLoader.java | 30 +++++++--------
.../loader/dialect/OraclePrivilegeLoader.java | 26 ++++++-------
.../loader/dialect/PostgreSQLPrivilegeLoader.java | 26 ++++++-------
.../natived/model/privilege/NativePrivileges.java} | 44 +++++++---------------
.../privilege/admin/AdministrativePrivileges.java | 4 +-
.../privilege/database/DatabasePrivileges.java | 4 +-
.../model/privilege/database/SchemaPrivileges.java | 4 +-
.../model/privilege/database/TablePrivileges.java | 4 +-
.../model/subject}/SchemaAccessSubject.java | 4 +-
.../natived/model/subject}/TableAccessSubject.java | 4 +-
.../authority/rule/AuthorityRule.java | 2 +-
.../authority/merge/PrivilegeMergeTest.java | 18 ++++-----
.../loader/dialect/MySQLPrivilegeLoaderTest.java | 6 +--
.../loader/dialect/OraclePrivilegeLoaderTest.java | 8 ++--
.../dialect/PostgreSQLPrivilegeLoaderTest.java | 8 ++--
.../auth/PostgreSQLAuthenticationEngineTest.java | 3 --
25 files changed, 152 insertions(+), 163 deletions(-)
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/subject/AccessSubject.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/AccessSubject.java
similarity index 93%
rename from
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/subject/AccessSubject.java
rename to
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/AccessSubject.java
index f2df100..bb61d49 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/subject/AccessSubject.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/AccessSubject.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.model.subject;
+package org.apache.shardingsphere.authority.model;
/**
* Access subject.
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/PrivilegeType.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/PrivilegeType.java
similarity index 96%
rename from
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/PrivilegeType.java
rename to
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/PrivilegeType.java
index 7e7a11d..b68c847 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/PrivilegeType.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/PrivilegeType.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.model.privilege;
+package org.apache.shardingsphere.authority.model;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/database/TablePrivileges.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/ShardingSpherePrivileges.java
similarity index 59%
copy from
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/database/TablePrivileges.java
copy to
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/ShardingSpherePrivileges.java
index a0428df..97f89b5 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/database/TablePrivileges.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/ShardingSpherePrivileges.java
@@ -15,34 +15,42 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.model.privilege.database;
-
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.authority.model.privilege.PrivilegeType;
+package org.apache.shardingsphere.authority.model;
import java.util.Collection;
/**
- * Table privileges.
+ * ShardingSphere Privileges.
*/
-@RequiredArgsConstructor
-@EqualsAndHashCode
-@Getter
-public final class TablePrivileges {
+public interface ShardingSpherePrivileges {
+
+ /**
+ * Set super privilege.
+ */
+ void setSuperPrivilege();
- private final String tableName;
+ /**
+ * Has privileges.
+ *
+ * @param schema schema
+ * @return has or not
+ */
+ boolean hasPrivileges(String schema);
- private final Collection<PrivilegeType> privileges;
+ /**
+ * Has privileges.
+ *
+ * @param privileges privileges
+ * @return has privileges or not
+ */
+ boolean hasPrivileges(Collection<PrivilegeType> privileges);
/**
* Has privileges.
*
+ * @param accessSubject access subject
* @param privileges privileges
* @return has privileges or not
*/
- public boolean hasPrivileges(final Collection<PrivilegeType> privileges) {
- return this.privileges.containsAll(privileges);
- }
+ boolean hasPrivileges(AccessSubject accessSubject,
Collection<PrivilegeType> privileges);
}
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 907a451..7fff91e 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.model.privilege.ShardingSpherePrivileges;
+import org.apache.shardingsphere.authority.model.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 1c52d64..a70366f 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.model.privilege.PrivilegeType;
-import
org.apache.shardingsphere.authority.model.privilege.ShardingSpherePrivileges;
+import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
+import org.apache.shardingsphere.authority.model.PrivilegeType;
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 d398a32..b9a6707 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.model.privilege.ShardingSpherePrivileges;
+import org.apache.shardingsphere.authority.model.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 9b9a47d..ca96bfc 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.model.privilege.ShardingSpherePrivileges;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.NativePrivileges;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.exception.ShardingSphereException;
@@ -69,33 +69,33 @@ public final class StoragePrivilegeBuilder {
* @param users users
* @return privileges
*/
- public static Map<ShardingSphereUser, ShardingSpherePrivileges>
build(final Collection<ShardingSphereMetaData> metaDataList, final
Collection<ShardingSphereUser> users) {
+ public static Map<ShardingSphereUser, NativePrivileges> build(final
Collection<ShardingSphereMetaData> metaDataList, final
Collection<ShardingSphereUser> users) {
return metaDataList.isEmpty() ? buildDefaultPrivileges(users) :
buildWithMetaData(metaDataList, users);
}
- private static Map<ShardingSphereUser, ShardingSpherePrivileges>
buildDefaultPrivileges(final Collection<ShardingSphereUser> users) {
- Map<ShardingSphereUser, ShardingSpherePrivileges> result = new
LinkedHashMap<>(users.size(), 1);
- ShardingSpherePrivileges privileges = new ShardingSpherePrivileges();
+ private static Map<ShardingSphereUser, NativePrivileges>
buildDefaultPrivileges(final Collection<ShardingSphereUser> users) {
+ Map<ShardingSphereUser, NativePrivileges> result = new
LinkedHashMap<>(users.size(), 1);
+ NativePrivileges privileges = new NativePrivileges();
privileges.setSuperPrivilege();
users.forEach(each -> result.put(each, privileges));
return result;
}
- private static Map<ShardingSphereUser, ShardingSpherePrivileges>
buildWithMetaData(final Collection<ShardingSphereMetaData> metaDataList, final
Collection<ShardingSphereUser> users) {
- Map<ShardingSphereUser, ShardingSpherePrivileges> result = new
LinkedHashMap<>();
+ private static Map<ShardingSphereUser, NativePrivileges>
buildWithMetaData(final Collection<ShardingSphereMetaData> metaDataList, final
Collection<ShardingSphereUser> users) {
+ Map<ShardingSphereUser, NativePrivileges> result = new
LinkedHashMap<>();
for (ShardingSphereMetaData each : metaDataList) {
result.putAll(buildWithMetaData(each, users));
}
return result;
}
- private static Map<ShardingSphereUser, ShardingSpherePrivileges>
buildWithMetaData(final ShardingSphereMetaData metaData, final
Collection<ShardingSphereUser> users) {
+ private static Map<ShardingSphereUser, NativePrivileges>
buildWithMetaData(final ShardingSphereMetaData metaData, final
Collection<ShardingSphereUser> users) {
DatabaseType databaseType =
getDatabaseType(metaData.getResource().getAllInstanceDataSources());
Optional<StoragePrivilegeLoader> loader =
TypedSPIRegistry.findRegisteredService(StoragePrivilegeLoader.class,
databaseType.getName(), new Properties());
if (!loader.isPresent()) {
return buildDefaultPrivileges(users);
}
- Map<ShardingSphereUser, Collection<ShardingSpherePrivileges>> result =
load(metaData.getResource().getAllInstanceDataSources(), users, loader.get());
+ Map<ShardingSphereUser, Collection<NativePrivileges>> result =
load(metaData.getResource().getAllInstanceDataSources(), users, loader.get());
checkPrivileges(result);
return StoragePrivilegeMerger.merge(result, metaData.getName(),
metaData.getRuleMetaData().getRules());
}
@@ -118,11 +118,11 @@ public final class StoragePrivilegeBuilder {
}
}
- private static Map<ShardingSphereUser,
Collection<ShardingSpherePrivileges>> load(final Collection<DataSource>
dataSources,
-
final Collection<ShardingSphereUser> users, final StoragePrivilegeLoader
loader) {
- Map<ShardingSphereUser, Collection<ShardingSpherePrivileges>> result =
new LinkedHashMap<>(users.size(), 1);
+ private static Map<ShardingSphereUser, Collection<NativePrivileges>>
load(final Collection<DataSource> dataSources,
+
final Collection<ShardingSphereUser> users, final StoragePrivilegeLoader
loader) {
+ Map<ShardingSphereUser, Collection<NativePrivileges>> result = new
LinkedHashMap<>(users.size(), 1);
ExecutorService executorService =
Executors.newFixedThreadPool(Math.min(CPU_CORES * 2, dataSources.isEmpty() ? 1
: dataSources.size()));
- Collection<Future<Map<ShardingSphereUser, ShardingSpherePrivileges>>>
futures = new HashSet<>(dataSources.size(), 1);
+ Collection<Future<Map<ShardingSphereUser, NativePrivileges>>> futures
= new HashSet<>(dataSources.size(), 1);
for (DataSource each : dataSources) {
futures.add(executorService.submit(() -> loader.load(users,
each)));
}
@@ -137,9 +137,9 @@ public final class StoragePrivilegeBuilder {
return result;
}
- private static void fillPrivileges(final Map<ShardingSphereUser,
Collection<ShardingSpherePrivileges>> userPrivilegeMap,
- final Future<Map<ShardingSphereUser,
ShardingSpherePrivileges>> future) throws InterruptedException,
ExecutionException, TimeoutException {
- for (Entry<ShardingSphereUser, ShardingSpherePrivileges> entry :
future.get(FUTURE_GET_TIME_OUT_MILLISECONDS, TimeUnit.MILLISECONDS).entrySet())
{
+ private static void fillPrivileges(final Map<ShardingSphereUser,
Collection<NativePrivileges>> userPrivilegeMap,
+ final Future<Map<ShardingSphereUser,
NativePrivileges>> future) throws InterruptedException, ExecutionException,
TimeoutException {
+ for (Entry<ShardingSphereUser, NativePrivileges> entry :
future.get(FUTURE_GET_TIME_OUT_MILLISECONDS, TimeUnit.MILLISECONDS).entrySet())
{
if (!userPrivilegeMap.containsKey(entry.getKey())) {
userPrivilegeMap.put(entry.getKey(), new LinkedHashSet<>());
}
@@ -147,13 +147,13 @@ public final class StoragePrivilegeBuilder {
}
}
- private static void checkPrivileges(final Map<ShardingSphereUser,
Collection<ShardingSpherePrivileges>> userPrivilegeMap) {
+ private static void checkPrivileges(final Map<ShardingSphereUser,
Collection<NativePrivileges>> userPrivilegeMap) {
userPrivilegeMap.forEach(StoragePrivilegeBuilder::checkPrivileges);
}
- private static void checkPrivileges(final ShardingSphereUser user, final
Collection<ShardingSpherePrivileges> privileges) {
- Iterator<ShardingSpherePrivileges> iterator = privileges.iterator();
- ShardingSpherePrivileges current = iterator.next();
+ private static void checkPrivileges(final ShardingSphereUser user, final
Collection<NativePrivileges> privileges) {
+ Iterator<NativePrivileges> iterator = privileges.iterator();
+ NativePrivileges current = iterator.next();
while (iterator.hasNext()) {
if (!current.equals(iterator.next())) {
throw new ShardingSphereException("Different physical
instances have different privileges for user %s",
user.getGrantee().toString().replaceAll("%", "%%"));
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 be9e7a4..005a006 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.model.privilege.ShardingSpherePrivileges;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.NativePrivileges;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.spi.typed.TypedSPI;
@@ -39,5 +39,5 @@ public interface StoragePrivilegeLoader extends TypedSPI {
* @return map of user and privilege
* @throws SQLException SQL exception
*/
- Map<ShardingSphereUser, ShardingSpherePrivileges>
load(Collection<ShardingSphereUser> users, DataSource dataSource) throws
SQLException;
+ Map<ShardingSphereUser, NativePrivileges>
load(Collection<ShardingSphereUser> users, DataSource dataSource) throws
SQLException;
}
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 db8e096..c72f7fa 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.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.authority.provider.natived.model.privilege.NativePrivileges;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.database.SchemaPrivileges;
+import
org.apache.shardingsphere.authority.provider.natived.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;
@@ -46,28 +46,28 @@ public final class StoragePrivilegeMerger {
* @param rules ShardingSphere rules
* @return privileges
*/
- public static Map<ShardingSphereUser, ShardingSpherePrivileges>
merge(final Map<ShardingSphereUser, Collection<ShardingSpherePrivileges>>
privileges,
- final
String schemaName, final Collection<ShardingSphereRule> rules) {
- Map<ShardingSphereUser, ShardingSpherePrivileges> result = new
HashMap<>(privileges.size(), 1);
- for (Entry<ShardingSphereUser, Collection<ShardingSpherePrivileges>>
entry : privileges.entrySet()) {
+ public static Map<ShardingSphereUser, NativePrivileges> merge(final
Map<ShardingSphereUser, Collection<NativePrivileges>> privileges,
+ final String
schemaName, final Collection<ShardingSphereRule> rules) {
+ Map<ShardingSphereUser, NativePrivileges> result = new
HashMap<>(privileges.size(), 1);
+ for (Entry<ShardingSphereUser, Collection<NativePrivileges>> entry :
privileges.entrySet()) {
result.put(entry.getKey(), merge(entry.getValue(), schemaName,
rules));
}
return result;
}
- private static ShardingSpherePrivileges merge(final
Collection<ShardingSpherePrivileges> privileges, final String schemaName, final
Collection<ShardingSphereRule> rules) {
- return privileges.isEmpty() ? new ShardingSpherePrivileges() :
getMergedPrivileges(privileges.iterator().next(), schemaName, rules);
+ private static NativePrivileges merge(final Collection<NativePrivileges>
privileges, final String schemaName, final Collection<ShardingSphereRule>
rules) {
+ return privileges.isEmpty() ? new NativePrivileges() :
getMergedPrivileges(privileges.iterator().next(), schemaName, rules);
}
- private static ShardingSpherePrivileges getMergedPrivileges(final
ShardingSpherePrivileges privilege, final String schemaName, final
Collection<ShardingSphereRule> rules) {
- ShardingSpherePrivileges result = new ShardingSpherePrivileges();
+ private static NativePrivileges getMergedPrivileges(final NativePrivileges
privilege, final String schemaName, final Collection<ShardingSphereRule> rules)
{
+ NativePrivileges result = new NativePrivileges();
result.getAdministrativePrivileges().getPrivileges().addAll(privilege.getAdministrativePrivileges().getPrivileges());
result.getDatabasePrivileges().getGlobalPrivileges().addAll(privilege.getDatabasePrivileges().getGlobalPrivileges());
result.getDatabasePrivileges().getSpecificPrivileges().putAll(getMergedSchemaPrivileges(privilege,
schemaName, rules));
return result;
}
- private static Map<String, SchemaPrivileges>
getMergedSchemaPrivileges(final ShardingSpherePrivileges privilege, final
String schemaName, final Collection<ShardingSphereRule> rules) {
+ private static Map<String, SchemaPrivileges>
getMergedSchemaPrivileges(final NativePrivileges privilege, final String
schemaName, final Collection<ShardingSphereRule> rules) {
Map<String, SchemaPrivileges> result = new
HashMap<>(privilege.getDatabasePrivileges().getSpecificPrivileges().size(), 1);
for (Entry<String, SchemaPrivileges> entry :
privilege.getDatabasePrivileges().getSpecificPrivileges().entrySet()) {
if (!result.containsKey(schemaName)) {
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 02eb856..6c8eb5d 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.model.privilege.database.SchemaPrivileges;
-import
org.apache.shardingsphere.authority.model.privilege.database.TablePrivileges;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.database.SchemaPrivileges;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.database.TablePrivileges;
import
org.apache.shardingsphere.authority.provider.natived.loader.StoragePrivilegeLoader;
-import org.apache.shardingsphere.authority.model.privilege.PrivilegeType;
-import
org.apache.shardingsphere.authority.model.privilege.ShardingSpherePrivileges;
+import org.apache.shardingsphere.authority.model.PrivilegeType;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.NativePrivileges;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
@@ -50,16 +50,16 @@ public final class MySQLPrivilegeLoader implements
StoragePrivilegeLoader {
private static final String TABLE_PRIVILEGE_SQL = "SELECT Db, Table_name,
Table_priv FROM mysql.tables_priv WHERE (user, host) in (%s)";
@Override
- public Map<ShardingSphereUser, ShardingSpherePrivileges> load(final
Collection<ShardingSphereUser> users, final DataSource dataSource) throws
SQLException {
- Map<ShardingSphereUser, ShardingSpherePrivileges> result = new
LinkedHashMap<>();
- users.forEach(user -> result.put(user, new
ShardingSpherePrivileges()));
+ public Map<ShardingSphereUser, NativePrivileges> load(final
Collection<ShardingSphereUser> users, final DataSource dataSource) throws
SQLException {
+ Map<ShardingSphereUser, NativePrivileges> result = new
LinkedHashMap<>();
+ users.forEach(user -> result.put(user, new NativePrivileges()));
fillGlobalPrivileges(result, dataSource, users);
fillSchemaPrivileges(result, dataSource, users);
fillTablePrivileges(result, dataSource, users);
return result;
}
- private void fillGlobalPrivileges(final Map<ShardingSphereUser,
ShardingSpherePrivileges> userPrivilegeMap,
+ private void fillGlobalPrivileges(final Map<ShardingSphereUser,
NativePrivileges> userPrivilegeMap,
final DataSource dataSource, final
Collection<ShardingSphereUser> users) throws SQLException {
try (Connection connection = dataSource.getConnection()) {
Statement statement = connection.createStatement();
@@ -71,7 +71,7 @@ public final class MySQLPrivilegeLoader implements
StoragePrivilegeLoader {
}
}
- private void fillGlobalPrivileges(final Map<ShardingSphereUser,
ShardingSpherePrivileges> userPrivilegeMap, final ResultSet resultSet) throws
SQLException {
+ private void fillGlobalPrivileges(final Map<ShardingSphereUser,
NativePrivileges> userPrivilegeMap, final ResultSet resultSet) throws
SQLException {
Optional<ShardingSphereUser> user =
findShardingSphereUser(userPrivilegeMap, resultSet);
if (user.isPresent()) {
userPrivilegeMap.get(user.get()).getAdministrativePrivileges().getPrivileges().addAll(loadAdministrativePrivileges(resultSet));
@@ -79,7 +79,7 @@ public final class MySQLPrivilegeLoader implements
StoragePrivilegeLoader {
}
}
- private void fillSchemaPrivileges(final Map<ShardingSphereUser,
ShardingSpherePrivileges> userPrivilegeMap,
+ private void fillSchemaPrivileges(final Map<ShardingSphereUser,
NativePrivileges> userPrivilegeMap,
final DataSource dataSource, final
Collection<ShardingSphereUser> users) throws SQLException {
try (Connection connection = dataSource.getConnection()) {
Statement statement = connection.createStatement();
@@ -91,7 +91,7 @@ public final class MySQLPrivilegeLoader implements
StoragePrivilegeLoader {
}
}
- private void fillSchemaPrivileges(final Map<ShardingSphereUser,
ShardingSpherePrivileges> userPrivilegeMap, final ResultSet resultSet) throws
SQLException {
+ private void fillSchemaPrivileges(final Map<ShardingSphereUser,
NativePrivileges> userPrivilegeMap, final ResultSet resultSet) throws
SQLException {
Optional<ShardingSphereUser> user =
findShardingSphereUser(userPrivilegeMap, resultSet);
if (user.isPresent()) {
String db = resultSet.getString("Db");
@@ -101,7 +101,7 @@ public final class MySQLPrivilegeLoader implements
StoragePrivilegeLoader {
}
}
- private void fillTablePrivileges(final Map<ShardingSphereUser,
ShardingSpherePrivileges> userPrivilegeMap,
+ private void fillTablePrivileges(final Map<ShardingSphereUser,
NativePrivileges> userPrivilegeMap,
final DataSource dataSource, final
Collection<ShardingSphereUser> users) throws SQLException {
try (Connection connection = dataSource.getConnection()) {
Statement statement = connection.createStatement();
@@ -113,13 +113,13 @@ public final class MySQLPrivilegeLoader implements
StoragePrivilegeLoader {
}
}
- private void fillTablePrivileges(final Map<ShardingSphereUser,
ShardingSpherePrivileges> userPrivilegeMap, final ResultSet resultSet) throws
SQLException {
+ private void fillTablePrivileges(final Map<ShardingSphereUser,
NativePrivileges> userPrivilegeMap, final ResultSet resultSet) throws
SQLException {
Optional<ShardingSphereUser> user =
findShardingSphereUser(userPrivilegeMap, resultSet);
if (user.isPresent()) {
String db = resultSet.getString("Db");
String tableName = resultSet.getString("Table_name");
TablePrivileges tablePrivileges = new TablePrivileges(tableName,
getPrivileges((String[]) resultSet.getArray("Table_priv").getArray()));
- ShardingSpherePrivileges privileges =
userPrivilegeMap.get(user.get());
+ NativePrivileges privileges = userPrivilegeMap.get(user.get());
if
(!privileges.getDatabasePrivileges().getSpecificPrivileges().containsKey(db)) {
privileges.getDatabasePrivileges().getSpecificPrivileges().put(db, new
SchemaPrivileges(db));
}
@@ -144,7 +144,7 @@ public final class MySQLPrivilegeLoader implements
StoragePrivilegeLoader {
return String.format(TABLE_PRIVILEGE_SQL, userHostTuples);
}
- private Optional<ShardingSphereUser> findShardingSphereUser(final
Map<ShardingSphereUser, ShardingSpherePrivileges> privileges, final ResultSet
resultSet) throws SQLException {
+ private Optional<ShardingSphereUser> findShardingSphereUser(final
Map<ShardingSphereUser, NativePrivileges> privileges, final ResultSet
resultSet) throws SQLException {
Grantee grantee = new Grantee(resultSet.getString("user"),
resultSet.getString("host"));
return privileges.keySet().stream().filter(each ->
each.getGrantee().equals(grantee)).findFirst();
}
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 7eea670..2dda305 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.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.authority.model.PrivilegeType;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.NativePrivileges;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.database.SchemaPrivileges;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.database.TablePrivileges;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
@@ -50,15 +50,15 @@ public final class OraclePrivilegeLoader implements
StoragePrivilegeLoader {
private static final String TABLE_PRIVILEGE_SQL = "SELECT GRANTEE,
TABLE_SCHEMA, TABLE_NAME, PRIVILEGE, GRANTABLE, INHERITED FROM ALL_TAB_PRIVS
WHERE GRANTEE IN (%s)";
@Override
- public Map<ShardingSphereUser, ShardingSpherePrivileges> load(final
Collection<ShardingSphereUser> users, final DataSource dataSource) throws
SQLException {
- Map<ShardingSphereUser, ShardingSpherePrivileges> result = new
LinkedHashMap<>();
- users.forEach(user -> result.put(user, new
ShardingSpherePrivileges()));
+ public Map<ShardingSphereUser, NativePrivileges> load(final
Collection<ShardingSphereUser> users, final DataSource dataSource) throws
SQLException {
+ Map<ShardingSphereUser, NativePrivileges> result = new
LinkedHashMap<>();
+ users.forEach(user -> result.put(user, new NativePrivileges()));
fillSysPrivileges(result, dataSource, users);
fillTablePrivileges(result, dataSource, users);
return result;
}
- private void fillTablePrivileges(final Map<ShardingSphereUser,
ShardingSpherePrivileges> userPrivilegeMap, final DataSource dataSource,
+ private void fillTablePrivileges(final Map<ShardingSphereUser,
NativePrivileges> userPrivilegeMap, final DataSource dataSource,
final Collection<ShardingSphereUser>
users) throws SQLException {
Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>>
privilegeCache = new HashMap<>();
try (Connection connection = dataSource.getConnection()) {
@@ -73,12 +73,12 @@ public final class OraclePrivilegeLoader implements
StoragePrivilegeLoader {
}
private void fillTablePrivileges(final Map<ShardingSphereUser, Map<String,
Map<String, List<PrivilegeType>>>> privilegeCache,
- final Map<ShardingSphereUser,
ShardingSpherePrivileges> userPrivilegeMap) {
+ final Map<ShardingSphereUser,
NativePrivileges> userPrivilegeMap) {
for (Entry<ShardingSphereUser, Map<String, Map<String,
List<PrivilegeType>>>> entry : privilegeCache.entrySet()) {
for (String db : entry.getValue().keySet()) {
for (String tableName : entry.getValue().get(db).keySet()) {
TablePrivileges tablePrivileges = new
TablePrivileges(tableName, entry.getValue().get(db).get(tableName));
- ShardingSpherePrivileges privileges =
userPrivilegeMap.get(entry.getKey());
+ NativePrivileges privileges =
userPrivilegeMap.get(entry.getKey());
if
(!privileges.getDatabasePrivileges().getSpecificPrivileges().containsKey(db)) {
privileges.getDatabasePrivileges().getSpecificPrivileges().put(db, new
SchemaPrivileges(db));
}
@@ -103,7 +103,7 @@ public final class OraclePrivilegeLoader implements
StoragePrivilegeLoader {
}
}
- private void fillSysPrivileges(final Map<ShardingSphereUser,
ShardingSpherePrivileges> userPrivilegeMap, final DataSource dataSource,
+ private void fillSysPrivileges(final Map<ShardingSphereUser,
NativePrivileges> userPrivilegeMap, final DataSource dataSource,
final Collection<ShardingSphereUser> users)
throws SQLException {
Map<ShardingSphereUser, List<PrivilegeType>> privilegeCache = new
HashMap<>();
try (Connection connection = dataSource.getConnection()) {
@@ -117,7 +117,7 @@ public final class OraclePrivilegeLoader implements
StoragePrivilegeLoader {
fillSysPrivileges(privilegeCache, userPrivilegeMap);
}
- private void fillSysPrivileges(final Map<ShardingSphereUser,
List<PrivilegeType>> privilegeCache, final Map<ShardingSphereUser,
ShardingSpherePrivileges> userPrivilegeMap) throws SQLException {
+ private void fillSysPrivileges(final Map<ShardingSphereUser,
List<PrivilegeType>> privilegeCache, final Map<ShardingSphereUser,
NativePrivileges> userPrivilegeMap) throws SQLException {
for (Entry<ShardingSphereUser, List<PrivilegeType>> entry :
privilegeCache.entrySet()) {
userPrivilegeMap.get(entry.getKey()).getAdministrativePrivileges().getPrivileges().addAll(entry.getValue());
}
@@ -131,7 +131,7 @@ public final class OraclePrivilegeLoader implements
StoragePrivilegeLoader {
.add(getPrivilegeType(privilegeType));
}
- private Optional<ShardingSphereUser> findShardingSphereUser(final
Map<ShardingSphereUser, ShardingSpherePrivileges> userPrivilegeMap, final
ResultSet resultSet) throws SQLException {
+ private Optional<ShardingSphereUser> findShardingSphereUser(final
Map<ShardingSphereUser, NativePrivileges> userPrivilegeMap, final ResultSet
resultSet) throws SQLException {
Grantee grantee = new Grantee(resultSet.getString("rolname"), "");
return userPrivilegeMap.keySet().stream().filter(each ->
each.getGrantee().equals(grantee)).findFirst();
}
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 8b3e654..a27a2ac 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.model.privilege.database.SchemaPrivileges;
-import
org.apache.shardingsphere.authority.model.privilege.database.TablePrivileges;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.database.SchemaPrivileges;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.database.TablePrivileges;
import
org.apache.shardingsphere.authority.provider.natived.loader.StoragePrivilegeLoader;
-import org.apache.shardingsphere.authority.model.privilege.PrivilegeType;
-import
org.apache.shardingsphere.authority.model.privilege.ShardingSpherePrivileges;
+import org.apache.shardingsphere.authority.model.PrivilegeType;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.NativePrivileges;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
@@ -52,15 +52,15 @@ public final class PostgreSQLPrivilegeLoader implements
StoragePrivilegeLoader {
"SELECT grantor, grantee, table_catalog, table_name,
privilege_type, is_grantable from information_schema.table_privileges WHERE
grantee IN (%s)";
@Override
- public Map<ShardingSphereUser, ShardingSpherePrivileges> load(final
Collection<ShardingSphereUser> users, final DataSource dataSource) throws
SQLException {
- Map<ShardingSphereUser, ShardingSpherePrivileges> result = new
LinkedHashMap<>();
- users.forEach(user -> result.put(user, new
ShardingSpherePrivileges()));
+ public Map<ShardingSphereUser, NativePrivileges> load(final
Collection<ShardingSphereUser> users, final DataSource dataSource) throws
SQLException {
+ Map<ShardingSphereUser, NativePrivileges> result = new
LinkedHashMap<>();
+ users.forEach(user -> result.put(user, new NativePrivileges()));
fillTablePrivileges(result, dataSource, users);
fillRolePrivileges(result, dataSource, users);
return result;
}
- private void fillTablePrivileges(final Map<ShardingSphereUser,
ShardingSpherePrivileges> userPrivilegeMap,
+ private void fillTablePrivileges(final Map<ShardingSphereUser,
NativePrivileges> userPrivilegeMap,
final DataSource dataSource, final
Collection<ShardingSphereUser> users) throws SQLException {
Map<ShardingSphereUser, Map<String, Map<String, List<PrivilegeType>>>>
privilegeCache = new HashMap<>();
try (Connection connection = dataSource.getConnection()) {
@@ -75,12 +75,12 @@ public final class PostgreSQLPrivilegeLoader implements
StoragePrivilegeLoader {
}
private void fillTablePrivileges(final Map<ShardingSphereUser, Map<String,
Map<String, List<PrivilegeType>>>> privilegeCache,
- final Map<ShardingSphereUser,
ShardingSpherePrivileges> userPrivilegeMap) {
+ final Map<ShardingSphereUser,
NativePrivileges> userPrivilegeMap) {
for (Entry<ShardingSphereUser, Map<String, Map<String,
List<PrivilegeType>>>> entry : privilegeCache.entrySet()) {
for (String db : entry.getValue().keySet()) {
for (String tableName : entry.getValue().get(db).keySet()) {
TablePrivileges tablePrivileges = new
TablePrivileges(tableName, entry.getValue().get(db).get(tableName));
- ShardingSpherePrivileges privileges =
userPrivilegeMap.get(entry.getKey());
+ NativePrivileges privileges =
userPrivilegeMap.get(entry.getKey());
if
(!privileges.getDatabasePrivileges().getSpecificPrivileges().containsKey(db)) {
privileges.getDatabasePrivileges().getSpecificPrivileges().put(db, new
SchemaPrivileges(db));
}
@@ -105,7 +105,7 @@ public final class PostgreSQLPrivilegeLoader implements
StoragePrivilegeLoader {
}
}
- private void fillRolePrivileges(final Map<ShardingSphereUser,
ShardingSpherePrivileges> userPrivilegeMap,
+ private void fillRolePrivileges(final Map<ShardingSphereUser,
NativePrivileges> userPrivilegeMap,
final DataSource dataSource, final
Collection<ShardingSphereUser> users) throws SQLException {
try (Connection connection = dataSource.getConnection()) {
Statement statement = connection.createStatement();
@@ -117,14 +117,14 @@ public final class PostgreSQLPrivilegeLoader implements
StoragePrivilegeLoader {
}
}
- private void fillRolePrivileges(final Map<ShardingSphereUser,
ShardingSpherePrivileges> userPrivilegeMap, final ResultSet resultSet) throws
SQLException {
+ private void fillRolePrivileges(final Map<ShardingSphereUser,
NativePrivileges> userPrivilegeMap, final ResultSet resultSet) throws
SQLException {
Optional<ShardingSphereUser> user =
findShardingSphereUser(userPrivilegeMap, resultSet);
if (user.isPresent()) {
userPrivilegeMap.get(user.get()).getAdministrativePrivileges().getPrivileges().addAll(loadRolePrivileges(resultSet));
}
}
- private Optional<ShardingSphereUser> findShardingSphereUser(final
Map<ShardingSphereUser, ShardingSpherePrivileges> userPrivilegeMap, final
ResultSet resultSet) throws SQLException {
+ private Optional<ShardingSphereUser> findShardingSphereUser(final
Map<ShardingSphereUser, NativePrivileges> userPrivilegeMap, final ResultSet
resultSet) throws SQLException {
Grantee grantee = new Grantee(resultSet.getString("rolname"), "");
return userPrivilegeMap.keySet().stream().filter(each ->
each.getGrantee().equals(grantee)).findFirst();
}
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/ShardingSpherePrivileges.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/privilege/NativePrivileges.java
similarity index 73%
rename from
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/ShardingSpherePrivileges.java
rename to
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/privilege/NativePrivileges.java
index 8cdb300..82f7243 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/ShardingSpherePrivileges.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/privilege/NativePrivileges.java
@@ -15,64 +15,48 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.model.privilege;
+package org.apache.shardingsphere.authority.provider.natived.model.privilege;
import lombok.EqualsAndHashCode;
import lombok.Getter;
-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 org.apache.shardingsphere.authority.model.PrivilegeType;
+import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.admin.AdministrativePrivileges;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.database.DatabasePrivileges;
+import org.apache.shardingsphere.authority.model.AccessSubject;
+import
org.apache.shardingsphere.authority.provider.natived.model.subject.SchemaAccessSubject;
+import
org.apache.shardingsphere.authority.provider.natived.model.subject.TableAccessSubject;
import java.util.Collection;
/**
- * ShardingSphere Privileges.
+ * Native Privileges.
*/
@Getter
@EqualsAndHashCode
-public final class ShardingSpherePrivileges {
+public final class NativePrivileges implements ShardingSpherePrivileges {
private final AdministrativePrivileges administrativePrivileges = new
AdministrativePrivileges();
private final DatabasePrivileges databasePrivileges = new
DatabasePrivileges();
- /**
- * Set super privilege.
- */
+ @Override
public void setSuperPrivilege() {
administrativePrivileges.getPrivileges().add(PrivilegeType.SUPER);
}
- /**
- * Has privilege for login and use db.
- *
- * @param schema schema
- * @return has or not
- */
+ @Override
public boolean hasPrivileges(final String schema) {
return
administrativePrivileges.getPrivileges().contains(PrivilegeType.SUPER)
|| !databasePrivileges.getGlobalPrivileges().isEmpty() ||
databasePrivileges.getSpecificPrivileges().containsKey(schema);
}
- /**
- * Has privileges.
- *
- * @param privileges privileges
- * @return has privileges or not
- */
+ @Override
public boolean hasPrivileges(final Collection<PrivilegeType> privileges) {
return administrativePrivileges.hasPrivileges(privileges);
}
- /**
- * Has privileges.
- *
- * @param accessSubject access subject
- * @param privileges privileges
- * @return has privileges or not
- */
+ @Override
public boolean hasPrivileges(final AccessSubject accessSubject, final
Collection<PrivilegeType> privileges) {
if (accessSubject instanceof SchemaAccessSubject) {
return hasPrivileges(((SchemaAccessSubject)
accessSubject).getSchema(), privileges);
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/admin/AdministrativePrivileges.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/privilege/admin/AdministrativePrivileges.java
similarity index 90%
rename from
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/admin/AdministrativePrivileges.java
rename to
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/privilege/admin/AdministrativePrivileges.java
index 2efbb0e..daa990c 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/admin/AdministrativePrivileges.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/privilege/admin/AdministrativePrivileges.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.model.privilege.admin;
+package
org.apache.shardingsphere.authority.provider.natived.model.privilege.admin;
import lombok.EqualsAndHashCode;
import lombok.Getter;
-import org.apache.shardingsphere.authority.model.privilege.PrivilegeType;
+import org.apache.shardingsphere.authority.model.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/model/privilege/database/DatabasePrivileges.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/privilege/database/DatabasePrivileges.java
similarity index 95%
rename from
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/database/DatabasePrivileges.java
rename to
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/privilege/database/DatabasePrivileges.java
index a65fa22..be898e9 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/database/DatabasePrivileges.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/privilege/database/DatabasePrivileges.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.model.privilege.database;
+package
org.apache.shardingsphere.authority.provider.natived.model.privilege.database;
import lombok.EqualsAndHashCode;
import lombok.Getter;
-import org.apache.shardingsphere.authority.model.privilege.PrivilegeType;
+import org.apache.shardingsphere.authority.model.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/model/privilege/database/SchemaPrivileges.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/privilege/database/SchemaPrivileges.java
similarity index 94%
rename from
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/database/SchemaPrivileges.java
rename to
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/privilege/database/SchemaPrivileges.java
index db2c89c..6150c3f 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/database/SchemaPrivileges.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/privilege/database/SchemaPrivileges.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.model.privilege.database;
+package
org.apache.shardingsphere.authority.provider.natived.model.privilege.database;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.authority.model.privilege.PrivilegeType;
+import org.apache.shardingsphere.authority.model.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/model/privilege/database/TablePrivileges.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/privilege/database/TablePrivileges.java
similarity index 90%
rename from
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/database/TablePrivileges.java
rename to
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/privilege/database/TablePrivileges.java
index a0428df..569a5a9 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/privilege/database/TablePrivileges.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/privilege/database/TablePrivileges.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.model.privilege.database;
+package
org.apache.shardingsphere.authority.provider.natived.model.privilege.database;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.authority.model.privilege.PrivilegeType;
+import org.apache.shardingsphere.authority.model.PrivilegeType;
import java.util.Collection;
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/subject/impl/SchemaAccessSubject.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/subject/SchemaAccessSubject.java
similarity index 88%
rename from
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/subject/impl/SchemaAccessSubject.java
rename to
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/subject/SchemaAccessSubject.java
index dbd6437..f2eba26 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/subject/impl/SchemaAccessSubject.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/subject/SchemaAccessSubject.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.model.subject.impl;
+package org.apache.shardingsphere.authority.provider.natived.model.subject;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.authority.model.subject.AccessSubject;
+import org.apache.shardingsphere.authority.model.AccessSubject;
/**
* Schema access subject.
diff --git
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/subject/impl/TableAccessSubject.java
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/subject/TableAccessSubject.java
similarity index 88%
rename from
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/subject/impl/TableAccessSubject.java
rename to
shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/subject/TableAccessSubject.java
index 193acf6..858f867 100644
---
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-api/src/main/java/org/apache/shardingsphere/authority/model/subject/impl/TableAccessSubject.java
+++
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/model/subject/TableAccessSubject.java
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.authority.model.subject.impl;
+package org.apache.shardingsphere.authority.provider.natived.model.subject;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.authority.model.subject.AccessSubject;
+import org.apache.shardingsphere.authority.model.AccessSubject;
/**
* Table access subject.
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 5c2031f..b6e0901 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.model.privilege.ShardingSpherePrivileges;
+import org.apache.shardingsphere.authority.model.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 cfb897d..044b04f 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.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.authority.model.PrivilegeType;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.NativePrivileges;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.database.SchemaPrivileges;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.database.TablePrivileges;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.rule.type.DataNodeContainedRule;
import org.junit.Test;
@@ -42,12 +42,12 @@ public final class PrivilegeMergeTest {
@Test
public void assertPrivilegeMergeResult() {
- ShardingSpherePrivileges privileges = buildPrivilege();
+ NativePrivileges privileges = buildPrivilege();
ShardingSphereUser user = new ShardingSphereUser("test", "test", "%");
- Map<ShardingSphereUser, Collection<ShardingSpherePrivileges>>
privilegeMap = new HashMap();
+ Map<ShardingSphereUser, Collection<NativePrivileges>> privilegeMap =
new HashMap();
privilegeMap.put(user, Collections.singletonList(privileges));
DataNodeContainedRule rule = buildShardingSphereRule();
- Map<ShardingSphereUser, ShardingSpherePrivileges> result =
StoragePrivilegeMerger.merge(privilegeMap, "schema",
Collections.singletonList(rule));
+ Map<ShardingSphereUser, NativePrivileges> result =
StoragePrivilegeMerger.merge(privilegeMap, "schema",
Collections.singletonList(rule));
assertEquals(1, result.size());
assertTrue(result.containsKey(user));
assertTrue(result.get(user).getAdministrativePrivileges().getPrivileges().isEmpty());
@@ -60,7 +60,7 @@ public final class PrivilegeMergeTest {
assertTrue(result.get(user).getDatabasePrivileges().getSpecificPrivileges().get("schema").getSpecificPrivileges().get("test").getPrivileges().contains(PrivilegeType.SELECT));
}
- private ShardingSpherePrivileges buildPrivilege() {
+ private NativePrivileges buildPrivilege() {
Collection<PrivilegeType> tablePrivileges = new LinkedList<>();
tablePrivileges.add(PrivilegeType.SELECT);
SchemaPrivileges schema1Privilege = new SchemaPrivileges("schema1");
@@ -69,7 +69,7 @@ public final class PrivilegeMergeTest {
SchemaPrivileges schema2Privilege = new SchemaPrivileges("schema2");
schema2Privilege.getSpecificPrivileges().put("table3", new
TablePrivileges("table3", tablePrivileges));
schema2Privilege.getSpecificPrivileges().put("table4", new
TablePrivileges("table4", tablePrivileges));
- ShardingSpherePrivileges result = new ShardingSpherePrivileges();
+ NativePrivileges result = new NativePrivileges();
result.getDatabasePrivileges().getSpecificPrivileges().put("schema1",
schema1Privilege);
result.getDatabasePrivileges().getSpecificPrivileges().put("schema2",
schema2Privilege);
return result;
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 83ae0bb..70fb112 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.model.privilege.PrivilegeType;
-import
org.apache.shardingsphere.authority.model.privilege.ShardingSpherePrivileges;
+import org.apache.shardingsphere.authority.model.PrivilegeType;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.NativePrivileges;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.typed.TypedSPIRegistry;
@@ -155,7 +155,7 @@ public final class MySQLPrivilegeLoaderTest {
return result;
}
- private void assertPrivileges(final Map<ShardingSphereUser,
ShardingSpherePrivileges> actual) {
+ private void assertPrivileges(final Map<ShardingSphereUser,
NativePrivileges> actual) {
assertThat(actual.size(), is(2));
ShardingSphereUser root = new ShardingSphereUser("root", "",
"localhost");
assertThat(actual.get(root).getAdministrativePrivileges().getPrivileges().size(),
is(3));
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 b379a5f..9b0d999 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.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.PrivilegeType;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.NativePrivileges;
+import
org.apache.shardingsphere.authority.provider.natived.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;
@@ -62,7 +62,7 @@ public final class OraclePrivilegeLoaderTest {
assertPrivileges(TypedSPIRegistry.getRegisteredService(StoragePrivilegeLoader.class,
"Oracle", new Properties()).load(users, dataSource));
}
- private void assertPrivileges(final Map<ShardingSphereUser,
ShardingSpherePrivileges> actual) {
+ private void assertPrivileges(final Map<ShardingSphereUser,
NativePrivileges> actual) {
assertThat(actual.size(), is(1));
ShardingSphereUser user = new ShardingSphereUser("admin", "", "");
assertThat(actual.get(user).getDatabasePrivileges().getGlobalPrivileges().size(),
is(0));
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 34a947c..957baa5 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.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.PrivilegeType;
+import
org.apache.shardingsphere.authority.provider.natived.model.privilege.NativePrivileges;
+import
org.apache.shardingsphere.authority.provider.natived.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;
@@ -62,7 +62,7 @@ public final class PostgreSQLPrivilegeLoaderTest {
assertPrivileges(TypedSPIRegistry.getRegisteredService(StoragePrivilegeLoader.class,
"PostgreSQL", new Properties()).load(users, dataSource));
}
- private void assertPrivileges(final Map<ShardingSphereUser,
ShardingSpherePrivileges> actual) {
+ private void assertPrivileges(final Map<ShardingSphereUser,
NativePrivileges> actual) {
assertThat(actual.size(), is(1));
ShardingSphereUser user = new ShardingSphereUser("postgres", "", "");
assertThat(actual.get(user).getDatabasePrivileges().getGlobalPrivileges().size(),
is(0));
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 2cb34bb..27fbca7 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,6 @@ 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.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;
@@ -123,8 +122,6 @@ public final class PostgreSQLAuthenticationEngineTest {
payload.writeInt4(4 + md5Digest.length() + 1);
payload.writeStringNul(md5Digest);
StandardMetaDataContexts standardMetaDataContexts = new
StandardMetaDataContexts();
- ShardingSpherePrivileges privileges = new ShardingSpherePrivileges();
- privileges.setSuperPrivilege();
standardMetaDataContexts.getUsers().getUsers().add(new
ShardingSphereUser(username, password, ""));
ProxyContext.getInstance().init(standardMetaDataContexts,
mock(TransactionContexts.class));
actual = engine.auth(channelHandlerContext, payload);