From 09d491ae8ba2f980442bc923e73926df1a1e0f29 Mon Sep 17 00:00:00 2001 From: hzzz Date: Wed, 11 Jul 2018 10:33:36 +0800 Subject: [PATCH 1/5] https --- .../env/RemoteDesignerWorkspaceInfo.java | 18 +++++++++++------- .../src/com/fr/env/RemoteEnvPane.java | 15 +++++++++++++-- .../mainframe/socketio/DesignerSocketIO.java | 17 ++++++++++++++--- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java b/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java index 8954f483b..25fc10225 100644 --- a/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java +++ b/designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java @@ -8,7 +8,7 @@ import com.fr.stable.xml.XMLableReader; import com.fr.workspace.connect.WorkspaceConnection; public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { - + private String name; private WorkspaceConnection connection; @@ -55,8 +55,10 @@ 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")); - this.connection = new WorkspaceConnection(url, username, password); + String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(" ", "\r\n")); + String certPath = reader.getAttrAsString("certPath", StringUtils.EMPTY); + String certSecretKey = reader.getAttrAsString("certSecretKey", StringUtils.EMPTY); + this.connection = new WorkspaceConnection(url, username, password, certPath, certSecretKey); } } } @@ -70,16 +72,18 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { 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()); writer.end(); } } - + @Override public Object clone() throws CloneNotSupportedException { - RemoteDesignerWorkspaceInfo object = (RemoteDesignerWorkspaceInfo)super.clone(); + RemoteDesignerWorkspaceInfo object = (RemoteDesignerWorkspaceInfo) super.clone(); - object.connection = (WorkspaceConnection)StableUtils.cloneObject(this.connection); - return object; + object.connection = (WorkspaceConnection) StableUtils.cloneObject(this.connection); + return object; } } diff --git a/designer-base/src/com/fr/env/RemoteEnvPane.java b/designer-base/src/com/fr/env/RemoteEnvPane.java index a07e9996c..68945319f 100644 --- a/designer-base/src/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/com/fr/env/RemoteEnvPane.java @@ -270,8 +270,13 @@ public class RemoteEnvPane extends BasicBeanPane { : new RemoteEnvURL(connection.getUrl()); String username = fromNullable(connection.getUserName()).or(StringUtils.EMPTY); String pwd = fromNullable(connection.getPassword()).or(StringUtils.EMPTY); + String certPath = fromNullable(connection.getCertPath()).or(StringUtils.EMPTY); + String certSecretKey = fromNullable(connection.getCertSecretKey()).or(StringUtils.EMPTY); this.usernameInput.setText(username); this.passwordInput.setText(pwd); + this.certPathInput.setText(certPath); + this.certSecretKeyInput.setText(certSecretKey); + } fillRemoteEnvURLField(); @@ -290,7 +295,9 @@ public class RemoteEnvPane extends BasicBeanPane { WorkspaceConnection connection = new WorkspaceConnection( this.remoteEnvURL.getURL(), this.usernameInput.getText(), - new String(this.passwordInput.getPassword())); + new String(this.passwordInput.getPassword()), + this.certPathInput.getText(), + new String(this.certSecretKeyInput.getPassword())); return RemoteDesignerWorkspaceInfo.create(connection); } @@ -478,7 +485,11 @@ public class RemoteEnvPane extends BasicBeanPane { final RemoteDesignerWorkspaceInfo remoteEnv = updateBean(); - return WorkContext.getConnector().testConnection(remoteEnv.getConnection()); + WorkspaceConnection connection = remoteEnv.getConnection(); + DesignerEnvManager.getEnvManager().setCertificatePath(connection.getCertPath()); + DesignerEnvManager.getEnvManager().setCertificatePass(connection.getCertSecretKey()); + + return WorkContext.getConnector().testConnection(connection); } @Override diff --git a/designer-realize/src/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/com/fr/design/mainframe/socketio/DesignerSocketIO.java index 9beaab345..c9b7d3abc 100644 --- a/designer-realize/src/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -4,15 +4,21 @@ import com.fr.decision.webservice.utils.DecisionServiceConstants; import com.fr.design.mainframe.loghandler.DesignerLogHandler; import com.fr.general.LogRecordTime; import com.fr.general.LogUtils; -import com.fr.general.http.HttpToolbox; +import com.fr.io.utils.ResourceIOUtils; import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.third.guava.base.Optional; import com.fr.third.guava.primitives.Ints; +import com.fr.third.org.apache.http.HttpEntity; +import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse; +import com.fr.third.org.apache.http.client.methods.HttpGet; +import com.fr.third.org.apache.http.impl.client.CloseableHttpClient; +import com.fr.third.org.apache.http.util.EntityUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.base.WorkspaceConstants; +import com.fr.workspace.engine.connector.FineWorkspaceConnector; import com.fr.workspace.engine.server.rpc.netty.RemoteCallClient; import io.socket.client.IO; import io.socket.client.Socket; @@ -76,13 +82,18 @@ public class DesignerSocketIO { private static int getPort(Workspace current) throws IOException { String url = current.getPath() + WorkspaceConstants.CONTROLLER_PREFIX + WorkspaceConstants.CONTROLLER_SOCKETIO_PORT; + CloseableHttpResponse response = null; try { - String portStr = HttpToolbox.get(url); - JSONObject jsonObject = new JSONObject(portStr); + HttpGet httpGet = new HttpGet(url); + response = FineWorkspaceConnector.getInstance().currentHttpClient().execute(httpGet); + HttpEntity entity = response.getEntity(); + JSONObject jsonObject = new JSONObject(EntityUtils.toString(entity)); return Ints.tryParse(jsonObject.optString("data")); } catch (JSONException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); throw new RuntimeException(e); + } finally { + ResourceIOUtils.close(response); } } } \ No newline at end of file From f419e51ecaf7e22adc1410d58be0edea7cebf777 Mon Sep 17 00:00:00 2001 From: hzzz Date: Wed, 11 Jul 2018 14:38:48 +0800 Subject: [PATCH 2/5] https --- .../mainframe/socketio/DesignerSocketIO.java | 29 +------------------ .../fr/start/module/DesignerActivator.java | 7 +++++ 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index c9b7d3abc..63ab63e62 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -4,21 +4,11 @@ import com.fr.decision.webservice.utils.DecisionServiceConstants; import com.fr.design.mainframe.loghandler.DesignerLogHandler; import com.fr.general.LogRecordTime; import com.fr.general.LogUtils; -import com.fr.io.utils.ResourceIOUtils; -import com.fr.json.JSONException; -import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.third.guava.base.Optional; -import com.fr.third.guava.primitives.Ints; -import com.fr.third.org.apache.http.HttpEntity; -import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse; -import com.fr.third.org.apache.http.client.methods.HttpGet; -import com.fr.third.org.apache.http.impl.client.CloseableHttpClient; -import com.fr.third.org.apache.http.util.EntityUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.base.WorkspaceConstants; -import com.fr.workspace.engine.connector.FineWorkspaceConnector; import com.fr.workspace.engine.server.rpc.netty.RemoteCallClient; import io.socket.client.IO; import io.socket.client.Socket; @@ -71,7 +61,7 @@ public class DesignerSocketIO { private static String getSocketUri(Workspace current) throws IOException { URL url = new URL(current.getPath()); - int port = getPort(current); + int port = WorkContext.getCurrent().get(SocketInfoOperator.class).getPort(); return String.format("http://%s:%s%s?%s=%s", url.getHost(), port, @@ -79,21 +69,4 @@ public class DesignerSocketIO { DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME, RemoteCallClient.getInstance().getToken()); } - - private static int getPort(Workspace current) throws IOException { - String url = current.getPath() + WorkspaceConstants.CONTROLLER_PREFIX + WorkspaceConstants.CONTROLLER_SOCKETIO_PORT; - CloseableHttpResponse response = null; - try { - HttpGet httpGet = new HttpGet(url); - response = FineWorkspaceConnector.getInstance().currentHttpClient().execute(httpGet); - HttpEntity entity = response.getEntity(); - JSONObject jsonObject = new JSONObject(EntityUtils.toString(entity)); - return Ints.tryParse(jsonObject.optString("data")); - } catch (JSONException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - throw new RuntimeException(e); - } finally { - ResourceIOUtils.close(response); - } - } } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index 12a7e9c05..f29224455 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -51,6 +51,8 @@ import com.fr.design.mainframe.loghandler.DesignerLogAppender; import com.fr.design.mainframe.loghandler.DesignerLogImpl; import com.fr.design.mainframe.loghandler.LogMessageBar; import com.fr.design.mainframe.socketio.DesignerSocketIO; +import com.fr.design.mainframe.socketio.FineSocketInfoOperator; +import com.fr.design.mainframe.socketio.SocketInfoOperator; import com.fr.design.module.DesignModuleFactory; import com.fr.design.parameter.FormParameterReader; import com.fr.design.parameter.ParameterPropertyPane; @@ -98,6 +100,8 @@ import com.fr.stable.script.ValueConverter; import com.fr.stable.xml.ObjectTokenizer; import com.fr.stable.xml.ObjectXMLWriterFinder; import com.fr.start.BBSGuestPaneProvider; +import com.fr.workspace.base.WorkspaceKey; +import com.fr.workspace.pool.WorkPRCRegister; import com.fr.xml.ReportXMLUtils; import java.awt.Image; @@ -409,5 +413,8 @@ public class DesignerActivator extends Activator implements Prepare { public void prepare() { addMutable(InterMutableKey.Path, "com/fr/design/i18n/main", "com/fr/design/i18n/chart"); + + addMutable(WorkspaceKey.RPC, WorkPRCRegister.wrap(SocketInfoOperator.class, new FineSocketInfoOperator())); + } } \ No newline at end of file From 6b57516dee0331dbcec41958efb812bce9f565db Mon Sep 17 00:00:00 2001 From: hzzz Date: Wed, 11 Jul 2018 14:43:04 +0800 Subject: [PATCH 3/5] https --- .../mainframe/socketio/FineSocketInfoOperator.java | 11 +++++++++++ .../design/mainframe/socketio/SocketInfoOperator.java | 5 +++++ 2 files changed, 16 insertions(+) create mode 100644 designer-realize/src/main/java/com/fr/design/mainframe/socketio/FineSocketInfoOperator.java create mode 100644 designer-realize/src/main/java/com/fr/design/mainframe/socketio/SocketInfoOperator.java diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/FineSocketInfoOperator.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/FineSocketInfoOperator.java new file mode 100644 index 000000000..9108299c5 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/FineSocketInfoOperator.java @@ -0,0 +1,11 @@ +package com.fr.design.mainframe.socketio; + +import com.fr.web.WebSocketConfig; + +public class FineSocketInfoOperator implements SocketInfoOperator { + + @Override + public int getPort() { + return WebSocketConfig.getInstance().getPort(); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/SocketInfoOperator.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/SocketInfoOperator.java new file mode 100644 index 000000000..338fb7fc5 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/SocketInfoOperator.java @@ -0,0 +1,5 @@ +package com.fr.design.mainframe.socketio; + +public interface SocketInfoOperator { + int getPort(); +} From 02d95aa006febc7b486a76160c000112e2894d6d Mon Sep 17 00:00:00 2001 From: hzzz Date: Wed, 11 Jul 2018 15:29:50 +0800 Subject: [PATCH 4/5] https --- .../design/mainframe/socketio/DesignerSocketIO.java | 1 + .../mainframe/socketio/FineSocketInfoOperator.java | 11 ----------- .../design/mainframe/socketio/SocketInfoOperator.java | 5 ----- .../java/com/fr/start/module/DesignerActivator.java | 4 ++-- 4 files changed, 3 insertions(+), 18 deletions(-) delete mode 100644 designer-realize/src/main/java/com/fr/design/mainframe/socketio/FineSocketInfoOperator.java delete mode 100644 designer-realize/src/main/java/com/fr/design/mainframe/socketio/SocketInfoOperator.java diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index 63ab63e62..1e5305300 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe.socketio; import com.fr.decision.webservice.utils.DecisionServiceConstants; import com.fr.design.mainframe.loghandler.DesignerLogHandler; +import com.fr.env.operator.socket.SocketInfoOperator; import com.fr.general.LogRecordTime; import com.fr.general.LogUtils; import com.fr.log.FineLoggerFactory; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/FineSocketInfoOperator.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/FineSocketInfoOperator.java deleted file mode 100644 index 9108299c5..000000000 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/FineSocketInfoOperator.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.fr.design.mainframe.socketio; - -import com.fr.web.WebSocketConfig; - -public class FineSocketInfoOperator implements SocketInfoOperator { - - @Override - public int getPort() { - return WebSocketConfig.getInstance().getPort(); - } -} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/SocketInfoOperator.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/SocketInfoOperator.java deleted file mode 100644 index 338fb7fc5..000000000 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/SocketInfoOperator.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.fr.design.mainframe.socketio; - -public interface SocketInfoOperator { - int getPort(); -} diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index f29224455..2090c0ff5 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -51,8 +51,8 @@ import com.fr.design.mainframe.loghandler.DesignerLogAppender; import com.fr.design.mainframe.loghandler.DesignerLogImpl; import com.fr.design.mainframe.loghandler.LogMessageBar; import com.fr.design.mainframe.socketio.DesignerSocketIO; -import com.fr.design.mainframe.socketio.FineSocketInfoOperator; -import com.fr.design.mainframe.socketio.SocketInfoOperator; +import com.fr.env.operator.socket.FineSocketInfoOperator; +import com.fr.env.operator.socket.SocketInfoOperator; import com.fr.design.module.DesignModuleFactory; import com.fr.design.parameter.FormParameterReader; import com.fr.design.parameter.ParameterPropertyPane; From c43fb7a7e795b3aa24ced6a01e2a62c0de205c93 Mon Sep 17 00:00:00 2001 From: hzzz Date: Wed, 11 Jul 2018 19:35:05 +0800 Subject: [PATCH 5/5] . --- .../com/fr/design/mainframe/socketio/DesignerSocketIO.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index 1e5305300..a44bdf8b2 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -63,7 +63,8 @@ public class DesignerSocketIO { private static String getSocketUri(Workspace current) throws IOException { URL url = new URL(current.getPath()); int port = WorkContext.getCurrent().get(SocketInfoOperator.class).getPort(); - return String.format("http://%s:%s%s?%s=%s", + return String.format("%s://%s:%s%s?%s=%s", + url.getProtocol(), url.getHost(), port, WorkspaceConstants.WS_NAMESPACE,