Browse Source

Pull request #14710: REPORT-130000 & REPORT-131068 & REPORT-131067 优化报错

Merge in DESIGN/design from ~DESTINY.LIN/design:fbp/release to fbp/release

* commit '355d63e19104061d04ae9f63ab19cb8b4f178d61':
  REPORT-131067 远程设计密码次数过多抛错异常 优化重复代码
  REPORT-131067 远程设计密码次数过多抛错异常
  REPORT-130000 fbp的fr服务启动失败,但是fbp设计器测试连接还是成功的,点击确定设计器页面卡死 & REPORT-131068 远程设计权限校验不生效
fbp/merge
Destiny.Lin-林锦龙 4 months ago
parent
commit
6f5ad61553
  1. 34
      designer-base/src/main/java/com/fr/design/env/HttpWorkspaceConnector.java
  2. 20
      designer-realize/src/main/java/com/fanruan/boot/init/DesignWorkContextComponent.java

34
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.RepositoryManager;
import com.fanruan.workplace.http.info.Stub;
import com.fr.exception.RemoteDesignPermissionDeniedException;
import com.fr.log.FineLoggerFactory;
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.compatible.register.CompatibleRegister;
import com.fr.workspace.server.repository.connect.FineWorkspaceHttpClient;
@ -44,6 +46,7 @@ public class HttpWorkspaceConnector implements WorkspaceConnector {
LoginResponseInfoBean bean;
try {
bean = RemoteAuthorityRepository.getInstance().login(createLoginBean(connectionInfo));
checkValidAndUpdateInfo(client, connectionInfo, bean);
} finally {
client.closePool();
}
@ -65,12 +68,7 @@ public class HttpWorkspaceConnector implements WorkspaceConnector {
throw new RuntimeException("Empty token, try connect again and check server");
}
FineLoggerFactory.getLogger().info("[connector] infos:{}", bean.getAccessToken());
WorkspaceConnection connection = new WorkspaceConnection(
UUID.randomUUID().toString(),
connectionInfo.getUserName(),
HttpConstants.AUTHORIZATION_PREFIX + bean.getAccessToken(),
InetAddress.getLocalHost().getHostAddress());
client.updateConnection(connection);
checkValidAndUpdateInfo(client, connectionInfo, bean);
client.startHeartBeat();
} catch (Exception e) {
client.closePool();
@ -81,6 +79,30 @@ public class HttpWorkspaceConnector implements WorkspaceConnector {
return client;
}
private void checkValidAndUpdateInfo(FineWorkspaceHttpClient client, WorkspaceConnectionInfo connectionInfo, LoginResponseInfoBean bean) throws Exception {
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();
}
}
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) {
LoginRequestInfoBean bean = new LoginRequestInfoBean();
bean.setUsername(connectionInfo.getUserName());

20
designer-realize/src/main/java/com/fanruan/boot/init/DesignWorkContextComponent.java

@ -11,6 +11,11 @@ import com.fanruan.workplace.conetxt.CompatiblePool;
import com.fanruan.workplace.http.HttpConstants;
import com.fanruan.workplace.http.RepositoryManager;
import com.fanruan.workplace.http.WorkspaceHeartBeatShell;
import com.fr.workspace.engine.exception.RemoteDesignLoginLockHandler;
import com.fr.workspace.engine.exception.RemoteDesignNoAuthHandler;
import com.fr.workspace.engine.exception.RemoteDesignPasswordNeedUpdateHandler;
import com.fr.workspace.engine.exception.RemoteDesignPasswordStrengthHandler;
import com.fr.workspace.engine.exception.RemoteDesignUserPwdErrorHandler;
import com.fanruan.workplace.http.exception.RemoteExceptionConvert;
import com.fanruan.workplace.standard.ServerInfo;
import com.fanruan.workplace.standard.ServerInfoOperator;
@ -43,10 +48,6 @@ import com.fr.workspace.engine.FineWorkspaceFactory;
import com.fr.workspace.engine.base.FineObjectPool;
import com.fr.workspace.engine.client.heartbeart.FineWorkspaceHeartbeat;
import com.fr.workspace.engine.client.heartbeart.WorkspaceHeartbeat;
import com.fr.workspace.engine.exception.RemoteDesignNoAuthException;
import com.fr.workspace.engine.exception.RemoteDesignPasswordNeedUpdateException;
import com.fr.workspace.engine.exception.RemoteDesignPasswordStrengthException;
import com.fr.workspace.engine.exception.RemoteDesignUserPwdErrorException;
import com.fr.workspace.engine.resource.FineWorkResource;
import com.fr.workspace.engine.resource.FineWorkResourceAdaptor;
import com.fr.workspace.pool.WorkRPCRegister;
@ -144,11 +145,12 @@ public class DesignWorkContextComponent {
private void startErrorConvert() {
RemoteExceptionConvert.registerException(HttpConstants.USER_PWD_ERROR_CODE, new RemoteDesignUserPwdErrorException());
RemoteExceptionConvert.registerException(HttpConstants.USER_PWD_NEED_UPDATE, new RemoteDesignPasswordNeedUpdateException());
RemoteExceptionConvert.registerException(HttpConstants.PASSWORD_STRENGTH_ERROR_CODE, new RemoteDesignPasswordStrengthException());
RemoteExceptionConvert.registerException(HttpConstants.REMOTE_AUTHORITY_ERROR_CODE, new RemoteDesignNoAuthException());
RemoteExceptionConvert.registerException(HttpConstants.PASSWORD_EMPTY_ERROR_CODE, new RemoteDesignUserPwdErrorException());
RemoteExceptionConvert.registerException(HttpConstants.USER_PWD_ERROR_CODE, new RemoteDesignUserPwdErrorHandler());
RemoteExceptionConvert.registerException(HttpConstants.USER_PWD_NEED_UPDATE, new RemoteDesignPasswordNeedUpdateHandler());
RemoteExceptionConvert.registerException(HttpConstants.PASSWORD_STRENGTH_ERROR_CODE, new RemoteDesignPasswordStrengthHandler());
RemoteExceptionConvert.registerException(HttpConstants.REMOTE_AUTHORITY_ERROR_CODE, new RemoteDesignNoAuthHandler());
RemoteExceptionConvert.registerException(HttpConstants.PASSWORD_EMPTY_ERROR_CODE, new RemoteDesignUserPwdErrorHandler());
RemoteExceptionConvert.registerException(HttpConstants.LOGIN_LOCK, new RemoteDesignLoginLockHandler());
}
private void supplementalCommon() {

Loading…
Cancel
Save