Skip to content

Commit

Permalink
Rename AuthorityProviderAlgorithm to AuthorityProvider (apache#23984)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Feb 3, 2023
1 parent 75968f6 commit abf141e
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions docs/document/content/dev-manual/proxy.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ chapter = true
| PostgreSQL | PostgreSQL 协议实现 | [`org.apache.shardingsphere.proxy.frontend.postgresql.PostgreSQLFrontendEngine`](https://github.com/apache/shardingsphere/blob/master/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLFrontendEngine.java) |
| openGauss | openGauss 协议实现 | [`org.apache.shardingsphere.proxy.frontend.opengauss.OpenGaussFrontendEngine`](https://github.com/apache/shardingsphere/blob/master/proxy/frontend/opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/OpenGaussFrontendEngine.java) |

## AuthorityProvideAlgorithm
## AuthorityProvide

### 全限定类名

[`org.apache.shardingsphere.authority.spi.AuthorityProviderAlgorithm`](https://github.com/apache/shardingsphere/blob/master/kernel/authority/api/src/main/java/org/apache/shardingsphere/authority/spi/AuthorityProviderAlgorithm.java)
[`org.apache.shardingsphere.authority.spi.AuthorityProvider`](https://github.com/apache/shardingsphere/blob/master/kernel/authority/api/src/main/java/org/apache/shardingsphere/authority/spi/AuthorityProvider.java)

### 定义

Expand All @@ -37,5 +37,5 @@ chapter = true

| *配置标识* | *详细说明* | *全限定类名* |
| ------------------ | --------------------------------------- | ---------- |
| ALL_PERMITTED | 默认授予所有权限(不鉴权) | [`org.apache.shardingsphere.authority.provider.simple.AllPermittedPrivilegesProviderAlgorithm`](https://github.com/apache/shardingsphere/blob/master/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/simple/AllPermittedPrivilegesProviderAlgorithm.java) |
| DATABASE_PERMITTED | 通过属性 user-database-mappings 配置的权限 | [`org.apache.shardingsphere.authority.provider.database.DatabasePermittedPrivilegesProviderAlgorithm`](https://github.com/apache/shardingsphere/blob/master/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/database/DatabasePermittedPrivilegesProviderAlgorithm.java) |
| ALL_PERMITTED | 默认授予所有权限(不鉴权) | [`org.apache.shardingsphere.authority.provider.simple.AllPermittedPrivilegesProvider`](https://github.com/apache/shardingsphere/blob/master/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/simple/AllPermittedPrivilegesProvider.java) |
| DATABASE_PERMITTED | 通过属性 user-database-mappings 配置的权限 | [`org.apache.shardingsphere.authority.provider.database.DatabasePermittedPrivilegesProvider`](https://github.com/apache/shardingsphere/blob/master/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/database/DatabasePermittedPrivilegesProvider.java) |
8 changes: 4 additions & 4 deletions docs/document/content/dev-manual/proxy.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ Protocols for ShardingSphere-Proxy to parse and adapt for accessing databases.
| PostgreSQL | Protocol implementation for PostgreSQL | [`org.apache.shardingsphere.proxy.frontend.postgresql.PostgreSQLFrontendEngine`](https://github.com/apache/shardingsphere/blob/master/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLFrontendEngine.java) |
| openGauss | Protocol implementation for openGauss | [`org.apache.shardingsphere.proxy.frontend.opengauss.OpenGaussFrontendEngine`](https://github.com/apache/shardingsphere/blob/master/proxy/frontend/opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/OpenGaussFrontendEngine.java) |

## AuthorityProvideAlgorithm
## AuthorityProvide

### Fully-qualified class name

[`org.apache.shardingsphere.authority.spi.AuthorityProviderAlgorithm`](https://github.com/apache/shardingsphere/blob/master/kernel/authority/api/src/main/java/org/apache/shardingsphere/authority/spi/AuthorityProviderAlgorithm.java)
[`org.apache.shardingsphere.authority.spi.AuthorityProvider`](https://github.com/apache/shardingsphere/blob/master/kernel/authority/api/src/main/java/org/apache/shardingsphere/authority/spi/AuthorityProvider.java)

### Definition

Expand All @@ -37,5 +37,5 @@ Loading logic for user permission.

| *Configuration Type* | *Description* | *Fully-qualified class name* |
| -------------------- | ------------------------------------------------ | ---------------------------- |
| ALL_PERMITTED | Grant all permissions by default (no forensics) | [`org.apache.shardingsphere.authority.provider.simple.AllPermittedPrivilegesProviderAlgorithm`](https://github.com/apache/shardingsphere/blob/master/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/simple/AllPermittedPrivilegesProviderAlgorithm.java) |
| DATABASE_PERMITTED | Permissions configured by user-database-mappings | [`org.apache.shardingsphere.authority.provider.database.DatabasePermittedPrivilegesProviderAlgorithm`](https://github.com/apache/shardingsphere/blob/master/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/database/DatabasePermittedPrivilegesProviderAlgorithm.java) |
| ALL_PERMITTED | Grant all permissions by default (no forensics) | [`org.apache.shardingsphere.authority.provider.simple.AllPermittedPrivilegesProvider`](https://github.com/apache/shardingsphere/blob/master/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/simple/AllPermittedPrivilegesProvider.java) |
| DATABASE_PERMITTED | Permissions configured by user-database-mappings | [`org.apache.shardingsphere.authority.provider.database.DatabasePermittedPrivilegesProvider`](https://github.com/apache/shardingsphere/blob/master/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/provider/database/DatabasePermittedPrivilegesProvider.java) |
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import java.util.Map;

/**
* Authority provider algorithm.
* Authority provider.
*/
public interface AuthorityProviderAlgorithm extends TypedSPI {
public interface AuthorityProvider extends TypedSPI {

/**
* Build authority registry.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
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.AuthorityProviderAlgorithm;
import org.apache.shardingsphere.authority.spi.AuthorityProvider;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;

Expand All @@ -30,9 +30,9 @@
import java.util.Properties;

/**
* Database permitted privileges provider algorithm.
* Database permitted privileges provider.
*/
public final class DatabasePermittedPrivilegesProviderAlgorithm implements AuthorityProviderAlgorithm {
public final class DatabasePermittedPrivilegesProvider implements AuthorityProvider {

public static final String PROP_USER_DATABASE_MAPPINGS = "user-database-mappings";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
import org.apache.shardingsphere.authority.provider.database.DatabasePermittedPrivilegesProviderAlgorithm;
import org.apache.shardingsphere.authority.provider.database.DatabasePermittedPrivilegesProvider;
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;
Expand Down Expand Up @@ -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(DatabasePermittedPrivilegesProviderAlgorithm.PROP_USER_DATABASE_MAPPINGS, "");
String mappingProp = props.getProperty(DatabasePermittedPrivilegesProvider.PROP_USER_DATABASE_MAPPINGS, "");
checkDatabases(mappingProp);
return buildPrivileges(users, mappingProp);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import org.apache.shardingsphere.authority.model.AuthorityRegistry;
import org.apache.shardingsphere.authority.registry.AllPermittedAuthorityRegistry;
import org.apache.shardingsphere.authority.spi.AuthorityProviderAlgorithm;
import org.apache.shardingsphere.authority.spi.AuthorityProvider;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;

Expand All @@ -28,9 +28,9 @@
import java.util.Map;

/**
* All permitted privileges provider algorithm.
* All permitted privileges provider.
*/
public final class AllPermittedPrivilegesProviderAlgorithm implements AuthorityProviderAlgorithm {
public final class AllPermittedPrivilegesProvider implements AuthorityProvider {

@Override
public AuthorityRegistry buildAuthorityRegistry(final Map<String, ShardingSphereDatabase> databases, final Collection<ShardingSphereUser> users) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
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.AuthorityProviderAlgorithm;
import org.apache.shardingsphere.authority.spi.AuthorityProvider;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
Expand All @@ -42,14 +42,14 @@ public final class AuthorityRule implements GlobalRule {

private final Collection<ShardingSphereUser> users;

private final AuthorityProviderAlgorithm provider;
private final AuthorityProvider provider;

private volatile AuthorityRegistry authorityRegistry;

public AuthorityRule(final AuthorityRuleConfiguration ruleConfig, final Map<String, ShardingSphereDatabase> databases) {
configuration = ruleConfig;
users = ruleConfig.getUsers();
provider = TypedSPILoader.getService(AuthorityProviderAlgorithm.class, ruleConfig.getProvider().getType(), ruleConfig.getProvider().getProps());
provider = TypedSPILoader.getService(AuthorityProvider.class, ruleConfig.getProvider().getType(), ruleConfig.getProvider().getProps());
authorityRegistry = provider.buildAuthorityRegistry(databases, ruleConfig.getUsers());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
# limitations under the License.
#

org.apache.shardingsphere.authority.provider.simple.AllPermittedPrivilegesProviderAlgorithm
org.apache.shardingsphere.authority.provider.database.DatabasePermittedPrivilegesProviderAlgorithm
org.apache.shardingsphere.authority.provider.simple.AllPermittedPrivilegesProvider
org.apache.shardingsphere.authority.provider.database.DatabasePermittedPrivilegesProvider
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import org.apache.shardingsphere.authority.model.AuthorityRegistry;
import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
import org.apache.shardingsphere.authority.provider.database.DatabasePermittedPrivilegesProviderAlgorithm;
import org.apache.shardingsphere.authority.spi.AuthorityProviderAlgorithm;
import org.apache.shardingsphere.authority.provider.database.DatabasePermittedPrivilegesProvider;
import org.apache.shardingsphere.authority.spi.AuthorityProvider;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
Expand All @@ -39,9 +39,9 @@ public final class DatabasePermittedPrivilegesProviderAlgorithmTest {
@Test
public void assertBuildAuthorityRegistry() {
Properties props = PropertiesBuilder.build(
new Property(DatabasePermittedPrivilegesProviderAlgorithm.PROP_USER_DATABASE_MAPPINGS, "root@localhost=test, [email protected]=db_dal_admin, user1@=test, user1@=test1, user1@=*"));
AuthorityProviderAlgorithm algorithm = TypedSPILoader.getService(AuthorityProviderAlgorithm.class, "DATABASE_PERMITTED", props);
AuthorityRegistry actual = algorithm.buildAuthorityRegistry(Collections.emptyMap(), Collections.singletonList(new ShardingSphereUser("user1", "", "127.0.0.2")));
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")));
Optional<ShardingSpherePrivileges> privileges = actual.findPrivileges(new Grantee("user1", "127.0.0.2"));
assertTrue(privileges.isPresent());
assertTrue(privileges.get().hasPrivileges("test"));
Expand Down

0 comments on commit abf141e

Please sign in to comment.