You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2021/06/09 11:47:18 UTC

[shardingsphere] branch master updated: Add default user (#10740)

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

zhangliang 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 c704d3b  Add default user (#10740)
c704d3b is described below

commit c704d3baf30a1b50cfb7342f7503f08d07e3c29e
Author: Juan Pan(Trista) <pa...@apache.org>
AuthorDate: Wed Jun 9 19:46:40 2021 +0800

    Add default user (#10740)
---
 .../DefaultAuthorityRuleConfigurationBuilder.java  | 12 ++++++--
 .../authority/rule/builder/DefaultUser.java        | 34 ++++++++++++++++++++++
 ...der.level.DefaultKernelRuleConfigurationBuilder |  2 +-
 3 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/DefaultAuthorityRuleConfigurationBuilder.java b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/DefaultAuthorityRuleConfigurationBuilder.java
index eec4b1c..7b346c3 100644
--- a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/DefaultAuthorityRuleConfigurationBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/DefaultAuthorityRuleConfigurationBuilder.java
@@ -20,9 +20,11 @@ package org.apache.shardingsphere.authority.rule.builder;
 import org.apache.shardingsphere.authority.api.config.AuthorityRuleConfiguration;
 import org.apache.shardingsphere.authority.constant.AuthorityOrder;
 import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
 import org.apache.shardingsphere.infra.rule.builder.level.DefaultKernelRuleConfigurationBuilder;
 
-import java.util.Collections;
+import java.util.Collection;
+import java.util.LinkedHashSet;
 import java.util.Properties;
 
 /**
@@ -32,7 +34,13 @@ public final class DefaultAuthorityRuleConfigurationBuilder implements DefaultKe
     
     @Override
     public AuthorityRuleConfiguration build() {
-        return new AuthorityRuleConfiguration(Collections.emptyList(), new ShardingSphereAlgorithmConfiguration("NATIVE", new Properties()));
+        return new AuthorityRuleConfiguration(getDefaultShardingSphereUsers(), new ShardingSphereAlgorithmConfiguration("NATIVE", new Properties()));
+    }
+    
+    private Collection<ShardingSphereUser> getDefaultShardingSphereUsers() {
+        Collection<ShardingSphereUser> users = new LinkedHashSet<>();
+        users.add(new ShardingSphereUser(DefaultUser.USER_NAME, DefaultUser.USER_PASSWORD, DefaultUser.USER_HOSTNAME));
+        return users;
     }
     
     @Override
diff --git a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/DefaultUser.java b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/DefaultUser.java
new file mode 100644
index 0000000..e7b9c8e
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/DefaultUser.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.authority.rule.builder;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+/**
+ * Default user.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class DefaultUser {
+    
+    public static final String USER_NAME = "root";
+    
+    public static final String USER_HOSTNAME = "%";
+    
+    public static final String USER_PASSWORD = "root";
+}
diff --git a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.level.DefaultKernelRuleConfigurationBuilder b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.level.DefaultKernelRuleConfigurationBuilder
index e46d73f..8d8d72c 100644
--- a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.level.DefaultKernelRuleConfigurationBuilder
+++ b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.level.DefaultKernelRuleConfigurationBuilder
@@ -15,4 +15,4 @@
 # limitations under the License.
 #
 
-#org.apache.shardingsphere.authority.rule.builder.DefaultAuthorityRuleConfigurationBuilder
+org.apache.shardingsphere.authority.rule.builder.DefaultAuthorityRuleConfigurationBuilder