From 6a0820c9e8d9ae271e6b2e6ea419d06d49d5dd15 Mon Sep 17 00:00:00 2001 From: Lanlan Date: Mon, 20 Jun 2022 14:52:14 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-72595=20FR=E6=BA=90=E7=A0=81=E4=B8=AD?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E5=8A=A0=E5=AF=86=E5=AF=86=E9=92=A5=E7=A1=AC?= =?UTF-8?q?=E7=BC=96=E7=A0=81=EF=BC=8C=E5=BB=BA=E8=AE=AE=E6=94=BE=E5=88=B0?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../login/utils/DesignerLoginUtils.java | 22 ++++++++++++++++--- .../resources/com/fr/design/config/default | 1 + 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 designer-base/src/main/resources/com/fr/design/config/default diff --git a/designer-base/src/main/java/com/fr/design/login/utils/DesignerLoginUtils.java b/designer-base/src/main/java/com/fr/design/login/utils/DesignerLoginUtils.java index a39a0be4b..ca238d154 100644 --- a/designer-base/src/main/java/com/fr/design/login/utils/DesignerLoginUtils.java +++ b/designer-base/src/main/java/com/fr/design/login/utils/DesignerLoginUtils.java @@ -9,12 +9,16 @@ import com.fr.general.http.HttpToolbox; import com.fr.general.log.MessageFormatter; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; +import com.fr.security.encryption.storage.keys.DefaultKeys; import com.fr.stable.StringUtils; import com.fr.third.org.bouncycastle.util.encoders.Hex; import java.awt.Window; +import java.io.IOException; +import java.io.InputStream; import java.security.SecureRandom; import java.util.HashMap; import java.util.Map; +import java.util.Properties; import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; @@ -28,8 +32,6 @@ public class DesignerLoginUtils { private static final String PRODUCT_FINEREPORT = "product-finereport"; - private static final String KEY = "i7hP48WAcuTrmxfN"; - public static Map renderMap() { Map map4Tpl = new HashMap<>(); map4Tpl.put("language", GeneralContext.getLocale().toString()); @@ -85,8 +87,11 @@ public class DesignerLoginUtils { jo.put("uid", manager.getDesignerLoginUid()); jo.put("username", manager.getDesignerLoginUsername()); jo.put("source", PRODUCT_FINEREPORT); + + Properties properties = read("/default"); + byte[] iv = randomIv(); - return new String(Hex.encode(iv)) + encrypt(jo.toString(), KEY.getBytes(), iv); + return new String(Hex.encode(iv)) + encrypt(jo.toString(), properties.getProperty("Fine-Designer_Login").getBytes(), iv); } private static byte[] randomIv() { @@ -105,4 +110,15 @@ public class DesignerLoginUtils { byte[] resultBytes = cipher.doFinal(content.getBytes()); return new String(Hex.encode(resultBytes)); } + + private static Properties read(String fileName) { + fileName = "com/fr/design/config" + fileName; + Properties properties = new Properties(); + try (InputStream inputStream = DefaultKeys.class.getClassLoader().getResourceAsStream(fileName)){ + properties.load(inputStream); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return properties; + } } diff --git a/designer-base/src/main/resources/com/fr/design/config/default b/designer-base/src/main/resources/com/fr/design/config/default new file mode 100644 index 000000000..f808a8237 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/config/default @@ -0,0 +1 @@ +Fine-Designer_Login=i7hP48WAcuTrmxfN