From 83aa0647da69837fb1bf688599d99a0a840b2ef2 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Fri, 17 Sep 2021 09:43:18 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-56220=20=E6=95=B0=E6=8D=AE=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E8=B6=8A=E6=9D=83=E6=BC=8F=E6=B4=9E=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/authority/DSColumnAuthorityChecker.java | 2 ++ .../mainframe/authority/ElementAuthorityChecker.java | 5 ++++- .../mainframe/authority/FormulaAuthorityChecker.java | 7 +++++-- .../authority/NameDatabaseConnectionAuthorityChecker.java | 2 ++ .../mainframe/authority/NameTableDataAuthorityChecker.java | 2 ++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/authority/DSColumnAuthorityChecker.java b/designer-base/src/main/java/com/fr/design/mainframe/authority/DSColumnAuthorityChecker.java index 7a4ae7ce77..fdab6ea2a2 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/authority/DSColumnAuthorityChecker.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/authority/DSColumnAuthorityChecker.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.authority; import com.fr.report.cell.cellattr.core.group.DSColumn; +import org.jetbrains.annotations.Nullable; import java.util.Arrays; import java.util.HashSet; @@ -9,6 +10,7 @@ import java.util.Set; public class DSColumnAuthorityChecker extends ElementAuthorityChecker { @Override + @Nullable Set getNoAuthDatasetNames(DSColumn dsColumn, Set authDatasetNames) { if (!authDatasetNames.contains(dsColumn.getDSName())) { return new HashSet<>(Arrays.asList(dsColumn.getDSName())); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/authority/ElementAuthorityChecker.java b/designer-base/src/main/java/com/fr/design/mainframe/authority/ElementAuthorityChecker.java index 3851406e73..67d0f1da36 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/authority/ElementAuthorityChecker.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/authority/ElementAuthorityChecker.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.authority; +import org.jetbrains.annotations.Nullable; import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl; import java.lang.reflect.Type; @@ -15,10 +16,11 @@ public abstract class ElementAuthorityChecker { * @param: authConnectionNames 有权限的数据连接名 * @return 如果有返回名称,没有返回null */ + @Nullable Set getNoAuthConnectionNames(T t, Set authConnectionNames) { return null; } - + /** * @Description 获取越权的服务器数据集 @@ -26,6 +28,7 @@ public abstract class ElementAuthorityChecker { * @param: authDatasetNames 有权限的服务器数据集名 * @return 如果有返回名称,没有返回null */ + @Nullable Set getNoAuthDatasetNames(T t, Set authDatasetNames) { return null; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/authority/FormulaAuthorityChecker.java b/designer-base/src/main/java/com/fr/design/mainframe/authority/FormulaAuthorityChecker.java index 73a3965a72..d108c18d41 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/authority/FormulaAuthorityChecker.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/authority/FormulaAuthorityChecker.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.authority; import com.fr.base.Formula; +import org.jetbrains.annotations.Nullable; import java.util.Arrays; import java.util.HashSet; @@ -9,11 +10,13 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public class FormulaAuthorityChecker extends ElementAuthorityChecker { + private static final Pattern FORMULA_PATTERN = Pattern.compile("^=SQL\\(\"(.+?)\","); + @Override + @Nullable public Set getNoAuthConnectionNames(Formula formula, Set authConnectionNames) { String content = formula.getContent(); - Pattern pattern = Pattern.compile("^=SQL\\(\"(.+?)\","); - Matcher matcher = pattern.matcher(content); + Matcher matcher = FORMULA_PATTERN.matcher(content); if (matcher.find()) { if (!authConnectionNames.contains(matcher.group(1))) { return new HashSet<>(Arrays.asList(matcher.group(1))); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/authority/NameDatabaseConnectionAuthorityChecker.java b/designer-base/src/main/java/com/fr/design/mainframe/authority/NameDatabaseConnectionAuthorityChecker.java index 4a7183f53d..96bc0b8c5d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/authority/NameDatabaseConnectionAuthorityChecker.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/authority/NameDatabaseConnectionAuthorityChecker.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.authority; import com.fr.data.impl.NameDatabaseConnection; +import org.jetbrains.annotations.Nullable; import java.util.Arrays; import java.util.HashSet; @@ -9,6 +10,7 @@ import java.util.stream.Collectors; public class NameDatabaseConnectionAuthorityChecker extends ElementAuthorityChecker { @Override + @Nullable Set getNoAuthConnectionNames(NameDatabaseConnection nameDatabaseConnection, Set authConnectionNames) { String name = nameDatabaseConnection.getName(); if (!authConnectionNames.contains(name)) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/authority/NameTableDataAuthorityChecker.java b/designer-base/src/main/java/com/fr/design/mainframe/authority/NameTableDataAuthorityChecker.java index 498c04af4d..13e7300856 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/authority/NameTableDataAuthorityChecker.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/authority/NameTableDataAuthorityChecker.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.authority; import com.fr.data.impl.NameTableData; +import org.jetbrains.annotations.Nullable; import java.util.Arrays; import java.util.HashSet; @@ -8,6 +9,7 @@ import java.util.Set; public class NameTableDataAuthorityChecker extends ElementAuthorityChecker { @Override + @Nullable Set getNoAuthDatasetNames(NameTableData nameTableData, Set authDatasetNames) { if (!authDatasetNames.contains(nameTableData.getName())) { return new HashSet<>(Arrays.asList(nameTableData.getName()));