Browse Source

REPORT-130000 fbp的fr服务启动失败,但是fbp设计器测试连接还是成功的,点击确定设计器页面卡死 & REPORT-131068 远程设计权限校验不生效

fbp/release
Destiny.Lin 3 months ago
parent
commit
cb1d74bc3d
  1. 32
      designer-base/src/main/java/com/fr/design/env/HttpWorkspaceConnector.java

32
designer-base/src/main/java/com/fr/design/env/HttpWorkspaceConnector.java vendored

@ -4,8 +4,10 @@ import com.fanruan.workplace.http.HttpConstants;
import com.fanruan.workplace.http.HttpServiceMap; import com.fanruan.workplace.http.HttpServiceMap;
import com.fanruan.workplace.http.RepositoryManager; import com.fanruan.workplace.http.RepositoryManager;
import com.fanruan.workplace.http.info.Stub; import com.fanruan.workplace.http.info.Stub;
import com.fr.exception.RemoteDesignPermissionDeniedException;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.engine.exception.RemoteDesignConnectionException;
import com.fr.workspace.server.repository.authority.RemoteAuthorityRepository; import com.fr.workspace.server.repository.authority.RemoteAuthorityRepository;
import com.fr.workspace.server.repository.compatible.register.CompatibleRegister; import com.fr.workspace.server.repository.compatible.register.CompatibleRegister;
import com.fr.workspace.server.repository.connect.FineWorkspaceHttpClient; import com.fr.workspace.server.repository.connect.FineWorkspaceHttpClient;
@ -43,7 +45,18 @@ public class HttpWorkspaceConnector implements WorkspaceConnector {
FineWorkspaceHttpClient client = FineWorkspaceHttpClient.create("Http-Client", connectionInfo); FineWorkspaceHttpClient client = FineWorkspaceHttpClient.create("Http-Client", connectionInfo);
LoginResponseInfoBean bean; LoginResponseInfoBean bean;
try { try {
bean = RemoteAuthorityRepository.getInstance().login(createLoginBean(connectionInfo)); bean = RemoteAuthorityRepository.getInstance().login(createLoginBean(connectionInfo));
WorkspaceConnection connection = new WorkspaceConnection(
UUID.randomUUID().toString(),
connectionInfo.getUserName(),
HttpConstants.AUTHORIZATION_PREFIX + bean.getAccessToken(),
InetAddress.getLocalHost().getHostAddress());
client.updateConnection(connection);
// 检查远程权限
if (!checkRemoteAuthority(connection)) {
// 无权限则抛出无权限的错
throw new RemoteDesignPermissionDeniedException();
}
} finally { } finally {
client.closePool(); client.closePool();
} }
@ -71,16 +84,31 @@ public class HttpWorkspaceConnector implements WorkspaceConnector {
HttpConstants.AUTHORIZATION_PREFIX + bean.getAccessToken(), HttpConstants.AUTHORIZATION_PREFIX + bean.getAccessToken(),
InetAddress.getLocalHost().getHostAddress()); InetAddress.getLocalHost().getHostAddress());
client.updateConnection(connection); client.updateConnection(connection);
// 检查远程权限
if (!checkRemoteAuthority(connection)) {
// 无权限则抛出无权限的错
throw new RemoteDesignPermissionDeniedException();
}
client.startHeartBeat(); client.startHeartBeat();
} catch (Exception e) { } catch (Exception e) {
client.closePool(); client.closePool();
throw e; throw new RemoteDesignConnectionException(e, StringUtils.EMPTY);
} }
CompatibleRegister.registerCompatibleEnv(); CompatibleRegister.registerCompatibleEnv();
RepositoryManager.getInstance().clearLastPool(); RepositoryManager.getInstance().clearLastPool();
return client; return client;
} }
private boolean checkRemoteAuthority(WorkspaceConnection connection) {
try {
return RemoteAuthorityRepository.getInstance().isRoot(connection.getUserName()) || RemoteAuthorityRepository.getInstance().hasAuthority(connection.getUserName());
} catch (Exception e) {
// 如果这里出现异常,就认为fr服务没启动
throw new RemoteDesignConnectionException(e, StringUtils.EMPTY);
}
}
private LoginRequestInfoBean createLoginBean(WorkspaceConnectionInfo connectionInfo) { private LoginRequestInfoBean createLoginBean(WorkspaceConnectionInfo connectionInfo) {
LoginRequestInfoBean bean = new LoginRequestInfoBean(); LoginRequestInfoBean bean = new LoginRequestInfoBean();
bean.setUsername(connectionInfo.getUserName()); bean.setUsername(connectionInfo.getUserName());

Loading…
Cancel
Save