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

yx9o 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 dc2f84cd24f Rename AuthorityRegistryProvider (#27868)
dc2f84cd24f is described below

commit dc2f84cd24fcd7a93ecf8b6b10a482119c6a40d1
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Aug 2 22:28:58 2023 +0800

    Rename AuthorityRegistryProvider (#27868)
---
 .../{AuthorityProvider.java => AuthorityRegistryProvider.java} |  6 +++---
 ...er.java => DatabasePermittedAuthorityRegistryProvider.java} |  8 ++++----
 .../provider/database/builder/DatabasePrivilegeBuilder.java    |  4 ++--
 ...rovider.java => AllPermittedAuthorityRegistryProvider.java} |  8 ++++----
 .../apache/shardingsphere/authority/rule/AuthorityRule.java    |  6 +++---
 ...che.shardingsphere.authority.spi.AuthorityRegistryProvider} |  4 ++--
 .../schema/DatabasePermittedPrivilegesProviderTest.java        | 10 +++++-----
 7 files changed, 23 insertions(+), 23 deletions(-)

diff --git 
a/kernel/authority/api/src/main/java/org/apache/shardingsphere/authority/spi/AuthorityProvider.java
 
b/kernel/authority/api/src/main/java/org/apache/shardingsphere/authority/spi/AuthorityRegistryProvider.java
similarity index 86%
rename from 
kernel/authority/api/src/main/java/org/apache/shardingsphere/authority/spi/AuthorityProvider.java
rename to 
kernel/authority/api/src/main/java/org/apache/shardingsphere/authority/spi/AuthorityRegistryProvider.java
index bdf607d16e2..14a854d86cf 100644
--- 
a/kernel/authority/api/src/main/java/org/apache/shardingsphere/authority/spi/AuthorityProvider.java
+++ 
b/kernel/authority/api/src/main/java/org/apache/shardingsphere/authority/spi/AuthorityRegistryProvider.java
@@ -26,9 +26,9 @@ import java.util.Collection;
 import java.util.Map;
 
 /**
- * Authority provider.
+ * Authority registry provider.
  */
