) event.getSource();
+ configs.forEach(configStore::override);
+ }
+
+}
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/java/org/dromara/visor/framework/security/core/crypto/CryptoConfig.java b/orion-visor-framework/orion-visor-spring-boot-starter-config/src/main/java/org/dromara/visor/framework/config/core/service/ConfigFrameworkService.java
similarity index 74%
rename from orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/java/org/dromara/visor/framework/security/core/crypto/CryptoConfig.java
rename to orion-visor-framework/orion-visor-spring-boot-starter-config/src/main/java/org/dromara/visor/framework/config/core/service/ConfigFrameworkService.java
index 4c2bcf8c..3362d857 100644
--- a/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/java/org/dromara/visor/framework/security/core/crypto/CryptoConfig.java
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-config/src/main/java/org/dromara/visor/framework/config/core/service/ConfigFrameworkService.java
@@ -20,28 +20,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.dromara.visor.framework.security.core.crypto;
+package org.dromara.visor.framework.config.core.service;
-import lombok.Data;
+import java.util.Map;
/**
- * 加密配置
+ * 配置框架服务
+ *
+ * 在业务层定义 bean
*
* @author Jiahang Li
* @version 1.0.0
- * @since 2023/7/8 0:14
+ * @since 2025/1/6 17:08
*/
-@Data
-public class CryptoConfig {
+public interface ConfigFrameworkService {
/**
- * 是否为默认加密器
+ * 获取全部配置
+ *
+ * @return config
*/
- protected boolean primary;
-
- /**
- * 是否启用
- */
- protected boolean enabled;
+ Map getAllConfig();
}
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/java/org/dromara/visor/framework/security/core/crypto/PrimaryAesEncryptor.java b/orion-visor-framework/orion-visor-spring-boot-starter-config/src/main/java/org/dromara/visor/framework/config/core/service/ConfigFrameworkServiceDelegate.java
similarity index 53%
rename from orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/java/org/dromara/visor/framework/security/core/crypto/PrimaryAesEncryptor.java
rename to orion-visor-framework/orion-visor-spring-boot-starter-config/src/main/java/org/dromara/visor/framework/config/core/service/ConfigFrameworkServiceDelegate.java
index 5a8135d3..9de5e34c 100644
--- a/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/java/org/dromara/visor/framework/security/core/crypto/PrimaryAesEncryptor.java
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-config/src/main/java/org/dromara/visor/framework/config/core/service/ConfigFrameworkServiceDelegate.java
@@ -20,42 +20,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.dromara.visor.framework.security.core.crypto;
+package org.dromara.visor.framework.config.core.service;
-import cn.orionsec.kit.lang.utils.Exceptions;
-import org.dromara.visor.common.interfaces.AesEncryptor;
+import java.util.Map;
/**
- * 默认加密器
+ * 配置框架服务代理
*
* @author Jiahang Li
* @version 1.0.0
- * @since 2023/7/21 12:11
+ * @since 2025/1/6 17:08
*/
-public class PrimaryAesEncryptor implements AesEncryptor {
+public class ConfigFrameworkServiceDelegate implements ConfigFrameworkService {
- private static AesEncryptor delegate;
+ private final ConfigFrameworkService configFrameworkService;
- @Override
- public void init() {
+ public ConfigFrameworkServiceDelegate(ConfigFrameworkService configFrameworkService) {
+ this.configFrameworkService = configFrameworkService;
}
@Override
- public byte[] encrypt(byte[] plain) {
- return delegate.encrypt(plain);
- }
-
- @Override
- public byte[] decrypt(byte[] text) {
- return delegate.decrypt(text);
- }
-
- protected static void setDelegate(AesEncryptor delegate) {
- if (PrimaryAesEncryptor.delegate != null) {
- // unmodified
- throw Exceptions.state();
- }
- PrimaryAesEncryptor.delegate = delegate;
+ public Map getAllConfig() {
+ return configFrameworkService.getAllConfig();
}
}
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-config/src/main/java/org/dromara/visor/framework/config/core/store/ManagementConfigStore.java b/orion-visor-framework/orion-visor-spring-boot-starter-config/src/main/java/org/dromara/visor/framework/config/core/store/ManagementConfigStore.java
new file mode 100644
index 00000000..e85a1ac7
--- /dev/null
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-config/src/main/java/org/dromara/visor/framework/config/core/store/ManagementConfigStore.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2023 - present Dromara, All rights reserved.
+ *
+ * https://visor.dromara.org
+ * https://visor.dromara.org.cn
+ * https://visor.orionsec.cn
+ *
+ * Members:
+ * Jiahang Li - ljh1553488six@139.com - author
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.dromara.visor.framework.config.core.store;
+
+import org.dromara.visor.common.config.ConfigRef;
+import org.dromara.visor.common.config.ConfigStore;
+
+/**
+ * 可控配置中心
+ *
+ * @author Jiahang Li
+ * @version 1.0.0
+ * @since 2025/1/6 23:00
+ */
+public interface ManagementConfigStore extends ConfigStore {
+
+ /**
+ * 加载全部配置
+ */
+ void loadAllConfig();
+
+ /**
+ * 覆盖配置
+ *
+ * @param key key
+ * @param value value
+ */
+ void override(String key, String value);
+
+ /**
+ * 注册 ref
+ *
+ * @param ref ref
+ */
+ void register(ConfigRef> ref);
+
+}
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-config/src/main/java/org/dromara/visor/framework/config/core/store/ManagementConfigStoreImpl.java b/orion-visor-framework/orion-visor-spring-boot-starter-config/src/main/java/org/dromara/visor/framework/config/core/store/ManagementConfigStoreImpl.java
new file mode 100644
index 00000000..2c2b07ef
--- /dev/null
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-config/src/main/java/org/dromara/visor/framework/config/core/store/ManagementConfigStoreImpl.java
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2023 - present Dromara, All rights reserved.
+ *
+ * https://visor.dromara.org
+ * https://visor.dromara.org.cn
+ * https://visor.orionsec.cn
+ *
+ * Members:
+ * Jiahang Li - ljh1553488six@139.com - author
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.dromara.visor.framework.config.core.store;
+
+import org.dromara.visor.common.config.ConfigRef;
+import org.dromara.visor.framework.config.core.service.ConfigFrameworkService;
+import cn.orionsec.kit.lang.utils.collect.Lists;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Function;
+
+/**
+ * 配置中心实现
+ *
+ * @author Jiahang Li
+ * @version 1.0.0
+ * @since 2025/1/6 17:20
+ */
+@Slf4j
+public class ManagementConfigStoreImpl implements ManagementConfigStore {
+
+ private final ConcurrentHashMap configMap = new ConcurrentHashMap<>();
+
+ private final ConcurrentHashMap>> configRefs = new ConcurrentHashMap<>();
+
+ private final ConfigFrameworkService service;
+
+ public ManagementConfigStoreImpl(ConfigFrameworkService service) {
+ this.service = service;
+ }
+
+ @Override
+ public void loadAllConfig() {
+ configMap.putAll(service.getAllConfig());
+ }
+
+ @Override
+ public void override(String key, String value) {
+ log.info("ManagementConfigStore.override key: {}, value: {}", key, value);
+ // 修改配置
+ configMap.put(key, value);
+ // 修改引用
+ List> refs = configRefs.get(key);
+ if (!Lists.isEmpty(refs)) {
+ refs.forEach(s -> s.override(value));
+ }
+ }
+
+ @Override
+ public void register(ConfigRef> ref) {
+ String key = ref.key;
+ log.info("ManagementConfigStore.register ref key: {}", key);
+ // 注册引用
+ configRefs.computeIfAbsent(key, k -> new ArrayList<>()).add(ref);
+ }
+
+ @Override
+ public String getConfig(String key) {
+ return this.getConfig(key, Function.identity(), null);
+ }
+
+ @Override
+ public String getConfig(String key, String defaultValue) {
+ return this.getConfig(key, Function.identity(), defaultValue);
+ }
+
+ @Override
+ public T getConfig(String key, Function convert) {
+ return this.getConfig(key, convert, null);
+ }
+
+ @Override
+ public T getConfig(String key, Function convert, T defaultValue) {
+ // 获取配置
+ String conf = configMap.get(key);
+ // 默认值
+ if (conf == null) {
+ return defaultValue;
+ }
+ // 转换
+ return convert.apply(conf);
+ }
+
+ @Override
+ public ConfigRef string(String key) {
+ return this.ref(key, Function.identity(), null);
+ }
+
+ @Override
+ public ConfigRef string(String key, String defaultValue) {
+ return this.ref(key, Function.identity(), defaultValue);
+ }
+
+ @Override
+ public ConfigRef int32(String key) {
+ return this.ref(key, Integer::valueOf, null);
+ }
+
+ @Override
+ public ConfigRef int32(String key, Integer defaultValue) {
+ return this.ref(key, Integer::valueOf, defaultValue);
+ }
+
+ @Override
+ public ConfigRef int64(String key) {
+ return this.ref(key, Long::valueOf, null);
+ }
+
+ @Override
+ public ConfigRef int64(String key, Long defaultValue) {
+ return this.ref(key, Long::valueOf, defaultValue);
+ }
+
+ @Override
+ public ConfigRef float64(String key) {
+ return this.ref(key, Double::valueOf, null);
+ }
+
+ @Override
+ public ConfigRef float64(String key, Double defaultValue) {
+ return this.ref(key, Double::valueOf, defaultValue);
+ }
+
+ @Override
+ public ConfigRef bool(String key) {
+ return this.ref(key, Boolean::valueOf, null);
+ }
+
+ @Override
+ public ConfigRef bool(String key, Boolean defaultValue) {
+ return this.ref(key, Boolean::valueOf, defaultValue);
+ }
+
+ @Override
+ public ConfigRef ref(String key, Function convert) {
+ return this.ref(key, convert, null);
+ }
+
+ @Override
+ public ConfigRef ref(String key, Function convert, T defaultValue) {
+ // 创建引用
+ ConfigRef ref = new ConfigRef<>(key, convert);
+ // 设置值
+ String value = configMap.get(key);
+ if (value != null) {
+ ref.override(value);
+ } else {
+ ref.set(defaultValue);
+ }
+ // 注册引用
+ this.register(ref);
+ return ref;
+ }
+
+}
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-config/src/main/java/org/dromara/visor/framework/config/core/utils/ConfigStores.java b/orion-visor-framework/orion-visor-spring-boot-starter-config/src/main/java/org/dromara/visor/framework/config/core/utils/ConfigStores.java
new file mode 100644
index 00000000..1c372556
--- /dev/null
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-config/src/main/java/org/dromara/visor/framework/config/core/utils/ConfigStores.java
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 2023 - present Dromara, All rights reserved.
+ *
+ * https://visor.dromara.org
+ * https://visor.dromara.org.cn
+ * https://visor.orionsec.cn
+ *
+ * Members:
+ * Jiahang Li - ljh1553488six@139.com - author
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.dromara.visor.framework.config.core.utils;
+
+import cn.orionsec.kit.lang.utils.Exceptions;
+import org.dromara.visor.common.config.ConfigRef;
+import org.dromara.visor.common.config.ConfigStore;
+
+import java.util.function.Function;
+
+/**
+ * 配置中心
+ *
+ * @author Jiahang Li
+ * @version 1.0.0
+ * @since 2025/1/6 17:20
+ */
+public class ConfigStores {
+
+ private static ConfigStore delegate;
+
+ private ConfigStores() {
+ }
+
+ /**
+ * 获取配置
+ *
+ * @param key key
+ * @return conf
+ */
+ public static String getConfig(String key) {
+ return delegate.getConfig(key);
+ }
+
+ /**
+ * 获取配置
+ *
+ * @param key key
+ * @param defaultValue defaultValue
+ * @return conf
+ */
+ public static String getConfig(String key, String defaultValue) {
+ return delegate.getConfig(key, defaultValue);
+ }
+
+ /**
+ * 获取配置
+ *
+ * @param key key
+ * @param convert convert
+ * @param T
+ * @return conf
+ */
+ public static T getConfig(String key, Function convert) {
+ return delegate.getConfig(key, convert);
+ }
+
+ /**
+ * 获取配置
+ *
+ * @param key key
+ * @param defaultValue defaultValue
+ * @param T
+ * @return conf
+ */
+ public static T getConfig(String key, Function convert, T defaultValue) {
+ return delegate.getConfig(key, convert, defaultValue);
+ }
+
+ /**
+ * 获取 string 配置
+ *
+ * @param key key
+ * @return ref
+ */
+ public static ConfigRef string(String key) {
+ return delegate.string(key);
+ }
+
+ /**
+ * 获取 string 配置
+ *
+ * @param key key
+ * @param defaultValue defaultValue
+ * @return ref
+ */
+ public static ConfigRef string(String key, String defaultValue) {
+ return delegate.string(key, defaultValue);
+ }
+
+ /**
+ * 获取 int 配置
+ *
+ * @param key key
+ * @return ref
+ */
+ public static ConfigRef int32(String key) {
+ return delegate.int32(key);
+ }
+
+ /**
+ * 获取 int 配置
+ *
+ * @param key key
+ * @param defaultValue defaultValue
+ * @return ref
+ */
+ public static ConfigRef int32(String key, Integer defaultValue) {
+ return delegate.int32(key, defaultValue);
+ }
+
+ /**
+ * 获取 long 配置
+ *
+ * @param key key
+ * @return ref
+ */
+ public static ConfigRef int64(String key) {
+ return delegate.int64(key);
+ }
+
+ /**
+ * 获取 long 配置
+ *
+ * @param key key
+ * @param defaultValue defaultValue
+ * @return ref
+ */
+ public static ConfigRef int64(String key, Long defaultValue) {
+ return delegate.int64(key, defaultValue);
+ }
+
+ /**
+ * 获取 double 配置
+ *
+ * @param key key
+ * @return ref
+ */
+ public static ConfigRef float64(String key) {
+ return delegate.float64(key);
+ }
+
+ /**
+ * 获取 double 配置
+ *
+ * @param key key
+ * @param defaultValue defaultValue
+ * @return ref
+ */
+ public static ConfigRef float64(String key, Double defaultValue) {
+ return delegate.float64(key, defaultValue);
+ }
+
+ /**
+ * 获取 boolean 配置
+ *
+ * @param key key
+ * @return ref
+ */
+ public static ConfigRef bool(String key) {
+ return delegate.bool(key);
+ }
+
+ /**
+ * 获取 boolean 配置
+ *
+ * @param key key
+ * @param defaultValue defaultValue
+ * @return ref
+ */
+ public static ConfigRef bool(String key, Boolean defaultValue) {
+ return delegate.bool(key, defaultValue);
+ }
+
+ /**
+ * 获取配置
+ *
+ * @param key key
+ * @param convert convert
+ * @param T
+ * @return ref
+ */
+ public static ConfigRef ref(String key, Function convert) {
+ return delegate.ref(key, convert);
+ }
+
+ /**
+ * 获取配置
+ *
+ * @param key key
+ * @param convert convert
+ * @param defaultValue defaultValue
+ * @param T
+ * @return ref
+ */
+ public static ConfigRef ref(String key, Function convert, T defaultValue) {
+ return delegate.ref(key, convert, defaultValue);
+ }
+
+ public static void setDelegate(ConfigStore configStore) {
+ if (ConfigStores.delegate != null) {
+ // unmodified
+ throw Exceptions.state();
+ }
+ ConfigStores.delegate = configStore;
+ }
+
+}
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-config/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/orion-visor-framework/orion-visor-spring-boot-starter-config/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 00000000..4a58ff77
--- /dev/null
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-config/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -0,0 +1 @@
+org.dromara.visor.framework.config.configuration.OrionConfigAutoConfiguration
\ No newline at end of file
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/pom.xml b/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/pom.xml
new file mode 100644
index 00000000..b1364d07
--- /dev/null
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/pom.xml
@@ -0,0 +1,33 @@
+
+
+
+ org.dromara.visor
+ orion-visor-framework
+ ${revision}
+
+
+ 4.0.0
+ orion-visor-spring-boot-starter-encrypt
+ ${project.artifactId}
+ jar
+
+ 项目加密包
+ https://github.com/dromara/orion-visor
+
+
+
+
+ org.dromara.visor
+ orion-visor-common
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+
+
\ No newline at end of file
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/java/org/dromara/visor/framework/security/configuration/OrionCryptoAutoConfiguration.java b/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/java/org/dromara/visor/framework/encrypt/configuration/OrionEncryptAutoConfiguration.java
similarity index 53%
rename from orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/java/org/dromara/visor/framework/security/configuration/OrionCryptoAutoConfiguration.java
rename to orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/java/org/dromara/visor/framework/encrypt/configuration/OrionEncryptAutoConfiguration.java
index 52787588..d61a9cc1 100644
--- a/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/java/org/dromara/visor/framework/security/configuration/OrionCryptoAutoConfiguration.java
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/java/org/dromara/visor/framework/encrypt/configuration/OrionEncryptAutoConfiguration.java
@@ -20,53 +20,58 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.dromara.visor.framework.security.configuration;
+package org.dromara.visor.framework.encrypt.configuration;
+import org.dromara.visor.common.config.ConfigStore;
import org.dromara.visor.common.constant.AutoConfigureOrderConst;
import org.dromara.visor.common.interfaces.AesEncryptor;
+import org.dromara.visor.common.interfaces.RsaEncryptor;
import org.dromara.visor.common.utils.AesEncryptUtils;
-import org.dromara.visor.framework.security.configuration.config.AesCryptoConfig;
-import org.dromara.visor.framework.security.core.crypto.PrimaryAesEncryptor;
-import org.dromara.visor.framework.security.core.crypto.processor.AesCryptoProcessor;
+import org.dromara.visor.common.utils.RsaEncryptorUtils;
+import org.dromara.visor.framework.encrypt.configuration.config.AesEncryptConfig;
+import org.dromara.visor.framework.encrypt.core.impl.AesEncryptorImpl;
+import org.dromara.visor.framework.encrypt.core.impl.RsaEncryptorImpl;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Primary;
/**
* 项目加密解密配置
*
* @author Jiahang Li
* @version 1.0.0
- * @since 2023/7/7 23:59
+ * @since 2025/1/7 22:32
*/
@AutoConfiguration
-@EnableConfigurationProperties({AesCryptoConfig.class})
-@AutoConfigureOrder(AutoConfigureOrderConst.FRAMEWORK_SECURITY_CRYPTO)
-public class OrionCryptoAutoConfiguration {
+@EnableConfigurationProperties({AesEncryptConfig.class})
+@AutoConfigureOrder(AutoConfigureOrderConst.FRAMEWORK_ENCRYPT)
+public class OrionEncryptAutoConfiguration {
/**
- * @return 默认加密器
+ * @param config config
+ * @return aes 加密器
*/
- @Bean(name = "valueCrypto")
- @Primary
- public AesEncryptor primaryValueCrypto() {
- // 创建加密器
- PrimaryAesEncryptor valueCrypto = new PrimaryAesEncryptor();
+ @Bean
+ public AesEncryptor aesEncryptor(AesEncryptConfig config) {
+ // 加密器
+ AesEncryptorImpl encryptor = new AesEncryptorImpl(config);
// 设置工具类
- AesEncryptUtils.setDelegate(valueCrypto);
- return valueCrypto;
+ AesEncryptUtils.setDelegate(encryptor);
+ return encryptor;
}
/**
- * @return aes 加密器
+ * @param configStore configStore
+ * @return rsa 加密器
*/
- @Bean(initMethod = "init")
- @ConditionalOnProperty(value = "orion.crypto.aes.enabled", havingValue = "true")
- public AesEncryptor aesValueCrypto(AesCryptoConfig config) {
- return new AesCryptoProcessor(config);
+ @Bean
+ public RsaEncryptor rsaEncryptor(ConfigStore configStore) {
+ // 加密器
+ RsaEncryptor encryptor = new RsaEncryptorImpl(configStore);
+ // 设置工具类
+ RsaEncryptorUtils.setDelegate(encryptor);
+ return encryptor;
}
}
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/java/org/dromara/visor/framework/security/configuration/config/AesCryptoConfig.java b/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/java/org/dromara/visor/framework/encrypt/configuration/config/AesEncryptConfig.java
similarity index 76%
rename from orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/java/org/dromara/visor/framework/security/configuration/config/AesCryptoConfig.java
rename to orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/java/org/dromara/visor/framework/encrypt/configuration/config/AesEncryptConfig.java
index ef557780..c681c8bd 100644
--- a/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/java/org/dromara/visor/framework/security/configuration/config/AesCryptoConfig.java
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/java/org/dromara/visor/framework/encrypt/configuration/config/AesEncryptConfig.java
@@ -20,14 +20,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.dromara.visor.framework.security.configuration.config;
+package org.dromara.visor.framework.encrypt.configuration.config;
import cn.orionsec.kit.lang.utils.crypto.CryptoConst;
import cn.orionsec.kit.lang.utils.crypto.enums.PaddingMode;
import cn.orionsec.kit.lang.utils.crypto.enums.WorkingMode;
import lombok.Data;
-import lombok.EqualsAndHashCode;
-import org.dromara.visor.framework.security.core.crypto.CryptoConfig;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
@@ -38,19 +36,18 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @since 2023/7/7 22:22
*/
@Data
-@EqualsAndHashCode(callSuper = true)
-@ConfigurationProperties("orion.crypto.aes")
-public class AesCryptoConfig extends CryptoConfig {
+@ConfigurationProperties("orion.encrypt.aes")
+public class AesEncryptConfig {
/**
* 加密模式
*/
- private WorkingMode workingMode = WorkingMode.ECB;
+ private WorkingMode workingMode;
/**
* 填充模式
*/
- private PaddingMode paddingMode = PaddingMode.PKCS5_PADDING;
+ private PaddingMode paddingMode;
/**
* 加密密钥
@@ -60,12 +57,12 @@ public class AesCryptoConfig extends CryptoConfig {
/**
* 是否生成密钥
*/
- private boolean useGeneratorKey = true;
+ private boolean useGeneratorKey;
/**
* 生成的密钥长度 128 192 256bytes
*/
- private int generatorKeyLength = CryptoConst.AES_KEY_LENGTH;
+ private int generatorKeyLength;
/**
* 向量 长度为 16bytes
@@ -83,4 +80,11 @@ public class AesCryptoConfig extends CryptoConfig {
*/
private String aad;
+ public AesEncryptConfig() {
+ this.workingMode = WorkingMode.ECB;
+ this.paddingMode = PaddingMode.PKCS5_PADDING;
+ this.useGeneratorKey = true;
+ this.generatorKeyLength = CryptoConst.AES_KEY_LENGTH;
+ }
+
}
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/java/org/dromara/visor/framework/security/core/crypto/CryptoProcessor.java b/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/java/org/dromara/visor/framework/encrypt/core/BaseAesEncryptor.java
similarity index 79%
rename from orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/java/org/dromara/visor/framework/security/core/crypto/CryptoProcessor.java
rename to orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/java/org/dromara/visor/framework/encrypt/core/BaseAesEncryptor.java
index 0d0baf5f..27e0a390 100644
--- a/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/java/org/dromara/visor/framework/security/core/crypto/CryptoProcessor.java
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/java/org/dromara/visor/framework/encrypt/core/BaseAesEncryptor.java
@@ -20,7 +20,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.dromara.visor.framework.security.core.crypto;
+package org.dromara.visor.framework.encrypt.core;
import org.dromara.visor.common.interfaces.AesEncryptor;
@@ -31,18 +31,19 @@ import org.dromara.visor.common.interfaces.AesEncryptor;
* @version 1.0.0
* @since 2023/7/7 22:48
*/
-public abstract class CryptoProcessor implements AesEncryptor {
+public abstract class BaseAesEncryptor implements AesEncryptor {
protected final Config config;
- protected CryptoProcessor(Config config) {
+ protected BaseAesEncryptor(Config config) {
this.config = config;
- // 设置为默认加密器
- if (config.isPrimary()) {
- PrimaryAesEncryptor.setDelegate(this);
- }
}
+ /**
+ * 初始化
+ */
+ protected abstract void init();
+
/**
* 初始化密钥
*/
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/java/org/dromara/visor/framework/security/core/crypto/processor/AesCryptoProcessor.java b/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/java/org/dromara/visor/framework/encrypt/core/impl/AesEncryptorImpl.java
similarity index 89%
rename from orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/java/org/dromara/visor/framework/security/core/crypto/processor/AesCryptoProcessor.java
rename to orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/java/org/dromara/visor/framework/encrypt/core/impl/AesEncryptorImpl.java
index d05c1ef0..e4bdb0ea 100644
--- a/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/java/org/dromara/visor/framework/security/core/crypto/processor/AesCryptoProcessor.java
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/java/org/dromara/visor/framework/encrypt/core/impl/AesEncryptorImpl.java
@@ -20,7 +20,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.dromara.visor.framework.security.core.crypto.processor;
+package org.dromara.visor.framework.encrypt.core.impl;
import cn.orionsec.kit.lang.utils.Strings;
import cn.orionsec.kit.lang.utils.crypto.Keys;
@@ -28,8 +28,8 @@ import cn.orionsec.kit.lang.utils.crypto.enums.CipherAlgorithm;
import cn.orionsec.kit.lang.utils.crypto.enums.WorkingMode;
import cn.orionsec.kit.lang.utils.crypto.symmetric.SymmetricBuilder;
import cn.orionsec.kit.lang.utils.crypto.symmetric.SymmetricCrypto;
-import org.dromara.visor.framework.security.configuration.config.AesCryptoConfig;
-import org.dromara.visor.framework.security.core.crypto.CryptoProcessor;
+import org.dromara.visor.framework.encrypt.configuration.config.AesEncryptConfig;
+import org.dromara.visor.framework.encrypt.core.BaseAesEncryptor;
import javax.crypto.SecretKey;
import java.security.spec.AlgorithmParameterSpec;
@@ -41,7 +41,7 @@ import java.security.spec.AlgorithmParameterSpec;
* @version 1.0.0
* @since 2023/7/8 0:05
*/
-public class AesCryptoProcessor extends CryptoProcessor {
+public class AesEncryptorImpl extends BaseAesEncryptor {
/**
* 加密器
@@ -53,12 +53,14 @@ public class AesCryptoProcessor extends CryptoProcessor {
*/
private SymmetricBuilder builder;
- public AesCryptoProcessor(AesCryptoConfig config) {
+ public AesEncryptorImpl(AesEncryptConfig config) {
super(config);
+ // 初始化
+ this.init();
}
@Override
- public void init() {
+ protected void init() {
// 创建构建器
this.builder = SymmetricBuilder.aes()
.workingMode(config.getWorkingMode())
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/java/org/dromara/visor/framework/encrypt/core/impl/RsaEncryptorImpl.java b/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/java/org/dromara/visor/framework/encrypt/core/impl/RsaEncryptorImpl.java
new file mode 100644
index 00000000..e6ec41bb
--- /dev/null
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/java/org/dromara/visor/framework/encrypt/core/impl/RsaEncryptorImpl.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2023 - present Dromara, All rights reserved.
+ *
+ * https://visor.dromara.org
+ * https://visor.dromara.org.cn
+ * https://visor.orionsec.cn
+ *
+ * Members:
+ * Jiahang Li - ljh1553488six@139.com - author
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.dromara.visor.framework.encrypt.core.impl;
+
+import cn.orionsec.kit.lang.utils.crypto.RSA;
+import org.dromara.visor.common.config.ConfigRef;
+import org.dromara.visor.common.config.ConfigStore;
+import org.dromara.visor.common.interfaces.RsaEncryptor;
+
+import java.security.interfaces.RSAPrivateKey;
+import java.security.interfaces.RSAPublicKey;
+
+/**
+ * rsa 加密器
+ *
+ * @author Jiahang Li
+ * @version 1.0.0
+ * @since 2025/1/7 11:32
+ */
+public class RsaEncryptorImpl implements RsaEncryptor {
+
+ private final ConfigRef publicKey;
+
+ private final ConfigRef privateKey;
+
+ public RsaEncryptorImpl(ConfigStore configStore) {
+ this.publicKey = configStore.ref("encrypt.publicKey", RSA::getPublicKey);
+ this.privateKey = configStore.ref("encrypt.privateKey", RSA::getPrivateKey);
+ }
+
+ @Override
+ public String encrypt(String value) {
+ return RSA.encrypt(value, publicKey.value);
+ }
+
+ @Override
+ public String decrypt(String value) {
+ return RSA.decrypt(value, privateKey.value);
+ }
+
+}
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/resources/META-INF/additional-spring-configuration-metadata.json
new file mode 100644
index 00000000..8dd616b9
--- /dev/null
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -0,0 +1,55 @@
+{
+ "groups": [
+ {
+ "name": "orion.encrypt.aes",
+ "type": "org.dromara.visor.framework.encrypt.configuration.config.AesEncryptConfig",
+ "sourceType": "org.dromara.visor.framework.encrypt.configuration.config.AesEncryptConfig"
+ }
+ ],
+ "properties": [
+ {
+ "name": "orion.encrypt.aes.working-mode",
+ "type": "cn.orionsec.kit.lang.utils.crypto.enums.WorkingMode",
+ "description": "加密模式.",
+ "defaultValue": "ECB"
+ },
+ {
+ "name": "orion.encrypt.aes.padding-mode",
+ "type": "cn.orionsec.kit.lang.utils.crypto.enums.PaddingMode",
+ "description": "填充模式.",
+ "defaultValue": "PKCS5_PADDING"
+ },
+ {
+ "name": "orion.encrypt.aes.secret-key",
+ "type": "java.lang.String",
+ "description": "加密密钥."
+ },
+ {
+ "name": "orion.encrypt.aes.use-generator-key",
+ "type": "java.lang.Boolean",
+ "description": "是否生成密钥.",
+ "defaultValue": "true"
+ },
+ {
+ "name": "orion.encrypt.aes.generator-key-length",
+ "type": "java.lang.Integer",
+ "description": "生成的密钥长度 128 192 256bytes.",
+ "defaultValue": "128"
+ },
+ {
+ "name": "orion.encrypt.aes.iv",
+ "type": "java.lang.String",
+ "description": "向量 长度为 16bytes."
+ },
+ {
+ "name": "orion.encrypt.aes.gcm",
+ "type": "java.lang.String",
+ "description": "GCM 模式参数 长度为 96 104 112 120 128bytes."
+ },
+ {
+ "name": "orion.encrypt.aes.aad",
+ "type": "java.lang.String",
+ "description": "GCM 模式 aad."
+ }
+ ]
+}
\ No newline at end of file
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 00000000..ed914b6c
--- /dev/null
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-encrypt/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -0,0 +1 @@
+org.dromara.visor.framework.encrypt.configuration.OrionEncryptAutoConfiguration
\ No newline at end of file
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/resources/META-INF/additional-spring-configuration-metadata.json
index 9c0b0f26..ce0153cf 100644
--- a/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/resources/META-INF/additional-spring-configuration-metadata.json
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -4,11 +4,6 @@
"name": "orion.security",
"type": "org.dromara.visor.framework.security.configuration.config.SecurityConfig",
"sourceType": "org.dromara.visor.framework.security.configuration.config.SecurityConfig"
- },
- {
- "name": "orion.crypto.aes",
- "type": "org.dromara.visor.framework.security.configuration.config.AesCryptoConfig",
- "sourceType": "org.dromara.visor.framework.security.configuration.config.AesCryptoConfig"
}
],
"properties": [
@@ -22,62 +17,6 @@
"name": "orion.security.permit-url",
"type": "java.util.List",
"description": "匿名接口."
- },
- {
- "name": "orion.crypto.aes.primary",
- "type": "java.lang.Boolean",
- "description": "是否为默认加密器.",
- "defaultValue": "false"
- },
- {
- "name": "orion.crypto.aes.enabled",
- "type": "java.lang.Boolean",
- "description": "是否启用.",
- "defaultValue": "false"
- },
- {
- "name": "orion.crypto.aes.working-mode",
- "type": "cn.orionsec.kit.lang.utils.crypto.enums.WorkingMode",
- "description": "加密模式.",
- "defaultValue": "ECB"
- },
- {
- "name": "orion.crypto.aes.padding-mode",
- "type": "cn.orionsec.kit.lang.utils.crypto.enums.PaddingMode",
- "description": "填充模式.",
- "defaultValue": "PKCS5_PADDING"
- },
- {
- "name": "orion.crypto.aes.secret-key",
- "type": "java.lang.String",
- "description": "加密密钥."
- },
- {
- "name": "orion.crypto.aes.use-generator-key",
- "type": "java.lang.Boolean",
- "description": "是否生成密钥.",
- "defaultValue": "true"
- },
- {
- "name": "orion.crypto.aes.generator-key-length",
- "type": "java.lang.Integer",
- "description": "生成的密钥长度 128 192 256bytes.",
- "defaultValue": "128"
- },
- {
- "name": "orion.crypto.aes.iv",
- "type": "java.lang.String",
- "description": "向量 长度为 16bytes."
- },
- {
- "name": "orion.crypto.aes.gcm",
- "type": "java.lang.String",
- "description": "GCM 模式参数 长度为 96 104 112 120 128bytes."
- },
- {
- "name": "orion.crypto.aes.aad",
- "type": "java.lang.String",
- "description": "GCM 模式 aad."
}
]
}
\ No newline at end of file
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
index 0de7d6c5..a63cfef4 100644
--- a/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-security/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -1,2 +1 @@
-org.dromara.visor.framework.security.configuration.OrionSecurityAutoConfiguration
-org.dromara.visor.framework.security.configuration.OrionCryptoAutoConfiguration
\ No newline at end of file
+org.dromara.visor.framework.security.configuration.OrionSecurityAutoConfiguration
\ No newline at end of file
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/java/org/dromara/visor/framework/storage/configuration/OrionStorageAutoConfiguration.java b/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/java/org/dromara/visor/framework/storage/configuration/OrionStorageAutoConfiguration.java
index c2d914b1..195ab9fb 100644
--- a/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/java/org/dromara/visor/framework/storage/configuration/OrionStorageAutoConfiguration.java
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/java/org/dromara/visor/framework/storage/configuration/OrionStorageAutoConfiguration.java
@@ -26,15 +26,12 @@ import org.dromara.visor.common.constant.AutoConfigureOrderConst;
import org.dromara.visor.common.interfaces.FileClient;
import org.dromara.visor.framework.storage.configuration.config.LocalStorageConfig;
import org.dromara.visor.framework.storage.configuration.config.LogsStorageConfig;
-import org.dromara.visor.framework.storage.core.client.PrimaryFileClient;
import org.dromara.visor.framework.storage.core.client.local.LocalFileClient;
-import org.dromara.visor.framework.storage.core.utils.FileClientUtils;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Primary;
/**
* 存储配置类
@@ -50,19 +47,6 @@ import org.springframework.context.annotation.Primary;
@EnableConfigurationProperties({LocalStorageConfig.class, LogsStorageConfig.class})
public class OrionStorageAutoConfiguration {
- /**
- * @return 默认文件客户端
- */
- @Bean(name = "fileClient")
- @Primary
- public FileClient primaryFileClient() {
- // 创建客户端
- PrimaryFileClient client = new PrimaryFileClient();
- // 设置工具类
- FileClientUtils.setDelegate(client);
- return client;
- }
-
/**
* @return 本地文件客户端
*/
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/java/org/dromara/visor/framework/storage/core/client/AbstractFileClient.java b/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/java/org/dromara/visor/framework/storage/core/client/AbstractFileClient.java
index 3e34680f..c60087b9 100644
--- a/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/java/org/dromara/visor/framework/storage/core/client/AbstractFileClient.java
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/java/org/dromara/visor/framework/storage/core/client/AbstractFileClient.java
@@ -45,10 +45,6 @@ public abstract class AbstractFileClient implem
public AbstractFileClient(Config config) {
this.config = config;
- // 设置默认文件客户端
- if (config.isPrimary()) {
- PrimaryFileClient.setDelegate(this);
- }
}
@Override
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/java/org/dromara/visor/framework/storage/core/client/FileClientConfig.java b/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/java/org/dromara/visor/framework/storage/core/client/FileClientConfig.java
index 8e744bd2..3ee25533 100644
--- a/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/java/org/dromara/visor/framework/storage/core/client/FileClientConfig.java
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/java/org/dromara/visor/framework/storage/core/client/FileClientConfig.java
@@ -35,11 +35,6 @@ import lombok.Data;
@Data
public class FileClientConfig {
- /**
- * 是否为默认客户端
- */
- protected boolean primary;
-
/**
* 是否启用
*/
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/java/org/dromara/visor/framework/storage/core/client/PrimaryFileClient.java b/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/java/org/dromara/visor/framework/storage/core/client/PrimaryFileClient.java
deleted file mode 100644
index ec45dfde..00000000
--- a/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/java/org/dromara/visor/framework/storage/core/client/PrimaryFileClient.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2023 - present Dromara, All rights reserved.
- *
- * https://visor.dromara.org
- * https://visor.dromara.org.cn
- * https://visor.orionsec.cn
- *
- * Members:
- * Jiahang Li - ljh1553488six@139.com - author
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.dromara.visor.framework.storage.core.client;
-
-import cn.orionsec.kit.lang.utils.Exceptions;
-import org.dromara.visor.common.interfaces.FileClient;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * 默认文件客户端
- *
- * @author Jiahang Li
- * @version 1.0.0
- * @since 2023/7/14 11:01
- */
-public class PrimaryFileClient implements FileClient {
-
- private static FileClient delegate;
-
- @Override
- public String upload(String path, byte[] content) throws Exception {
- return delegate.upload(path, content);
- }
-
- @Override
- public String upload(String path, byte[] content, boolean overrideIfExist) throws Exception {
- return delegate.upload(path, content, overrideIfExist);
- }
-
- @Override
- public String upload(String path, InputStream in) throws Exception {
- return delegate.upload(path, in);
- }
-
- @Override
- public String upload(String path, InputStream in, boolean autoClose) throws Exception {
- return delegate.upload(path, in, autoClose);
- }
-
- @Override
- public String upload(String path, InputStream in, boolean autoClose, boolean overrideIfExist) throws Exception {
- return delegate.upload(path, in, autoClose, overrideIfExist);
- }
-
- @Override
- public boolean isExists(String path) {
- return delegate.isExists(path);
- }
-
- @Override
- public boolean delete(String path) throws Exception {
- return delegate.delete(path);
- }
-
- @Override
- public byte[] getContent(String path) throws Exception {
- return delegate.getContent(path);
- }
-
- @Override
- public InputStream getContentInputStream(String path) throws Exception {
- return delegate.getContentInputStream(path);
- }
-
- @Override
- public OutputStream getContentOutputStream(String path) throws Exception {
- return delegate.getContentOutputStream(path);
- }
-
- @Override
- public OutputStream getContentOutputStream(String path, boolean append) throws Exception {
- return delegate.getContentOutputStream(path, append);
- }
-
- @Override
- public String getReturnPath(String path) {
- return delegate.getReturnPath(path);
- }
-
- @Override
- public String getAbsolutePath(String returnPath) {
- return delegate.getAbsolutePath(returnPath);
- }
-
- public static void setDelegate(FileClient delegate) {
- if (PrimaryFileClient.delegate != null) {
- // unmodified
- throw Exceptions.state();
- }
- PrimaryFileClient.delegate = delegate;
- }
-
-}
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/java/org/dromara/visor/framework/storage/core/utils/FileClientUtils.java b/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/java/org/dromara/visor/framework/storage/core/utils/FileClientUtils.java
deleted file mode 100644
index ac4a32c4..00000000
--- a/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/java/org/dromara/visor/framework/storage/core/utils/FileClientUtils.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright (c) 2023 - present Dromara, All rights reserved.
- *
- * https://visor.dromara.org
- * https://visor.dromara.org.cn
- * https://visor.orionsec.cn
- *
- * Members:
- * Jiahang Li - ljh1553488six@139.com - author
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.dromara.visor.framework.storage.core.utils;
-
-import cn.orionsec.kit.lang.utils.Exceptions;
-import org.dromara.visor.common.interfaces.FileClient;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * 文件客户端工具
- *
- * PrimaryFileClient 代理类工具
- *
- * @author Jiahang Li
- * @version 1.0.0
- * @since 2023/7/21 12:05
- */
-public class FileClientUtils {
-
- private static FileClient delegate;
-
- private FileClientUtils() {
- }
-
- /**
- * 上传文件
- *
- * @param path 文件路径
- * @param content 文件内容
- * @return 路径
- * @throws Exception Exception
- */
- public static String upload(String path, byte[] content) throws Exception {
- return delegate.upload(path, content);
- }
-
- /**
- * 上传文件
- *
- * @param path 文件路径
- * @param content 文件内容
- * @param overrideIfExist 文件存在是否覆盖
- * @return 路径
- * @throws Exception Exception
- */
- public static String upload(String path, byte[] content, boolean overrideIfExist) throws Exception {
- return delegate.upload(path, content, overrideIfExist);
- }
-
- /**
- * 上传文件
- *
- * @param path 文件路径
- * @param in in
- * @return 路径
- * @throws Exception Exception
- */
- public static String upload(String path, InputStream in) throws Exception {
- return delegate.upload(path, in);
- }
-
- /**
- * 上传文件
- *
- * @param path 文件路径
- * @param in in
- * @param autoClose autoClose
- * @return 路径
- * @throws Exception Exception
- */
- public static String upload(String path, InputStream in, boolean autoClose) throws Exception {
- return delegate.upload(path, in, autoClose);
- }
-
- /**
- * 上传文件
- *
- * @param path 文件路径
- * @param in in
- * @param autoClose autoClose
- * @param overrideIfExist 文件存在是否覆盖
- * @return 路径
- * @throws Exception Exception
- */
- public static String upload(String path, InputStream in, boolean autoClose, boolean overrideIfExist) throws Exception {
- return delegate.upload(path, in, autoClose, overrideIfExist);
- }
-
- /**
- * 检查文件是否存在
- *
- * @param path path
- * @return 是否存在
- */
- public static boolean isExists(String path) {
- return delegate.isExists(path);
- }
-
- /**
- * 删除文件
- *
- * @param path 路径
- * @return 是否删除
- * @throws Exception Exception
- */
- public static boolean delete(String path) throws Exception {
- return delegate.delete(path);
- }
-
- /**
- * 获取文件内容
- *
- * @param path path
- * @return bytes
- * @throws Exception Exception
- */
- public static byte[] getContent(String path) throws Exception {
- return delegate.getContent(path);
- }
-
- /**
- * 获取文件输入流
- *
- * @param path path
- * @return stream
- * @throws Exception Exception
- */
- public static InputStream getContentInputStream(String path) throws Exception {
- return delegate.getContentInputStream(path);
- }
-
- /**
- * 获取文件输出流
- *
- * @param path path
- * @return stream
- * @throws Exception Exception
- */
- public static OutputStream getContentOutputStream(String path) throws Exception {
- return delegate.getContentOutputStream(path);
- }
-
- /**
- * 获取文件输出流
- *
- * @param path path
- * @param append append
- * @return stream
- * @throws Exception Exception
- */
- public static OutputStream getContentOutputStream(String path, boolean append) throws Exception {
- return delegate.getContentOutputStream(path, append);
- }
-
- /**
- * 获取返回路径 用于客户端返回
- *
- * @param path path
- * @return returnPath
- */
- public static String getReturnPath(String path) {
- return delegate.getReturnPath(path);
- }
-
- /**
- * 获取实际存储路径 用于服务端的存储
- *
- * @param returnPath returnPath
- * @return absolutePath
- */
- public static String getAbsolutePath(String returnPath) {
- return delegate.getAbsolutePath(returnPath);
- }
-
- public static void setDelegate(FileClient delegate) {
- if (FileClientUtils.delegate != null) {
- // unmodified
- throw Exceptions.state();
- }
- FileClientUtils.delegate = delegate;
- }
-
-}
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/resources/META-INF/additional-spring-configuration-metadata.json
index 965b6c8a..8a688732 100644
--- a/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/resources/META-INF/additional-spring-configuration-metadata.json
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-storage/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -12,12 +12,6 @@
}
],
"properties": [
- {
- "name": "orion.storage.local.primary",
- "type": "java.lang.Boolean",
- "description": "是否为默认客户端.",
- "defaultValue": false
- },
{
"name": "orion.storage.local.enabled",
"type": "java.lang.Boolean",
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-web/src/main/java/org/dromara/visor/framework/web/core/annotation/ParamDecrypt.java b/orion-visor-framework/orion-visor-spring-boot-starter-web/src/main/java/org/dromara/visor/framework/web/core/annotation/ParamDecrypt.java
new file mode 100644
index 00000000..76d9e3c7
--- /dev/null
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-web/src/main/java/org/dromara/visor/framework/web/core/annotation/ParamDecrypt.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2023 - present Dromara, All rights reserved.
+ *
+ * https://visor.dromara.org
+ * https://visor.dromara.org.cn
+ * https://visor.orionsec.cn
+ *
+ * Members:
+ * Jiahang Li - ljh1553488six@139.com - author
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.dromara.visor.framework.web.core.annotation;
+
+import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import org.dromara.visor.framework.web.core.deserializer.ParamDecryptDeserializer;
+
+import java.lang.annotation.*;
+
+/**
+ * Jackson 参数解密元注解
+ *
+ * Jackson 标注在字段上则标记该字段执行 http 反列化 (解析 request)时解密的字段 (http-message-converts 用的是 jackson)
+ *
+ * @author Jiahang Li
+ * @version 1.0.0
+ * @since 2025/1/5 15:33
+ */
+@Target({ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@JacksonAnnotationsInside
+@JsonDeserialize(using = ParamDecryptDeserializer.class)
+public @interface ParamDecrypt {
+}
diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-web/src/main/java/org/dromara/visor/framework/web/core/deserializer/ParamDecryptDeserializer.java b/orion-visor-framework/orion-visor-spring-boot-starter-web/src/main/java/org/dromara/visor/framework/web/core/deserializer/ParamDecryptDeserializer.java
new file mode 100644
index 00000000..710643c4
--- /dev/null
+++ b/orion-visor-framework/orion-visor-spring-boot-starter-web/src/main/java/org/dromara/visor/framework/web/core/deserializer/ParamDecryptDeserializer.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2023 - present Dromara, All rights reserved.
+ *
+ * https://visor.dromara.org
+ * https://visor.dromara.org.cn
+ * https://visor.orionsec.cn
+ *
+ * Members:
+ * Jiahang Li - ljh1553488six@139.com - author
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.dromara.visor.framework.web.core.deserializer;
+
+import cn.orionsec.kit.lang.utils.Strings;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.dromara.visor.common.constant.ErrorMessage;
+import org.dromara.visor.common.utils.RsaEncryptorUtils;
+import org.dromara.visor.common.utils.Valid;
+
+import java.io.IOException;
+
+/**
+ * 参数解密反序列化器
+ *
+ * @author Jiahang Li
+ * @version 1.0.0
+ * @since 2025/1/5 15:32
+ */
+public class ParamDecryptDeserializer extends JsonDeserializer {
+
+ @Override
+ public String deserialize(JsonParser p, DeserializationContext ctx) throws IOException {
+ JsonNode node = p.getCodec().readTree(p);
+ String value = node.asText();
+ // 为空直接返回
+ if (Strings.isBlank(value)) {
+ return value;
+ }
+ // 解密参数
+ String decrypt = RsaEncryptorUtils.decrypt(value);
+ return Valid.notNull(decrypt, ErrorMessage.DECRYPT_ERROR);
+ }
+
+}
\ No newline at end of file
diff --git a/orion-visor-framework/pom.xml b/orion-visor-framework/pom.xml
index ed45894e..209522eb 100644
--- a/orion-visor-framework/pom.xml
+++ b/orion-visor-framework/pom.xml
@@ -21,10 +21,12 @@
orion-visor-spring-boot-starter-swagger
orion-visor-spring-boot-starter-datasource
orion-visor-spring-boot-starter-mybatis
+ orion-visor-spring-boot-starter-config
orion-visor-spring-boot-starter-job
orion-visor-spring-boot-starter-websocket
orion-visor-spring-boot-starter-redis
orion-visor-spring-boot-starter-desensitize
+ orion-visor-spring-boot-starter-encrypt
orion-visor-spring-boot-starter-log
orion-visor-spring-boot-starter-storage
orion-visor-spring-boot-starter-security
diff --git a/orion-visor-launch/pom.xml b/orion-visor-launch/pom.xml
index 56f1725b..22fd2893 100644
--- a/orion-visor-launch/pom.xml
+++ b/orion-visor-launch/pom.xml
@@ -22,13 +22,26 @@
spring-boot-configuration-processor
true