Browse Source

https

master
hzzz 7 years ago
parent
commit
09d491ae8b
  1. 14
      designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java
  2. 15
      designer-base/src/com/fr/env/RemoteEnvPane.java
  3. 17
      designer-realize/src/com/fr/design/mainframe/socketio/DesignerSocketIO.java

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

@ -55,8 +55,10 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
String url = reader.getAttrAsString("url", StringUtils.EMPTY); String url = reader.getAttrAsString("url", StringUtils.EMPTY);
String username = reader.getAttrAsString("username", 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(" ", "\r\n"));
this.connection = new WorkspaceConnection(url, username, password); String certPath = reader.getAttrAsString("certPath", StringUtils.EMPTY);
String certSecretKey = reader.getAttrAsString("certSecretKey", StringUtils.EMPTY);
this.connection = new WorkspaceConnection(url, username, password, certPath, certSecretKey);
} }
} }
} }
@ -70,6 +72,8 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
writer.attr("url", connection.getUrl()); writer.attr("url", connection.getUrl());
writer.attr("username", connection.getUserName()); writer.attr("username", connection.getUserName());
writer.attr("password", SecurityToolbox.defaultEncrypt(connection.getPassword())); writer.attr("password", SecurityToolbox.defaultEncrypt(connection.getPassword()));
writer.attr("certPath", connection.getCertPath());
writer.attr("certSecretKey", connection.getCertSecretKey());
writer.end(); writer.end();
} }
} }
@ -77,9 +81,9 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
@Override @Override
public Object clone() throws CloneNotSupportedException { public Object clone() throws CloneNotSupportedException {
RemoteDesignerWorkspaceInfo object = (RemoteDesignerWorkspaceInfo)super.clone(); RemoteDesignerWorkspaceInfo object = (RemoteDesignerWorkspaceInfo) super.clone();
object.connection = (WorkspaceConnection)StableUtils.cloneObject(this.connection); object.connection = (WorkspaceConnection) StableUtils.cloneObject(this.connection);
return object; return object;
} }
} }

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

@ -270,8 +270,13 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
: new RemoteEnvURL(connection.getUrl()); : new RemoteEnvURL(connection.getUrl());
String username = fromNullable(connection.getUserName()).or(StringUtils.EMPTY); String username = fromNullable(connection.getUserName()).or(StringUtils.EMPTY);
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 certSecretKey = fromNullable(connection.getCertSecretKey()).or(StringUtils.EMPTY);
this.usernameInput.setText(username); this.usernameInput.setText(username);
this.passwordInput.setText(pwd); this.passwordInput.setText(pwd);
this.certPathInput.setText(certPath);
this.certSecretKeyInput.setText(certSecretKey);
} }
fillRemoteEnvURLField(); fillRemoteEnvURLField();
@ -290,7 +295,9 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
WorkspaceConnection connection = new WorkspaceConnection( WorkspaceConnection connection = new WorkspaceConnection(
this.remoteEnvURL.getURL(), this.remoteEnvURL.getURL(),
this.usernameInput.getText(), 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); return RemoteDesignerWorkspaceInfo.create(connection);
} }
@ -478,7 +485,11 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
final RemoteDesignerWorkspaceInfo remoteEnv = updateBean(); 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 @Override

17
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.design.mainframe.loghandler.DesignerLogHandler;
import com.fr.general.LogRecordTime; import com.fr.general.LogRecordTime;
import com.fr.general.LogUtils; 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.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.third.guava.base.Optional; import com.fr.third.guava.base.Optional;
import com.fr.third.guava.primitives.Ints; 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.WorkContext;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.base.WorkspaceConstants; import com.fr.workspace.base.WorkspaceConstants;
import com.fr.workspace.engine.connector.FineWorkspaceConnector;
import com.fr.workspace.engine.server.rpc.netty.RemoteCallClient; import com.fr.workspace.engine.server.rpc.netty.RemoteCallClient;
import io.socket.client.IO; import io.socket.client.IO;
import io.socket.client.Socket; import io.socket.client.Socket;
@ -76,13 +82,18 @@ public class DesignerSocketIO {
private static int getPort(Workspace current) throws IOException { private static int getPort(Workspace current) throws IOException {
String url = current.getPath() + WorkspaceConstants.CONTROLLER_PREFIX + WorkspaceConstants.CONTROLLER_SOCKETIO_PORT; String url = current.getPath() + WorkspaceConstants.CONTROLLER_PREFIX + WorkspaceConstants.CONTROLLER_SOCKETIO_PORT;
CloseableHttpResponse response = null;
try { try {
String portStr = HttpToolbox.get(url); HttpGet httpGet = new HttpGet(url);
JSONObject jsonObject = new JSONObject(portStr); response = FineWorkspaceConnector.getInstance().currentHttpClient().execute(httpGet);
HttpEntity entity = response.getEntity();
JSONObject jsonObject = new JSONObject(EntityUtils.toString(entity));
return Ints.tryParse(jsonObject.optString("data")); return Ints.tryParse(jsonObject.optString("data"));
} catch (JSONException e) { } catch (JSONException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
throw new RuntimeException(e); throw new RuntimeException(e);
} finally {
ResourceIOUtils.close(response);
} }
} }
} }
Loading…
Cancel
Save