You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2020/12/10 23:32:32 UTC
[shardingsphere] branch master updated: Add authentication SPI for
external authentication (#8566)
This is an automated email from the ASF dual-hosted git repository.
menghaoran 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 74a10c2 Add authentication SPI for external authentication (#8566)
74a10c2 is described below
commit 74a10c21f3c7d63c5dd4365b17873f6966ad0487
Author: Liang Zhang <te...@163.com>
AuthorDate: Fri Dec 11 07:32:04 2020 +0800
Add authentication SPI for external authentication (#8566)
* Rename ShardingSphereUser
* Add MemoryAuthentication
* Rename UserYamlSwapper
* Rename YamlUserConfiguration
* Add memory package
* Refactor usage of Authentication
* Add AuthenticationEngine
* Refactor StandardMetaDataContexts
* Rename DefaultAuthentication
* Resolve conflict
---
.../metadata/GovernanceMetaDataContexts.java | 2 +-
.../metadata/GovernanceMetaDataContextsTest.java | 6 ++---
.../governance/core/config/ConfigCenter.java | 14 +++++------
.../listener/AuthenticationChangedListener.java | 4 +--
.../model/auth/AuthenticationChangedEvent.java | 4 +--
.../governance/core/facade/GovernanceFacade.java | 4 +--
.../governance/core/config/ConfigCenterTest.java | 10 ++++----
.../core/facade/GovernanceFacadeTest.java | 4 +--
.../shardingsphere/infra/auth/Authentication.java | 15 ++---------
...thentication.java => AuthenticationEngine.java} | 29 +++++++++++-----------
.../DefaultAuthentication.java} | 17 +++++--------
.../config/YamlAuthenticationConfiguration.java | 4 +--
.../yaml/config/YamlUserConfiguration.java} | 6 ++---
.../yaml/swapper/AuthenticationYamlSwapper.java | 16 ++++++------
.../yaml/swapper/UserYamlSwapper.java} | 14 +++++------
.../config/YamlEngineUserConfigurationTest.java} | 8 +++---
.../swapper/AuthenticationYamlSwapperTest.java | 20 +++++++--------
.../yaml/swapper/UserYamlSwapperTest.java} | 16 ++++++------
.../context/metadata/MetaDataContextsBuilder.java | 5 ++--
.../metadata/impl/StandardMetaDataContexts.java | 15 ++++++++---
.../metadata/MetaDataContextsBuilderTest.java | 7 +++---
.../impl/StandardMetaDataContextsTest.java | 4 +--
.../GovernanceShardingSphereDataSource.java | 6 ++---
.../DatabaseCommunicationEngineFactoryTest.java | 4 +--
.../jdbc/connection/BackendConnectionTest.java | 4 +--
.../jdbc/datasource/JDBCBackendDataSourceTest.java | 4 +--
.../proxy/backend/context/ProxyContextTest.java | 12 ++++-----
.../impl/BroadcastDatabaseBackendHandlerTest.java | 4 +--
.../SchemaAssignedDatabaseBackendHandlerTest.java | 6 ++---
.../impl/UnicastDatabaseBackendHandlerTest.java | 6 ++---
.../text/metadata/rdl/RDLBackendHandlerTest.java | 4 +--
.../impl/ShowDatabasesBackendHandlerTest.java | 6 ++---
.../schema/impl/ShowTablesBackendHandlerTest.java | 6 ++---
.../schema/impl/UseDatabaseBackendHandlerTest.java | 6 ++---
.../ShardingCTLExplainBackendHandlerTest.java | 4 +--
.../hint/ShardingCTLHintBackendHandlerTest.java | 4 +--
.../sctl/set/ShardingCTLSetBackendHandlerTest.java | 4 +--
.../impl/GovernanceBootstrapInitializer.java | 10 ++++----
.../impl/GovernanceBootstrapInitializerTest.java | 4 +--
.../impl/StandardBootstrapInitializerTest.java | 14 +++++------
.../proxy/config/ProxyConfiguration.java | 4 +--
.../proxy/config/ProxyConfigurationLoader.java | 4 ++-
.../config/yaml/YamlProxyServerConfiguration.java | 2 +-
.../swapper/YamlProxyConfigurationSwapper.java | 6 ++---
.../swapper/YamlProxyConfigurationSwapperTest.java | 12 ++++-----
.../frontend/mysql/MySQLFrontendEngineTest.java | 8 +++---
.../mysql/auth/MySQLAuthenticationEngineTest.java | 4 +--
.../mysql/auth/MySQLAuthenticationHandlerTest.java | 8 +++---
.../command/MySQLCommandExecutorFactoryTest.java | 4 +--
.../execute/MySQLComStmtExecuteExecutorTest.java | 4 +--
.../auth/PostgreSQLAuthenticationEngineTest.java | 3 ++-
.../parse/PostgreSQLComParseExecutorTest.java | 4 +--
52 files changed, 197 insertions(+), 198 deletions(-)
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 a80b921..c56942c 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
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.governance.context.metadata;
import com.google.common.collect.Maps;
import com.google.common.eventbus.Subscribe;
-import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
import org.apache.shardingsphere.governance.core.event.model.auth.AuthenticationChangedEvent;
import org.apache.shardingsphere.governance.core.event.model.datasource.DataSourceChangeCompletedEvent;
import org.apache.shardingsphere.governance.core.event.model.datasource.DataSourceChangedEvent;
@@ -41,6 +40,7 @@ import org.apache.shardingsphere.infra.context.metadata.MetaDataContextsBuilder;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
+import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
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 9aeef51..e720253 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
@@ -30,7 +30,7 @@ import org.apache.shardingsphere.governance.core.lock.LockCenter;
import org.apache.shardingsphere.governance.core.registry.RegistryCenter;
import org.apache.shardingsphere.governance.core.registry.event.DisabledStateChangedEvent;
import org.apache.shardingsphere.governance.core.registry.schema.GovernanceSchema;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
@@ -75,7 +75,7 @@ import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public final class GovernanceMetaDataContextsTest {
- private final Authentication authentication = new Authentication();
+ private final DefaultAuthentication authentication = new DefaultAuthentication();
private final ConfigurationProperties props = new ConfigurationProperties(new Properties());
@@ -183,7 +183,7 @@ public final class GovernanceMetaDataContextsTest {
@Test
public void assertAuthenticationChanged() {
- Authentication authentication = new Authentication();
+ DefaultAuthentication authentication = new DefaultAuthentication();
AuthenticationChangedEvent event = new AuthenticationChangedEvent(authentication);
governanceMetaDataContexts.renew(event);
assertThat(governanceMetaDataContexts.getAuthentication(), is(authentication));
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java
index bfbf3e3..370a71c 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java
@@ -36,9 +36,9 @@ import org.apache.shardingsphere.governance.core.yaml.swapper.SchemaYamlSwapper;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.ha.api.config.HARuleConfiguration;
import org.apache.shardingsphere.ha.api.config.rule.HADataSourceRuleConfiguration;
-import org.apache.shardingsphere.infra.auth.Authentication;
-import org.apache.shardingsphere.infra.auth.yaml.config.YamlAuthenticationConfiguration;
-import org.apache.shardingsphere.infra.auth.yaml.swapper.AuthenticationYamlSwapper;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.config.YamlAuthenticationConfiguration;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.swapper.AuthenticationYamlSwapper;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
@@ -105,7 +105,7 @@ public final class ConfigCenter {
* @param props properties
* @param isOverwrite is overwrite config center's configuration
*/
- public void persistGlobalConfiguration(final Authentication authentication, final Properties props, final boolean isOverwrite) {
+ public void persistGlobalConfiguration(final DefaultAuthentication authentication, final Properties props, final boolean isOverwrite) {
persistAuthentication(authentication, isOverwrite);
persistProperties(props, isOverwrite);
}
@@ -265,7 +265,7 @@ public final class ConfigCenter {
return !config.getTables().isEmpty() || null != config.getDefaultTableShardingStrategy() || !config.getAutoTables().isEmpty();
}
- private void persistAuthentication(final Authentication authentication, final boolean isOverwrite) {
+ private void persistAuthentication(final DefaultAuthentication authentication, final boolean isOverwrite) {
if (null != authentication && (isOverwrite || !hasAuthentication())) {
repository.persist(node.getAuthenticationPath(), YamlEngine.marshal(new AuthenticationYamlSwapper().swapToYamlConfiguration(authentication)));
}
@@ -327,10 +327,10 @@ public final class ConfigCenter {
*
* @return authentication
*/
- public Authentication loadAuthentication() {
+ public DefaultAuthentication loadAuthentication() {
return hasAuthentication()
? new AuthenticationYamlSwapper().swapToObject(YamlEngine.unmarshal(repository.get(node.getAuthenticationPath()), YamlAuthenticationConfiguration.class))
- : new Authentication();
+ : new DefaultAuthentication();
}
/**
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/config/listener/AuthenticationChangedListener.java b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/config/listener/AuthenticationChangedListener.java
index b6087cf..464552e 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/config/listener/AuthenticationChangedListener.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/config/listener/AuthenticationChangedListener.java
@@ -23,8 +23,8 @@ import org.apache.shardingsphere.governance.core.event.model.GovernanceEvent;
import org.apache.shardingsphere.governance.core.event.model.auth.AuthenticationChangedEvent;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.governance.repository.api.listener.DataChangedEvent;
-import org.apache.shardingsphere.infra.auth.yaml.config.YamlAuthenticationConfiguration;
-import org.apache.shardingsphere.infra.auth.yaml.swapper.AuthenticationYamlSwapper;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.config.YamlAuthenticationConfiguration;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.swapper.AuthenticationYamlSwapper;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import java.util.Collections;
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/event/model/auth/AuthenticationChangedEvent.java b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/event/model/auth/AuthenticationChangedEvent.java
index 8a56bef..3ed0033 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/event/model/auth/AuthenticationChangedEvent.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/event/model/auth/AuthenticationChangedEvent.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.governance.core.event.model.auth;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.governance.core.event.model.GovernanceEvent;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
/**
* Authentication changed event.
@@ -29,5 +29,5 @@ import org.apache.shardingsphere.infra.auth.Authentication;
@Getter
public final class AuthenticationChangedEvent implements GovernanceEvent {
- private final Authentication authentication;
+ private final DefaultAuthentication authentication;
}
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/facade/GovernanceFacade.java b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/facade/GovernanceFacade.java
index 67b5d19..fb15eb4 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/facade/GovernanceFacade.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/facade/GovernanceFacade.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.governance.core.lock.LockCenter;
import org.apache.shardingsphere.governance.core.registry.RegistryCenter;
import org.apache.shardingsphere.governance.core.state.GovernedStateContext;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
@@ -80,7 +80,7 @@ public final class GovernanceFacade implements AutoCloseable {
* @param props properties
*/
public void onlineInstance(final Map<String, Map<String, DataSourceConfiguration>> dataSourceConfigMap,
- final Map<String, Collection<RuleConfiguration>> schemaRuleMap, final Authentication authentication, final Properties props) {
+ final Map<String, Collection<RuleConfiguration>> schemaRuleMap, final DefaultAuthentication authentication, final Properties props) {
configCenter.persistGlobalConfiguration(authentication, props, isOverwrite);
for (Entry<String, Map<String, DataSourceConfiguration>> entry : dataSourceConfigMap.entrySet()) {
configCenter.persistConfigurations(entry.getKey(), dataSourceConfigMap.get(entry.getKey()), schemaRuleMap.get(entry.getKey()), isOverwrite);
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/config/ConfigCenterTest.java b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/config/ConfigCenterTest.java
index 86848be..de83ce2 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/config/ConfigCenterTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/config/ConfigCenterTest.java
@@ -27,10 +27,10 @@ import org.apache.shardingsphere.governance.core.yaml.config.schema.YamlSchema;
import org.apache.shardingsphere.governance.core.yaml.swapper.SchemaYamlSwapper;
import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
import org.apache.shardingsphere.ha.api.config.HARuleConfiguration;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.auth.ShardingSphereUser;
-import org.apache.shardingsphere.infra.auth.yaml.config.YamlAuthenticationConfiguration;
-import org.apache.shardingsphere.infra.auth.yaml.swapper.AuthenticationYamlSwapper;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.config.YamlAuthenticationConfiguration;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.swapper.AuthenticationYamlSwapper;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
@@ -302,7 +302,7 @@ public final class ConfigCenterTest {
return new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(SHADOW_RULE_YAML), YamlRootRuleConfigurations.class).getRules());
}
- private Authentication createAuthentication() {
+ private DefaultAuthentication createAuthentication() {
return new AuthenticationYamlSwapper().swapToObject(YamlEngine.unmarshal(readYAML(AUTHENTICATION_YAML), YamlAuthenticationConfiguration.class));
}
@@ -419,7 +419,7 @@ public final class ConfigCenterTest {
public void assertLoadAuthentication() {
when(configurationRepository.get("/authentication")).thenReturn(readYAML(AUTHENTICATION_YAML));
ConfigCenter configCenter = new ConfigCenter(configurationRepository);
- Authentication actual = configCenter.loadAuthentication();
+ DefaultAuthentication actual = configCenter.loadAuthentication();
Optional<ShardingSphereUser> user = actual.findUser("root1");
assertTrue(user.isPresent());
assertThat(user.get().getPassword(), is("root1"));
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 d284cd7..ae83e3a 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.facade.util.FieldUtil;
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.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.auth.ShardingSphereUser;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
@@ -75,7 +75,7 @@ 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", Collections.singleton("db1"));
- Authentication authentication = new Authentication();
+ DefaultAuthentication authentication = new DefaultAuthentication();
authentication.getUsers().put("root", user);
Properties props = new Properties();
governanceFacade.onlineInstance(Collections.singletonMap("sharding_db", dataSourceConfigMap), ruleConfigurationMap, authentication, props);
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/Authentication.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/Authentication.java
index 2e26734..30fc63a 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/Authentication.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/Authentication.java
@@ -17,21 +17,12 @@
package org.apache.shardingsphere.infra.auth;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
import java.util.Optional;
/**
* Authentication.
*/
-@RequiredArgsConstructor
-@Getter
-public final class Authentication {
-
- private final Map<String, ShardingSphereUser> users = new LinkedHashMap<>();
+public interface Authentication {
/**
* Find user.
@@ -39,7 +30,5 @@ public final class Authentication {
* @param username username
* @return found user
*/
- public Optional<ShardingSphereUser> findUser(final String username) {
- return Optional.ofNullable(users.get(username));
- }
+ Optional<ShardingSphereUser> findUser(String username);
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/Authentication.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/AuthenticationEngine.java
similarity index 55%
copy from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/Authentication.java
copy to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/AuthenticationEngine.java
index 2e26734..5e69d50 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/Authentication.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/AuthenticationEngine.java
@@ -17,29 +17,30 @@
package org.apache.shardingsphere.infra.auth;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
-import java.util.LinkedHashMap;
-import java.util.Map;
+import java.util.Collection;
import java.util.Optional;
/**
- * Authentication.
+ * Authentication engine.
*/
-@RequiredArgsConstructor
-@Getter
-public final class Authentication {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class AuthenticationEngine {
- private final Map<String, ShardingSphereUser> users = new LinkedHashMap<>();
+ static {
+ ShardingSphereServiceLoader.register(Authentication.class);
+ }
/**
- * Find user.
+ * Find SPI authentication.
*
- * @param username username
- * @return found user
+ * @return authentication
*/
- public Optional<ShardingSphereUser> findUser(final String username) {
- return Optional.ofNullable(users.get(username));
+ public static Optional<Authentication> findSPIAuthentication() {
+ Collection<Authentication> authentications = ShardingSphereServiceLoader.newServiceInstances(Authentication.class);
+ return authentications.isEmpty() ? Optional.empty() : Optional.of(authentications.iterator().next());
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/Authentication.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/builtin/DefaultAuthentication.java
similarity index 80%
copy from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/Authentication.java
copy to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/builtin/DefaultAuthentication.java
index 2e26734..4998028 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/Authentication.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/builtin/DefaultAuthentication.java
@@ -15,30 +15,25 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.auth;
+package org.apache.shardingsphere.infra.auth.builtin;
import lombok.Getter;
-import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.ShardingSphereUser;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
/**
- * Authentication.
+ * Default authentication.
*/
-@RequiredArgsConstructor
@Getter
-public final class Authentication {
+public final class DefaultAuthentication implements Authentication {
private final Map<String, ShardingSphereUser> users = new LinkedHashMap<>();
- /**
- * Find user.
- *
- * @param username username
- * @return found user
- */
+ @Override
public Optional<ShardingSphereUser> findUser(final String username) {
return Optional.ofNullable(users.get(username));
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/yaml/config/YamlAuthenticationConfiguration.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/builtin/yaml/config/YamlAuthenticationConfiguration.java
similarity index 89%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/yaml/config/YamlAuthenticationConfiguration.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/builtin/yaml/config/YamlAuthenticationConfiguration.java
index 2d18554..ddd1c78 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/yaml/config/YamlAuthenticationConfiguration.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/builtin/yaml/config/YamlAuthenticationConfiguration.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.auth.yaml.config;
+package org.apache.shardingsphere.infra.auth.builtin.yaml.config;
import lombok.Getter;
import lombok.Setter;
@@ -30,5 +30,5 @@ import java.util.Map;
@Setter
public final class YamlAuthenticationConfiguration implements YamlConfiguration {
- private Map<String, YamlShardingSphereUserConfiguration> users;
+ private Map<String, YamlUserConfiguration> users;
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/yaml/config/YamlShardingSphereUserConfiguration.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/builtin/yaml/config/YamlUserConfiguration.java
similarity index 85%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/yaml/config/YamlShardingSphereUserConfiguration.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/builtin/yaml/config/YamlUserConfiguration.java
index cf794e8..ed8c8aa 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/yaml/config/YamlShardingSphereUserConfiguration.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/builtin/yaml/config/YamlUserConfiguration.java
@@ -15,18 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.auth.yaml.config;
+package org.apache.shardingsphere.infra.auth.builtin.yaml.config;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.infra.yaml.config.YamlConfiguration;
/**
- * ShardingSphere user for YAML.
+ * User for YAML.
*/
@Getter
@Setter
-public final class YamlShardingSphereUserConfiguration implements YamlConfiguration {
+public final class YamlUserConfiguration implements YamlConfiguration {
private String password;
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/yaml/swapper/AuthenticationYamlSwapper.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/builtin/yaml/swapper/AuthenticationYamlSwapper.java
similarity index 72%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/yaml/swapper/AuthenticationYamlSwapper.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/builtin/yaml/swapper/AuthenticationYamlSwapper.java
index fb35205..f660287 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/yaml/swapper/AuthenticationYamlSwapper.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/builtin/yaml/swapper/AuthenticationYamlSwapper.java
@@ -15,30 +15,30 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.auth.yaml.swapper;
+package org.apache.shardingsphere.infra.auth.builtin.yaml.swapper;
import com.google.common.collect.Maps;
-import org.apache.shardingsphere.infra.auth.Authentication;
-import org.apache.shardingsphere.infra.auth.yaml.config.YamlAuthenticationConfiguration;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.config.YamlAuthenticationConfiguration;
import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
/**
* Authentication YAML swapper.
*/
-public final class AuthenticationYamlSwapper implements YamlSwapper<YamlAuthenticationConfiguration, Authentication> {
+public final class AuthenticationYamlSwapper implements YamlSwapper<YamlAuthenticationConfiguration, DefaultAuthentication> {
- private final ShardingSphereUserYamlSwapper userYamlSwapper = new ShardingSphereUserYamlSwapper();
+ private final UserYamlSwapper userYamlSwapper = new UserYamlSwapper();
@Override
- public YamlAuthenticationConfiguration swapToYamlConfiguration(final Authentication data) {
+ public YamlAuthenticationConfiguration swapToYamlConfiguration(final DefaultAuthentication data) {
YamlAuthenticationConfiguration result = new YamlAuthenticationConfiguration();
result.setUsers(Maps.transformValues(data.getUsers(), userYamlSwapper::swapToYamlConfiguration));
return result;
}
@Override
- public Authentication swapToObject(final YamlAuthenticationConfiguration yamlConfig) {
- Authentication result = new Authentication();
+ public DefaultAuthentication swapToObject(final YamlAuthenticationConfiguration yamlConfig) {
+ DefaultAuthentication result = new DefaultAuthentication();
if (null == yamlConfig) {
return result;
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/yaml/swapper/ShardingSphereUserYamlSwapper.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/builtin/yaml/swapper/UserYamlSwapper.java
similarity index 73%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/yaml/swapper/ShardingSphereUserYamlSwapper.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/builtin/yaml/swapper/UserYamlSwapper.java
index e369e8a..a87befe 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/yaml/swapper/ShardingSphereUserYamlSwapper.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/auth/builtin/yaml/swapper/UserYamlSwapper.java
@@ -15,25 +15,25 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.auth.yaml.swapper;
+package org.apache.shardingsphere.infra.auth.builtin.yaml.swapper;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.auth.ShardingSphereUser;
-import org.apache.shardingsphere.infra.auth.yaml.config.YamlShardingSphereUserConfiguration;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.config.YamlUserConfiguration;
import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
import java.util.Collections;
/**
- * ShardingSphere user YAML swapper.
+ * User YAML swapper.
*/
-public final class ShardingSphereUserYamlSwapper implements YamlSwapper<YamlShardingSphereUserConfiguration, ShardingSphereUser> {
+public final class UserYamlSwapper implements YamlSwapper<YamlUserConfiguration, ShardingSphereUser> {
@Override
- public YamlShardingSphereUserConfiguration swapToYamlConfiguration(final ShardingSphereUser data) {
- YamlShardingSphereUserConfiguration result = new YamlShardingSphereUserConfiguration();
+ public YamlUserConfiguration swapToYamlConfiguration(final ShardingSphereUser data) {
+ YamlUserConfiguration result = new YamlUserConfiguration();
result.setPassword(data.getPassword());
String authorizedSchemas = null == data.getAuthorizedSchemas() ? "" : Joiner.on(',').join(data.getAuthorizedSchemas());
result.setAuthorizedSchemas(authorizedSchemas);
@@ -41,7 +41,7 @@ public final class ShardingSphereUserYamlSwapper implements YamlSwapper<YamlShar
}
@Override
- public ShardingSphereUser swapToObject(final YamlShardingSphereUserConfiguration yamlConfig) {
+ public ShardingSphereUser swapToObject(final YamlUserConfiguration yamlConfig) {
if (Strings.isNullOrEmpty(yamlConfig.getAuthorizedSchemas())) {
return new ShardingSphereUser(yamlConfig.getPassword(), Collections.emptyList());
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/auth/yaml/config/YamlEngineShardingSphereUserConfigurationTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/auth/builtin/yaml/config/YamlEngineUserConfigurationTest.java
similarity index 85%
rename from shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/auth/yaml/config/YamlEngineShardingSphereUserConfigurationTest.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/auth/builtin/yaml/config/YamlEngineUserConfigurationTest.java
index 4d952c6..11adc45 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/auth/yaml/config/YamlEngineShardingSphereUserConfigurationTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/auth/builtin/yaml/config/YamlEngineUserConfigurationTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.auth.yaml.config;
+package org.apache.shardingsphere.infra.auth.builtin.yaml.config;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.junit.Test;
@@ -27,11 +27,11 @@ import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public final class YamlEngineShardingSphereUserConfigurationTest {
+public final class YamlEngineUserConfigurationTest {
@Test
public void assertUnmarshal() {
- YamlShardingSphereUserConfiguration actual = YamlEngine.unmarshal("password: pwd\nauthorizedSchemas: db1", YamlShardingSphereUserConfiguration.class);
+ YamlUserConfiguration actual = YamlEngine.unmarshal("password: pwd\nauthorizedSchemas: db1", YamlUserConfiguration.class);
assertThat(actual.getPassword(), is("pwd"));
assertThat(actual.getAuthorizedSchemas(), is("db1"));
}
@@ -53,7 +53,7 @@ public final class YamlEngineShardingSphereUserConfigurationTest {
@Test
public void assertMarshal() {
- YamlShardingSphereUserConfiguration actual = new YamlShardingSphereUserConfiguration();
+ YamlUserConfiguration actual = new YamlUserConfiguration();
actual.setPassword("pwd");
actual.setAuthorizedSchemas("db1");
assertThat(YamlEngine.marshal(actual), is("authorizedSchemas: db1\npassword: pwd\n"));
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/auth/yaml/swapper/AuthenticationYamlSwapperTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/auth/builtin/yaml/swapper/AuthenticationYamlSwapperTest.java
similarity index 78%
rename from shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/auth/yaml/swapper/AuthenticationYamlSwapperTest.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/auth/builtin/yaml/swapper/AuthenticationYamlSwapperTest.java
index 13f48d3..109dea3 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/auth/yaml/swapper/AuthenticationYamlSwapperTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/auth/builtin/yaml/swapper/AuthenticationYamlSwapperTest.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.auth.yaml.swapper;
+package org.apache.shardingsphere.infra.auth.builtin.yaml.swapper;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.auth.ShardingSphereUser;
-import org.apache.shardingsphere.infra.auth.yaml.config.YamlAuthenticationConfiguration;
-import org.apache.shardingsphere.infra.auth.yaml.config.YamlShardingSphereUserConfiguration;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.config.YamlAuthenticationConfiguration;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.config.YamlUserConfiguration;
import org.junit.Test;
import java.util.Collections;
@@ -36,7 +36,7 @@ public final class AuthenticationYamlSwapperTest {
@Test
public void assertSwapToYaml() {
- Authentication authentication = new Authentication();
+ DefaultAuthentication authentication = new DefaultAuthentication();
authentication.getUsers().put("user1", new ShardingSphereUser("pwd1", Collections.singleton("db1")));
authentication.getUsers().put("user2", new ShardingSphereUser("pwd2", Collections.singleton("db2")));
YamlAuthenticationConfiguration actual = new AuthenticationYamlSwapper().swapToYamlConfiguration(authentication);
@@ -49,18 +49,18 @@ public final class AuthenticationYamlSwapperTest {
@Test
public void assertSwapToObject() {
- YamlShardingSphereUserConfiguration user1 = new YamlShardingSphereUserConfiguration();
+ YamlUserConfiguration user1 = new YamlUserConfiguration();
user1.setPassword("pwd1");
user1.setAuthorizedSchemas("db1");
- YamlShardingSphereUserConfiguration user2 = new YamlShardingSphereUserConfiguration();
+ YamlUserConfiguration user2 = new YamlUserConfiguration();
user2.setPassword("pwd2");
user2.setAuthorizedSchemas("db2,db1");
- Map<String, YamlShardingSphereUserConfiguration> users = new HashMap<>(2, 1);
+ Map<String, YamlUserConfiguration> users = new HashMap<>(2, 1);
users.put("user1", user1);
users.put("user2", user2);
YamlAuthenticationConfiguration yamlConfig = new YamlAuthenticationConfiguration();
yamlConfig.setUsers(users);
- Authentication actual = new AuthenticationYamlSwapper().swapToObject(yamlConfig);
+ DefaultAuthentication actual = new AuthenticationYamlSwapper().swapToObject(yamlConfig);
Optional<ShardingSphereUser> actualUser1 = actual.findUser("user1");
assertTrue(actualUser1.isPresent());
assertThat(actualUser1.get().getAuthorizedSchemas().size(), is(1));
@@ -71,7 +71,7 @@ public final class AuthenticationYamlSwapperTest {
@Test
public void assertSwapToObjectForNull() {
- Authentication actual = new AuthenticationYamlSwapper().swapToObject(null);
+ DefaultAuthentication actual = new AuthenticationYamlSwapper().swapToObject(null);
assertTrue(actual.getUsers().isEmpty());
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/auth/yaml/swapper/ShardingSphereUserYamlSwapperTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/auth/builtin/yaml/swapper/UserYamlSwapperTest.java
similarity index 67%
rename from shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/auth/yaml/swapper/ShardingSphereUserYamlSwapperTest.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/auth/builtin/yaml/swapper/UserYamlSwapperTest.java
index db20593..d4f414e 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/auth/yaml/swapper/ShardingSphereUserYamlSwapperTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/auth/builtin/yaml/swapper/UserYamlSwapperTest.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.auth.yaml.swapper;
+package org.apache.shardingsphere.infra.auth.builtin.yaml.swapper;
import org.apache.shardingsphere.infra.auth.ShardingSphereUser;
-import org.apache.shardingsphere.infra.auth.yaml.config.YamlShardingSphereUserConfiguration;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.config.YamlUserConfiguration;
import org.junit.Test;
import java.util.Collections;
@@ -26,30 +26,30 @@ import java.util.Collections;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-public final class ShardingSphereUserYamlSwapperTest {
+public final class UserYamlSwapperTest {
@Test
public void assertSwapToYaml() {
- YamlShardingSphereUserConfiguration actual = new ShardingSphereUserYamlSwapper().swapToYamlConfiguration(new ShardingSphereUser("pwd", Collections.singleton("db1")));
+ YamlUserConfiguration actual = new UserYamlSwapper().swapToYamlConfiguration(new ShardingSphereUser("pwd", Collections.singleton("db1")));
assertThat(actual.getAuthorizedSchemas(), is("db1"));
assertThat(actual.getPassword(), is("pwd"));
}
@Test
public void assertSwapToObject() {
- YamlShardingSphereUserConfiguration yamlUserConfig = new YamlShardingSphereUserConfiguration();
+ YamlUserConfiguration yamlUserConfig = new YamlUserConfiguration();
yamlUserConfig.setAuthorizedSchemas("db1");
yamlUserConfig.setPassword("pwd");
- ShardingSphereUser actual = new ShardingSphereUserYamlSwapper().swapToObject(yamlUserConfig);
+ ShardingSphereUser actual = new UserYamlSwapper().swapToObject(yamlUserConfig);
assertThat(actual.getAuthorizedSchemas().iterator().next(), is("db1"));
assertThat(actual.getPassword(), is("pwd"));
}
@Test
public void assertSwapToObjectWithoutAuthorizedSchemas() {
- YamlShardingSphereUserConfiguration yamlUserConfig = new YamlShardingSphereUserConfiguration();
+ YamlUserConfiguration yamlUserConfig = new YamlUserConfiguration();
yamlUserConfig.setPassword("pwd");
- ShardingSphereUser actual = new ShardingSphereUserYamlSwapper().swapToObject(yamlUserConfig);
+ ShardingSphereUser actual = new UserYamlSwapper().swapToObject(yamlUserConfig);
assertThat(actual.getAuthorizedSchemas().size(), is(0));
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilder.java b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilder.java
index f2fb9ab..a62a819 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilder.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.infra.context.metadata;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.config.DatabaseAccessConfiguration;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
@@ -31,8 +32,8 @@ import org.apache.shardingsphere.infra.metadata.resource.CachedDatabaseMetaData;
import org.apache.shardingsphere.infra.metadata.resource.DataSourcesMetaData;
import org.apache.shardingsphere.infra.metadata.resource.ShardingSphereResource;
import org.apache.shardingsphere.infra.metadata.rule.ShardingSphereRuleMetaData;
-import org.apache.shardingsphere.infra.metadata.schema.builder.SchemaBuilder;
import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
+import org.apache.shardingsphere.infra.metadata.schema.builder.SchemaBuilder;
import org.apache.shardingsphere.infra.metadata.schema.builder.SchemaBuilderMaterials;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.rule.builder.ShardingSphereRulesBuilder;
@@ -68,7 +69,7 @@ public final class MetaDataContextsBuilder {
public MetaDataContextsBuilder(final DatabaseType databaseType, final Map<String, Map<String, DataSource>> dataSources,
final Map<String, Collection<RuleConfiguration>> ruleConfigs, final Properties props) {
- this(databaseType, dataSources, ruleConfigs, new Authentication(), props);
+ this(databaseType, dataSources, ruleConfigs, new DefaultAuthentication(), props);
}
public MetaDataContextsBuilder(final DatabaseType databaseType, final Map<String, Map<String, DataSource>> dataSources,
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/impl/StandardMetaDataContexts.java b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/impl/StandardMetaDataContexts.java
index 024f2d4..82acaf6 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/impl/StandardMetaDataContexts.java
+++ b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/impl/StandardMetaDataContexts.java
@@ -18,8 +18,9 @@
package org.apache.shardingsphere.infra.context.metadata.impl;
import lombok.Getter;
-import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.AuthenticationEngine;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
import org.apache.shardingsphere.infra.database.DefaultSchema;
@@ -35,7 +36,6 @@ import java.util.Properties;
/**
* Standard meta data contexts.
*/
-@RequiredArgsConstructor
@Getter
public final class StandardMetaDataContexts implements MetaDataContexts {
@@ -51,7 +51,16 @@ public final class StandardMetaDataContexts implements MetaDataContexts {
public StandardMetaDataContexts() {
// TODO MySQLDatabaseType is invalid because it can not update again
- this(new HashMap<>(), null, new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType());
+ this(new HashMap<>(), null, new DefaultAuthentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType());
+ }
+
+ public StandardMetaDataContexts(final Map<String, ShardingSphereMetaData> metaDataMap,
+ final ExecutorEngine executorEngine, final Authentication authentication, final ConfigurationProperties props, final DatabaseType databaseType) {
+ this.metaDataMap = metaDataMap;
+ this.executorEngine = executorEngine;
+ this.authentication = AuthenticationEngine.findSPIAuthentication().orElse(authentication);
+ this.props = props;
+ this.databaseType = databaseType;
}
@Override
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilderTest.java b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilderTest.java
index 89525de..7f17ee0 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilderTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilderTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.infra.context.metadata;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.context.fixture.FixtureRule;
import org.apache.shardingsphere.infra.context.fixture.FixtureRuleConfiguration;
@@ -44,7 +45,7 @@ public final class MetaDataContextsBuilderTest {
MetaDataContexts actual = new MetaDataContextsBuilder(databaseType, Collections.emptyMap(), Collections.emptyMap(), null).build();
assertThat(actual.getDatabaseType(), CoreMatchers.is(databaseType));
assertTrue(actual.getMetaDataMap().isEmpty());
- assertTrue(actual.getAuthentication().getUsers().isEmpty());
+ assertTrue(((DefaultAuthentication) actual.getAuthentication()).getUsers().isEmpty());
assertTrue(actual.getProps().getProps().isEmpty());
}
@@ -58,7 +59,7 @@ public final class MetaDataContextsBuilderTest {
assertThat(actual.getDatabaseType(), CoreMatchers.is(databaseType));
assertRules(actual);
assertTrue(actual.getMetaDataMap().get("logic_db").getResource().getDataSources().isEmpty());
- assertTrue(actual.getAuthentication().getUsers().isEmpty());
+ assertTrue(((DefaultAuthentication) actual.getAuthentication()).getUsers().isEmpty());
assertThat(actual.getProps().getProps().size(), CoreMatchers.is(1));
assertThat(actual.getProps().getValue(ConfigurationPropertyKey.EXECUTOR_SIZE), CoreMatchers.is(1));
}
@@ -73,7 +74,7 @@ public final class MetaDataContextsBuilderTest {
assertThat(actual.getDatabaseType(), CoreMatchers.is(databaseType));
assertRules(actual);
assertDataSources(actual);
- assertTrue(actual.getAuthentication().getUsers().isEmpty());
+ assertTrue(((DefaultAuthentication) actual.getAuthentication()).getUsers().isEmpty());
assertThat(actual.getProps().getProps().size(), CoreMatchers.is(1));
assertThat(actual.getProps().getValue(ConfigurationPropertyKey.EXECUTOR_SIZE), CoreMatchers.is(1));
}
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/metadata/impl/StandardMetaDataContextsTest.java b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/metadata/impl/StandardMetaDataContextsTest.java
index 7bedb28..7c7baa3 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/metadata/impl/StandardMetaDataContextsTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/metadata/impl/StandardMetaDataContextsTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.infra.context.metadata.impl;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine;
@@ -47,7 +47,7 @@ public final class StandardMetaDataContextsTest {
ExecutorEngine executorEngine = mock(ExecutorEngine.class);
ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class);
StandardMetaDataContexts standardMetaDataContexts = new StandardMetaDataContexts(Collections.singletonMap("logic_db", metaData),
- executorEngine, new Authentication(), new ConfigurationProperties(new Properties()), DatabaseTypeRegistry.getTrunkDatabaseType("SQL92"));
+ executorEngine, new DefaultAuthentication(), new ConfigurationProperties(new Properties()), DatabaseTypeRegistry.getTrunkDatabaseType("SQL92"));
standardMetaDataContexts.close();
verify(executorEngine).close();
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSource.java b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSource.java
index 150c78d..8483b8f 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSource.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-governance/src/main/java/org/apache/shardingsphere/driver/governance/internal/datasource/GovernanceShardingSphereDataSource.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.governance.context.metadata.GovernanceMetaDataC
import org.apache.shardingsphere.governance.core.config.ConfigCenter;
import org.apache.shardingsphere.governance.core.facade.GovernanceFacade;
import org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConverter;
@@ -85,13 +85,13 @@ public final class GovernanceShardingSphereDataSource extends AbstractUnsupporte
Collection<RuleConfiguration> ruleConfigurations = configCenter.loadRuleConfigurations(DefaultSchema.LOGIC_NAME);
Map<String, DataSource> dataSourceMap = DataSourceConverter.getDataSourceMap(dataSourceConfigs);
MetaDataContextsBuilder metaDataContextsBuilder = new MetaDataContextsBuilder(createDatabaseType(dataSourceMap), Collections.singletonMap(DefaultSchema.LOGIC_NAME, dataSourceMap),
- Collections.singletonMap(DefaultSchema.LOGIC_NAME, ruleConfigurations), new Authentication(), configCenter.loadProperties());
+ Collections.singletonMap(DefaultSchema.LOGIC_NAME, ruleConfigurations), new DefaultAuthentication(), configCenter.loadProperties());
return metaDataContextsBuilder.build();
}
private MetaDataContexts createMetaDataContexts(final Map<String, DataSource> dataSourceMap, final Collection<RuleConfiguration> ruleConfigs, final Properties props) throws SQLException {
MetaDataContextsBuilder metaDataContextsBuilder = new MetaDataContextsBuilder(createDatabaseType(dataSourceMap), Collections.singletonMap(DefaultSchema.LOGIC_NAME, dataSourceMap),
- Collections.singletonMap(DefaultSchema.LOGIC_NAME, ruleConfigs), new Authentication(), props);
+ Collections.singletonMap(DefaultSchema.LOGIC_NAME, ruleConfigs), new DefaultAuthentication(), props);
return metaDataContextsBuilder.build();
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java
index 9acfbbd..b50175a 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngineFactoryTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.proxy.backend.communication;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
@@ -48,7 +48,7 @@ public final class DatabaseCommunicationEngineFactoryTest {
Field metaDataContexts = ProxyContext.getInstance().getClass().getDeclaredField("metaDataContexts");
metaDataContexts.setAccessible(true);
metaDataContexts.set(ProxyContext.getInstance(),
- new StandardMetaDataContexts(getMetaDataMap(), mock(ExecutorEngine.class), new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
+ new StandardMetaDataContexts(getMetaDataMap(), mock(ExecutorEngine.class), new DefaultAuthentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
BackendConnection backendConnection = mock(BackendConnection.class, RETURNS_DEEP_STUBS);
when(backendConnection.getSchemaName()).thenReturn("schema");
when(backendConnection.isSerialExecute()).thenReturn(true);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java
index 98dc0e4..4fe091d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.backend.communication.jdbc.connection;
import com.google.common.collect.Multimap;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
@@ -101,7 +101,7 @@ public final class BackendConnectionTest {
Field field = ProxyContext.getInstance().getClass().getDeclaredField("metaDataContexts");
field.setAccessible(true);
field.set(ProxyContext.getInstance(),
- new StandardMetaDataContexts(createMetaDataMap(), mock(ExecutorEngine.class), new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
+ new StandardMetaDataContexts(createMetaDataMap(), mock(ExecutorEngine.class), new DefaultAuthentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
}
private Map<String, ShardingSphereMetaData> createMetaDataMap() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSourceTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSourceTest.java
index ab0e8ef..57e8876 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSourceTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSourceTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.backend.communication.jdbc.datasource;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
@@ -74,7 +74,7 @@ public final class JDBCBackendDataSourceTest {
Field metaDataContexts = ProxyContext.getInstance().getClass().getDeclaredField("metaDataContexts");
metaDataContexts.setAccessible(true);
metaDataContexts.set(ProxyContext.getInstance(),
- new StandardMetaDataContexts(createMetaDataMap(), mock(ExecutorEngine.class), new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
+ new StandardMetaDataContexts(createMetaDataMap(), mock(ExecutorEngine.class), new DefaultAuthentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
}
private Map<String, ShardingSphereMetaData> createMetaDataMap() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/ProxyContextTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/ProxyContextTest.java
index 8e27737..b996196 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/ProxyContextTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/ProxyContextTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.proxy.backend.context;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
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;
@@ -61,7 +61,7 @@ public final class ProxyContextTest {
Field metaDataContexts = ProxyContext.getInstance().getClass().getDeclaredField("metaDataContexts");
metaDataContexts.setAccessible(true);
metaDataContexts.set(ProxyContext.getInstance(), new StandardMetaDataContexts(mockMetaDataMap(mockDataSourceMap),
- mock(ExecutorEngine.class), new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
+ mock(ExecutorEngine.class), new DefaultAuthentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
Optional<DataSource> actual = ProxyContext.getInstance().getDataSourceSample();
assertThat(actual, is(Optional.of(mockDataSourceMap.get("ds_1"))));
}
@@ -82,7 +82,7 @@ public final class ProxyContextTest {
Field metaDataContexts = ProxyContext.getInstance().getClass().getDeclaredField("metaDataContexts");
metaDataContexts.setAccessible(true);
metaDataContexts.set(ProxyContext.getInstance(),
- new StandardMetaDataContexts(metaDataMap, mock(ExecutorEngine.class), new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
+ new StandardMetaDataContexts(metaDataMap, mock(ExecutorEngine.class), new DefaultAuthentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
assertTrue(ProxyContext.getInstance().schemaExists("schema"));
assertFalse(ProxyContext.getInstance().schemaExists("schema_2"));
}
@@ -103,7 +103,7 @@ public final class ProxyContextTest {
Field metaDataContexts = ProxyContext.getInstance().getClass().getDeclaredField("metaDataContexts");
metaDataContexts.setAccessible(true);
metaDataContexts.set(ProxyContext.getInstance(),
- new StandardMetaDataContexts(metaDataMap, mock(ExecutorEngine.class), new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
+ new StandardMetaDataContexts(metaDataMap, mock(ExecutorEngine.class), new DefaultAuthentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
ProxyContext.getInstance().getMetaData("schema1");
}
@@ -113,7 +113,7 @@ public final class ProxyContextTest {
Field metaDataContexts = ProxyContext.getInstance().getClass().getDeclaredField("metaDataContexts");
metaDataContexts.setAccessible(true);
metaDataContexts.set(ProxyContext.getInstance(),
- new StandardMetaDataContexts(metaDataMap, mock(ExecutorEngine.class), new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
+ new StandardMetaDataContexts(metaDataMap, mock(ExecutorEngine.class), new DefaultAuthentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
assertThat(metaDataMap.get("schema"), is(ProxyContext.getInstance().getMetaData("schema")));
}
@@ -123,7 +123,7 @@ public final class ProxyContextTest {
Field metaDataContexts = ProxyContext.getInstance().getClass().getDeclaredField("metaDataContexts");
metaDataContexts.setAccessible(true);
metaDataContexts.set(ProxyContext.getInstance(),
- new StandardMetaDataContexts(metaDataMap, mock(ExecutorEngine.class), new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
+ new StandardMetaDataContexts(metaDataMap, mock(ExecutorEngine.class), new DefaultAuthentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
assertThat(new LinkedHashSet<>(ProxyContext.getInstance().getAllSchemaNames()), is(metaDataMap.keySet()));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/BroadcastDatabaseBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/BroadcastDatabaseBackendHandlerTest.java
index 30368c1..427005a 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/BroadcastDatabaseBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/BroadcastDatabaseBackendHandlerTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.backend.text.data.impl;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
@@ -73,7 +73,7 @@ public final class BroadcastDatabaseBackendHandlerTest {
Field metaDataContexts = ProxyContext.getInstance().getClass().getDeclaredField("metaDataContexts");
metaDataContexts.setAccessible(true);
metaDataContexts.set(ProxyContext.getInstance(),
- new StandardMetaDataContexts(getMetaDataMap(), mock(ExecutorEngine.class), new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
+ new StandardMetaDataContexts(getMetaDataMap(), mock(ExecutorEngine.class), new DefaultAuthentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
when(backendConnection.getSchemaName()).thenReturn(String.format(SCHEMA_PATTERN, 0));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandlerTest.java
index e264dd4..66ff194 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/SchemaAssignedDatabaseBackendHandlerTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.backend.text.data.impl;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.auth.ShardingSphereUser;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
@@ -93,9 +93,9 @@ public final class SchemaAssignedDatabaseBackendHandlerTest {
return result;
}
- private Authentication getAuthentication() {
+ private DefaultAuthentication getAuthentication() {
ShardingSphereUser user = new ShardingSphereUser("root", Arrays.asList(String.format(SCHEMA_PATTERN, 0), String.format(SCHEMA_PATTERN, 1)));
- Authentication result = new Authentication();
+ DefaultAuthentication result = new DefaultAuthentication();
result.getUsers().put("root", user);
return result;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/UnicastDatabaseBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/UnicastDatabaseBackendHandlerTest.java
index 4b815ee..170436f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/UnicastDatabaseBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/data/impl/UnicastDatabaseBackendHandlerTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.backend.text.data.impl;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.auth.ShardingSphereUser;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
@@ -94,9 +94,9 @@ public final class UnicastDatabaseBackendHandlerTest {
return result;
}
- private Authentication getAuthentication() {
+ private DefaultAuthentication getAuthentication() {
ShardingSphereUser user = new ShardingSphereUser("root", Arrays.asList(String.format(SCHEMA_PATTERN, 0), String.format(SCHEMA_PATTERN, 1)));
- Authentication result = new Authentication();
+ DefaultAuthentication result = new DefaultAuthentication();
result.getUsers().put("root", user);
return result;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/metadata/rdl/RDLBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/metadata/rdl/RDLBackendHandlerTest.java
index e251bca..78e1cf0 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/metadata/rdl/RDLBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/metadata/rdl/RDLBackendHandlerTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.text.metadata.rdl;
import lombok.SneakyThrows;
import org.apache.shardingsphere.distsql.parser.statement.rdl.CreateDataSourcesStatement;
import org.apache.shardingsphere.distsql.parser.statement.rdl.CreateShardingRuleStatement;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
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;
@@ -62,7 +62,7 @@ public final class RDLBackendHandlerTest {
Field metaDataContexts = ProxyContext.getInstance().getClass().getDeclaredField("metaDataContexts");
metaDataContexts.setAccessible(true);
metaDataContexts.set(ProxyContext.getInstance(),
- new StandardMetaDataContexts(getMetaDataMap(), mock(ExecutorEngine.class), new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
+ new StandardMetaDataContexts(getMetaDataMap(), mock(ExecutorEngine.class), new DefaultAuthentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
}
@Test
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/metadata/schema/impl/ShowDatabasesBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/metadata/schema/impl/ShowDatabasesBackendHandlerTest.java
index ddbf3e1..39cc162 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/metadata/schema/impl/ShowDatabasesBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/metadata/schema/impl/ShowDatabasesBackendHandlerTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.proxy.backend.text.metadata.schema.impl;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.auth.ShardingSphereUser;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
@@ -71,9 +71,9 @@ public final class ShowDatabasesBackendHandlerTest {
return result;
}
- private Authentication getAuthentication() {
+ private DefaultAuthentication getAuthentication() {
ShardingSphereUser user = new ShardingSphereUser("root", Arrays.asList(String.format(SCHEMA_PATTERN, 0), String.format(SCHEMA_PATTERN, 1)));
- Authentication result = new Authentication();
+ DefaultAuthentication result = new DefaultAuthentication();
result.getUsers().put("root", user);
return result;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/metadata/schema/impl/ShowTablesBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/metadata/schema/impl/ShowTablesBackendHandlerTest.java
index 3552bdd..349e1aa 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/metadata/schema/impl/ShowTablesBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/metadata/schema/impl/ShowTablesBackendHandlerTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.proxy.backend.text.metadata.schema.impl;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.auth.ShardingSphereUser;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
@@ -73,9 +73,9 @@ public final class ShowTablesBackendHandlerTest {
return result;
}
- private Authentication getAuthentication() {
+ private DefaultAuthentication getAuthentication() {
ShardingSphereUser user = new ShardingSphereUser("root", Arrays.asList(String.format(SCHEMA_PATTERN, 0), String.format(SCHEMA_PATTERN, 1)));
- Authentication result = new Authentication();
+ DefaultAuthentication result = new DefaultAuthentication();
result.getUsers().put("root", user);
return result;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/metadata/schema/impl/UseDatabaseBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/metadata/schema/impl/UseDatabaseBackendHandlerTest.java
index 0e7b9a8..5a4eaa3 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/metadata/schema/impl/UseDatabaseBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/metadata/schema/impl/UseDatabaseBackendHandlerTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.proxy.backend.text.metadata.schema.impl;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.auth.ShardingSphereUser;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
@@ -73,9 +73,9 @@ public final class UseDatabaseBackendHandlerTest {
return result;
}
- private Authentication getAuthentication() {
+ private DefaultAuthentication getAuthentication() {
ShardingSphereUser user = new ShardingSphereUser("root", Arrays.asList(String.format(SCHEMA_PATTERN, 0), String.format(SCHEMA_PATTERN, 1)));
- Authentication result = new Authentication();
+ DefaultAuthentication result = new DefaultAuthentication();
result.getUsers().put("root", user);
return result;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandlerTest.java
index 534b100..56f7934 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandlerTest.java
@@ -1,6 +1,6 @@
package org.apache.shardingsphere.proxy.backend.text.sctl.explain;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
@@ -62,7 +62,7 @@ public final class ShardingCTLExplainBackendHandlerTest {
Field metaDataContexts = ProxyContext.getInstance().getClass().getDeclaredField("metaDataContexts");
metaDataContexts.setAccessible(true);
metaDataContexts.set(ProxyContext.getInstance(),
- new StandardMetaDataContexts(getMetaDataMap(), mock(ExecutorEngine.class), new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
+ new StandardMetaDataContexts(getMetaDataMap(), mock(ExecutorEngine.class), new DefaultAuthentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
}
private Map<String, ShardingSphereMetaData> getMetaDataMap() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java
index 6bb03c4..a9d75ae 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.backend.text.sctl.hint;
import com.google.common.collect.ImmutableMap;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
@@ -167,7 +167,7 @@ public final class ShardingCTLHintBackendHandlerTest {
Properties props = new Properties();
props.setProperty(ConfigurationPropertyKey.PROXY_HINT_ENABLED.getKey(), Boolean.TRUE.toString());
metaDataContexts.set(ProxyContext.getInstance(),
- new StandardMetaDataContexts(getMetaDataMap(), mock(ExecutorEngine.class), new Authentication(), new ConfigurationProperties(props), new MySQLDatabaseType()));
+ new StandardMetaDataContexts(getMetaDataMap(), mock(ExecutorEngine.class), new DefaultAuthentication(), new ConfigurationProperties(props), new MySQLDatabaseType()));
String sql = "sctl:hint show table status";
ShardingCTLHintBackendHandler defaultHintBackendHandler = new ShardingCTLHintBackendHandler(sql, backendConnection);
ResponseHeader responseHeader = defaultHintBackendHandler.execute();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetBackendHandlerTest.java
index f1e5bc1..efcc00c 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetBackendHandlerTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.proxy.backend.text.sctl.set;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
@@ -54,7 +54,7 @@ public final class ShardingCTLSetBackendHandlerTest {
Field metaDataContexts = ProxyContext.getInstance().getClass().getDeclaredField("metaDataContexts");
metaDataContexts.setAccessible(true);
metaDataContexts.set(ProxyContext.getInstance(),
- new StandardMetaDataContexts(getMetaDataMap(), mock(ExecutorEngine.class), new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
+ new StandardMetaDataContexts(getMetaDataMap(), mock(ExecutorEngine.class), new DefaultAuthentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
}
private Map<String, ShardingSphereMetaData> getMetaDataMap() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializer.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializer.java
index 755f09b..408e363 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializer.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/impl/GovernanceBootstrapInitializer.java
@@ -22,9 +22,9 @@ import org.apache.shardingsphere.governance.context.transaction.GovernanceTransa
import org.apache.shardingsphere.governance.core.facade.GovernanceFacade;
import org.apache.shardingsphere.governance.core.lock.GovernanceLockStrategy;
import org.apache.shardingsphere.governance.core.yaml.swapper.GovernanceConfigurationYamlSwapper;
-import org.apache.shardingsphere.infra.auth.Authentication;
-import org.apache.shardingsphere.infra.auth.yaml.config.YamlAuthenticationConfiguration;
-import org.apache.shardingsphere.infra.auth.yaml.swapper.AuthenticationYamlSwapper;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.config.YamlAuthenticationConfiguration;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.swapper.AuthenticationYamlSwapper;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceParameter;
@@ -90,7 +90,7 @@ public final class GovernanceBootstrapInitializer extends AbstractBootstrapIniti
entry -> swapperEngine.swapToRuleConfigurations(entry.getValue().getRules()), (oldValue, currentValue) -> oldValue, LinkedHashMap::new));
}
- private Authentication getAuthentication(final YamlAuthenticationConfiguration authConfig) {
+ private DefaultAuthentication getAuthentication(final YamlAuthenticationConfiguration authConfig) {
return new AuthenticationYamlSwapper().swapToObject(authConfig);
}
@@ -98,7 +98,7 @@ public final class GovernanceBootstrapInitializer extends AbstractBootstrapIniti
Collection<String> schemaNames = governanceFacade.getConfigCenter().getAllSchemaNames();
Map<String, Map<String, DataSourceParameter>> schemaDataSources = loadDataSourceParametersMap(schemaNames);
Map<String, Collection<RuleConfiguration>> schemaRules = loadSchemaRules(schemaNames);
- Authentication authentication = governanceFacade.getConfigCenter().loadAuthentication();
+ DefaultAuthentication authentication = governanceFacade.getConfigCenter().loadAuthentication();
Properties props = governanceFacade.getConfigCenter().loadProperties();
return new ProxyConfiguration(schemaDataSources, schemaRules, authentication, props);
}
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 e8786b9..46c2230 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
@@ -21,7 +21,7 @@ import lombok.SneakyThrows;
import org.apache.shardingsphere.governance.context.metadata.GovernanceMetaDataContexts;
import org.apache.shardingsphere.governance.context.transaction.GovernanceTransactionContexts;
import org.apache.shardingsphere.governance.core.config.ConfigCenterNode;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.auth.ShardingSphereUser;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
@@ -193,7 +193,7 @@ public final class GovernanceBootstrapInitializerTest extends AbstractBootstrapI
assertThat(props.getProperty("algorithm-expression"), is(expectedAlgorithmExpr));
}
- private void assertAuthentication(final Authentication actual) {
+ private void assertAuthentication(final DefaultAuthentication actual) {
Optional<ShardingSphereUser> rootUser = actual.findUser("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 cbba3e4..886250d 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
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.proxy.initializer.impl;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.auth.ShardingSphereUser;
-import org.apache.shardingsphere.infra.auth.yaml.config.YamlAuthenticationConfiguration;
-import org.apache.shardingsphere.infra.auth.yaml.config.YamlShardingSphereUserConfiguration;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.config.YamlAuthenticationConfiguration;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.config.YamlUserConfiguration;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceParameter;
import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
@@ -146,7 +146,7 @@ public final class StandardBootstrapInitializerTest extends AbstractBootstrapIni
assertThat(((FixtureRuleConfiguration) actual).getName(), is("testRule"));
}
- private void assertAuthentication(final Authentication actual) {
+ private void assertAuthentication(final DefaultAuthentication actual) {
Optional<ShardingSphereUser> rootUser = actual.findUser("root");
assertTrue(rootUser.isPresent());
assertThat(rootUser.get().getPassword(), is("root"));
@@ -170,15 +170,15 @@ public final class StandardBootstrapInitializerTest extends AbstractBootstrapIni
}
private YamlAuthenticationConfiguration createYamlAuthenticationConfiguration() {
- Map<String, YamlShardingSphereUserConfiguration> users = new HashMap<>(1, 1);
+ Map<String, YamlUserConfiguration> users = new HashMap<>(1, 1);
users.put("root", createYamlUserConfiguration());
YamlAuthenticationConfiguration result = new YamlAuthenticationConfiguration();
result.setUsers(users);
return result;
}
- private YamlShardingSphereUserConfiguration createYamlUserConfiguration() {
- YamlShardingSphereUserConfiguration result = new YamlShardingSphereUserConfiguration();
+ private YamlUserConfiguration createYamlUserConfiguration() {
+ YamlUserConfiguration result = new YamlUserConfiguration();
result.setPassword("root");
result.setAuthorizedSchemas("ds-1,ds-2");
return result;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfiguration.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfiguration.java
index 931ba56..939c062 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfiguration.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/ProxyConfiguration.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceParameter;
@@ -38,7 +38,7 @@ public final class ProxyConfiguration {
private final Map<String, Collection<RuleConfiguration>> schemaRules;
- private final Authentication authentication;
+ private final DefaultAuthentication authentication;
private final Properties props;
}
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 6f19296..ba54508 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,6 +20,7 @@ package org.apache.shardingsphere.proxy.config;
import com.google.common.base.Preconditions;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.infra.auth.AuthenticationEngine;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import org.apache.shardingsphere.proxy.config.yaml.YamlProxyRuleConfiguration;
import org.apache.shardingsphere.proxy.config.yaml.YamlProxyServerConfiguration;
@@ -75,7 +76,8 @@ public final class ProxyConfigurationLoader {
private static YamlProxyServerConfiguration loadServerConfiguration(final File yamlFile) throws IOException {
YamlProxyServerConfiguration result = YamlEngine.unmarshal(yamlFile, YamlProxyServerConfiguration.class);
Preconditions.checkNotNull(result, "Server configuration file `%s` is invalid.", yamlFile.getName());
- Preconditions.checkState(null != result.getAuthentication() || null != result.getGovernance(), "Authority configuration is invalid.");
+ Preconditions.checkState(
+ AuthenticationEngine.findSPIAuthentication().isPresent() || null != result.getAuthentication() || null != result.getGovernance(), "Authority configuration is invalid.");
return result;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlProxyServerConfiguration.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlProxyServerConfiguration.java
index c5f606f..b51bf23 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlProxyServerConfiguration.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlProxyServerConfiguration.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.config.yaml;
import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceConfiguration;
-import org.apache.shardingsphere.infra.auth.yaml.config.YamlAuthenticationConfiguration;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.config.YamlAuthenticationConfiguration;
import org.apache.shardingsphere.infra.yaml.config.YamlConfiguration;
import java.util.Properties;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapper.java b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapper.java
index 7bbc141..747c291 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapper.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/swapper/YamlProxyConfigurationSwapper.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.proxy.config.yaml.swapper;
-import org.apache.shardingsphere.infra.auth.Authentication;
-import org.apache.shardingsphere.infra.auth.yaml.swapper.AuthenticationYamlSwapper;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.swapper.AuthenticationYamlSwapper;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.infra.config.datasource.DataSourceParameter;
@@ -48,7 +48,7 @@ public final class YamlProxyConfigurationSwapper {
public ProxyConfiguration swap(final YamlProxyConfiguration yamlConfig) {
Map<String, Map<String, DataSourceParameter>> schemaDataSources = getDataSourceParametersMap(yamlConfig.getRuleConfigurations());
Map<String, Collection<RuleConfiguration>> schemaRules = getRuleConfigurations(yamlConfig.getRuleConfigurations());
- Authentication authentication = new AuthenticationYamlSwapper().swapToObject(yamlConfig.getServerConfiguration().getAuthentication());
+ DefaultAuthentication authentication = new AuthenticationYamlSwapper().swapToObject(yamlConfig.getServerConfiguration().getAuthentication());
Properties props = yamlConfig.getServerConfiguration().getProps();
return new ProxyConfiguration(schemaDataSources, schemaRules, authentication, props);
}
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 a8a65ba..9857516 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
@@ -19,10 +19,10 @@ package org.apache.shardingsphere.proxy.config.yaml.swapper;
import org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceCenterConfiguration;
import org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceConfiguration;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.auth.ShardingSphereUser;
-import org.apache.shardingsphere.infra.auth.yaml.config.YamlAuthenticationConfiguration;
-import org.apache.shardingsphere.infra.auth.yaml.config.YamlShardingSphereUserConfiguration;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.config.YamlAuthenticationConfiguration;
+import org.apache.shardingsphere.infra.auth.builtin.yaml.config.YamlUserConfiguration;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.config.datasource.DataSourceParameter;
import org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration;
@@ -102,7 +102,7 @@ public final class YamlProxyConfigurationSwapperTest {
}
private void assertAuthentication(final ProxyConfiguration proxyConfig) {
- Authentication authentication = proxyConfig.getAuthentication();
+ DefaultAuthentication authentication = proxyConfig.getAuthentication();
assertNotNull(authentication);
Optional<ShardingSphereUser> user = authentication.findUser("user1");
assertTrue(user.isPresent());
@@ -213,8 +213,8 @@ public final class YamlProxyConfigurationSwapperTest {
}
private void prepareAuthentication(final YamlProxyServerConfiguration yamlProxyServerConfig) {
- Map<String, YamlShardingSphereUserConfiguration> yamlUserConfigurationMap = new HashMap<>(1, 1);
- YamlShardingSphereUserConfiguration yamlUserConfig = mock(YamlShardingSphereUserConfiguration.class);
+ Map<String, YamlUserConfiguration> yamlUserConfigurationMap = new HashMap<>(1, 1);
+ YamlUserConfiguration yamlUserConfig = mock(YamlUserConfiguration.class);
when(yamlUserConfig.getPassword()).thenReturn("pass");
when(yamlUserConfig.getAuthorizedSchemas()).thenReturn("db1");
yamlUserConfigurationMap.put("user1", yamlUserConfig);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java
index b468b08..980a39e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java
@@ -25,7 +25,7 @@ import org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLErrPacket
import org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLOKPacket;
import org.apache.shardingsphere.db.protocol.mysql.packet.handshake.MySQLHandshakePacket;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.auth.ShardingSphereUser;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
@@ -144,7 +144,7 @@ public final class MySQLFrontendEngineTest {
}
private void setAuthentication(final ShardingSphereUser user) {
- Authentication authentication = new Authentication();
+ DefaultAuthentication authentication = new DefaultAuthentication();
authentication.getUsers().put("root", user);
initProxyContext(authentication);
}
@@ -157,13 +157,13 @@ public final class MySQLFrontendEngineTest {
}
@SneakyThrows(ReflectiveOperationException.class)
- private void initProxyContext(final Authentication authentication) {
+ private void initProxyContext(final DefaultAuthentication authentication) {
Field field = ProxyContext.getInstance().getClass().getDeclaredField("metaDataContexts");
field.setAccessible(true);
field.set(ProxyContext.getInstance(), getMetaDataContexts(authentication));
}
- private MetaDataContexts getMetaDataContexts(final Authentication authentication) {
+ private MetaDataContexts getMetaDataContexts(final DefaultAuthentication authentication) {
return new StandardMetaDataContexts(getMetaDataMap(), mock(ExecutorEngine.class), authentication, new ConfigurationProperties(new Properties()), new MySQLDatabaseType());
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationEngineTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationEngineTest.java
index b4520e0..3f0e5ef 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationEngineTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationEngineTest.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLErrPacket
import org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLOKPacket;
import org.apache.shardingsphere.db.protocol.mysql.packet.handshake.MySQLHandshakePacket;
import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
@@ -141,7 +141,7 @@ public final class MySQLAuthenticationEngineTest {
Field field = ProxyContext.getInstance().getClass().getDeclaredField("metaDataContexts");
field.setAccessible(true);
field.set(ProxyContext.getInstance(), new StandardMetaDataContexts(Collections.singletonMap("sharding_db", mock(ShardingSphereMetaData.class)),
- mock(ExecutorEngine.class), new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
+ mock(ExecutorEngine.class), new DefaultAuthentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
}
private MySQLPacketPayload getPayload(final String username, final String database, final byte[] authResponse) {
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 313f343..56d9350 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
@@ -21,7 +21,7 @@ import com.google.common.primitives.Bytes;
import lombok.SneakyThrows;
import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLServerErrorCode;
import org.apache.shardingsphere.db.protocol.mysql.packet.handshake.MySQLAuthPluginData;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.auth.ShardingSphereUser;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.metadata.MetaDataContexts;
@@ -108,19 +108,19 @@ public final class MySQLAuthenticationHandlerTest {
}
private void setAuthentication(final ShardingSphereUser user) {
- Authentication authentication = new Authentication();
+ DefaultAuthentication authentication = new DefaultAuthentication();
authentication.getUsers().put("root", user);
initProxyContext(authentication);
}
@SneakyThrows(ReflectiveOperationException.class)
- private void initProxyContext(final Authentication authentication) {
+ private void initProxyContext(final DefaultAuthentication authentication) {
Field field = ProxyContext.getInstance().getClass().getDeclaredField("metaDataContexts");
field.setAccessible(true);
field.set(ProxyContext.getInstance(), getMetaDataContexts(authentication));
}
- private MetaDataContexts getMetaDataContexts(final Authentication authentication) {
+ private MetaDataContexts getMetaDataContexts(final DefaultAuthentication authentication) {
return new StandardMetaDataContexts(getMetaDataMap(), mock(ExecutorEngine.class), authentication, new ConfigurationProperties(new Properties()), new MySQLDatabaseType());
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java
index 3b7ffd2..1e3e8df 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.r
import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.text.fieldlist.MySQLComFieldListPacket;
import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.text.query.MySQLComQueryPacket;
import org.apache.shardingsphere.db.protocol.packet.CommandPacket;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
@@ -74,7 +74,7 @@ public final class MySQLCommandExecutorFactoryTest {
field.setAccessible(true);
Map<String, ShardingSphereMetaData> metaDataMap = Collections.singletonMap("logic_db", mock(ShardingSphereMetaData.class, RETURNS_DEEP_STUBS));
field.set(ProxyContext.getInstance(),
- new StandardMetaDataContexts(metaDataMap, mock(ExecutorEngine.class), new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
+ new StandardMetaDataContexts(metaDataMap, mock(ExecutorEngine.class), new DefaultAuthentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
}
@Test
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
index 09a1f69..35e760e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.execute;
import org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.execute.MySQLComStmtExecutePacket;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
@@ -63,7 +63,7 @@ public final class MySQLComStmtExecuteExecutorTest {
metaDataContexts.setAccessible(true);
Map<String, ShardingSphereMetaData> metaDataMap = Collections.singletonMap("logic_db", mock(ShardingSphereMetaData.class, RETURNS_DEEP_STUBS));
metaDataContexts.set(ProxyContext.getInstance(),
- new StandardMetaDataContexts(metaDataMap, mock(ExecutorEngine.class), new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
+ new StandardMetaDataContexts(metaDataMap, mock(ExecutorEngine.class), new DefaultAuthentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
}
@Test
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 877c78a..055f5ab 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,6 +27,7 @@ import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.bin
import org.apache.shardingsphere.db.protocol.postgresql.packet.handshake.PostgreSQLAuthenticationMD5PasswordPacket;
import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
import org.apache.shardingsphere.infra.auth.ShardingSphereUser;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.frontend.auth.AuthenticationResult;
@@ -125,7 +126,7 @@ public final class PostgreSQLAuthenticationEngineTest {
ProxyContext proxyContext = ProxyContext.getInstance();
StandardMetaDataContexts standardMetaDataContexts = new StandardMetaDataContexts();
- standardMetaDataContexts.getAuthentication().getUsers().put(username, new ShardingSphereUser(password, null));
+ ((DefaultAuthentication) standardMetaDataContexts.getAuthentication()).getUsers().put(username, new ShardingSphereUser(password, null));
proxyContext.init(standardMetaDataContexts, mock(TransactionContexts.class));
actual = engine.auth(channelHandlerContext, payload);
assertThat(actual.isFinished(), is(password.equals(inputPassword)));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/parse/PostgreSQLComParseExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/parse/PostgreSQLComParseExecutorTest.java
index 92f2fbb..5aa183f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/parse/PostgreSQLComParseExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/parse/PostgreSQLComParseExecutorTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.frontend.postgresql.command.query.binary
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.BinaryStatementRegistry;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.parse.PostgreSQLComParsePacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.binary.parse.PostgreSQLParseCompletePacket;
-import org.apache.shardingsphere.infra.auth.Authentication;
+import org.apache.shardingsphere.infra.auth.builtin.DefaultAuthentication;
import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
import org.apache.shardingsphere.infra.context.metadata.impl.StandardMetaDataContexts;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
@@ -60,7 +60,7 @@ public final class PostgreSQLComParseExecutorTest {
Field metaDataContexts = ProxyContext.getInstance().getClass().getDeclaredField("metaDataContexts");
metaDataContexts.setAccessible(true);
metaDataContexts.set(ProxyContext.getInstance(),
- new StandardMetaDataContexts(getMetaDataMap(), mock(ExecutorEngine.class), new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
+ new StandardMetaDataContexts(getMetaDataMap(), mock(ExecutorEngine.class), new DefaultAuthentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
BinaryStatementRegistry.getInstance().register(1);
PostgreSQLComParseExecutor actual = new PostgreSQLComParseExecutor(parsePacket, backendConnection);
assertThat(actual.execute().iterator().next(), instanceOf(PostgreSQLParseCompletePacket.class));