You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2021/06/09 10:34:52 UTC
[shardingsphere] branch master updated: Code format for authority
(#10739)
This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new f343829 Code format for authority (#10739)
f343829 is described below
commit f343829fa26ccdc2da810c3d974ba0fc58c33237
Author: Liang Zhang <te...@163.com>
AuthorDate: Wed Jun 9 18:34:08 2021 +0800
Code format for authority (#10739)
---
.../authority/checker/AuthorityChecker.java | 20 ++++++++------------
.../authority/constant/AuthorityOrder.java | 5 -----
.../infra/executor/check/SQLChecker.java | 13 ++++++-------
3 files changed, 14 insertions(+), 24 deletions(-)
diff --git a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/checker/AuthorityChecker.java b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/checker/AuthorityChecker.java
index 464a2e6..77d1065 100644
--- a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/checker/AuthorityChecker.java
+++ b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/checker/AuthorityChecker.java
@@ -39,7 +39,7 @@ import java.util.function.BiPredicate;
* Authority checker.
*/
public final class AuthorityChecker implements SQLChecker<AuthorityRule> {
-
+
@Override
public boolean check(final String schemaName, final Grantee grantee, final AuthorityRule authorityRule) {
if (null == grantee) {
@@ -58,25 +58,21 @@ public final class AuthorityChecker implements SQLChecker<AuthorityRule> {
// TODO add error msg
return privileges.map(optional -> new SQLCheckResult(optional.hasPrivileges(Collections.singletonList(getPrivilege(sqlStatement))), "")).orElseGet(() -> new SQLCheckResult(false, ""));
}
-
+
@Override
public boolean check(final Grantee grantee, final AuthorityRule authorityRule) {
- Optional<ShardingSphereUser> user = authorityRule.findUser(grantee);
- return user.isPresent() ? true : false;
+ return authorityRule.findUser(grantee).isPresent();
}
-
+
@Override
- public boolean check(final Grantee grantee, final BiPredicate<Object, Object> validate, final Object cipher, final AuthorityRule authorityRule) {
+ public boolean check(final Grantee grantee, final BiPredicate<Object, Object> validator, final Object cipher, final AuthorityRule authorityRule) {
Optional<ShardingSphereUser> user = authorityRule.findUser(grantee);
- if (!user.isPresent()) {
- return false;
- }
- if (validate.test(user.get(), cipher)) {
- return true;
+ if (user.isPresent()) {
+ return validator.test(user.get(), cipher);
}
return false;
}
-
+
private PrivilegeType getPrivilege(final SQLStatement sqlStatement) {
if (sqlStatement instanceof MySQLShowDatabasesStatement) {
return PrivilegeType.SHOW_DB;
diff --git a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/constant/AuthorityOrder.java b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/constant/AuthorityOrder.java
index 339d894..384792e 100644
--- a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/constant/AuthorityOrder.java
+++ b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/constant/AuthorityOrder.java
@@ -30,9 +30,4 @@ public final class AuthorityOrder {
* Authority order.
*/
public static final int ORDER = 500;
-
- /**
- * Algorithm provider authority order.
- */
- public static final int ALGORITHM_PROVIDER_AUTHORITY_ORDER = ORDER + 1;
}
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/check/SQLChecker.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/check/SQLChecker.java
index 94c52e9..a929b65 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/check/SQLChecker.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/check/SQLChecker.java
@@ -29,7 +29,6 @@ import java.util.function.BiPredicate;
/**
* SQL checker.
- *
*/
public interface SQLChecker<T extends ShardingSphereRule> extends OrderedSPI<T> {
@@ -55,8 +54,7 @@ public interface SQLChecker<T extends ShardingSphereRule> extends OrderedSPI<T>
* @return SQL check result
*/
SQLCheckResult check(SQLStatement sqlStatement, List<Object> parameters, Grantee grantee, String currentSchema, Map<String, ShardingSphereMetaData> metaDataMap, T rule);
-
-
+
/**
* Check User.
* @param grantee grantee
@@ -64,14 +62,15 @@ public interface SQLChecker<T extends ShardingSphereRule> extends OrderedSPI<T>
* @return check result
*/
boolean check(Grantee grantee, T rule);
-
+
/**
- * Check User.
+ * Check user.
+ *
* @param grantee grantee
- * @param validate password validate
+ * @param validator password validator
* @param cipher cipher
* @param rule rule
* @return check result
*/
- boolean check(Grantee grantee, BiPredicate<Object, Object> validate, Object cipher, T rule);
+ boolean check(Grantee grantee, BiPredicate<Object, Object> validator, Object cipher, T rule);
}