Browse Source

Pull request #1730: REPORT-31418 【10.0.7】远程设计连接远程服务器时,允许不记录密码

Merge in DESIGN/design from ~LUCIAN.CHEN/design:release/10.0 to release/10.0

* commit '14d7408ac6072353a5b176aeec576b2296b974cf':
  REPORT-31418 【10.0.7】远程设计连接远程服务器时,允许不记录密码
feature/big-screen
Lucian.Chen 5 years ago
parent
commit
dd9d8a8f9c
  1. 29
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 9
      designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java
  3. 4
      designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java
  4. 28
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  5. 30
      designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java
  6. 3
      designer-base/src/test/java/com/fr/design/env/RemoteWorkspaceTest.java

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

@ -8,6 +8,7 @@ import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.env.RemoteWorkspace; import com.fr.design.env.RemoteWorkspace;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.TemplateTreePane; import com.fr.design.file.TemplateTreePane;
@ -380,15 +381,21 @@ public class EnvChangeEntrance {
* 出现对话框选择使用的工作环境 * 出现对话框选择使用的工作环境
*/ */
public void chooseEnv() { public void chooseEnv() {
chooseEnv(currentEnvName);
}
public void chooseEnv(final String envName) {
final EnvListPane envListPane = new EnvListPane(); final EnvListPane envListPane = new EnvListPane();
final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
envListPane.populateEnvManager(currentEnvName); envListPane.populateEnvManager(envName);
envListDialog.addDialogActionListener(new DialogActionAdapter() { envListDialog.addDialogActionListener(new DialogActionAdapter() {
@Override @Override
public void doOk() { public void doOk() {
envListOkAction(envListPane, PopTipStrategy.LATER); envListOkAction(envListPane, PopTipStrategy.LATER);
// 切换完成后清理密码
updateSelectEnv(envName);
} }
@Override @Override
@ -418,6 +425,8 @@ public class EnvChangeEntrance {
FineProcessContext.getParentPipe().fire(new CarryMessageEvent(ReportState.ACTIVE.getValue())); FineProcessContext.getParentPipe().fire(new CarryMessageEvent(ReportState.ACTIVE.getValue()));
if (!envListOkAction(envListPane, PopTipStrategy.NOW)) { if (!envListOkAction(envListPane, PopTipStrategy.NOW)) {
DesignerExiter.getInstance().execute(); DesignerExiter.getInstance().execute();
} else {
updateSelectEnv(currentEnvName);
} }
} }
@ -429,6 +438,24 @@ public class EnvChangeEntrance {
envListDialog.setVisible(true); envListDialog.setVisible(true);
} }
/**
* 切换环境后 刷新远程目录需要忘记密码的情况
* @param envName 环境名
*/
private void updateSelectEnv(String envName) {
DesignerEnvManager mgr = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo info = mgr.getWorkspaceInfo(envName);
if (info != null) {
WorkspaceConnectionInfo connection = info.getConnection();
if (connection != null && !connection.isRememberPwd()) {
DesignerWorkspaceInfo workspaceInfo = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo(
connection.getUrl(), connection.getUserName(), StringUtils.EMPTY, connection.getCertPath(), connection.getCertSecretKey(), false));
mgr.putEnv(envName, workspaceInfo);
}
}
}
/** /**
* 提示显示策略 * 提示显示策略

9
designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java

@ -59,7 +59,14 @@ public class SwitchExistEnv extends MenuDef {
*/ */
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
final String envName = getName(); final String envName = getName();
EnvChangeEntrance.getInstance().switch2Env(envName); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName);
if (selectedEnv.getConnection() != null && !selectedEnv.getConnection().isRememberPwd()) {
// 打开配置目录面板
EnvChangeEntrance.getInstance().chooseEnv(envName);
} else {
EnvChangeEntrance.getInstance().switch2Env(envName);
}
} }
} }
} }

4
designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java vendored

