From 6072f19b3c636ed0b2ad204f253f45c22665dffc Mon Sep 17 00:00:00 2001 From: pengda Date: Thu, 17 Jun 2021 15:38:57 +0800 Subject: [PATCH 1/6] =?UTF-8?q?REPORT-53873=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=99=BB=E5=BD=95=E7=AD=96=E7=95=A5=E8=B0=83?= =?UTF-8?q?=E6=95=B4-=E6=B6=88=E6=81=AF=E6=8F=90=E9=86=92-=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8F=90=E9=86=92=E6=A1=86=E5=BC=B9=E5=87=BA=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 2 + .../fr/design/dialog/NotificationDialog.java | 83 +++++++++++++----- .../login/message/DesignerMessageHelper.java | 4 +- .../ui/NotificationCenterDialog.java | 11 ++- .../ui/NotificationCenterPane.java | 6 +- .../versioncheck/VersionCheckUtils.java | 2 +- .../notification/ui}/notificationCenter.png | Bin .../ui}/notificationCenterDot.png | Bin 8 files changed, 79 insertions(+), 29 deletions(-) rename {designer-realize/src/main/resources/com/fr/design/mainframe/notificationCenter => designer-base/src/main/resources/com/fr/design/notification/ui}/notificationCenter.png (100%) rename {designer-realize/src/main/resources/com/fr/design/mainframe/notificationCenter => designer-base/src/main/resources/com/fr/design/notification/ui}/notificationCenterDot.png (100%) diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index 4ab6b3089..f38643737 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -17,6 +17,7 @@ import com.fr.design.file.TemplateTreePane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; +import com.fr.design.notification.NotificationCenter; import com.fr.design.utils.DesignUtils; import com.fr.design.versioncheck.VersionCheckUtils; import com.fr.env.EnvListPane; @@ -182,6 +183,7 @@ public class EnvChangeEntrance { if (model != null) { model.envChanged(); } + NotificationCenter.getInstance().clearAllNotifications(); return true; } diff --git a/designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java b/designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java index 4b18ab3e0..ee2a17a87 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java +++ b/designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java @@ -1,12 +1,14 @@ package com.fr.design.dialog; +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.notification.Notification; import com.fr.design.notification.NotificationCenter; -import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.module.ModuleContext; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; @@ -14,6 +16,8 @@ import java.awt.Frame; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JDialog; @@ -24,7 +28,6 @@ import javax.swing.UIManager; /** * 带查看详情的简要通知框 - * */ public class NotificationDialog extends JDialog { public static final int ERROR_MESSAGE = 0; @@ -32,13 +35,18 @@ public class NotificationDialog extends JDialog { public static final int WARNING_MESSAGE = 2; public static final String HTML_TAG_1 = ""; public static final String HTML_TAG_2 = ""; + private static final String HIDE_MSG = "HIDE_MSG_TIMER"; private UILabel messageText; private NotificationDialogAction notificationDialogAction; + private ScheduledExecutorService TIMER; - public NotificationDialog(Frame owner, String title, boolean isModal, int messageType, String message,NotificationDialogAction action) { + public NotificationDialog(Frame owner, String title, boolean isModal, int messageType, String message, NotificationDialogAction action) { super(owner); + setFocusable(false); + setAutoRequestFocus(false); + setResizable(false); setTitle(title); - initComponents(messageType, message, isModal,action); + initComponents(messageType, message, isModal, action); } public NotificationDialog(Builder builder) { @@ -47,27 +55,29 @@ public class NotificationDialog extends JDialog { initComponents(builder.messageType, builder.message, builder.modal, builder.action); } - public void initComponents(int messageType, String message, boolean isModal,NotificationDialogAction action) { - NotificationCenter.getInstance().addNotification(new Notification(messageType,message,action)); + public void initComponents(int messageType, String message, boolean isModal, NotificationDialogAction action) { + NotificationCenter.getInstance().addNotification(new Notification(messageType, message, action)); notificationDialogAction = action; setModal(isModal); - setResizable(false); + JPanel body = FRGUIPaneFactory.createBorderLayout_L_Pane(); + body.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); //消息内容 UILabel icon = new UILabel(getIconForType(messageType)); JPanel iconPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); - iconPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 8)); + iconPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 10, 8)); iconPanel.add(icon); - add(iconPanel, BorderLayout.WEST); + body.add(iconPanel, BorderLayout.WEST); messageText = new UILabel(HTML_TAG_1 + message + HTML_TAG_2); messageText.setForeground(new Color(51, 51, 52)); JPanel centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); - centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 10)); + centerPanel.setBorder(BorderFactory.createEmptyBorder(8, 0, 5, 20)); JScrollPane jScrollPane = new JScrollPane(messageText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jScrollPane.setBorder(BorderFactory.createEmptyBorder()); centerPanel.add(jScrollPane, BorderLayout.CENTER); - add(centerPanel, BorderLayout.CENTER); + centerPanel.setPreferredSize(new Dimension(230, 95)); + body.add(centerPanel, BorderLayout.CENTER); //查看详情 UILabel detailLabel = new UILabel(); @@ -75,37 +85,67 @@ public class NotificationDialog extends JDialog { detailLabel.setForeground(Color.BLUE); JPanel detailPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); detailPanel.add(detailLabel, BorderLayout.EAST); - add(detailPanel, BorderLayout.SOUTH); - setPreferredSize(new Dimension(262, 135)); + body.add(detailPanel, BorderLayout.SOUTH); detailLabel.addMouseListener(detailClickListener); messageText.addMouseListener(detailClickListener); - - pack(); - if (getOwner() != null) { - GUICoreUtils.setWindowCenter(getOwner(), this); - } + addMouseListener(bodyMouseListener); + + add(body); + Dimension dimension = body.getPreferredSize(); + setSize(dimension.width, dimension.height); + setLocation((DesignerContext.getDesignerFrame().getWidth() - dimension.width - 30 + DesignerContext.getDesignerFrame().getX()), + DesignerContext.getDesignerFrame().getY() + DesignerContext.getDesignerFrame().getHeight() - dimension.height - 30); + disappear(); } private MouseListener detailClickListener = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - if(notificationDialogAction != null){ + if (notificationDialogAction != null) { hideDialog(); notificationDialogAction.doClick(); } } }; + private MouseListener bodyMouseListener = new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + if (TIMER != null) { + TIMER.shutdownNow(); + } + } + + @Override + public void mouseExited(MouseEvent e) { + disappear(); + } + }; + + public void disappear() { + TIMER = createScheduleExecutorService(); + TIMER.schedule(new Runnable() { + @Override + public void run() { + hideDialog(); + } + }, 10000, TimeUnit.MILLISECONDS); + } + + private ScheduledExecutorService createScheduleExecutorService() { + return ModuleContext.getExecutor().newSingleThreadScheduledExecutor(new NamedThreadFactory(HIDE_MSG)); + } /** * 设置通知消息 */ - public void setMessage(String message){ + public void setMessage(String message) { messageText.setText(HTML_TAG_1 + message + HTML_TAG_2); } - private void hideDialog(){ + private void hideDialog() { + this.setVisible(false); this.dispose(); } @@ -138,6 +178,7 @@ public class NotificationDialog extends JDialog { public Frame owner = null; public String title; public NotificationDialogAction action; + private Builder() { } diff --git a/designer-base/src/main/java/com/fr/design/login/message/DesignerMessageHelper.java b/designer-base/src/main/java/com/fr/design/login/message/DesignerMessageHelper.java index dbb2d69c4..68072b940 100644 --- a/designer-base/src/main/java/com/fr/design/login/message/DesignerMessageHelper.java +++ b/designer-base/src/main/java/com/fr/design/login/message/DesignerMessageHelper.java @@ -90,7 +90,7 @@ public class DesignerMessageHelper { NotificationDialog.Builder() .owner(DesignerContext.getDesignerFrame()) .title(title) - .modal(true) + .modal(false) .messageType(NotificationDialog.NEW_MESSAGE) .message(body) .notificationDialogAction(new NotificationDialogAction() { @@ -107,7 +107,7 @@ public class DesignerMessageHelper { NotificationDialog.Builder() .owner(DesignerContext.getDesignerFrame()) .title(title) - .modal(true) + .modal(false) .messageType(NotificationDialog.NEW_MESSAGE) .message(body) .notificationDialogAction(designerModuleClickType.getAction()) diff --git a/designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterDialog.java b/designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterDialog.java index 3048959c5..de6374a80 100644 --- a/designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterDialog.java +++ b/designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterDialog.java @@ -15,8 +15,9 @@ import java.awt.Window; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.util.ArrayList; -import java.util.List; import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JDialog; @@ -32,10 +33,16 @@ public class NotificationCenterDialog extends JDialog { private static final int NOTIFICATIONCOUNT = 5; public NotificationCenterDialog(Frame parent) { - super(parent, true); + super(parent); setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Notification")); setResizable(false); notificationNeedShow = new ArrayList<>(); + addWindowFocusListener(new WindowAdapter() { + @Override + public void windowLostFocus(WindowEvent e) { + hideDialog(); + } + }); initComponents(); } diff --git a/designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterPane.java b/designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterPane.java index d0f09df00..f5af0bfc0 100644 --- a/designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterPane.java +++ b/designer-base/src/main/java/com/fr/design/notification/ui/NotificationCenterPane.java @@ -20,7 +20,7 @@ public class NotificationCenterPane extends BasicPane { setPreferredSize(new Dimension(24, 24)); setLayout(new BorderLayout()); notificationCenterButton = new UIButton(); - notificationCenterButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/notificationcenter/notificationCenter.png")); + notificationCenterButton.setIcon(IOUtils.readIcon("/com/fr/design/notification/ui/notificationCenter.png")); notificationCenterButton.setToolTipText(Toolkit.i18nText("Fine-Design_Basic_Show_Notification")); notificationCenterButton.set4ToolbarButton(); notificationCenterButton.setRolloverEnabled(false); @@ -41,9 +41,9 @@ public class NotificationCenterPane extends BasicPane { public void refreshButton() { if (NotificationCenter.getInstance().getNotificationsCount() > 0) { - notificationCenterButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/notificationcenter/notificationCenterDot.png")); + notificationCenterButton.setIcon(IOUtils.readIcon("/com/fr/design/notification/ui/notificationCenterDot.png")); } else { - notificationCenterButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/notificationcenter/notificationCenter.png")); + notificationCenterButton.setIcon(IOUtils.readIcon("/com/fr/design/notification/ui/notificationCenter.png")); } } diff --git a/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java b/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java index daf645270..26406b385 100644 --- a/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java +++ b/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java @@ -73,7 +73,7 @@ public class VersionCheckUtils { public static void showVersionCheckDialog(String envName) { if (!VersionCheckUtils.versionCheck(envName)) { NotificationDialog notificationDialog = new NotificationDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Sync_Prompt"), - true, NotificationDialog.WARNING_MESSAGE, Toolkit.i18nText("Fine-Design_Basic_Sync_Check_Brief_Info"), new NotificationDialogAction() { + false, NotificationDialog.WARNING_MESSAGE, Toolkit.i18nText("Fine-Design_Basic_Sync_Check_Brief_Info"), new NotificationDialogAction() { @Override public void doClick() { CheckServiceDialog checkServiceDialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), GeneralUtils.readFullBuildNO(), getRemoteBranch(envName),getNoExistServiceDescription(envName)); diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/notificationCenter/notificationCenter.png b/designer-base/src/main/resources/com/fr/design/notification/ui/notificationCenter.png similarity index 100% rename from designer-realize/src/main/resources/com/fr/design/mainframe/notificationCenter/notificationCenter.png rename to designer-base/src/main/resources/com/fr/design/notification/ui/notificationCenter.png diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/notificationCenter/notificationCenterDot.png b/designer-base/src/main/resources/com/fr/design/notification/ui/notificationCenterDot.png similarity index 100% rename from designer-realize/src/main/resources/com/fr/design/mainframe/notificationCenter/notificationCenterDot.png rename to designer-base/src/main/resources/com/fr/design/notification/ui/notificationCenterDot.png From cfcdb21c80a56e457eb4ebf1bbb6b7ec538f5cc1 Mon Sep 17 00:00:00 2001 From: pengda Date: Thu, 17 Jun 2021 16:01:44 +0800 Subject: [PATCH 2/6] =?UTF-8?q?REPORT-53873=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=99=BB=E5=BD=95=E7=AD=96=E7=95=A5=E8=B0=83?= =?UTF-8?q?=E6=95=B4-=E6=B6=88=E6=81=AF=E6=8F=90=E9=86=92-=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8F=90=E9=86=92=E6=A1=86=E5=BC=B9=E5=87=BA=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/dialog/NotificationDialog.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java b/designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java index ee2a17a87..b3398c53d 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java +++ b/designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java @@ -42,9 +42,6 @@ public class NotificationDialog extends JDialog { public NotificationDialog(Frame owner, String title, boolean isModal, int messageType, String message, NotificationDialogAction action) { super(owner); - setFocusable(false); - setAutoRequestFocus(false); - setResizable(false); setTitle(title); initComponents(messageType, message, isModal, action); } @@ -59,6 +56,9 @@ public class NotificationDialog extends JDialog { NotificationCenter.getInstance().addNotification(new Notification(messageType, message, action)); notificationDialogAction = action; setModal(isModal); + setFocusable(false); + setAutoRequestFocus(false); + setResizable(false); JPanel body = FRGUIPaneFactory.createBorderLayout_L_Pane(); body.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); From ddcfd7cea6384e2bad2557acb10548398c8597a5 Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 18 Jun 2021 14:40:35 +0800 Subject: [PATCH 3/6] =?UTF-8?q?REPORT-53647=E3=80=90=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=A4=8D=E7=94=A8=E6=B6=89=E5=8F=8A=E5=88=B0=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD=E3=80=91=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E6=9C=AC=E8=BA=AB=E6=98=AF=E6=B2=A1=E6=9C=89=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E7=9A=84=EF=BC=8C=E6=8D=A2=E6=88=90=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=9A=84nightly=E5=90=8E=EF=BC=8C=E6=89=93=E5=BC=80=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=99=A8=E5=90=8E=E6=97=A0=E8=AE=BA=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E7=99=BB=E5=BD=95=EF=BC=8C=E4=B8=8B=E8=BD=BD=E5=9C=A8=E7=BA=BF?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E9=83=BD=E4=BC=9A=E6=8F=90=E7=A4=BA=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5@lanla?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/share/util/DownloadUtils.java | 60 +++++++++++++------ 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java b/designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java index 93a8f73b0..7f9a379b5 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java @@ -1,9 +1,9 @@ package com.fr.design.mainframe.share.util; -import com.fr.config.MarketConfig; import com.fr.design.extra.PluginConstants; import com.fr.form.share.base.CancelCheck; import com.fr.form.share.constants.ShareComponentConstants; +import com.fr.ftp.util.Base64; import com.fr.general.CloudCenter; import com.fr.log.FineLoggerFactory; import com.fr.stable.ProductConstants; @@ -21,31 +21,27 @@ import com.fr.third.org.apache.http.impl.client.CloseableHttpClient; import com.fr.third.org.apache.http.impl.client.HttpClients; import org.jetbrains.annotations.NotNull; +import javax.crypto.Cipher; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.security.KeyFactory; +import java.security.interfaces.RSAPublicKey; +import java.security.spec.X509EncodedKeySpec; /** * created by Harrison on 2020/05/27 **/ public class DownloadUtils { - private static final String MARKET_LOGIN_URL = CloudCenter.getInstance().acquireUrlByKind("market.login"); private static final String REUSES_URL = CloudCenter.getInstance().acquireUrlByKind("af.reuseInfo") + "file/"; private static final String PACKAGE_REUSES_URL = CloudCenter.getInstance().acquireUrlByKind("af.reuseInfo") + "package/download/"; + private static final String CERTIFICATE_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCtsz62CPSWXZE/IYZRiAuTSZkw\n" + + "1WOwer8+JFktK0uKLAUuQoBr+UjAMFtRA8W7JgKMDwZy/2liEAiXEOSPU/hrdV8D\n" + + "tT541LnGi1X/hXiRwuttPWYN3L2GYm/d5blU+FBNwghBIrdAxXTzYBc6P4KL/oYX\n" + + "nMdTIrkz8tYkG3QoFQIDAQAB"; - public static boolean login(CloseableHttpClient client) throws Exception { - - HttpUriRequest login = RequestBuilder.post() - .setUri(MARKET_LOGIN_URL) - .setHeader("User-Agent", "Mozilla/5.0") - .addParameter("username", MarketConfig.getInstance().getBbsUsername()) - .addParameter("password", MarketConfig.getInstance().getBbsPassword()) - .build(); - CloseableHttpResponse loginResponse = client.execute(login); - return loginResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK; - } - private static CloseableHttpClient createClient() { BasicCookieStore cookieStore = new BasicCookieStore(); @@ -59,8 +55,10 @@ public class DownloadUtils { @NotNull public static String download(String id, String fileName, com.fr.design.extra.Process process) throws Exception { CloseableHttpResponse fileRes = getHttpResponse(REUSES_URL, id); + if (fileRes.getStatusLine().getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY) { + fileRes = getHttpResponse(fileRes.getHeaders("Location")[0].getValue()); + } if (fileRes.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { - String realPath = StableUtils.pathJoin(ProductConstants.getEnvHome(), ShareComponentConstants.PLUGIN_CACHE, ShareComponentConstants.DOWNLOAD_SHARE); String filePath; @@ -95,7 +93,9 @@ public class DownloadUtils { public static String downloadPackage(String id, String fileName, CancelCheck cancelCheck) throws Exception { CloseableHttpResponse fileRes = getHttpResponse(PACKAGE_REUSES_URL, id); - + if (fileRes.getStatusLine().getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY) { + fileRes = getHttpResponse(fileRes.getHeaders("Location")[0].getValue()); + } String realPath = StableUtils.pathJoin(ProductConstants.getEnvHome(), ShareComponentConstants.PLUGIN_CACHE, ShareComponentConstants.DOWNLOAD_PACKAGE_SHARE); String filePath; if (fileRes.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { @@ -133,11 +133,35 @@ public class DownloadUtils { //先登录一下。不然可能失败 CloseableHttpClient client = createClient(); FineLoggerFactory.getLogger().info("login fr-market"); - login(client); FineLoggerFactory.getLogger().info("start download widget {}", id); + HttpUriRequest file = RequestBuilder.post() + .setHeader("User-Agent", "Mozilla/5.0") + .setUri(url).addParameter("id", encrypt(id)) + .build(); + return client.execute(file); + } + + + private static CloseableHttpResponse getHttpResponse(String url) throws Exception { + //先登录一下。不然可能失败 + CloseableHttpClient client = createClient(); HttpUriRequest file = RequestBuilder.get() - .setUri(url + id) + .setUri(url) .build(); return client.execute(file); } + + + private static String encrypt(String str) throws Exception { + //base64编码的公钥 + byte[] decoded = Base64.decodeBase64(CERTIFICATE_PUBLIC_KEY); + RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded)); + //RSA加密 + Cipher cipher = Cipher.getInstance("RSA"); + cipher.init(Cipher.ENCRYPT_MODE, pubKey); + String outStr = Base64.encodeBase64String(cipher.doFinal(str.getBytes(StandardCharsets.UTF_8))); + return outStr; + } + + } From 2bd3625d692b717982573762d3a1a51a80b65f1b Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 18 Jun 2021 15:39:30 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0username=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/share/util/DownloadUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java b/designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java index 7f9a379b5..e415f0055 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.share.util; +import com.fr.design.DesignerEnvManager; import com.fr.design.extra.PluginConstants; import com.fr.form.share.base.CancelCheck; import com.fr.form.share.constants.ShareComponentConstants; @@ -136,7 +137,8 @@ public class DownloadUtils { FineLoggerFactory.getLogger().info("start download widget {}", id); HttpUriRequest file = RequestBuilder.post() .setHeader("User-Agent", "Mozilla/5.0") - .setUri(url).addParameter("id", encrypt(id)) + .setUri(url).addParameter("id", encrypt(id)).addParameter("username", + DesignerEnvManager.getEnvManager().getDesignerLoginUsername() ) .build(); return client.execute(file); } From cc792aae6bce6712722897bc31bd848fc6a3b25f Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 18 Jun 2021 15:49:57 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/mainframe/share/util/DownloadUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java b/designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java index e415f0055..499c70156 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java @@ -137,7 +137,7 @@ public class DownloadUtils { FineLoggerFactory.getLogger().info("start download widget {}", id); HttpUriRequest file = RequestBuilder.post() .setHeader("User-Agent", "Mozilla/5.0") - .setUri(url).addParameter("id", encrypt(id)).addParameter("username", + .setUri(url).addParameter("id", encrypt(id)).addParameter("userId", DesignerEnvManager.getEnvManager().getDesignerLoginUsername() ) .build(); return client.execute(file); From 52663464441fc47d316c7fd58cddf94584b7d3e2 Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 18 Jun 2021 16:15:20 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/mainframe/share/util/DownloadUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java b/designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java index 499c70156..2b4dc70c3 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java @@ -138,7 +138,7 @@ public class DownloadUtils { HttpUriRequest file = RequestBuilder.post() .setHeader("User-Agent", "Mozilla/5.0") .setUri(url).addParameter("id", encrypt(id)).addParameter("userId", - DesignerEnvManager.getEnvManager().getDesignerLoginUsername() ) + String.valueOf(DesignerEnvManager.getEnvManager().getDesignerLoginUid())) .build(); return client.execute(file); }