Browse Source

Pull request #2719: REPORT-40646 远程设计对接平台密码策略

Merge in DESIGN/design from ~HADES/design:release/10.0 to release/10.0

* commit '358d972dee8097028365832a103cd98d85d94abd':
  REPORT-40646 去掉无用的代码
  REPORT-40646 远程设计对接平台密码策略
feature/big-screen
ju.ju 4 years ago
parent
commit
fdafab794b
  1. 52
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 55
      designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java
  3. 19
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  4. 2
      designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java
  5. 139
      designer-base/src/main/java/com/fr/env/TestConnectionResult.java

52
designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java

@ -5,6 +5,7 @@ import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
@ -18,7 +19,10 @@ import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.DesignUtils;
import com.fr.env.CheckServiceDialog;
import com.fr.env.EnvListPane;
import com.fr.env.RemoteWorkspaceURL;
import com.fr.env.TestConnectionResult;
import com.fr.exit.DesignerExiter;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.invoke.Reflect;
import com.fr.json.JSONArray;
@ -40,6 +44,7 @@ import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.base.FineObjectPool;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import com.fr.workspace.engine.exception.WorkspaceAuthException;
import com.fr.workspace.engine.exception.WorkspaceCheckException;
import com.fr.workspace.engine.exception.WorkspaceConnectionException;
import com.fr.workspace.engine.rpc.WorkspaceProxyPool;
@ -145,21 +150,28 @@ public class EnvChangeEntrance {
strategy.showTip(new PopTip() {
@Override
public void show() {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon"));
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
Toolkit.i18nText("Fine-Design_Basic_Error"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
}
});
return false;
} catch (WorkspaceCheckException e) {
handleWorkspaceCheckException(e, strategy, connectionInfo);
return false;
} catch (Exception exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
strategy.showTip(new PopTip() {
@Override
public void show() {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon"));
}
});
if (exception.getCause() instanceof WorkspaceCheckException) {
handleWorkspaceCheckException((WorkspaceCheckException) exception.getCause(), strategy, connectionInfo);
} else {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
strategy.showTip(() -> FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
Toolkit.i18nText("Fine-Design_Basic_Error"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")));
}
return false;
}
TemplateTreePane.getInstance().refreshDockingView();
@ -170,6 +182,24 @@ public class EnvChangeEntrance {
return true;
}
private void handleWorkspaceCheckException(WorkspaceCheckException e, PopTipStrategy strategy, WorkspaceConnectionInfo info) {
TestConnectionResult result = TestConnectionResult.parseByException(e);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
if (ComparatorUtils.equals(result, TestConnectionResult.AUTH_FAILED)) {
strategy.showTip(() -> FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
Toolkit.i18nText("Fine-Design_Basic_Error"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")));
} else {
strategy.showTip(() -> FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
new MessageWithLink(result.getText(), Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"), info.getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH),
Toolkit.i18nText("Fine-Design_Basic_Error"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")));
}
}
/**
* 这个功能留着可能会加回来先做注释处理
* 切换远程环境之前进行版本检测当版本不一致的时候提示

55
designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java

@ -0,0 +1,55 @@
package com.fr.design.dialog.link;
import com.fr.design.gui.ilable.UILabel;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.Font;
import java.net.URI;
import javax.swing.JEditorPane;
import javax.swing.event.HyperlinkEvent;
/**
* 用来构建JOptionPane带超链的消息提示
*
* @author hades
* @version 10.0
* Created by hades on 2020/10/23
*/
public class MessageWithLink extends JEditorPane {
public MessageWithLink(String message, String linkName, String link) {
super("text/html", "<html><body style=\"" + getStyle() + "\">" + message + "<a href=\"" + link + "\">" + linkName + "</a>" + "</body></html>");
addHyperlinkListener(e -> {
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
try {
Desktop.getDesktop().browse(URI.create(link));
} catch (Exception exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
}
}
});
setEditable(false);
setBorder(null);
}
public MessageWithLink(String linkName, String link ) {
this(StringUtils.EMPTY, linkName, link);
}
private static StringBuilder getStyle() {
// 构建和相同风格样式
UILabel label = new UILabel();
Font font = label.getFont();
Color color = label.getBackground();
StringBuilder style = new StringBuilder("font-family:" + font.getFamily() + ";");
style.append("font-weight:").append(font.isBold() ? "bold" : "normal").append(";");
style.append("font-size:").append(font.getSize()).append("pt;");
style.append("background-color: rgb(").append(color.getRed()).append(",").append(color.getGreen()).append(",").append(color.getBlue()).append(");");
return style;
}
}

19
designer-base/src/main/java/com/fr/env/RemoteEnvPane.java vendored

@ -4,6 +4,8 @@ import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.border.UITitledBorder;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.fun.DesignerEnvProcessor;
import com.fr.design.gui.ibutton.UIButton;
@ -16,6 +18,7 @@ import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.scrollruler.ModLineBorder;
import com.fr.license.exception.RegistEditionException;
import com.fr.log.FineLoggerFactory;
@ -25,6 +28,7 @@ import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.exception.WorkspaceAuthException;
import com.fr.workspace.engine.exception.WorkspaceCheckException;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JDialog;
@ -53,12 +57,13 @@ import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.util.function.Supplier;
import static com.fr.design.layout.TableLayout.FILL;
import static com.fr.design.layout.TableLayout.PREFERRED;
import static com.fr.env.TestConnectionResult.AUTH_FAILED;
import static com.fr.third.guava.base.Optional.fromNullable;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
/**
* @author yaohwu
@ -583,6 +588,8 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
} catch (RegistEditionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
throw e;
} catch (WorkspaceCheckException e) {
return TestConnectionResult.parseByException(e);
}
}
@ -591,6 +598,14 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
okButton.setEnabled(true);
try {
TestConnectionResult result = get();
if (result.isVerifyResult()) {
dialog.dispose();
FineJOptionPane.showMessageDialog(RemoteEnvPane.this,
new MessageWithLink(result.getText(), Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"), connection.getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH),
Toolkit.i18nText("Fine-Design_Basic_Dialog_Message_Title"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
}
message.setText(result.getText());
uiLabel.setIcon(result.getIcon());
} catch (Exception e) {
@ -635,7 +650,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0));
okButton.setEnabled(false);
dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane.this), UIManager.getString("OptionPane.messageDialogTitle"), true);
dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane.this), Toolkit.i18nText("Fine-Design_Basic_Dialog_Message_Title"), true);
dialog.setSize(new Dimension(308, 132));
okButton.setEnabled(false);

2
designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java vendored

@ -9,6 +9,8 @@ import com.fr.stable.StringUtils;
*/
public class RemoteWorkspaceURL implements FCloneable {
public static final String SYSTEM_LOGIN_PATH = "#management/system/login";
/**
* 默认 web app name
*/

139
designer-base/src/main/java/com/fr/env/TestConnectionResult.java vendored

@ -1,12 +1,15 @@
package com.fr.env;
import com.fr.decision.webservice.exception.login.UserLoginLockException;
import com.fr.decision.webservice.exception.login.UserPasswordNeedUpdateException;
import com.fr.decision.webservice.exception.user.UserPasswordStrengthLimitException;
import com.fr.design.i18n.Toolkit;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.AssistUtils;
import com.fr.workspace.WorkContext;
import com.fr.exception.RemoteDesignPermissionDeniedException;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import com.fr.workspace.engine.exception.WorkspaceCheckException;
import javax.swing.Icon;
import javax.swing.UIManager;
@ -76,12 +79,127 @@ public enum TestConnectionResult {
public String getText() {
return Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed");
}
},
/**
* 登录锁定
*/
LOGIN_LOCK {
private String value;
@Override
public Icon getIcon() {
return UIManager.getIcon("OptionPane.errorIcon");
}
@Override
public String getText() {
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Login_Lock", value);
}
@Override
public String errorCode() {
return UserLoginLockException.ERROR_CODE;
}
@Override
public void setValue(String lockMin) {
this.value = lockMin;
}
@Override
public boolean isVerifyResult() {
return true;
}
},
/**
* 没有远程设计权限
*/
PERMISSION_DENIED {
@Override
public Icon getIcon() {
return UIManager.getIcon("OptionPane.errorIcon");
}
@Override
public String getText() {
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Permission_Denied");
}
@Override
public String errorCode() {
return RemoteDesignPermissionDeniedException.ERROR_CODE;
}
},
/**
* 弱密码
*/
PASSWORD_STRENGTH_LIMIT () {
@Override
public Icon getIcon() {
return UIManager.getIcon("OptionPane.errorIcon");
}
@Override
public String getText() {
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Weak_Password");
}
@Override
public String errorCode() {
return UserPasswordStrengthLimitException.ERROR_CODE;
}
@Override
public boolean isVerifyResult() {
return true;
}
},
/**
* 密码更新
*/
PASSWORD_NEED_UPDATE {
@Override
public Icon getIcon() {
return UIManager.getIcon("OptionPane.errorIcon");
}
@Override
public String getText() {
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Update_Password");
}
@Override
public String errorCode() {
return UserPasswordNeedUpdateException.ERROR_CODE;
}
@Override
public boolean isVerifyResult() {
return true;
}
};
public abstract Icon getIcon();
public abstract String getText();
public void setValue(String value) {
// do noting
}
public String errorCode() {
return StringUtils.EMPTY;
}
public boolean isVerifyResult() {
return false;
}
public static TestConnectionResult parse(Boolean value, WorkspaceConnectionInfo info) {
if (value == null) {
return AUTH_FAILED;
@ -92,4 +210,17 @@ public enum TestConnectionResult {
//去掉测试连接时所做的检测
return FULLY_SUCCESS;
}
public static TestConnectionResult parseByException(WorkspaceCheckException e) {
for (TestConnectionResult result : values()) {
if (ComparatorUtils.equals(e.errorCode(), result.errorCode())) {
// 登录锁定 获取下锁定的时间
if (ComparatorUtils.equals(result, LOGIN_LOCK)) {
result.setValue(e.getMessage().replaceAll("\\D+", StringUtils.EMPTY));
}
return result;
}
}
return AUTH_FAILED;
}
}

Loading…
Cancel
Save