@ -72,7 +72,8 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(" ", "\r\n")); String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(" ", "\r\n"));
String certPath = reader.getAttrAsString("certPath", StringUtils.EMPTY); String certPath = reader.getAttrAsString("certPath", StringUtils.EMPTY);
String certSecretKey = reader.getAttrAsString("certSecretKey", StringUtils.EMPTY); String certSecretKey = reader.getAttrAsString("certSecretKey", StringUtils.EMPTY);
this.connection = new WorkspaceConnectionInfo(url, username, password, certPath, certSecretKey); boolean rememberPwd = reader.getAttrAsBoolean("rememberPwd", true);
this.connection = new WorkspaceConnectionInfo(url, username, password, certPath, certSecretKey, rememberPwd);
} }
} }
} }
@ -89,6 +90,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
writer.attr("password", SecurityToolbox.defaultEncrypt(connection.getPassword())); writer.attr("password", SecurityToolbox.defaultEncrypt(connection.getPassword()));
writer.attr("certPath", connection.getCertPath()); writer.attr("certPath", connection.getCertPath());
writer.attr("certSecretKey", connection.getCertSecretKey()); writer.attr("certSecretKey", connection.getCertSecretKey());
writer.attr("rememberPwd", connection.isRememberPwd());
writer.end(); writer.end();
} }
} }

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

