From 355d63e19104061d04ae9f63ab19cb8b4f178d61 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 26 Aug 2024 16:29:32 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-131067=20=E8=BF=9C=E7=A8=8B=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=AF=86=E7=A0=81=E6=AC=A1=E6=95=B0=E8=BF=87=E5=A4=9A?= =?UTF-8?q?=E6=8A=9B=E9=94=99=E5=BC=82=E5=B8=B8=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/env/HttpWorkspaceConnector.java | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/env/HttpWorkspaceConnector.java b/designer-base/src/main/java/com/fr/design/env/HttpWorkspaceConnector.java index e6a9720bc1..d3d1d06176 100644 --- a/designer-base/src/main/java/com/fr/design/env/HttpWorkspaceConnector.java +++ b/designer-base/src/main/java/com/fr/design/env/HttpWorkspaceConnector.java @@ -46,17 +46,7 @@ public class HttpWorkspaceConnector implements WorkspaceConnector { LoginResponseInfoBean bean; try { 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(); - } + checkValidAndUpdateInfo(client, connectionInfo, bean); } finally { client.closePool(); } @@ -78,17 +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); - // 检查远程权限 - if (!checkRemoteAuthority(connection)) { - // 无权限则抛出无权限的错 - throw new RemoteDesignPermissionDeniedException(); - } + checkValidAndUpdateInfo(client, connectionInfo, bean); client.startHeartBeat(); } catch (Exception e) { client.closePool(); @@ -99,6 +79,20 @@ 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());