diff --git a/framework/fit/java/fit-builtin/plugins/fit-security-simple/pom.xml b/framework/fit/java/fit-builtin/plugins/fit-security-simple/pom.xml new file mode 100644 index 00000000..02e1c826 --- /dev/null +++ b/framework/fit/java/fit-builtin/plugins/fit-security-simple/pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + + + org.fitframework.plugin + fit-plugin-parent + 3.5.0-SNAPSHOT + + + fit-security-simple + + + + + org.fitframework + fit-dependency + ${fit.version} + pom + import + + + + + + + + org.fitframework + fit-api + + + org.fitframework + fit-util + + + + + org.fitframework.service + fit-security + + + + + + + org.fitframework + fit-build-maven-plugin + ${fit.version} + + + org.apache.maven.plugins + maven-antrun-plugin + ${maven.antrun.version} + + + package + + + + + + + run + + + + + + + diff --git a/framework/fit/java/fit-builtin/plugins/fit-security-simple/src/main/java/modelengine/fit/security/simple/SimpleCipher.java b/framework/fit/java/fit-builtin/plugins/fit-security-simple/src/main/java/modelengine/fit/security/simple/SimpleCipher.java new file mode 100644 index 00000000..ed1ff7b8 --- /dev/null +++ b/framework/fit/java/fit-builtin/plugins/fit-security-simple/src/main/java/modelengine/fit/security/simple/SimpleCipher.java @@ -0,0 +1,34 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved. + * This file is a part of the ModelEngine Project. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +package modelengine.fit.security.simple; + +import modelengine.fit.security.Decryptor; +import modelengine.fit.security.Encryptor; +import modelengine.fitframework.annotation.Component; +import modelengine.fitframework.util.StringUtils; + +/** + * 表示 {@link Decryptor} 的简单实现。 + * + * @author 季聿阶 + * @since 2023-07-31 + */ +@Component +public class SimpleCipher implements Encryptor, Decryptor { + @Override + public String encrypt(String decrypted) { + return CIPHER_PREFIX + decrypted + CIPHER_SUFFIX; + } + + @Override + public String decrypt(String encrypted) { + if (StringUtils.startsWithIgnoreCase(encrypted, CIPHER_PREFIX) && StringUtils.endsWithIgnoreCase(encrypted, CIPHER_SUFFIX)) { + return encrypted.substring(CIPHER_PREFIX.length(), encrypted.length() - CIPHER_SUFFIX.length()); + } + return encrypted; + } +} diff --git a/framework/fit/java/fit-builtin/plugins/fit-security-simple/src/main/resources/application.yml b/framework/fit/java/fit-builtin/plugins/fit-security-simple/src/main/resources/application.yml new file mode 100644 index 00000000..00b77d7e --- /dev/null +++ b/framework/fit/java/fit-builtin/plugins/fit-security-simple/src/main/resources/application.yml @@ -0,0 +1,4 @@ +fit: + beans: + packages: + - 'modelengine.fit.security.simple' diff --git a/framework/fit/java/fit-builtin/plugins/pom.xml b/framework/fit/java/fit-builtin/plugins/pom.xml index 5a50f41d..d0930beb 100644 --- a/framework/fit/java/fit-builtin/plugins/pom.xml +++ b/framework/fit/java/fit-builtin/plugins/pom.xml @@ -26,6 +26,7 @@ fit-logger fit-message-serializer-cbor fit-message-serializer-json-jackson + fit-security-simple fit-server-http fit-service-coordination-locator fit-service-coordination-simple