Browse Source

https

master
hzzz 7 years ago
parent
commit
09d491ae8b
  1. 6
      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

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

@ -56,7 +56,9 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
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 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("username", connection.getUserName());
writer.attr("password", SecurityToolbox.defaultEncrypt(connection.getPassword()));
writer.attr("certPath", connection.getCertPath());
writer.attr("certSecretKey", connection.getCertSecretKey());
writer.end();
}
}

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

@ -270,8 +270,13 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
: 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<RemoteDesignerWorkspaceInfo> {
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<RemoteDesignerWorkspaceInfo> {
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

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.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);
}
}
}
Loading…
Cancel
Save