From 643c946415e4c347b7afcec00df864abc84e5b71 Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 15 Sep 2020 18:49:51 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-38872=20=E8=AE=BE=E8=AE=A1=E5=99=A8h?= =?UTF-8?q?ttps=E8=AF=81=E4=B9=A6=E5=AF=86=E7=A0=81=E6=98=8E=E6=96=87?= =?UTF-8?q?=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../env/RemoteDesignerWorkspaceInfo.java | 38 ++++++++++- .../src/main/java/com/fr/env/EnvListPane.java | 24 ++++++- .../env/RemoteDesignerWorkspaceInfoTest.java | 67 +++++++++++++++++++ 3 files changed, 125 insertions(+), 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java index 2f30f70b9..37a671eeb 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java @@ -40,6 +40,12 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { private WorkspaceConnectionInfo connection; + /** + * 标记下新创建的远程工作目录 兼容存留的远程目录客户升级后再回退 读取为密文 + * 仅保证当前新增是加密的 + */ + private boolean newCreated; + public static RemoteDesignerWorkspaceInfo create(WorkspaceConnectionInfo connection) { RemoteDesignerWorkspaceInfo info = new RemoteDesignerWorkspaceInfo(); info.connection = connection; @@ -79,12 +85,21 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { return remindTime; } + public boolean isNewCreated() { + return newCreated; + } + + public void setNewCreated(boolean newCreated) { + this.newCreated = newCreated; + } + @Override public void readXML(XMLableReader reader) { if (reader.isAttr()) { this.name = reader.getAttrAsString("name", StringUtils.EMPTY); this.remindTime = reader.getAttrAsString("remindTime", StringUtils.EMPTY); + this.newCreated = reader.getAttrAsBoolean("newCreated", false); } if (reader.isChildNode()) { String tagName = reader.getTagName(); @@ -92,32 +107,49 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { String url = reader.getAttrAsString("url", StringUtils.EMPTY); String username = reader.getAttrAsString("username", StringUtils.EMPTY); //密码解密 - String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(" ", "\r\n")); + String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(StringUtils.BLANK, "\r\n")); String certPath = reader.getAttrAsString("certPath", StringUtils.EMPTY); - String certSecretKey = reader.getAttrAsString("certSecretKey", StringUtils.EMPTY); + String certSecretKey = readCertSecretKey(reader); boolean rememberPwd = reader.getAttrAsBoolean("rememberPwd", true); this.connection = new WorkspaceConnectionInfo(url, username, password, certPath, certSecretKey, rememberPwd); } } } + private String readCertSecretKey(XMLableReader reader) { + if (isNewCreated()) { + return SecurityToolbox.defaultDecrypt(reader.getAttrAsString("certSecretKey", StringUtils.EMPTY).replaceAll(StringUtils.BLANK, "\r\n")); + } else { + return reader.getAttrAsString("certSecretKey", StringUtils.EMPTY); + } + } + @Override public void writeXML(XMLPrintWriter writer) { writer.attr("name", name); writer.attr("remindTime", remindTime); + writer.attr("newCreated", isNewCreated()); if (this.connection != null) { writer.startTAG("Connection"); writer.attr("url", connection.getUrl()); writer.attr("username", connection.getUserName()); writer.attr("password", SecurityToolbox.defaultEncrypt(connection.getPassword())); writer.attr("certPath", connection.getCertPath()); - writer.attr("certSecretKey", connection.getCertSecretKey()); + writeCertSecretKey(writer); writer.attr("rememberPwd", connection.isRememberPwd()); writer.end(); } } + private void writeCertSecretKey(XMLPrintWriter writer) { + if (isNewCreated()) { + writer.attr("certSecretKey", SecurityToolbox.defaultEncrypt(connection.getCertSecretKey())); + } else { + writer.attr("certSecretKey", connection.getCertSecretKey()); + } + } + @Override @SuppressWarnings("squid:S2975") public Object clone() throws CloneNotSupportedException { diff --git a/designer-base/src/main/java/com/fr/env/EnvListPane.java b/designer-base/src/main/java/com/fr/env/EnvListPane.java index 911a7b22f..2d875cb45 100644 --- a/designer-base/src/main/java/com/fr/env/EnvListPane.java +++ b/designer-base/src/main/java/com/fr/env/EnvListPane.java @@ -3,6 +3,7 @@ package com.fr.env; import com.fr.design.DesignerEnvManager; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.gui.controlpane.JListControlPane; @@ -17,8 +18,10 @@ import com.fr.stable.core.PropertyChangeAdapter; import javax.swing.*; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; /** * @author yaohwu @@ -98,11 +101,30 @@ public class EnvListPane extends JListControlPane { DesignerEnvManager mgr = DesignerEnvManager.getEnvManager(); //这里代码时序换一下,因为update中需要借助mgr来获取提醒时间,已确认mgr对res无依赖 Nameable[] res = this.update(); + Set set = findNewWorkSpaceInfo(res); mgr.clearAllEnv(); for (Nameable re : res) { NameObject nameObject = (NameObject) re; - mgr.putEnv(nameObject.getName(), (DesignerWorkspaceInfo) nameObject.getObject()); + DesignerWorkspaceInfo info = (DesignerWorkspaceInfo) nameObject.getObject(); + if (set.contains(re) && info.getType() == DesignerWorkspaceType.Remote) { + RemoteDesignerWorkspaceInfo newInfo = (RemoteDesignerWorkspaceInfo) info; + newInfo.setNewCreated(true); + mgr.putEnv(nameObject.getName(), newInfo); + } else { + mgr.putEnv(nameObject.getName(), info); + } } return this.getSelectedName(); } + + private Set findNewWorkSpaceInfo(Nameable[] res) { + Set set = new HashSet<>(); + for (Nameable val : res) { + NameObject nameObject = (NameObject) val; + if (DesignerEnvManager.getEnvManager().getWorkspaceInfo(nameObject.getName()) == null) { + set.add(val); + } + } + return set; + } } diff --git a/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java b/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java index 54dbae3b0..d6e89cd93 100644 --- a/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java +++ b/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java @@ -1,9 +1,16 @@ package com.fr.design.env; +import com.fr.invoke.Reflect; +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLReaderHelper; +import com.fr.stable.xml.XMLableReader; import com.fr.workspace.connect.WorkspaceConnectionInfo; import junit.framework.TestCase; import org.junit.Assert; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; + /** * @author hades * @version 10.0 @@ -22,4 +29,64 @@ public class RemoteDesignerWorkspaceInfoTest extends TestCase { Assert.assertFalse(workspaceInfo3.checkValid()); } + public void testReadXml() { + String xml0 = ""; + String xml1 = ""; + byte[] bytes0 = xml0.getBytes(); + byte[] bytes1 = xml1.getBytes(); + RemoteDesignerWorkspaceInfo info = new RemoteDesignerWorkspaceInfo(); + ByteArrayInputStream in0 = new ByteArrayInputStream(bytes0); + ByteArrayInputStream in1 = new ByteArrayInputStream(bytes1); + + try { + XMLableReader reader0 = XMLReaderHelper.createXMLableReader(in0, XMLPrintWriter.XML_ENCODER); + Reflect.on(reader0).set("state", 1); + info.setNewCreated(true); + info.readXML(reader0); + Assert.assertEquals("xxxxxxx", info.getConnection().getCertSecretKey()); + + XMLableReader reader1 = XMLReaderHelper.createXMLableReader(in1, XMLPrintWriter.XML_ENCODER); + Reflect.on(reader1).set("state", 1); + info.setNewCreated(false); + info.readXML(reader1); + Assert.assertEquals("xxxxxxx", info.getConnection().getCertSecretKey()); + } catch (Exception ignore) { + + } + } + + public void testWriteXml() { + ByteArrayOutputStream out0 = new ByteArrayOutputStream(); + XMLPrintWriter writer0 = XMLPrintWriter.create(out0); + RemoteDesignerWorkspaceInfo info0 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("127.0.0.1", "1", "1", "/xxx", "xxxxx", true)); + info0.setNewCreated(true); + info0.writeXML(writer0); + writer0.close(); + String result0 = new String(out0.toByteArray()); + Assert.assertTrue(result0.contains("certSecretKey")); + Assert.assertFalse(result0.contains("certSecretKey=\"xxxxx\"")); + + ByteArrayOutputStream out1 = new ByteArrayOutputStream(); + XMLPrintWriter writer1 = XMLPrintWriter.create(out1); + RemoteDesignerWorkspaceInfo info1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("127.0.0.1", "1", "1", "/xxx", "xxxxx", true)); + info1.writeXML(writer1); + writer1.close(); + String result1 = new String(out1.toByteArray()); + Assert.assertTrue(result1.contains("certSecretKey")); + Assert.assertTrue(result1.contains("certSecretKey=\"xxxxx\"")); + + } + } From 2d9479f52d7c5321638ded5d662302bfab3f2ca9 Mon Sep 17 00:00:00 2001 From: shine Date: Wed, 16 Sep 2020 14:26:54 +0800 Subject: [PATCH 2/3] =?UTF-8?q?CHART-15263=20=E7=B3=BB=E5=88=97=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=97=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chartx/component/AbstractCustomFieldComboBoxPane.java | 7 +++++-- .../java/com/fr/extended/chart/UIComboBoxWithNone.java | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java index e4e27b7f4..16f983c75 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java @@ -82,6 +82,10 @@ public abstract class AbstractCustomFieldComboBoxPane extends BasicBeanPane extends BasicBeanPane Date: Wed, 16 Sep 2020 15:59:09 +0800 Subject: [PATCH 3/3] =?UTF-8?q?CHART-15263=20=E8=BD=AE=E6=92=ADgis?= =?UTF-8?q?=E5=92=8C=E4=B8=89=E7=BB=B4=E7=BB=84=E5=90=88=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=20=E7=B3=BB=E5=88=97=20=E6=97=A0=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/extended/chart/ExtendedCustomFieldComboBoxPane.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java index 119d73bda..fe02f67c0 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java @@ -22,6 +22,10 @@ public class ExtendedCustomFieldComboBoxPane extends AbstractCustomFieldComboBox return new ExtendedCustomFieldNamePane(); } + @Override + protected boolean seriesComboBoxHasNone() { + return true; + } @Override public void populateBean(AbstractDataConfig ob) {