You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2021/04/07 08:52:54 UTC
[shardingsphere] branch master updated: Rename
ShardingSphereAuthentication to Authority (#9969)
This is an automated email from the ASF dual-hosted git repository.
panjuan 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 9a1fc42 Rename ShardingSphereAuthentication to Authority (#9969)
9a1fc42 is described below
commit 9a1fc42cbaa72656f9048f287bbd9a88292b8111
Author: Liang Zhang <te...@163.com>
AuthorDate: Wed Apr 7 16:52:17 2021 +0800
Rename ShardingSphereAuthentication to Authority (#9969)
---
.../authority/checker/AuthorityChecker.java | 6 ++---
...nticationContext.java => AuthorityContext.java} | 20 +++++++--------
...henticationEngine.java => AuthorityEngine.java} | 16 ++++++------
...ntication.java => ShardingSphereAuthority.java} | 12 ++++-----
...ltAuthentication.java => DefaultAuthority.java} | 16 ++++++------
.../storage/impl/StoragePrivilegeMerger.java | 8 +++---
.../authority/rule/AuthorityRule.java | 12 ++++-----
.../authority/GovernanceAuthorityContext.java | 30 +++++++++++-----------
.../metadata/GovernanceMetaDataContexts.java | 4 +--
.../metadata/GovernanceMetaDataContextsTest.java | 10 ++++----
.../governance/core/registry/RegistryCenter.java | 6 ++---
.../yaml/config/YamlConfigurationConverter.java | 2 +-
.../core/facade/GovernanceFacadeTest.java | 10 ++++----
.../core/registry/RegistryCenterTest.java | 8 +++---
.../mysql/executor/ShowDatabasesExecutorTest.java | 16 ++++++------
.../impl/GovernanceBootstrapInitializerTest.java | 12 ++++-----
.../impl/StandardBootstrapInitializerTest.java | 12 ++++-----
.../proxy/config/ProxyConfigurationLoader.java | 4 +--
.../swapper/YamlProxyConfigurationSwapperTest.java | 16 ++++++------
.../mysql/auth/MySQLAuthenticationHandlerTest.java | 16 ++++++------
20 files changed, 116 insertions(+), 120 deletions(-)
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 c0101fc..292abba 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
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.authority.rule.AuthorityRule;
import org.apache.shardingsphere.infra.check.SQLCheckResult;
import org.apache.shardingsphere.infra.check.SQLChecker;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.authority.engine.AuthenticationContext;
+import org.apache.shardingsphere.authority.engine.AuthorityContext;
import org.apache.shardingsphere.authority.model.PrivilegeType;
import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
@@ -43,7 +43,7 @@ public final class AuthorityChecker implements SQLChecker<AuthorityRule> {
if (null == grantee) {
return true;
}
- return AuthenticationContext.getInstance().getAuthentication().findPrivileges(grantee).map(optional -> optional.hasPrivileges(schemaName)).orElse(false);
+ return AuthorityContext.getInstance().getAuthority().findPrivileges(grantee).map(optional -> optional.hasPrivileges(schemaName)).orElse(false);
}
@Override
@@ -51,7 +51,7 @@ public final class AuthorityChecker implements SQLChecker<AuthorityRule> {
if (null == grantee) {
return new SQLCheckResult(true, "");
}
- Optional<ShardingSpherePrivileges> privileges = AuthenticationContext.getInstance().getAuthentication().findPrivileges(grantee);
+ Optional<ShardingSpherePrivileges> privileges = AuthorityContext.getInstance().getAuthority().findPrivileges(grantee);
// TODO add error msg
return privileges.map(optional -> new SQLCheckResult(optional.hasPrivileges(Collections.singletonList(getPrivilege(sqlStatement))), "")).orElseGet(() -> new SQLCheckResult(false, ""));
}
diff --git a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/AuthenticationContext.java b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/AuthorityContext.java
similarity index 68%
rename from shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/AuthenticationContext.java
rename to shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/AuthorityContext.java
index 7dd0937..7dc0540 100644
--- a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/AuthenticationContext.java
+++ b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/AuthorityContext.java
@@ -22,33 +22,31 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
/**
- * Authentication context.
- *
- * @author zhangliang
+ * Authority context.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
-public final class AuthenticationContext {
+public final class AuthorityContext {
- private static final AuthenticationContext INSTANCE = new AuthenticationContext();
+ private static final AuthorityContext INSTANCE = new AuthorityContext();
- private volatile Authentication authentication;
+ private volatile ShardingSphereAuthority authority;
/**
* Get instance.
*
* @return instance
*/
- public static AuthenticationContext getInstance() {
+ public static AuthorityContext getInstance() {
return INSTANCE;
}
/**
- * Initial authentication.
+ * Initial authority.
*
- * @param authentication authentication
+ * @param authority authority
*/
- public synchronized void init(final Authentication authentication) {
- this.authentication = AuthenticationEngine.findSPIAuthentication().orElse(authentication);
+ public synchronized void init(final ShardingSphereAuthority authority) {
+ this.authority = AuthorityEngine.findSPIAuthority().orElse(authority);
}
}
diff --git a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/AuthenticationEngine.java b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/AuthorityEngine.java
similarity index 69%
rename from shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/AuthenticationEngine.java
rename to shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/AuthorityEngine.java
index 0424399..eb18fbf 100644
--- a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/AuthenticationEngine.java
+++ b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/AuthorityEngine.java
@@ -25,22 +25,22 @@ import java.util.Collection;
import java.util.Optional;
/**
- * Authentication engine.
+ * Authority engine.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class AuthenticationEngine {
+public final class AuthorityEngine {
static {
- ShardingSphereServiceLoader.register(Authentication.class);
+ ShardingSphereServiceLoader.register(ShardingSphereAuthority.class);
}
/**
- * Find SPI authentication.
+ * Find SPI authority.
*
- * @return authentication
+ * @return authority
*/
- public static Optional<Authentication> findSPIAuthentication() {
- Collection<Authentication> authentications = ShardingSphereServiceLoader.newServiceInstances(Authentication.class);
- return authentications.isEmpty() ? Optional.empty() : Optional.of(authentications.iterator().next());
+ public static Optional<ShardingSphereAuthority> findSPIAuthority() {
+ Collection<ShardingSphereAuthority> authorities = ShardingSphereServiceLoader.newServiceInstances(ShardingSphereAuthority.class);
+ return authorities.isEmpty() ? Optional.empty() : Optional.of(authorities.iterator().next());
}
}
diff --git a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/Authentication.java b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/ShardingSphereAuthority.java
similarity index 89%
rename from shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/Authentication.java
rename to shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/ShardingSphereAuthority.java
index 0be9015..8b59275 100644
--- a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/Authentication.java
+++ b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/ShardingSphereAuthority.java
@@ -26,23 +26,23 @@ import java.util.Map;
import java.util.Optional;
/**
- * Authentication.
+ * ShardingSphere authority.
*/
-public interface Authentication {
+public interface ShardingSphereAuthority {
/**
- * Initialize authentication.
+ * Initialize authority.
*
* @param loadedPrivileges loaded privileges
*/
void init(Map<ShardingSphereUser, ShardingSpherePrivileges> loadedPrivileges);
/**
- * Get authentication.
+ * Get authority.
*
- * @return Authentication
+ * @return authority
*/
- Map<ShardingSphereUser, ShardingSpherePrivileges> getAuthentication();
+ Map<ShardingSphereUser, ShardingSpherePrivileges> getAuthority();
/**
* Get all users.
diff --git a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/impl/DefaultAuthentication.java b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/impl/DefaultAuthority.java
similarity index 78%
rename from shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/impl/DefaultAuthentication.java
rename to shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/impl/DefaultAuthority.java
index 47bdb85..2555164 100644
--- a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/impl/DefaultAuthentication.java
+++ b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/engine/impl/DefaultAuthority.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.authority.engine.impl;
import lombok.Getter;
-import org.apache.shardingsphere.authority.engine.Authentication;
+import org.apache.shardingsphere.authority.engine.ShardingSphereAuthority;
import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
@@ -29,30 +29,30 @@ import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
/**
- * Default authentication.
+ * Default authority.
*/
@Getter
-public final class DefaultAuthentication implements Authentication {
+public final class DefaultAuthority implements ShardingSphereAuthority {
- private final Map<ShardingSphereUser, ShardingSpherePrivileges> authentication = new ConcurrentHashMap<>();
+ private final Map<ShardingSphereUser, ShardingSpherePrivileges> authority = new ConcurrentHashMap<>();
@Override
public void init(final Map<ShardingSphereUser, ShardingSpherePrivileges> loadedPrivileges) {
- authentication.putAll(loadedPrivileges);
+ authority.putAll(loadedPrivileges);
}
@Override
public Collection<ShardingSphereUser> getAllUsers() {
- return authentication.keySet();
+ return authority.keySet();
}
@Override
public Optional<ShardingSphereUser> findUser(final Grantee grantee) {
- return authentication.keySet().stream().filter(each -> each.getGrantee().equals(grantee)).findFirst();
+ return authority.keySet().stream().filter(each -> each.getGrantee().equals(grantee)).findFirst();
}
@Override
public Optional<ShardingSpherePrivileges> findPrivileges(final Grantee grantee) {
- return findUser(grantee).map(authentication::get);
+ return findUser(grantee).map(authority::get);
}
}
diff --git a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/loader/storage/impl/StoragePrivilegeMerger.java b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/loader/storage/impl/StoragePrivilegeMerger.java
index 64f47cd..2d41d85 100644
--- a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/loader/storage/impl/StoragePrivilegeMerger.java
+++ b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/loader/storage/impl/StoragePrivilegeMerger.java
@@ -43,15 +43,15 @@ public final class StoragePrivilegeMerger {
/**
* Merge privileges.
*
- * @param authentication authentication
+ * @param authority authority
* @param schemaName schema name
* @param rules ShardingSphere rules
* @return privileges
*/
- public static Map<ShardingSphereUser, ShardingSpherePrivileges> merge(final Map<ShardingSphereUser, Collection<ShardingSpherePrivileges>> authentication,
+ public static Map<ShardingSphereUser, ShardingSpherePrivileges> merge(final Map<ShardingSphereUser, Collection<ShardingSpherePrivileges>> authority,
final String schemaName, final Collection<ShardingSphereRule> rules) {
- Map<ShardingSphereUser, ShardingSpherePrivileges> result = new HashMap<>(authentication.size(), 1);
- for (Entry<ShardingSphereUser, Collection<ShardingSpherePrivileges>> entry : authentication.entrySet()) {
+ Map<ShardingSphereUser, ShardingSpherePrivileges> result = new HashMap<>(authority.size(), 1);
+ for (Entry<ShardingSphereUser, Collection<ShardingSpherePrivileges>> entry : authority.entrySet()) {
result.put(entry.getKey(), merge(entry.getKey(), entry.getValue(), schemaName, rules));
}
return result;
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 350c9b3..6335477 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
@@ -21,9 +21,9 @@ import org.apache.shardingsphere.authority.api.config.AuthorityRuleConfiguration
import org.apache.shardingsphere.authority.spi.PrivilegeLoadAlgorithm;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmFactory;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.authority.engine.Authentication;
-import org.apache.shardingsphere.authority.engine.AuthenticationContext;
-import org.apache.shardingsphere.authority.engine.impl.DefaultAuthentication;
+import org.apache.shardingsphere.authority.engine.ShardingSphereAuthority;
+import org.apache.shardingsphere.authority.engine.AuthorityContext;
+import org.apache.shardingsphere.authority.engine.impl.DefaultAuthority;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
@@ -43,8 +43,8 @@ public final class AuthorityRule implements ShardingSphereRule {
public AuthorityRule(final AuthorityRuleConfiguration config, final String schemaName, final DatabaseType databaseType,
final Collection<DataSource> dataSources, final Collection<ShardingSphereUser> users, final Collection<ShardingSphereRule> builtRules) {
PrivilegeLoadAlgorithm privilegeLoader = ShardingSphereAlgorithmFactory.createAlgorithm(config.getPrivilegeLoader(), PrivilegeLoadAlgorithm.class);
- Authentication authentication = null == AuthenticationContext.getInstance().getAuthentication() ? new DefaultAuthentication() : AuthenticationContext.getInstance().getAuthentication();
- authentication.init(privilegeLoader.load(schemaName, databaseType, dataSources, builtRules, users));
- AuthenticationContext.getInstance().init(authentication);
+ ShardingSphereAuthority authority = null == AuthorityContext.getInstance().getAuthority() ? new DefaultAuthority() : AuthorityContext.getInstance().getAuthority();
+ authority.init(privilegeLoader.load(schemaName, databaseType, dataSources, builtRules, users));
+ AuthorityContext.getInstance().init(authority);
}
}
diff --git a/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/authority/GovernanceAuthorityContext.java b/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/authority/GovernanceAuthorityContext.java
index 5f8549a..342c731 100644
--- a/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/authority/GovernanceAuthorityContext.java
+++ b/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/authority/GovernanceAuthorityContext.java
@@ -20,9 +20,9 @@ package org.apache.shardingsphere.governance.context.authority;
import com.google.common.base.Preconditions;
import com.google.common.eventbus.Subscribe;
import lombok.Setter;
-import org.apache.shardingsphere.authority.engine.Authentication;
-import org.apache.shardingsphere.authority.engine.AuthenticationContext;
-import org.apache.shardingsphere.authority.engine.impl.DefaultAuthentication;
+import org.apache.shardingsphere.authority.engine.ShardingSphereAuthority;
+import org.apache.shardingsphere.authority.engine.AuthorityContext;
+import org.apache.shardingsphere.authority.engine.impl.DefaultAuthority;
import org.apache.shardingsphere.authority.loader.storage.impl.StoragePrivilegeBuilder;
import org.apache.shardingsphere.authority.loader.storage.impl.StoragePrivilegeLoader;
import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
@@ -56,8 +56,8 @@ public final class GovernanceAuthorityContext implements MetaDataAwareEventSubsc
*/
@Subscribe
public synchronized void renew(final UserRuleChangedEvent event) {
- Authentication authentication = createAuthentication(event.getUsers());
- AuthenticationContext.getInstance().init(authentication);
+ ShardingSphereAuthority authority = createAuthority(event.getUsers());
+ AuthorityContext.getInstance().init(authority);
reloadPrivilege(event.getUsers());
}
@@ -71,8 +71,8 @@ public final class GovernanceAuthorityContext implements MetaDataAwareEventSubsc
reloadPrivilege(event.getUsers());
}
- private Authentication createAuthentication(final Collection<ShardingSphereUser> users) {
- Authentication result = new DefaultAuthentication();
+ private ShardingSphereAuthority createAuthority(final Collection<ShardingSphereUser> users) {
+ ShardingSphereAuthority result = new DefaultAuthority();
Collection<ShardingSphereUser> newUsers = getNewUsers(users);
Map<ShardingSphereUser, ShardingSpherePrivileges> modifiedUsers = getModifiedUsers(users);
for (ShardingSphereUser each : newUsers) {
@@ -83,15 +83,15 @@ public final class GovernanceAuthorityContext implements MetaDataAwareEventSubsc
}
private Collection<ShardingSphereUser> getNewUsers(final Collection<ShardingSphereUser> users) {
- return users.stream().filter(each -> !AuthenticationContext.getInstance().getAuthentication().findUser(each.getGrantee()).isPresent()).collect(Collectors.toList());
+ return users.stream().filter(each -> !AuthorityContext.getInstance().getAuthority().findUser(each.getGrantee()).isPresent()).collect(Collectors.toList());
}
private Map<ShardingSphereUser, ShardingSpherePrivileges> getModifiedUsers(final Collection<ShardingSphereUser> users) {
Map<ShardingSphereUser, ShardingSpherePrivileges> result = new HashMap<>(users.size(), 1);
for (ShardingSphereUser each : users) {
- Optional<ShardingSphereUser> user = AuthenticationContext.getInstance().getAuthentication().findUser(each.getGrantee());
+ Optional<ShardingSphereUser> user = AuthorityContext.getInstance().getAuthority().findUser(each.getGrantee());
if (user.isPresent()) {
- Optional<ShardingSpherePrivileges> privilege = AuthenticationContext.getInstance().getAuthentication().findPrivileges(user.get().getGrantee());
+ Optional<ShardingSpherePrivileges> privilege = AuthorityContext.getInstance().getAuthority().findPrivileges(user.get().getGrantee());
privilege.ifPresent(optional -> result.put(user.get(), optional));
}
}
@@ -99,21 +99,21 @@ public final class GovernanceAuthorityContext implements MetaDataAwareEventSubsc
}
private void reloadPrivilege(final Collection<ShardingSphereUser> users) {
- Authentication authentication = AuthenticationContext.getInstance().getAuthentication();
+ ShardingSphereAuthority authority = AuthorityContext.getInstance().getAuthority();
DatabaseType databaseType = metaDataContexts.getMetaDataMap().values().iterator().next().getResource().getDatabaseType();
Optional<StoragePrivilegeLoader> loader = TypedSPIRegistry.findRegisteredService(StoragePrivilegeLoader.class, databaseType.getName(), new Properties());
if (loader.isPresent()) {
Map<ShardingSphereUser, ShardingSpherePrivileges> privileges = StoragePrivilegeBuilder.build(databaseType, metaDataContexts.getMetaDataMap().values(), users);
- authentication.getAuthentication().putAll(getPrivilegesWithPassword(authentication, privileges));
+ authority.getAuthority().putAll(getPrivilegesWithPassword(authority, privileges));
}
- AuthenticationContext.getInstance().init(authentication);
+ AuthorityContext.getInstance().init(authority);
}
- private Map<ShardingSphereUser, ShardingSpherePrivileges> getPrivilegesWithPassword(final Authentication authentication, final Map<ShardingSphereUser, ShardingSpherePrivileges> privileges) {
+ private Map<ShardingSphereUser, ShardingSpherePrivileges> getPrivilegesWithPassword(final ShardingSphereAuthority authority, final Map<ShardingSphereUser, ShardingSpherePrivileges> privileges) {
Map<ShardingSphereUser, ShardingSpherePrivileges> result = new HashMap<>(privileges.size(), 1);
for (Map.Entry<ShardingSphereUser, ShardingSpherePrivileges> entry : privileges.entrySet()) {
if (privileges.containsKey(entry.getKey())) {
- Optional<ShardingSphereUser> user = authentication.findUser(entry.getKey().getGrantee());
+ Optional<ShardingSphereUser> user = authority.findUser(entry.getKey().getGrantee());
Preconditions.checkState(user.isPresent());
result.put(user.get(), entry.getValue());
}
diff --git a/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContexts.java b/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContexts.java
index bd015c2..743f19f 100644
--- a/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContexts.java
+++ b/shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContexts.java
@@ -205,9 +205,9 @@ public final class GovernanceMetaDataContexts implements MetaDataContexts {
}
/**
- * Renew authentication.
+ * Renew authority.
*
- * @param event User rule changed event
+ * @param event user rule changed event
*/
@Subscribe
public synchronized void renew(final UserRuleChangedEvent event) {
diff --git a/shardingsphere-governance/shardingsphere-governance-context/src/test/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContextsTest.java b/shardingsphere-governance/shardingsphere-governance-context/src/test/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContextsTest.java
index 0aac8bc..fd08f13 100644
--- a/shardingsphere-governance/shardingsphere-governance-context/src/test/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContextsTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-context/src/test/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContextsTest.java
@@ -35,7 +35,7 @@ import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataCon
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.authority.engine.impl.DefaultAuthentication;
+import org.apache.shardingsphere.authority.engine.impl.DefaultAuthority;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUsers;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
@@ -156,11 +156,11 @@ public final class GovernanceMetaDataContextsTest {
}
@Test
- public void assertAuthenticationChanged() {
- DefaultAuthentication authentication = new DefaultAuthentication();
- UserRuleChangedEvent event = new UserRuleChangedEvent(authentication.getAllUsers());
+ public void assertAuthorityChanged() {
+ DefaultAuthority authority = new DefaultAuthority();
+ UserRuleChangedEvent event = new UserRuleChangedEvent(authority.getAllUsers());
governanceMetaDataContexts.renew(event);
- assertThat(governanceMetaDataContexts.getUsers().getUsers().size(), is(authentication.getAuthentication().size()));
+ assertThat(governanceMetaDataContexts.getUsers().getUsers().size(), is(authority.getAuthority().size()));
}
@Test
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenter.java b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenter.java
index 2993c49..cb47b25 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenter.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/registry/RegistryCenter.java
@@ -260,12 +260,10 @@ public final class RegistryCenter {
/**
* Load user rule.
*
- * @return authentication
+ * @return authority
*/
public Collection<ShardingSphereUser> loadUserRule() {
- return hasAuthentication()
- ? YamlConfigurationConverter.convertUserRule(repository.get(node.getAuthenticationPath()))
- : Collections.emptyList();
+ return hasAuthentication() ? YamlConfigurationConverter.convertUserRule(repository.get(node.getAuthenticationPath())) : Collections.emptyList();
}
/**
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/config/YamlConfigurationConverter.java b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/config/YamlConfigurationConverter.java
index e1238cc..7b5179a 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/config/YamlConfigurationConverter.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/config/YamlConfigurationConverter.java
@@ -110,7 +110,7 @@ public final class YamlConfigurationConverter {
* Convert user rule from YAML content.
*
* @param yamlContent YAML content
- * @return authentication
+ * @return users
*/
public static Collection<ShardingSphereUser> convertUserRule(final String yamlContent) {
return new UsersYamlSwapper().swapToObject(YamlEngine.unmarshal(yamlContent, YamlUsersConfiguration.class));
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/facade/GovernanceFacadeTest.java b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/facade/GovernanceFacadeTest.java
index 1b65095..ad4d720 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/facade/GovernanceFacadeTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/facade/GovernanceFacadeTest.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.governance.core.registry.RegistryCenter;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
-import org.apache.shardingsphere.authority.engine.impl.DefaultAuthentication;
+import org.apache.shardingsphere.authority.engine.impl.DefaultAuthority;
import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
@@ -71,13 +71,13 @@ public final class GovernanceFacadeTest {
Map<String, DataSourceConfiguration> dataSourceConfigMap = Collections.singletonMap("test_ds", mock(DataSourceConfiguration.class));
Map<String, Collection<RuleConfiguration>> ruleConfigurationMap = Collections.singletonMap("sharding_db", Collections.singletonList(mock(RuleConfiguration.class)));
ShardingSphereUser user = new ShardingSphereUser("root", "root", "");
- DefaultAuthentication authentication = new DefaultAuthentication();
- authentication.getAuthentication().put(user, new ShardingSpherePrivileges());
+ DefaultAuthority authority = new DefaultAuthority();
+ authority.getAuthority().put(user, new ShardingSpherePrivileges());
Properties props = new Properties();
governanceFacade.onlineInstance(
- Collections.singletonMap("sharding_db", dataSourceConfigMap), ruleConfigurationMap, authentication.getAllUsers(), props);
+ Collections.singletonMap("sharding_db", dataSourceConfigMap), ruleConfigurationMap, authority.getAllUsers(), props);
verify(registryCenter).persistConfigurations("sharding_db", dataSourceConfigMap, ruleConfigurationMap.get("sharding_db"), false);
- verify(registryCenter).persistGlobalConfiguration(authentication.getAllUsers(), props, false);
+ verify(registryCenter).persistGlobalConfiguration(authority.getAllUsers(), props, false);
verify(registryCenter).persistInstanceOnline();
verify(registryCenter).persistDataNodes();
verify(listenerManager).init();
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterTest.java b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterTest.java
index 5b3f389..f5d3e74 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterTest.java
@@ -35,7 +35,7 @@ import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
-import org.apache.shardingsphere.authority.engine.impl.DefaultAuthentication;
+import org.apache.shardingsphere.authority.engine.impl.DefaultAuthority;
import org.apache.shardingsphere.infra.metadata.user.yaml.config.YamlUsersConfiguration;
import org.apache.shardingsphere.infra.metadata.user.yaml.swapper.UsersYamlSwapper;
import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
@@ -371,12 +371,12 @@ public final class RegistryCenterTest {
return new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(SHADOW_RULE_YAML), YamlRootRuleConfigurations.class).getRules());
}
- private DefaultAuthentication createAuthentication() {
+ private DefaultAuthority createAuthentication() {
Collection<ShardingSphereUser> users =
new UsersYamlSwapper().swapToObject(YamlEngine.unmarshal(readYAML(AUTHENTICATION_YAML), YamlUsersConfiguration.class));
- DefaultAuthentication result = new DefaultAuthentication();
+ DefaultAuthority result = new DefaultAuthority();
for (ShardingSphereUser each : users) {
- result.getAuthentication().put(each, new ShardingSpherePrivileges());
+ result.getAuthority().put(each, new ShardingSpherePrivileges());
}
return result;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowDatabasesExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowDatabasesExecutorTest.java
index 23a69cf..6dcd742 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowDatabasesExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/ShowDatabasesExecutorTest.java
@@ -22,9 +22,9 @@ import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataCon
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.authority.engine.Authentication;
-import org.apache.shardingsphere.authority.engine.impl.DefaultAuthentication;
-import org.apache.shardingsphere.authority.engine.AuthenticationContext;
+import org.apache.shardingsphere.authority.engine.ShardingSphereAuthority;
+import org.apache.shardingsphere.authority.engine.impl.DefaultAuthority;
+import org.apache.shardingsphere.authority.engine.AuthorityContext;
import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
@@ -62,15 +62,15 @@ public final class ShowDatabasesExecutorTest {
showDatabasesExecutor = new ShowDatabasesExecutor();
Field metaDataContexts = ProxyContext.getInstance().getClass().getDeclaredField("metaDataContexts");
metaDataContexts.setAccessible(true);
- initAuthentication();
+ initAuthority();
metaDataContexts.set(ProxyContext.getInstance(), new StandardMetaDataContexts(getMetaDataMap(),
mock(ExecutorEngine.class), new ShardingSphereUsers(Collections.singleton(new ShardingSphereUser("root", "root", ""))), new ConfigurationProperties(new Properties())));
}
- private void initAuthentication() {
- Authentication authentication = new DefaultAuthentication();
- authentication.getAuthentication().put(new ShardingSphereUser("root", "root", ""), new ShardingSpherePrivileges());
- AuthenticationContext.getInstance().init(authentication);
+ private void initAuthority() {
+ ShardingSphereAuthority authority = new DefaultAuthority();
+ authority.getAuthority().put(new ShardingSphereUser("root", "root", ""), new ShardingSpherePrivileges());
+ AuthorityContext.getInstance().init(authority);
}
private Map<String, ShardingSphereMetaData> getMetaDataMap() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializerTest.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializerTest.java
index 5574907..c118550 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializerTest.java
@@ -27,8 +27,8 @@ import org.apache.shardingsphere.infra.config.datasource.DataSourceParameter;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
-import org.apache.shardingsphere.authority.engine.Authentication;
-import org.apache.shardingsphere.authority.engine.impl.DefaultAuthentication;
+import org.apache.shardingsphere.authority.engine.ShardingSphereAuthority;
+import org.apache.shardingsphere.authority.engine.impl.DefaultAuthority;
import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
@@ -115,9 +115,9 @@ public final class GovernanceBootstrapInitializerTest extends AbstractBootstrapI
assertNotNull(actual);
assertSchemaDataSources(actual.getSchemaDataSources());
assertSchemaRules(actual.getSchemaRules());
- Authentication authentication = new DefaultAuthentication();
- authentication.init(getPrivileges(actual.getUsers()));
- assertAuthentication(authentication);
+ ShardingSphereAuthority authority = new DefaultAuthority();
+ authority.init(getPrivileges(actual.getUsers()));
+ assertAuthority(authority);
assertProps(actual.getProps());
}
@@ -205,7 +205,7 @@ public final class GovernanceBootstrapInitializerTest extends AbstractBootstrapI
return privileges;
}
- private void assertAuthentication(final Authentication actual) {
+ private void assertAuthority(final ShardingSphereAuthority actual) {
Optional<ShardingSphereUser> rootUser = actual.findUser(new Grantee("root", ""));
assertTrue(rootUser.isPresent());
assertThat(rootUser.get().getPassword(), is("root"));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/StandardBootstrapInitializerTest.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/StandardBootstrapInitializerTest.java
index ac75882..ed110f2 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/StandardBootstrapInitializerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/initializer/impl/StandardBootstrapInitializerTest.java
@@ -20,8 +20,8 @@ package org.apache.shardingsphere.proxy.initializer.impl;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceParameter;
import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
-import org.apache.shardingsphere.authority.engine.Authentication;
-import org.apache.shardingsphere.authority.engine.impl.DefaultAuthentication;
+import org.apache.shardingsphere.authority.engine.ShardingSphereAuthority;
+import org.apache.shardingsphere.authority.engine.impl.DefaultAuthority;
import org.apache.shardingsphere.infra.metadata.user.yaml.config.YamlUserConfiguration;
import org.apache.shardingsphere.infra.metadata.user.yaml.config.YamlUsersConfiguration;
import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
@@ -112,9 +112,9 @@ public final class StandardBootstrapInitializerTest extends AbstractBootstrapIni
private void assertProxyConfiguration(final ProxyConfiguration actual) {
assertSchemaDataSources(actual.getSchemaDataSources());
assertSchemaRules(actual.getSchemaRules());
- Authentication authentication = new DefaultAuthentication();
- authentication.init(getPrivileges(actual.getUsers()));
- assertAuthentication(authentication);
+ ShardingSphereAuthority authority = new DefaultAuthority();
+ authority.init(getPrivileges(actual.getUsers()));
+ assertAuthority(authority);
assertProps(actual.getProps());
}
@@ -160,7 +160,7 @@ public final class StandardBootstrapInitializerTest extends AbstractBootstrapIni
return privileges;
}
- private void assertAuthentication(final Authentication actual) {
+ private void assertAuthority(final ShardingSphereAuthority actual) {
Optional<ShardingSphereUser> rootUser = actual.findUser(new Grantee("root", ""));
assertTrue(rootUser.isPresent());
assertThat(rootUser.get().getPassword(), is("root"));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfigurationLoader.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfigurationLoader.java
index 5e37d78..4e601b5 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfigurationLoader.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfigurationLoader.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.config;
import com.google.common.base.Preconditions;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.authority.engine.AuthenticationEngine;
+import org.apache.shardingsphere.authority.engine.AuthorityEngine;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.proxy.config.yaml.YamlProxyRuleConfiguration;
import org.apache.shardingsphere.proxy.config.yaml.YamlProxyServerConfiguration;
@@ -73,7 +73,7 @@ public final class ProxyConfigurationLoader {
YamlProxyServerConfiguration result = YamlEngine.unmarshal(yamlFile, YamlProxyServerConfiguration.class);
Preconditions.checkNotNull(result, "Server configuration file `%s` is invalid.", yamlFile.getName());
Preconditions.checkState(
- AuthenticationEngine.findSPIAuthentication().isPresent() || null != result.getAuthentication() || null != result.getGovernance(), "Authority configuration is invalid.");
+ AuthorityEngine.findSPIAuthority().isPresent() || null != result.getAuthentication() || null != result.getGovernance(), "Authority configuration is invalid.");
return result;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/test/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/test/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java
index b6732d9..5a609ff 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/test/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-common/src/test/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapperTest.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceCente
import org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceConfiguration;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceParameter;
-import org.apache.shardingsphere.authority.engine.impl.DefaultAuthentication;
+import org.apache.shardingsphere.authority.engine.impl.DefaultAuthority;
import org.apache.shardingsphere.infra.metadata.user.yaml.config.YamlUserConfiguration;
import org.apache.shardingsphere.infra.metadata.user.yaml.config.YamlUsersConfiguration;
import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
@@ -58,7 +58,7 @@ public final class YamlProxyConfigurationSwapperTest {
public void assertSwap() {
YamlProxyConfiguration yamlProxyConfig = getYamlProxyConfiguration();
ProxyConfiguration proxyConfig = new YamlProxyConfigurationSwapper().swap(yamlProxyConfig);
- assertAuthentication(proxyConfig);
+ assertAuthority(proxyConfig);
assertProxyConfigurationProps(proxyConfig);
assertSchemaDataSources(proxyConfig);
assertSchemaRules(proxyConfig);
@@ -103,14 +103,14 @@ public final class YamlProxyConfigurationSwapperTest {
assertThat(proxyConfigurationProps.getProperty("key4"), is("value4"));
}
- private void assertAuthentication(final ProxyConfiguration proxyConfig) {
- DefaultAuthentication authentication = new DefaultAuthentication();
- authentication.init(getPrivileges(proxyConfig.getUsers()));
- assertNotNull(authentication);
- Optional<ShardingSphereUser> user = authentication.findUser(new Grantee("user1", ""));
+ private void assertAuthority(final ProxyConfiguration proxyConfig) {
+ DefaultAuthority authority = new DefaultAuthority();
+ authority.init(getPrivileges(proxyConfig.getUsers()));
+ assertNotNull(authority);
+ Optional<ShardingSphereUser> user = authority.findUser(new Grantee("user1", ""));
assertTrue(user.isPresent());
assertThat(user.get().getPassword(), is("pass"));
- assertNotNull(authentication);
+ assertNotNull(authority);
}
private Map<ShardingSphereUser, ShardingSpherePrivileges> getPrivileges(final Collection<ShardingSphereUser> users) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationHandlerTest.java
index d5fbf27..17ff97c 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationHandlerTest.java
@@ -28,7 +28,7 @@ import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataCon
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.authority.engine.impl.DefaultAuthentication;
+import org.apache.shardingsphere.authority.engine.impl.DefaultAuthority;
import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUsers;
@@ -81,28 +81,28 @@ public final class MySQLAuthenticationHandlerTest {
@Test
public void assertLoginWithPassword() {
- setAuthentication(new ShardingSphereUser("root", "root", ""));
+ setAuthority(new ShardingSphereUser("root", "root", ""));
byte[] authResponse = {-27, 89, -20, -27, 65, -120, -64, -101, 86, -100, -108, -100, 6, -125, -37, 117, 14, -43, 95, -113};
assertFalse(authenticationHandler.login("root", "", authResponse, "db1").isPresent());
}
@Test
public void assertLoginWithAbsentUser() {
- setAuthentication(new ShardingSphereUser("root", "root", ""));
+ setAuthority(new ShardingSphereUser("root", "root", ""));
byte[] authResponse = {-27, 89, -20, -27, 65, -120, -64, -101, 86, -100, -108, -100, 6, -125, -37, 117, 14, -43, 95, -113};
assertThat(authenticationHandler.login("root1", "", authResponse, "db1").orElse(null), is(MySQLServerErrorCode.ER_ACCESS_DENIED_ERROR));
}
@Test
public void assertLoginWithIncorrectPassword() {
- setAuthentication(new ShardingSphereUser("root", "root", ""));
+ setAuthority(new ShardingSphereUser("root", "root", ""));
byte[] authResponse = {0, 89, -20, -27, 65, -120, -64, -101, 86, -100, -108, -100, 6, -125, -37, 117, 14, -43, 95, -113};
assertThat(authenticationHandler.login("root", "", authResponse, "db1").orElse(null), is(MySQLServerErrorCode.ER_ACCESS_DENIED_ERROR));
}
@Test
public void assertLoginWithoutPassword() {
- setAuthentication(new ShardingSphereUser("root", null, ""));
+ setAuthority(new ShardingSphereUser("root", null, ""));
byte[] authResponse = {};
assertFalse(authenticationHandler.login("root", "", authResponse, "db1").isPresent());
}
@@ -121,11 +121,11 @@ public final class MySQLAuthenticationHandlerTest {
assertThat(authenticationHandler.getAuthPluginData().getAuthPluginData(), is(Bytes.concat(part1, part2)));
}
- private void setAuthentication(final ShardingSphereUser user) {
- DefaultAuthentication authentication = new DefaultAuthentication();
+ private void setAuthority(final ShardingSphereUser user) {
+ DefaultAuthority authority = new DefaultAuthority();
ShardingSpherePrivileges privileges = new ShardingSpherePrivileges();
privileges.setSuperPrivilege();
- authentication.getAuthentication().put(user, privileges);
+ authority.getAuthority().put(user, privileges);
initProxyContext(user);
}