-public interface AuthorityProvider extends TypedSPI {
+public interface AuthorityRegistryProvider extends TypedSPI {
     
     /**
      * Build authority registry.
@@ -37,5 +37,5 @@ public interface AuthorityProvider extends TypedSPI {
      * @param users users
      * @return built authority registry
      */
-    AuthorityRegistry buildAuthorityRegistry(Map<String, 
ShardingSphereDatabase> databases, Collection<ShardingSphereUser> users);
+    AuthorityRegistry build(Map<String, ShardingSphereDatabase> databases, 
Collection<ShardingSphereUser> users);
 }
diff --git 
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/database/DatabasePermittedPrivilegesProvider.java
 
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/database/DatabasePermittedAuthorityRegistryProvider.java
similarity index 84%
rename from 
kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/database/DatabasePermittedPrivilegesProvider.java
rename to 
kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/database/DatabasePermittedAuthorityRegistryProvider.java
index 7e1a9dbc514..f3367c92088 100644
--- 
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/database/DatabasePermittedPrivilegesProvider.java
+++ 
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/database/DatabasePermittedAuthorityRegistryProvider.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.authority.provider.database;
 import org.apache.shardingsphere.authority.model.AuthorityRegistry;
 import 
org.apache.shardingsphere.authority.provider.database.builder.DatabasePrivilegeBuilder;
 import 
org.apache.shardingsphere.authority.registry.UserPrivilegeMapAuthorityRegistry;
-import org.apache.shardingsphere.authority.spi.AuthorityProvider;
+import org.apache.shardingsphere.authority.spi.AuthorityRegistryProvider;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
 
@@ -30,9 +30,9 @@ import java.util.Map;
 import java.util.Properties;
 
 /**
- * Database permitted privileges provider.
+ * Database permitted authority registry provider.
  */
-public final class DatabasePermittedPrivilegesProvider implements 
AuthorityProvider {
+public final class DatabasePermittedAuthorityRegistryProvider implements 
AuthorityRegistryProvider {
     
     public static final String PROP_USER_DATABASE_MAPPINGS = 
"user-database-mappings";
     
@@ -44,7 +44,7 @@ public final class DatabasePermittedPrivilegesProvider 
implements AuthorityProvi
     }
     
     @Override
-    public AuthorityRegistry buildAuthorityRegistry(final Map<String, 
ShardingSphereDatabase> databases, final Collection<ShardingSphereUser> users) {
+    public AuthorityRegistry build(final Map<String, ShardingSphereDatabase> 
databases, final Collection<ShardingSphereUser> users) {
         return new 
UserPrivilegeMapAuthorityRegistry(DatabasePrivilegeBuilder.build(users, props));
     }
     
diff --git 
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/database/builder/DatabasePrivilegeBuilder.java
 
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/database/builder/DatabasePrivilegeBuilder.java
index 89e7bf95d6a..939b7efdf2c 100644
--- 
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/database/builder/DatabasePrivilegeBuilder.java
+++ 
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/database/builder/DatabasePrivilegeBuilder.java
@@ -21,7 +21,7 @@ import com.google.common.base.Preconditions;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
-import 
org.apache.shardingsphere.authority.provider.database.DatabasePermittedPrivilegesProvider;
+import 
org.apache.shardingsphere.authority.provider.database.DatabasePermittedAuthorityRegistryProvider;
 import 
org.apache.shardingsphere.authority.provider.database.model.privilege.DatabasePermittedPrivileges;
 import org.apache.shardingsphere.infra.metadata.user.Grantee;
 import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
@@ -49,7 +49,7 @@ public final class DatabasePrivilegeBuilder {
      * @return privileges
      */
     public static Map<ShardingSphereUser, ShardingSpherePrivileges> 
build(final Collection<ShardingSphereUser> users, final Properties props) {
-        String mappingProp = 
props.getProperty(DatabasePermittedPrivilegesProvider.PROP_USER_DATABASE_MAPPINGS,
 "");
+        String mappingProp = 
props.getProperty(DatabasePermittedAuthorityRegistryProvider.PROP_USER_DATABASE_MAPPINGS,
 "");
         checkDatabases(mappingProp);
         return buildPrivileges(users, mappingProp);
     }
diff --git 
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/simple/AllPermittedPrivilegesProvider.java
 
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/simple/AllPermittedAuthorityRegistryProvider.java
similarity index 81%
rename from 
kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/simple/AllPermittedPrivilegesProvider.java
rename to 
kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/simple/AllPermittedAuthorityRegistryProvider.java
index 05a6d0c0ebc..203e59ef819 100644
--- 
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/simple/AllPermittedPrivilegesProvider.java
+++ 
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/simple/AllPermittedAuthorityRegistryProvider.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.authority.provider.simple;
 
 import org.apache.shardingsphere.authority.model.AuthorityRegistry;
 import 
org.apache.shardingsphere.authority.registry.AllPermittedAuthorityRegistry;
-import org.apache.shardingsphere.authority.spi.AuthorityProvider;
+import org.apache.shardingsphere.authority.spi.AuthorityRegistryProvider;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
 
@@ -28,12 +28,12 @@ import java.util.Collections;
 import java.util.Map;
 
 /**
- * All permitted privileges provider.
+ * All permitted authority registry provider.
  */
-public final class AllPermittedPrivilegesProvider implements AuthorityProvider 
{
+public final class AllPermittedAuthorityRegistryProvider implements 
AuthorityRegistryProvider {
     
     @Override
-    public AuthorityRegistry buildAuthorityRegistry(final Map<String, 
ShardingSphereDatabase> databases, final Collection<ShardingSphereUser> users) {
+    public AuthorityRegistry build(final Map<String, ShardingSphereDatabase> 
databases, final Collection<ShardingSphereUser> users) {
         return new AllPermittedAuthorityRegistry();
     }
     
diff --git 
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java
 
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java
index 402c6487c3c..667b9831365 100644
--- 
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java
+++ 
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java
@@ -21,7 +21,7 @@ import lombok.Getter;
 import org.apache.shardingsphere.authority.config.AuthorityRuleConfiguration;
 import org.apache.shardingsphere.authority.model.AuthorityRegistry;
 import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
-import org.apache.shardingsphere.authority.spi.AuthorityProvider;
+import org.apache.shardingsphere.authority.spi.AuthorityRegistryProvider;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.metadata.user.Grantee;
 import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
@@ -43,8 +43,8 @@ public final class AuthorityRule implements GlobalRule {
     
     public AuthorityRule(final AuthorityRuleConfiguration ruleConfig, final 
Map<String, ShardingSphereDatabase> databases) {
         configuration = ruleConfig;
-        AuthorityProvider provider = 
TypedSPILoader.getService(AuthorityProvider.class, 
ruleConfig.getAuthorityProvider().getType(), 
ruleConfig.getAuthorityProvider().getProps());
-        authorityRegistry = provider.buildAuthorityRegistry(databases, 
ruleConfig.getUsers());
+        AuthorityRegistryProvider provider = 
TypedSPILoader.getService(AuthorityRegistryProvider.class, 
ruleConfig.getAuthorityProvider().getType(), 
ruleConfig.getAuthorityProvider().getProps());
+        authorityRegistry = provider.build(databases, ruleConfig.getUsers());
     }
     
     /**
diff --git 
a/kernel/authority/core/src/main/resources/META-INF/services/org.apache.shardingsphere.authority.spi.AuthorityProvider
 
b/kernel/authority/core/src/main/resources/META-INF/services/org.apache.shardingsphere.authority.spi.AuthorityRegistryProvider
similarity index 93%
rename from 
kernel/authority/core/src/main/resources/META-INF/services/org.apache.shardingsphere.authority.spi.AuthorityProvider
rename to 
kernel/authority/core/src/main/resources/META-INF/services/org.apache.shardingsphere.authority.spi.AuthorityRegistryProvider
index b51eb952c8f..b25b1f20818 100644
--- 
a/kernel/authority/core/src/main/resources/META-INF/services/org.apache.shardingsphere.authority.spi.AuthorityProvider
+++ 
b/kernel/authority/core/src/main/resources/META-INF/services/org.apache.shardingsphere.authority.spi.AuthorityRegistryProvider
@@ -15,5 +15,5 @@
 # limitations under the License.
 #
 
-org.apache.shardingsphere.authority.provider.simple.AllPermittedPrivilegesProvider
-org.apache.shardingsphere.authority.provider.database.DatabasePermittedPrivilegesProvider
+org.apache.shardingsphere.authority.provider.simple.AllPermittedAuthorityRegistryProvider
+org.apache.shardingsphere.authority.provider.database.DatabasePermittedAuthorityRegistryProvider
diff --git 
a/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/provider/schema/DatabasePermittedPrivilegesProviderTest.java
 
b/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/provider/schema/DatabasePermittedPrivilegesProviderTest.java
index 6283512fba5..30be983d616 100644
--- 
a/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/provider/schema/DatabasePermittedPrivilegesProviderTest.java
+++ 
b/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/provider/schema/DatabasePermittedPrivilegesProviderTest.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.authority.provider.schema;
 
 import org.apache.shardingsphere.authority.model.AuthorityRegistry;
 import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
-import 
org.apache.shardingsphere.authority.provider.database.DatabasePermittedPrivilegesProvider;
-import org.apache.shardingsphere.authority.spi.AuthorityProvider;
+import 
org.apache.shardingsphere.authority.provider.database.DatabasePermittedAuthorityRegistryProvider;
+import org.apache.shardingsphere.authority.spi.AuthorityRegistryProvider;
 import org.apache.shardingsphere.infra.metadata.user.Grantee;
 import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
 import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
@@ -39,9 +39,9 @@ class DatabasePermittedPrivilegesProviderTest {
     @Test
     void assertBuildAuthorityRegistry() {
         Properties props = PropertiesBuilder.build(
-                new 
Property(DatabasePermittedPrivilegesProvider.PROP_USER_DATABASE_MAPPINGS, 
"root@localhost=test, [email protected]=db_dal_admin, user1@=test, user1@=test1, 
user1@=*"));
-        AuthorityProvider provider = 
TypedSPILoader.getService(AuthorityProvider.class, "DATABASE_PERMITTED", props);
-        AuthorityRegistry actual = 
provider.buildAuthorityRegistry(Collections.emptyMap(), 
Collections.singletonList(new ShardingSphereUser("user1", "", "127.0.0.2")));
+                new 
Property(DatabasePermittedAuthorityRegistryProvider.PROP_USER_DATABASE_MAPPINGS,
 "root@localhost=test, [email protected]=db_dal_admin, user1@=test, user1@=test1, 
user1@=*"));
+        AuthorityRegistryProvider provider = 
TypedSPILoader.getService(AuthorityRegistryProvider.class, 
"DATABASE_PERMITTED", props);
+        AuthorityRegistry actual = provider.build(Collections.emptyMap(), 
Collections.singletonList(new ShardingSphereUser("user1", "", "127.0.0.2")));
         Optional<ShardingSpherePrivileges> privileges = 
actual.findPrivileges(new Grantee("user1", "127.0.0.2"));
         assertTrue(privileges.isPresent());
         assertTrue(privileges.get().hasPrivileges("test"));

Reply via email to