@ -96,6 +96,10 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
* 密码 * 密码
*/ */
private UIPassWordField passwordInput = new UIPassWordField(); private UIPassWordField passwordInput = new UIPassWordField();
/**
* 是否记住密码
*/
private UICheckBox rememberPwdCheckbox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Remote_Env_Remember_Password"));
/** /**
* https证书路径 * https证书路径
*/ */
@ -212,7 +216,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
updateHttpsConfigPanel(); updateHttpsConfigPanel();
remoteWorkspaceURL.setHttps(isHttps); remoteWorkspaceURL.setHttps(isHttps);
// reset下url,将勾选状态是否htpps加到url里 // reset下url,将勾选状态是否https加到url里
remoteWorkspaceURL.resetUrl(); remoteWorkspaceURL.resetUrl();
fillRemoteEnvURLField(); fillRemoteEnvURLField();
@ -286,6 +290,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
contentPanel.add(configPanel, BorderLayout.NORTH); contentPanel.add(configPanel, BorderLayout.NORTH);
contentPanel.add(accountPanel, BorderLayout.CENTER); contentPanel.add(accountPanel, BorderLayout.CENTER);
contentPanel.add(packRememberPwdConfigPanel(), BorderLayout.SOUTH);
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.add(contentPanel, BorderLayout.NORTH); panel.add(contentPanel, BorderLayout.NORTH);
panel.add(testPanel, BorderLayout.CENTER); panel.add(testPanel, BorderLayout.CENTER);
@ -306,15 +311,18 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
String pwd = fromNullable(connection.getPassword()).or(StringUtils.EMPTY); String pwd = fromNullable(connection.getPassword()).or(StringUtils.EMPTY);
String certPath = fromNullable(connection.getCertPath()).or(StringUtils.EMPTY); String certPath = fromNullable(connection.getCertPath()).or(StringUtils.EMPTY);
String certSecretKey = fromNullable(connection.getCertSecretKey()).or(StringUtils.EMPTY); String certSecretKey = fromNullable(connection.getCertSecretKey()).or(StringUtils.EMPTY);
boolean rememberPwd = fromNullable(connection.isRememberPwd()).or(true);
this.usernameInput.setText(username); this.usernameInput.setText(username);
this.passwordInput.setText(pwd); this.passwordInput.setText(pwd);
this.certPathInput.setText(certPath); this.certPathInput.setText(certPath);
this.certSecretKeyInput.setText(certSecretKey); this.certSecretKeyInput.setText(certSecretKey);
this.rememberPwdCheckbox.setSelected(rememberPwd);
} else { } else {
this.remoteWorkspaceURL = RemoteWorkspaceURL.createDefaultURL(); this.remoteWorkspaceURL = RemoteWorkspaceURL.createDefaultURL();
this.usernameInput.setText(StringUtils.EMPTY); this.usernameInput.setText(StringUtils.EMPTY);
this.passwordInput.setText(StringUtils.EMPTY); this.passwordInput.setText(StringUtils.EMPTY);
this.rememberPwdCheckbox.setSelected(true);
} }
fillRemoteEnvURLField(); fillRemoteEnvURLField();
@ -333,6 +341,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
String url = this.remoteWorkspaceURL.getURL(); String url = this.remoteWorkspaceURL.getURL();
String username = this.usernameInput.getText(); String username = this.usernameInput.getText();
String password = new String(this.passwordInput.getPassword()); String password = new String(this.passwordInput.getPassword());
boolean rememberPwd = this.rememberPwdCheckbox.isSelected();
DesignerEnvProcessor envProcessor = ExtraDesignClassManager.getInstance().getSingle(DesignerEnvProcessor.XML_TAG); DesignerEnvProcessor envProcessor = ExtraDesignClassManager.getInstance().getSingle(DesignerEnvProcessor.XML_TAG);
if (envProcessor != null) { if (envProcessor != null) {
url = envProcessor.changeEnvPathBeforeConnect(username, password, url); url = envProcessor.changeEnvPathBeforeConnect(username, password, url);
@ -342,7 +351,8 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
username, username,
password, password,
this.certPathInput.getText(), this.certPathInput.getText(),
new String(this.certSecretKeyInput.getPassword())); new String(this.certSecretKeyInput.getPassword()),
rememberPwd);
return RemoteDesignerWorkspaceInfo.create(connection); return RemoteDesignerWorkspaceInfo.create(connection);
} }
@ -522,6 +532,20 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
accountPanel.add(content, BorderLayout.CENTER); accountPanel.add(content, BorderLayout.CENTER);
} }
private JPanel packRememberPwdConfigPanel() {
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{
new Component[]{rememberPwdCheckbox}
},
new double[]{PREFERRED},
new double[]{PREFERRED},
5,
10
);
TableLayoutHelper.modifyTableLayoutIndexHGap(panel, 0, 50);
return panel;
}
private JPanel createHttpsCertFileInputPanel() { private JPanel createHttpsCertFileInputPanel() {
JPanel inputPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); JPanel inputPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();

30
designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java

@ -2,7 +2,9 @@ package com.fr.design;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.env.CheckServiceDialog; import com.fr.env.CheckServiceDialog;
import com.fr.invoke.Reflect;
import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import org.easymock.EasyMock; import org.easymock.EasyMock;
@ -19,7 +21,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
* @Description: * @Description:
*/ */
@RunWith(PowerMockRunner.class) @RunWith(PowerMockRunner.class)
@PrepareForTest({FunctionalHttpRequest.class,EnvChangeEntrance.class,CheckServiceDialog.class}) @PrepareForTest({FunctionalHttpRequest.class,EnvChangeEntrance.class,CheckServiceDialog.class, DesignerEnvManager.class})
public class EnvChangeEntranceTest { public class EnvChangeEntranceTest {
@Test @Test
@ -55,4 +57,30 @@ public class EnvChangeEntranceTest {
} }
} }
@Test
public void testUpdateSelectEnv() {
DesignerEnvManager manager = new DesignerEnvManager();
PowerMock.mockStatic(DesignerEnvManager.class);
EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(manager).anyTimes();
PowerMock.replayAll();
EnvChangeEntrance entrance = EnvChangeEntrance.getInstance();
manager.putEnv("test1", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true)));
manager.putEnv("test2", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", false)));
Reflect.on(entrance).call("updateSelectEnv", "test1");
Reflect.on(entrance).call("updateSelectEnv", "test2");
Assert.assertEquals(manager.getWorkspaceInfo("test1").getConnection(), RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true)).getConnection());
Assert.assertEquals(manager.getWorkspaceInfo("test2").getConnection(), RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "", "", "", false)).getConnection());
PowerMock.verifyAll();
}
} }

3
designer-base/src/test/java/com/fr/design/env/RemoteWorkspaceTest.java vendored

@ -38,7 +38,7 @@ public class RemoteWorkspaceTest {
EasyMock.replay(workspace, operator); EasyMock.replay(workspace, operator);
PowerMock.replayAll(); PowerMock.replayAll();
WorkspaceConnectionInfo info = new WorkspaceConnectionInfo("url", "username", "password", "certPath", "certSecretKey"); WorkspaceConnectionInfo info = new WorkspaceConnectionInfo("url", "username", "password", "certPath", "certSecretKey", true);
RemoteWorkspace remoteWorkspace= new RemoteWorkspace(null, info); RemoteWorkspace remoteWorkspace= new RemoteWorkspace(null, info);
@ -51,4 +51,5 @@ public class RemoteWorkspaceTest {
} }
} }
Loading…
Cancel
Save