diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/CustomFieldType.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/CustomFieldType.java index 8c8b1c2bda..242db3d91d 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/CustomFieldType.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/CustomFieldType.java @@ -21,7 +21,7 @@ public enum CustomFieldType { RICH_TEXT(false), CASCADING_SELECT(false); - private Boolean hasOption; + private final Boolean hasOption; CustomFieldType(Boolean hasOption) { this.hasOption = hasOption; diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ElementConstants.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ElementConstants.java deleted file mode 100644 index fa3513d432..0000000000 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ElementConstants.java +++ /dev/null @@ -1,71 +0,0 @@ -package io.metersphere.sdk.constants; - -import java.util.ArrayList; -import java.util.List; - -public class ElementConstants { - public static final String HASH_TREE = "hashTree"; - public static final String CLAZZ_NAME = "clazzName"; - public static final String SCENARIO = "scenario"; - public static final String SCENARIO_UPPER = "SCENARIO"; - public static final String HTTP_SAMPLER = "HTTPSamplerProxy"; - public static final String TCP_SAMPLER = "TCPSampler"; - public static final String DUBBO_SAMPLER = "DubboSampler"; - public static final String JDBC_SAMPLER = "JDBCSampler"; - public static final String JSR223 = "JSR223Processor"; - public static final String JSR223_PRE = "JSR223PreProcessor"; - public static final String JSR223_POST = "JSR223PostProcessor"; - public static final String JDBC_PRE = "JDBCPreProcessor"; - public static final String JDBC_POST = "JDBCPostProcessor"; - public static final String JMETER_ELE = "JmeterElement"; - public static final String TEST_PLAN = "TestPlan"; - public static final String THREAD_GROUP = "ThreadGroup"; - public static final String DNS_CACHE = "DNSCacheManager"; - public static final String DEBUG_SAMPLER = "DebugSampler"; - public static final String AUTH_MANAGER = "AuthManager"; - public static final String ABS_SAMPLER = "AbstractSampler"; - public static final String IF_CONTROLLER = "IfController"; - public static final String TRANSACTION_CONTROLLER = "TransactionController"; - public static final String LOOP_CONTROLLER = "LoopController"; - public static final String CONSTANT_TIMER = "ConstantTimer"; - public static final String ASSERTIONS = "Assertions"; - public static final String EXTRACT = "Extract"; - public static final String STEP_CREATED = "Created"; - public static final String INDEX = "index"; - public static final String ID = "id"; - public static final String REF_ENABLE = "refEnable"; - - public final static List REQUESTS = new ArrayList() {{ - this.add(ElementConstants.HTTP_SAMPLER); - this.add(ElementConstants.DUBBO_SAMPLER); - this.add(ElementConstants.JDBC_SAMPLER); - this.add(ElementConstants.TCP_SAMPLER); - this.add(ElementConstants.JSR223); - this.add(ElementConstants.JSR223_PRE); - this.add(ElementConstants.JSR223_POST); - this.add(ElementConstants.JDBC_PRE); - this.add(ElementConstants.JDBC_POST); - this.add(ElementConstants.JMETER_ELE); - this.add(ElementConstants.TEST_PLAN); - this.add(ElementConstants.THREAD_GROUP); - this.add(ElementConstants.DNS_CACHE); - this.add(ElementConstants.DEBUG_SAMPLER); - this.add(ElementConstants.AUTH_MANAGER); - this.add(ElementConstants.ABS_SAMPLER); - }}; - - public static final String SCRIPT = "script"; - public static final String BEANSHELL = "beanshell"; - public static final String IS_REF = "isRef"; - public static final String FILE_ID = "fileId"; - - public static final String RESOURCE_ID = "resourceId"; - public static final String FILENAME = "filename"; - public static final String COVER = "COVER"; - public static final String MS_KEYSTORE_FILE_PATH = "MS-KEYSTORE-FILE-PATH"; - public static final String MS_KEYSTORE_FILE_PASSWORD = "MS-KEYSTORE-FILE-PASSWORD"; - public static final String VIRTUAL_STEPS = "VIRTUAL_STEPS"; - public static final String REF = "$ref"; - public static final String TYPE = "type"; - -} diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/HttpMethodConstants.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/HttpMethodConstants.java index 4136ded7de..1cae24780d 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/HttpMethodConstants.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/HttpMethodConstants.java @@ -1,8 +1,5 @@ package io.metersphere.sdk.constants; -import java.util.HashMap; -import java.util.Map; - public enum HttpMethodConstants { GET, HEAD, @@ -11,29 +8,5 @@ public enum HttpMethodConstants { PATCH, DELETE, OPTIONS, - TRACE; - - private static final Map mappings = new HashMap(16); - - private HttpMethodConstants() { - } - - public static HttpMethodConstants resolve(String method) { - return method != null ? (HttpMethodConstants) mappings.get(method) : null; - } - - public boolean matches(String method) { - return this.name().equals(method); - } - - static { - HttpMethodConstants[] var0 = values(); - int var1 = var0.length; - - for (int var2 = 0; var2 < var1; ++var2) { - HttpMethodConstants HttpMethodConstants = var0[var2]; - mappings.put(HttpMethodConstants.name(), HttpMethodConstants); - } - - } + TRACE } diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/KafkaPluginTopicType.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/KafkaPluginTopicType.java deleted file mode 100644 index 6cc787ab87..0000000000 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/KafkaPluginTopicType.java +++ /dev/null @@ -1,6 +0,0 @@ -package io.metersphere.sdk.constants; - -public class KafkaPluginTopicType { - public static final String ADD = "ADD"; - public static final String DELETE = "DELETE"; -} diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/KafkaTopicConstants.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/KafkaTopicConstants.java index 5f170654ce..05061408b5 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/KafkaTopicConstants.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/KafkaTopicConstants.java @@ -2,4 +2,9 @@ package io.metersphere.sdk.constants; public class KafkaTopicConstants { public static final String PLUGIN = "PLUGIN"; + + public static class TYPE{ + public static final String ADD = "ADD"; + public static final String DELETE = "DELETE"; + } } diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/RequestTypeConstants.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/RequestTypeConstants.java deleted file mode 100644 index 8c2c69226a..0000000000 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/RequestTypeConstants.java +++ /dev/null @@ -1,12 +0,0 @@ -package io.metersphere.sdk.constants; - -public class RequestTypeConstants { - - public static final String HTTP = "HTTP"; - - public static final String DUBBO = "DUBBO"; - - public static final String SQL = "SQL"; - - public static final String TCP = "TCP"; -} diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/StorageType.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/StorageType.java index bdf25013ff..86063cf64c 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/StorageType.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/StorageType.java @@ -1,5 +1,5 @@ package io.metersphere.sdk.constants; public enum StorageType { - MINIO, GIT, FILE_REF, LOCAL + MINIO, GIT, LOCAL } diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/UserRoleEnum.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/UserRoleEnum.java index dbdd4327c2..c9d1ed80f4 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/UserRoleEnum.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/UserRoleEnum.java @@ -3,7 +3,7 @@ package io.metersphere.sdk.constants; public enum UserRoleEnum { GLOBAL("global"); - private String value; + private final String value; UserRoleEnum(String value) { this.value = value; diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/LoginRequest.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/LoginRequest.java index 2fe4108546..f7f7df1724 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/LoginRequest.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/LoginRequest.java @@ -1,7 +1,7 @@ package io.metersphere.sdk.dto; import io.metersphere.sdk.util.RsaKey; -import io.metersphere.sdk.util.RsaUtil; +import io.metersphere.sdk.util.RsaUtils; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Size; import lombok.Getter; @@ -21,8 +21,8 @@ public class LoginRequest { public String getUsername() { try { - RsaKey rsaKey = RsaUtil.getRsaKey(); - return RsaUtil.privateDecrypt(username, rsaKey.getPrivateKey()); + RsaKey rsaKey = RsaUtils.getRsaKey(); + return RsaUtils.privateDecrypt(username, rsaKey.getPrivateKey()); } catch (Exception e) { return username; } @@ -30,8 +30,8 @@ public class LoginRequest { public String getPassword() { try { - RsaKey rsaKey = RsaUtil.getRsaKey(); - return RsaUtil.privateDecrypt(password, rsaKey.getPrivateKey()); + RsaKey rsaKey = RsaUtils.getRsaKey(); + return RsaUtils.privateDecrypt(password, rsaKey.getPrivateKey()); } catch (Exception e) { return password; } diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/SessionUser.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/SessionUser.java index 3c921245bd..a3a20aca19 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/SessionUser.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/SessionUser.java @@ -1,6 +1,6 @@ package io.metersphere.sdk.dto; -import io.metersphere.sdk.util.CodingUtil; +import io.metersphere.sdk.util.CodingUtils; import lombok.Getter; import lombok.Setter; import org.apache.commons.lang3.RandomStringUtils; @@ -29,7 +29,7 @@ public class SessionUser extends UserDTO implements Serializable { BeanUtils.copyProperties(user, sessionUser); List infos = Arrays.asList(user.getId(), RandomStringUtils.randomAlphabetic(6), sessionId, StringUtils.EMPTY + System.currentTimeMillis()); - sessionUser.csrfToken = CodingUtil.aesEncrypt(StringUtils.join(infos, "|"), secret, iv); + sessionUser.csrfToken = CodingUtils.aesEncrypt(StringUtils.join(infos, "|"), secret, iv); sessionUser.sessionId = sessionId; return sessionUser; } diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/CodingUtil.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/CodingUtils.java similarity index 99% rename from backend/framework/sdk/src/main/java/io/metersphere/sdk/util/CodingUtil.java rename to backend/framework/sdk/src/main/java/io/metersphere/sdk/util/CodingUtils.java index 56b285bb98..ce735cfc6d 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/CodingUtil.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/CodingUtils.java @@ -13,7 +13,7 @@ import java.security.MessageDigest; * * @author kun.mo */ -public class CodingUtil { +public class CodingUtils { private static final String UTF_8 = "UTF-8"; diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/EncryptUtils.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/EncryptUtils.java index 555a2a3414..43d7fa2efa 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/EncryptUtils.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/EncryptUtils.java @@ -3,7 +3,7 @@ package io.metersphere.sdk.util; import java.util.List; import java.util.stream.Collectors; -public class EncryptUtils extends CodingUtil { +public class EncryptUtils extends CodingUtils { private static final String secretKey = "www.fit2cloud.co"; private static final String iv = "1234567890123456"; diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/FilePreviewUtil.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/FilePreviewUtils.java similarity index 98% rename from backend/framework/sdk/src/main/java/io/metersphere/sdk/util/FilePreviewUtil.java rename to backend/framework/sdk/src/main/java/io/metersphere/sdk/util/FilePreviewUtils.java index df51694c0f..6365a23ac6 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/FilePreviewUtil.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/FilePreviewUtils.java @@ -4,7 +4,7 @@ import org.apache.commons.lang3.StringUtils; import java.io.*; -public class FilePreviewUtil { +public class FilePreviewUtils { private static final String BASE_FILE_FOLDER = File.separator + "opt" + File.separator + "metersphere" + File.separator + "data" + File.separator + "file" + File.separator + "preview" + File.separator; public static boolean isImage(String type) { diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/RsaUtil.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/RsaUtils.java similarity index 99% rename from backend/framework/sdk/src/main/java/io/metersphere/sdk/util/RsaUtil.java rename to backend/framework/sdk/src/main/java/io/metersphere/sdk/util/RsaUtils.java index eb8b9745de..8b740cb98f 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/RsaUtil.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/util/RsaUtils.java @@ -12,7 +12,7 @@ import java.security.spec.InvalidKeySpecException; import java.security.spec.PKCS8EncodedKeySpec; import java.security.spec.X509EncodedKeySpec; -public class RsaUtil { +public class RsaUtils { public static final String CHARSET = StandardCharsets.UTF_8.name(); public static final String RSA_ALGORITHM = "RSA"; @@ -31,7 +31,7 @@ public class RsaUtil { public static void setRsaKey(RsaKey rsaKey) throws NoSuchAlgorithmException { // 放到缓存里 - RsaUtil.rsaKey = rsaKey; + RsaUtils.rsaKey = rsaKey; } public static RsaKey createKeys() throws NoSuchAlgorithmException { diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java index 8b7039fca0..fa2271493b 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java @@ -59,8 +59,8 @@ public class FileMetadataService { List fileMetadataList = extFileMetadataMapper.selectByKeywordAndFileType(request.getProjectId(), request.getKeyword(), request.getModuleIds(), request.getFileTypes(), false); fileMetadataList.forEach(fileMetadata -> { FileInformationDTO fileInformationDTO = new FileInformationDTO(fileMetadata); - if (FilePreviewUtil.isImage(fileMetadata.getType())) { - fileInformationDTO.setPreviewSrc(FilePreviewUtil.catchFileIfNotExists(fileMetadata.getPath() + "." + fileMetadata.getType(), this.getFile(fileMetadata))); + if (FilePreviewUtils.isImage(fileMetadata.getType())) { + fileInformationDTO.setPreviewSrc(FilePreviewUtils.catchFileIfNotExists(fileMetadata.getPath() + "." + fileMetadata.getType(), this.getFile(fileMetadata))); } returnList.add(fileInformationDTO); }); diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/utils/FileManagementBaseUtils.java b/backend/services/project-management/src/test/java/io/metersphere/project/utils/FileManagementBaseUtils.java index 298004d7b1..83bda378dc 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/utils/FileManagementBaseUtils.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/utils/FileManagementBaseUtils.java @@ -4,7 +4,7 @@ import io.metersphere.project.dto.FileInformationDTO; import io.metersphere.project.dto.FileTableResult; import io.metersphere.project.request.filemanagement.FileMetadataTableRequest; import io.metersphere.sdk.dto.BaseTreeNode; -import io.metersphere.sdk.util.FilePreviewUtil; +import io.metersphere.sdk.util.FilePreviewUtils; import io.metersphere.sdk.util.JSON; import org.apache.commons.collections4.CollectionUtils; import org.junit.jupiter.api.Assertions; @@ -103,7 +103,7 @@ public class FileManagementBaseUtils { Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(result.getTableData().getList())).size() <= request.getPageSize()); List fileInformationDTOList = JSON.parseArray(JSON.toJSONString(result.getTableData().getList()), FileInformationDTO.class); for (FileInformationDTO fileInformationDTO : fileInformationDTOList) { - if (FilePreviewUtil.isImage(fileInformationDTO.getFileType())) { + if (FilePreviewUtils.isImage(fileInformationDTO.getFileType())) { //检查是否有预览文件 String previewPath = fileInformationDTO.getPreviewSrc(); File file = new File(previewPath); diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/config/RsaConfig.java b/backend/services/system-setting/src/main/java/io/metersphere/system/config/RsaConfig.java index 36a717252d..b52267bab3 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/config/RsaConfig.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/config/RsaConfig.java @@ -6,7 +6,7 @@ import io.metersphere.sdk.file.FileRepository; import io.metersphere.sdk.file.FileRequest; import io.metersphere.system.log.constants.OperationLogModule; import io.metersphere.sdk.util.RsaKey; -import io.metersphere.sdk.util.RsaUtil; +import io.metersphere.sdk.util.RsaUtils; import org.apache.commons.lang3.SerializationUtils; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; @@ -27,15 +27,15 @@ public class RsaConfig implements ApplicationRunner { byte[] file = fileRepository.getFile(request); if (file != null) { RsaKey rsaKey = SerializationUtils.deserialize(file); - RsaUtil.setRsaKey(rsaKey); + RsaUtils.setRsaKey(rsaKey); return; } } catch (Exception ignored) { } // 保存到minio - RsaKey rsaKey = RsaUtil.getRsaKey(); + RsaKey rsaKey = RsaUtils.getRsaKey(); byte[] bytes = SerializationUtils.serialize(rsaKey); fileRepository.saveFile(bytes, request); - RsaUtil.setRsaKey(rsaKey); + RsaUtils.setRsaKey(rsaKey); } } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/LoginController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/LoginController.java index 55b4d464a8..00023b87cf 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/LoginController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/LoginController.java @@ -12,7 +12,7 @@ import io.metersphere.sdk.exception.MSException; import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.service.BaseUserService; import io.metersphere.sdk.util.RsaKey; -import io.metersphere.sdk.util.RsaUtil; +import io.metersphere.sdk.util.RsaUtils; import io.metersphere.system.utils.SessionUtils; import io.metersphere.sdk.util.Translator; import io.swagger.v3.oas.annotations.Operation; @@ -62,7 +62,7 @@ public class LoginController { @GetMapping(value = "/get-key") @Operation(summary = "获取公钥") public ResultHolder getKey() throws Exception { - RsaKey rsaKey = RsaUtil.getRsaKey(); + RsaKey rsaKey = RsaUtils.getRsaKey(); return ResultHolder.success(rsaKey.getPublicKey()); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/listener/PluginListener.java b/backend/services/system-setting/src/main/java/io/metersphere/system/listener/PluginListener.java index 95fc56d003..ef2f521829 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/listener/PluginListener.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/listener/PluginListener.java @@ -1,12 +1,11 @@ package io.metersphere.system.listener; -import io.metersphere.sdk.constants.KafkaPluginTopicType; import io.metersphere.sdk.constants.KafkaTopicConstants; -import io.metersphere.system.service.PluginLoadService; import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.LogUtils; import io.metersphere.system.dto.PluginNotifiedDTO; +import io.metersphere.system.service.PluginLoadService; import jakarta.annotation.Resource; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.springframework.kafka.annotation.KafkaListener; @@ -29,10 +28,10 @@ public class PluginListener { String pluginId = pluginNotifiedDTO.getPluginId(); String fileName = pluginNotifiedDTO.getFileName(); switch (operate) { - case KafkaPluginTopicType.ADD: + case KafkaTopicConstants.TYPE.ADD: pluginLoadService.handlePluginAddNotified(pluginId, fileName); break; - case KafkaPluginTopicType.DELETE: + case KafkaTopicConstants.TYPE.DELETE: pluginLoadService.handlePluginDeleteNotified(pluginId, fileName); break; default: diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/security/ApiKeyHandler.java b/backend/services/system-setting/src/main/java/io/metersphere/system/security/ApiKeyHandler.java index 474457823d..e5be4c4b0b 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/security/ApiKeyHandler.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/security/ApiKeyHandler.java @@ -1,6 +1,6 @@ package io.metersphere.system.security; -import io.metersphere.sdk.util.CodingUtil; +import io.metersphere.sdk.util.CodingUtils; import io.metersphere.sdk.util.CommonBeanFactory; import io.metersphere.system.domain.UserKey; import io.metersphere.system.service.UserKeyService; @@ -37,7 +37,7 @@ public class ApiKeyHandler { } String signatureDecrypt; try { - signatureDecrypt = CodingUtil.aesDecrypt(signature, userKey.getSecretKey(), accessKey); + signatureDecrypt = CodingUtils.aesDecrypt(signature, userKey.getSecretKey(), accessKey); } catch (Throwable t) { throw new RuntimeException("invalid signature"); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/security/CsrfFilter.java b/backend/services/system-setting/src/main/java/io/metersphere/system/security/CsrfFilter.java index 68f025d9b7..635be69418 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/security/CsrfFilter.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/security/CsrfFilter.java @@ -3,7 +3,7 @@ package io.metersphere.system.security; import io.metersphere.sdk.constants.SessionConstants; import io.metersphere.sdk.dto.SessionUser; -import io.metersphere.sdk.util.CodingUtil; +import io.metersphere.sdk.util.CodingUtils; import io.metersphere.sdk.util.CommonBeanFactory; import io.metersphere.system.utils.SessionUtils; import jakarta.servlet.ServletRequest; @@ -73,7 +73,7 @@ public class CsrfFilter extends AnonymousFilter { if (StringUtils.isBlank(csrfToken)) { throw new RuntimeException("csrf token is empty"); } - csrfToken = CodingUtil.aesDecrypt(csrfToken, SessionUser.secret, SessionUser.iv); + csrfToken = CodingUtils.aesDecrypt(csrfToken, SessionUser.secret, SessionUser.iv); String[] signatureArray = StringUtils.split(StringUtils.trimToNull(csrfToken), "|"); if (signatureArray.length != 4) { diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseUserService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseUserService.java index 7568b2b9c1..bcb85be7aa 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseUserService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseUserService.java @@ -12,7 +12,7 @@ import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.log.service.OperationLogService; import io.metersphere.system.mapper.BaseProjectMapper; import io.metersphere.system.mapper.BaseUserMapper; -import io.metersphere.sdk.util.CodingUtil; +import io.metersphere.sdk.util.CodingUtils; import io.metersphere.system.utils.SessionUtils; import io.metersphere.sdk.util.Translator; import io.metersphere.system.domain.*; @@ -380,7 +380,7 @@ public class BaseUserService { throw new MSException(Translator.get("password_is_null")); } UserExample example = new UserExample(); - example.createCriteria().andIdEqualTo(userId).andPasswordEqualTo(CodingUtil.md5(password)); + example.createCriteria().andIdEqualTo(userId).andPasswordEqualTo(CodingUtils.md5(password)); return userMapper.countByExample(example) > 0; } @@ -417,7 +417,7 @@ public class BaseUserService { if (StringUtils.equals("admin", request.getUsername())) { UserExample example = new UserExample(); example.createCriteria().andIdEqualTo("admin") - .andPasswordEqualTo(CodingUtil.md5("metersphere")); + .andPasswordEqualTo(CodingUtils.md5("metersphere")); return userMapper.countByExample(example) > 0; } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/PluginService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/PluginService.java index 9a7874ef8d..813b7d561c 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/PluginService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/PluginService.java @@ -4,15 +4,13 @@ package io.metersphere.system.service; import io.metersphere.plugin.api.api.AbstractApiProtocolPlugin; import io.metersphere.plugin.platform.api.AbstractPlatformPlugin; import io.metersphere.plugin.sdk.api.MsPlugin; -import io.metersphere.sdk.constants.KafkaPluginTopicType; import io.metersphere.sdk.constants.KafkaTopicConstants; import io.metersphere.sdk.constants.PluginScenarioType; -import io.metersphere.system.controller.handler.result.CommonResultCode; import io.metersphere.sdk.dto.OptionDTO; import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.JSON; -import io.metersphere.system.utils.ServiceUtils; +import io.metersphere.system.controller.handler.result.CommonResultCode; import io.metersphere.system.domain.Plugin; import io.metersphere.system.domain.PluginExample; import io.metersphere.system.dto.PluginDTO; @@ -20,6 +18,7 @@ import io.metersphere.system.dto.PluginNotifiedDTO; import io.metersphere.system.mapper.ExtPluginMapper; import io.metersphere.system.mapper.PluginMapper; import io.metersphere.system.request.PluginUpdateRequest; +import io.metersphere.system.utils.ServiceUtils; import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletResponse; import org.apache.commons.collections.CollectionUtils; @@ -186,7 +185,7 @@ public class PluginService { * @param fileName */ public void notifiedPluginAdd(String pluginId, String fileName) { - notifiedPluginOperate(pluginId, fileName, KafkaPluginTopicType.ADD); + notifiedPluginOperate(pluginId, fileName, KafkaTopicConstants.TYPE.ADD); } public void notifiedPluginOperate(String pluginId, String fileName, String operate) { @@ -203,7 +202,7 @@ public class PluginService { * @param pluginId */ public void notifiedPluginDelete(String pluginId, String fileName) { - notifiedPluginOperate(pluginId, fileName, KafkaPluginTopicType.DELETE); + notifiedPluginOperate(pluginId, fileName, KafkaTopicConstants.TYPE.DELETE); } public Plugin update(PluginUpdateRequest request) { diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserService.java index 49596907b2..2e5a609358 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserService.java @@ -121,7 +121,7 @@ public class UserService { user.setCreateTime(createTime); user.setUpdateUser(operator); user.setUpdateTime(createTime); - user.setPassword(CodingUtil.md5(user.getEmail())); + user.setPassword(CodingUtils.md5(user.getEmail())); user.setSource(source); user.setDeleted(false); userMapper.insertSelective(user); @@ -334,9 +334,9 @@ public class UserService { User updateModel = new User(); updateModel.setId(user.getId()); if (StringUtils.equalsIgnoreCase("admin", user.getId())) { - updateModel.setPassword(CodingUtil.md5("metersphere")); + updateModel.setPassword(CodingUtils.md5("metersphere")); } else { - updateModel.setPassword(CodingUtil.md5(user.getEmail())); + updateModel.setPassword(CodingUtils.md5(user.getEmail())); } updateModel.setUpdateTime(updateTime); updateModel.setUpdateUser(operator); @@ -460,7 +460,7 @@ public class UserService { User user = new User(); user.setId(UUID.randomUUID().toString()); user.setEmail(userInvite.getEmail()); - user.setPassword(CodingUtil.md5(RsaUtil.privateDecrypt(request.getPassword(), RsaUtil.getRsaKey().getPrivateKey()))); + user.setPassword(CodingUtils.md5(RsaUtils.privateDecrypt(request.getPassword(), RsaUtils.getRsaKey().getPrivateKey()))); user.setName(request.getName()); user.setPhone(request.getPhone()); user.setCreateUser(userInvite.getInviteUser()); diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/user/UserControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/user/UserControllerTests.java index 593fe2437c..2c78e7fff9 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/user/UserControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/user/UserControllerTests.java @@ -670,7 +670,7 @@ public class UserControllerTests extends BaseTest { this.requestPostAndReturn(UserRequestUtils.URL_USER_RESET_PASSWORD, request); //检查数据库 UserExample userExample = new UserExample(); - userExample.createCriteria().andIdEqualTo("admin").andPasswordEqualTo(CodingUtil.md5("metersphere")); + userExample.createCriteria().andIdEqualTo("admin").andPasswordEqualTo(CodingUtils.md5("metersphere")); Assertions.assertEquals(1, userMapper.countByExample(userExample)); this.checkLog("admin", OperationLogType.UPDATE, UserRequestUtils.URL_USER_RESET_PASSWORD); } @@ -691,7 +691,7 @@ public class UserControllerTests extends BaseTest { List userList = userToolService.selectByIdList(Collections.singletonList(userId)); for (User checkUser : userList) { UserExample userExample = new UserExample(); - userExample.createCriteria().andIdEqualTo(checkUser.getId()).andPasswordEqualTo(CodingUtil.md5(checkUser.getEmail())); + userExample.createCriteria().andIdEqualTo(checkUser.getId()).andPasswordEqualTo(CodingUtils.md5(checkUser.getEmail())); Assertions.assertEquals(1, userMapper.countByExample(userExample)); this.checkLog(checkUser.getId(), OperationLogType.UPDATE, UserRequestUtils.URL_USER_RESET_PASSWORD); } @@ -715,7 +715,7 @@ public class UserControllerTests extends BaseTest { List userList = userMapper.selectByExample(example); for (User checkUser : userList) { UserExample userExample = new UserExample(); - userExample.createCriteria().andIdEqualTo(checkUser.getId()).andPasswordEqualTo(CodingUtil.md5(checkUser.getEmail())); + userExample.createCriteria().andIdEqualTo(checkUser.getId()).andPasswordEqualTo(CodingUtils.md5(checkUser.getEmail())); Assertions.assertEquals(1, userMapper.countByExample(userExample)); this.checkLog(checkUser.getId(), OperationLogType.UPDATE, UserRequestUtils.URL_USER_RESET_PASSWORD); } @@ -1174,7 +1174,7 @@ public class UserControllerTests extends BaseTest { UserRegisterRequest request = new UserRegisterRequest(); request.setInviteId(inviteId); request.setName("建国通过邮箱邀请"); - request.setPassword(RsaUtil.publicEncrypt("Cao..12138", RsaUtil.getRsaKey().getPublicKey())); + request.setPassword(RsaUtils.publicEncrypt("Cao..12138", RsaUtils.getRsaKey().getPublicKey())); MvcResult mvcResult = userRequestUtils.responsePost(UserRequestUtils.URL_INVITE_REGISTER, request); String resultHolderStr = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); ResultHolder resultHolder = JSON.parseObject(resultHolderStr, ResultHolder.class);