🔨 添加配置及加密模块.
This commit is contained in:
@@ -1,3 +1,25 @@
|
||||
/*
|
||||
* 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.common.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -1,3 +1,25 @@
|
||||
/*
|
||||
* 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.common.config;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -94,6 +94,8 @@ public interface ErrorMessage {
|
||||
|
||||
String UNSUPPORTED_CHARSET = "不支持的编码 [{}]";
|
||||
|
||||
String DECRYPT_ERROR = "数据解密失败";
|
||||
|
||||
String PASSWORD_MISSING = "请输入密码";
|
||||
|
||||
String BEFORE_PASSWORD_ERROR = "原密码错误";
|
||||
|
||||
@@ -1,3 +1,25 @@
|
||||
/*
|
||||
* 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.common.interfaces;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,25 @@
|
||||
/*
|
||||
* 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.common.utils;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.Exceptions;
|
||||
|
||||
@@ -75,6 +75,11 @@
|
||||
<artifactId>orion-visor-spring-boot-starter-web</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-config</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-swagger</artifactId>
|
||||
@@ -110,6 +115,11 @@
|
||||
<artifactId>orion-visor-spring-boot-starter-desensitize</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-encrypt</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-log</artifactId>
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-framework</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>orion-visor-spring-boot-starter-config</artifactId>
|
||||
<name>${project.artifactId}</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>项目配置中心</description>
|
||||
<url>https://github.com/dromara/orion-visor</url>
|
||||
|
||||
<dependencies>
|
||||
<!-- common -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- spring boot starter -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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.configuration;
|
||||
|
||||
import org.dromara.visor.common.constant.AutoConfigureOrderConst;
|
||||
import org.dromara.visor.framework.config.core.listener.ConfigUpdateListener;
|
||||
import org.dromara.visor.framework.config.core.service.ConfigFrameworkService;
|
||||
import org.dromara.visor.framework.config.core.service.ConfigFrameworkServiceDelegate;
|
||||
import org.dromara.visor.framework.config.core.store.ManagementConfigStore;
|
||||
import org.dromara.visor.framework.config.core.store.ManagementConfigStoreImpl;
|
||||
import org.dromara.visor.framework.config.core.utils.ConfigStores;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
/**
|
||||
* 配置中心 自动配置类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2025/1/6 15:44
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@AutoConfigureOrder(AutoConfigureOrderConst.FRAMEWORK_CONFIG)
|
||||
public class OrionConfigAutoConfiguration {
|
||||
|
||||
/**
|
||||
* @param impl impl
|
||||
* @return 配置框架服务
|
||||
*/
|
||||
@Bean
|
||||
@Primary
|
||||
public ConfigFrameworkServiceDelegate configFrameworkService(ConfigFrameworkService impl) {
|
||||
return new ConfigFrameworkServiceDelegate(impl);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param delegate delegate
|
||||
* @return 配置修改监听器
|
||||
*/
|
||||
@Bean
|
||||
public ManagementConfigStore configStore(ConfigFrameworkServiceDelegate delegate) {
|
||||
// 初始化
|
||||
ManagementConfigStoreImpl configStore = new ManagementConfigStoreImpl(delegate);
|
||||
// 加载全部配置
|
||||
configStore.loadAllConfig();
|
||||
// 设置 ConfigStores
|
||||
ConfigStores.setDelegate(configStore);
|
||||
return configStore;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param configStore configStore
|
||||
* @return 配置更新监听器
|
||||
*/
|
||||
@Bean
|
||||
public ConfigUpdateListener configUpdateListener(ManagementConfigStore configStore) {
|
||||
return new ConfigUpdateListener(configStore);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.event;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.collect.Maps;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 配置更新事件
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2025/1/6 17:24
|
||||
*/
|
||||
public class ConfigUpdateEvent extends ApplicationEvent {
|
||||
|
||||
private ConfigUpdateEvent(Map<String, String> configs) {
|
||||
super(configs);
|
||||
}
|
||||
|
||||
public static ConfigUpdateEvent of(Map<String, String> configs) {
|
||||
return new ConfigUpdateEvent(configs);
|
||||
}
|
||||
|
||||
public static ConfigUpdateEvent of(String key, String value) {
|
||||
return new ConfigUpdateEvent(Maps.of(key, value));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.listener;
|
||||
|
||||
import org.dromara.visor.framework.config.core.event.ConfigUpdateEvent;
|
||||
import org.dromara.visor.framework.config.core.store.ManagementConfigStore;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 配置修改监听器
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2025/1/6 16:01
|
||||
*/
|
||||
public class ConfigUpdateListener implements ApplicationListener<ConfigUpdateEvent> {
|
||||
|
||||
private final ManagementConfigStore configStore;
|
||||
|
||||
public ConfigUpdateListener(ManagementConfigStore configStore) {
|
||||
this.configStore = configStore;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void onApplicationEvent(ConfigUpdateEvent event) {
|
||||
// 获取修改的配置并且覆盖
|
||||
Map<String, String> configs = (Map<String, String>) event.getSource();
|
||||
configs.forEach(configStore::override);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* 加密配置
|
||||
* 配置框架服务
|
||||
* <p>
|
||||
* 在业务层定义 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<String, String> getAllConfig();
|
||||
|
||||
}
|
||||
@@ -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<String, String> getAllConfig() {
|
||||
return configFrameworkService.getAllConfig();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -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<String, String> configMap = new ConcurrentHashMap<>();
|
||||
|
||||
private final ConcurrentHashMap<String, List<ConfigRef<?>>> 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<ConfigRef<?>> 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> T getConfig(String key, Function<String, T> convert) {
|
||||
return this.getConfig(key, convert, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getConfig(String key, Function<String, T> convert, T defaultValue) {
|
||||
// 获取配置
|
||||
String conf = configMap.get(key);
|
||||
// 默认值
|
||||
if (conf == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
// 转换
|
||||
return convert.apply(conf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigRef<String> string(String key) {
|
||||
return this.ref(key, Function.identity(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigRef<String> string(String key, String defaultValue) {
|
||||
return this.ref(key, Function.identity(), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigRef<Integer> int32(String key) {
|
||||
return this.ref(key, Integer::valueOf, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigRef<Integer> int32(String key, Integer defaultValue) {
|
||||
return this.ref(key, Integer::valueOf, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigRef<Long> int64(String key) {
|
||||
return this.ref(key, Long::valueOf, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigRef<Long> int64(String key, Long defaultValue) {
|
||||
return this.ref(key, Long::valueOf, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigRef<Double> float64(String key) {
|
||||
return this.ref(key, Double::valueOf, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigRef<Double> float64(String key, Double defaultValue) {
|
||||
return this.ref(key, Double::valueOf, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigRef<Boolean> bool(String key) {
|
||||
return this.ref(key, Boolean::valueOf, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigRef<Boolean> bool(String key, Boolean defaultValue) {
|
||||
return this.ref(key, Boolean::valueOf, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> ConfigRef<T> ref(String key, Function<String, T> convert) {
|
||||
return this.ref(key, convert, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> ConfigRef<T> ref(String key, Function<String, T> convert, T defaultValue) {
|
||||
// 创建引用
|
||||
ConfigRef<T> 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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> T
|
||||
* @return conf
|
||||
*/
|
||||
public static <T> T getConfig(String key, Function<String, T> convert) {
|
||||
return delegate.getConfig(key, convert);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置
|
||||
*
|
||||
* @param key key
|
||||
* @param defaultValue defaultValue
|
||||
* @param <T> T
|
||||
* @return conf
|
||||
*/
|
||||
public static <T> T getConfig(String key, Function<String, T> convert, T defaultValue) {
|
||||
return delegate.getConfig(key, convert, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 string 配置
|
||||
*
|
||||
* @param key key
|
||||
* @return ref
|
||||
*/
|
||||
public static ConfigRef<String> string(String key) {
|
||||
return delegate.string(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 string 配置
|
||||
*
|
||||
* @param key key
|
||||
* @param defaultValue defaultValue
|
||||
* @return ref
|
||||
*/
|
||||
public static ConfigRef<String> string(String key, String defaultValue) {
|
||||
return delegate.string(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 int 配置
|
||||
*
|
||||
* @param key key
|
||||
* @return ref
|
||||
*/
|
||||
public static ConfigRef<Integer> int32(String key) {
|
||||
return delegate.int32(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 int 配置
|
||||
*
|
||||
* @param key key
|
||||
* @param defaultValue defaultValue
|
||||
* @return ref
|
||||
*/
|
||||
public static ConfigRef<Integer> int32(String key, Integer defaultValue) {
|
||||
return delegate.int32(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 long 配置
|
||||
*
|
||||
* @param key key
|
||||
* @return ref
|
||||
*/
|
||||
public static ConfigRef<Long> int64(String key) {
|
||||
return delegate.int64(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 long 配置
|
||||
*
|
||||
* @param key key
|
||||
* @param defaultValue defaultValue
|
||||
* @return ref
|
||||
*/
|
||||
public static ConfigRef<Long> int64(String key, Long defaultValue) {
|
||||
return delegate.int64(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 double 配置
|
||||
*
|
||||
* @param key key
|
||||
* @return ref
|
||||
*/
|
||||
public static ConfigRef<Double> float64(String key) {
|
||||
return delegate.float64(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 double 配置
|
||||
*
|
||||
* @param key key
|
||||
* @param defaultValue defaultValue
|
||||
* @return ref
|
||||
*/
|
||||
public static ConfigRef<Double> float64(String key, Double defaultValue) {
|
||||
return delegate.float64(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 boolean 配置
|
||||
*
|
||||
* @param key key
|
||||
* @return ref
|
||||
*/
|
||||
public static ConfigRef<Boolean> bool(String key) {
|
||||
return delegate.bool(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 boolean 配置
|
||||
*
|
||||
* @param key key
|
||||
* @param defaultValue defaultValue
|
||||
* @return ref
|
||||
*/
|
||||
public static ConfigRef<Boolean> bool(String key, Boolean defaultValue) {
|
||||
return delegate.bool(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置
|
||||
*
|
||||
* @param key key
|
||||
* @param convert convert
|
||||
* @param <T> T
|
||||
* @return ref
|
||||
*/
|
||||
public static <T> ConfigRef<T> ref(String key, Function<String, T> convert) {
|
||||
return delegate.ref(key, convert);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置
|
||||
*
|
||||
* @param key key
|
||||
* @param convert convert
|
||||
* @param defaultValue defaultValue
|
||||
* @param <T> T
|
||||
* @return ref
|
||||
*/
|
||||
public static <T> ConfigRef<T> ref(String key, Function<String, T> 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
org.dromara.visor.framework.config.configuration.OrionConfigAutoConfiguration
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-framework</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>orion-visor-spring-boot-starter-encrypt</artifactId>
|
||||
<name>${project.artifactId}</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<description>项目加密包</description>
|
||||
<url>https://github.com/dromara/orion-visor</url>
|
||||
|
||||
<dependencies>
|
||||
<!-- common -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- spring boot starter -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<Config extends CryptoConfig> implements AesEncryptor {
|
||||
public abstract class BaseAesEncryptor<Config> 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();
|
||||
|
||||
/**
|
||||
* 初始化密钥
|
||||
*/
|
||||
@@ -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<AesCryptoConfig> {
|
||||
public class AesEncryptorImpl extends BaseAesEncryptor<AesEncryptConfig> {
|
||||
|
||||
/**
|
||||
* 加密器
|
||||
@@ -53,12 +53,14 @@ public class AesCryptoProcessor extends CryptoProcessor<AesCryptoConfig> {
|
||||
*/
|
||||
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())
|
||||
@@ -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<RSAPublicKey> publicKey;
|
||||
|
||||
private final ConfigRef<RSAPrivateKey> 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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
org.dromara.visor.framework.encrypt.configuration.OrionEncryptAutoConfiguration
|
||||
@@ -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."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,2 +1 @@
|
||||
org.dromara.visor.framework.security.configuration.OrionSecurityAutoConfiguration
|
||||
org.dromara.visor.framework.security.configuration.OrionCryptoAutoConfiguration
|
||||
@@ -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 本地文件客户端
|
||||
*/
|
||||
|
||||
@@ -45,10 +45,6 @@ public abstract class AbstractFileClient<Config extends FileClientConfig> implem
|
||||
|
||||
public AbstractFileClient(Config config) {
|
||||
this.config = config;
|
||||
// 设置默认文件客户端
|
||||
if (config.isPrimary()) {
|
||||
PrimaryFileClient.setDelegate(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,11 +35,6 @@ import lombok.Data;
|
||||
@Data
|
||||
public class FileClientConfig {
|
||||
|
||||
/**
|
||||
* 是否为默认客户端
|
||||
*/
|
||||
protected boolean primary;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* 文件客户端工具
|
||||
* <p>
|
||||
* 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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",
|
||||
|
||||
@@ -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 参数解密元注解
|
||||
* <p>
|
||||
* 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 {
|
||||
}
|
||||
@@ -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<String> {
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,10 +21,12 @@
|
||||
<module>orion-visor-spring-boot-starter-swagger</module>
|
||||
<module>orion-visor-spring-boot-starter-datasource</module>
|
||||
<module>orion-visor-spring-boot-starter-mybatis</module>
|
||||
<module>orion-visor-spring-boot-starter-config</module>
|
||||
<module>orion-visor-spring-boot-starter-job</module>
|
||||
<module>orion-visor-spring-boot-starter-websocket</module>
|
||||
<module>orion-visor-spring-boot-starter-redis</module>
|
||||
<module>orion-visor-spring-boot-starter-desensitize</module>
|
||||
<module>orion-visor-spring-boot-starter-encrypt</module>
|
||||
<module>orion-visor-spring-boot-starter-log</module>
|
||||
<module>orion-visor-spring-boot-starter-storage</module>
|
||||
<module>orion-visor-spring-boot-starter-security</module>
|
||||
|
||||
@@ -22,13 +22,26 @@
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- starter -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- orion-visor starter -->
|
||||
<!-- modules -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-module-infra-service</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-module-asset-service</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- framework starter -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-banner</artifactId>
|
||||
@@ -49,6 +62,14 @@
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-mybatis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-encrypt</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-job</artifactId>
|
||||
@@ -85,19 +106,6 @@
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-biz-operator-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- orion-visor modules -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-module-infra-service</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-module-asset-service</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -61,7 +61,7 @@ orion:
|
||||
logging:
|
||||
printer:
|
||||
mode: ROW
|
||||
crypto:
|
||||
encrypt:
|
||||
aes:
|
||||
# 加密密钥
|
||||
secret-key: ${SECRET_KEY:uQeacXV8b3isvKLK}
|
||||
|
||||
@@ -256,7 +256,6 @@ orion:
|
||||
storage:
|
||||
# 本地文件存储
|
||||
local:
|
||||
primary: true
|
||||
enabled: true
|
||||
timestamp-prefix: false
|
||||
date-directory: false
|
||||
@@ -274,11 +273,9 @@ orion:
|
||||
# 匿名接口
|
||||
permit-url:
|
||||
- ${orion.api.prefix}/server/bootstrap/health
|
||||
crypto:
|
||||
encrypt:
|
||||
# aes加密器
|
||||
aes:
|
||||
primary: true
|
||||
enabled: true
|
||||
working-mode: ECB
|
||||
padding-mode: PKCS5_PADDING
|
||||
# 加密密钥
|
||||
|
||||
@@ -21,75 +21,63 @@
|
||||
<artifactId>orion-visor-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- infra provider -->
|
||||
<!-- module provider -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-module-infra-provider</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- asset provider -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-module-asset-provider</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- web -->
|
||||
<!-- framework starter -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- websocket -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- log -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- operator-log -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-biz-operator-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- desensitize -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-desensitize</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- security -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-encrypt</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- redis -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- mybatis -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-mybatis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- storage -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-storage</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- job -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-job</artifactId>
|
||||
|
||||
@@ -27,9 +27,9 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.common.utils.Valid;
|
||||
import org.dromara.visor.common.validator.group.Page;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.framework.log.core.annotation.IgnoreLog;
|
||||
import org.dromara.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
import org.dromara.visor.framework.security.core.utils.SecurityUtils;
|
||||
|
||||
@@ -27,8 +27,8 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.common.validator.group.Page;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.framework.log.core.annotation.IgnoreLog;
|
||||
import org.dromara.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
import org.dromara.visor.framework.web.core.annotation.DemoDisableApi;
|
||||
|
||||
@@ -27,9 +27,9 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.common.utils.Valid;
|
||||
import org.dromara.visor.common.validator.group.Page;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.framework.log.core.annotation.IgnoreLog;
|
||||
import org.dromara.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
import org.dromara.visor.framework.web.core.annotation.RestWrapper;
|
||||
|
||||
@@ -27,8 +27,8 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.common.validator.group.Page;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.framework.log.core.annotation.IgnoreLog;
|
||||
import org.dromara.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
import org.dromara.visor.framework.web.core.annotation.DemoDisableApi;
|
||||
|
||||
@@ -27,8 +27,8 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.common.validator.group.Page;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.framework.log.core.annotation.IgnoreLog;
|
||||
import org.dromara.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
import org.dromara.visor.framework.web.core.annotation.DemoDisableApi;
|
||||
|
||||
@@ -27,8 +27,8 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.common.validator.group.Page;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.framework.log.core.annotation.IgnoreLog;
|
||||
import org.dromara.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
import org.dromara.visor.framework.web.core.annotation.DemoDisableApi;
|
||||
|
||||
@@ -27,8 +27,8 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.common.validator.group.Page;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.framework.log.core.annotation.IgnoreLog;
|
||||
import org.dromara.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
import org.dromara.visor.framework.web.core.annotation.DemoDisableApi;
|
||||
|
||||
@@ -27,9 +27,9 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.common.validator.group.Id;
|
||||
import org.dromara.visor.common.validator.group.Page;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.framework.log.core.annotation.IgnoreLog;
|
||||
import org.dromara.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
import org.dromara.visor.framework.web.core.annotation.DemoDisableApi;
|
||||
|
||||
@@ -27,8 +27,8 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.common.validator.group.Page;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.framework.log.core.annotation.IgnoreLog;
|
||||
import org.dromara.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
import org.dromara.visor.framework.web.core.annotation.IgnoreWrapper;
|
||||
|
||||
@@ -27,8 +27,8 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.common.validator.group.Page;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import org.dromara.visor.framework.log.core.annotation.IgnoreLog;
|
||||
import org.dromara.visor.framework.log.core.enums.IgnoreLogMode;
|
||||
import org.dromara.visor.framework.web.core.annotation.RestWrapper;
|
||||
|
||||
@@ -24,8 +24,8 @@ package org.dromara.visor.module.asset.handler.host.exec.job;
|
||||
|
||||
import cn.orionsec.kit.spring.SpringHolder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.constant.FieldConst;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.module.asset.dao.ExecJobDAO;
|
||||
import org.dromara.visor.module.asset.entity.domain.ExecJobDO;
|
||||
import org.dromara.visor.module.asset.entity.request.exec.ExecJobTriggerRequest;
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
*/
|
||||
package org.dromara.visor.module.asset.handler.host.terminal.handler;
|
||||
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.model.OperatorLogModel;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.service.OperatorLogFrameworkService;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.framework.websocket.core.utils.WebSockets;
|
||||
import org.dromara.visor.module.asset.handler.host.terminal.enums.OutputTypeEnum;
|
||||
import org.dromara.visor.module.asset.handler.host.terminal.manager.TerminalManager;
|
||||
|
||||
@@ -24,8 +24,8 @@ package org.dromara.visor.module.asset.handler.host.terminal.handler;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.enums.BooleanBit;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.module.asset.define.operator.TerminalOperatorType;
|
||||
import org.dromara.visor.module.asset.handler.host.terminal.enums.OutputTypeEnum;
|
||||
import org.dromara.visor.module.asset.handler.host.terminal.model.request.SftpChangeModeRequest;
|
||||
|
||||
@@ -24,8 +24,8 @@ package org.dromara.visor.module.asset.handler.host.terminal.handler;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.enums.BooleanBit;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.module.asset.define.operator.TerminalOperatorType;
|
||||
import org.dromara.visor.module.asset.handler.host.terminal.enums.OutputTypeEnum;
|
||||
import org.dromara.visor.module.asset.handler.host.terminal.model.request.SftpBaseRequest;
|
||||
|
||||
@@ -24,8 +24,8 @@ package org.dromara.visor.module.asset.handler.host.terminal.handler;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.enums.BooleanBit;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.module.asset.define.operator.TerminalOperatorType;
|
||||
import org.dromara.visor.module.asset.handler.host.terminal.enums.OutputTypeEnum;
|
||||
import org.dromara.visor.module.asset.handler.host.terminal.model.request.SftpMoveRequest;
|
||||
|
||||
@@ -24,8 +24,8 @@ package org.dromara.visor.module.asset.handler.host.terminal.handler;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.enums.BooleanBit;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.module.asset.define.operator.TerminalOperatorType;
|
||||
import org.dromara.visor.module.asset.handler.host.terminal.enums.OutputTypeEnum;
|
||||
import org.dromara.visor.module.asset.handler.host.terminal.model.request.SftpBaseRequest;
|
||||
|
||||
@@ -25,8 +25,8 @@ package org.dromara.visor.module.asset.handler.host.terminal.handler;
|
||||
import cn.orionsec.kit.lang.id.UUIds;
|
||||
import cn.orionsec.kit.lang.utils.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.enums.BooleanBit;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.framework.redis.core.utils.RedisStrings;
|
||||
import org.dromara.visor.module.asset.define.cache.TerminalCacheKeyDefine;
|
||||
import org.dromara.visor.module.asset.define.operator.TerminalOperatorType;
|
||||
|
||||
@@ -24,8 +24,8 @@ package org.dromara.visor.module.asset.handler.host.terminal.handler;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.enums.BooleanBit;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.module.asset.define.operator.TerminalOperatorType;
|
||||
import org.dromara.visor.module.asset.handler.host.terminal.enums.OutputTypeEnum;
|
||||
import org.dromara.visor.module.asset.handler.host.terminal.model.request.SftpBaseRequest;
|
||||
|
||||
@@ -24,8 +24,8 @@ package org.dromara.visor.module.asset.handler.host.terminal.handler;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.enums.BooleanBit;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.module.asset.define.operator.TerminalOperatorType;
|
||||
import org.dromara.visor.module.asset.handler.host.terminal.enums.OutputTypeEnum;
|
||||
import org.dromara.visor.module.asset.handler.host.terminal.model.request.SftpBaseRequest;
|
||||
|
||||
@@ -27,12 +27,12 @@ import cn.orionsec.kit.lang.exception.argument.InvalidArgumentException;
|
||||
import cn.orionsec.kit.lang.utils.Exceptions;
|
||||
import cn.orionsec.kit.lang.utils.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.model.OperatorLogModel;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.service.OperatorLogFrameworkService;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.constant.ExtraFieldConst;
|
||||
import org.dromara.visor.common.enums.BooleanBit;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.model.OperatorLogModel;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.service.OperatorLogFrameworkService;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.framework.websocket.core.utils.WebSockets;
|
||||
import org.dromara.visor.module.asset.dao.HostDAO;
|
||||
import org.dromara.visor.module.asset.define.operator.TerminalOperatorType;
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
*/
|
||||
package org.dromara.visor.module.asset.handler.host.terminal.utils;
|
||||
|
||||
import org.dromara.visor.common.constant.ExtraFieldConst;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.model.OperatorLogModel;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogFiller;
|
||||
import org.dromara.visor.common.constant.ExtraFieldConst;
|
||||
import org.dromara.visor.framework.websocket.core.utils.WebSockets;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@ package org.dromara.visor.module.asset.service.impl;
|
||||
import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import cn.orionsec.kit.spring.SpringHolder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.utils.Valid;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.module.asset.dao.HostIdentityDAO;
|
||||
import org.dromara.visor.module.asset.dao.HostKeyDAO;
|
||||
import org.dromara.visor.module.asset.entity.domain.HostIdentityDO;
|
||||
|
||||
@@ -34,7 +34,6 @@ import cn.orionsec.kit.lang.utils.json.matcher.ReplacementFormatters;
|
||||
import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.constant.FileConst;
|
||||
@@ -43,6 +42,7 @@ import org.dromara.visor.common.interfaces.FileClient;
|
||||
import org.dromara.visor.common.security.LoginUser;
|
||||
import org.dromara.visor.common.utils.PathUtils;
|
||||
import org.dromara.visor.common.utils.Valid;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.framework.security.core.utils.SecurityUtils;
|
||||
import org.dromara.visor.module.asset.convert.ExecConvert;
|
||||
import org.dromara.visor.module.asset.convert.ExecHostLogConvert;
|
||||
|
||||
@@ -25,9 +25,9 @@ package org.dromara.visor.module.asset.service.impl;
|
||||
import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.utils.Valid;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.module.asset.convert.ExecHostLogConvert;
|
||||
import org.dromara.visor.module.asset.dao.ExecHostLogDAO;
|
||||
import org.dromara.visor.module.asset.entity.domain.ExecHostLogDO;
|
||||
|
||||
@@ -30,11 +30,11 @@ import cn.orionsec.kit.lang.utils.time.cron.Cron;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.security.LoginUser;
|
||||
import org.dromara.visor.common.utils.Valid;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.framework.job.core.utils.QuartzUtils;
|
||||
import org.dromara.visor.framework.security.core.utils.SecurityUtils;
|
||||
import org.dromara.visor.module.asset.convert.ExecJobConvert;
|
||||
|
||||
@@ -36,7 +36,6 @@ import cn.orionsec.kit.web.servlet.web.Servlets;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.constant.FileConst;
|
||||
@@ -44,6 +43,7 @@ import org.dromara.visor.common.enums.EndpointDefine;
|
||||
import org.dromara.visor.common.interfaces.FileClient;
|
||||
import org.dromara.visor.common.utils.SqlUtils;
|
||||
import org.dromara.visor.common.utils.Valid;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.framework.redis.core.utils.RedisStrings;
|
||||
import org.dromara.visor.framework.security.core.utils.SecurityUtils;
|
||||
import org.dromara.visor.module.asset.convert.ExecHostLogConvert;
|
||||
|
||||
@@ -27,10 +27,10 @@ import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.utils.Valid;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.framework.security.core.utils.SecurityUtils;
|
||||
import org.dromara.visor.module.asset.convert.ExecTemplateConvert;
|
||||
import org.dromara.visor.module.asset.dao.ExecTemplateDAO;
|
||||
|
||||
@@ -30,12 +30,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.security.PasswordModifier;
|
||||
import org.dromara.visor.common.utils.AesEncryptUtils;
|
||||
import org.dromara.visor.common.utils.Valid;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.framework.redis.core.utils.RedisMaps;
|
||||
import org.dromara.visor.framework.redis.core.utils.RedisUtils;
|
||||
import org.dromara.visor.framework.redis.core.utils.barrier.CacheBarriers;
|
||||
|
||||
@@ -28,12 +28,12 @@ import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.security.PasswordModifier;
|
||||
import org.dromara.visor.common.utils.AesEncryptUtils;
|
||||
import org.dromara.visor.common.utils.Valid;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.framework.redis.core.utils.RedisMaps;
|
||||
import org.dromara.visor.framework.redis.core.utils.RedisUtils;
|
||||
import org.dromara.visor.framework.redis.core.utils.barrier.CacheBarriers;
|
||||
|
||||
@@ -31,11 +31,11 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.handler.data.model.GenericsDataModel;
|
||||
import org.dromara.visor.common.utils.Valid;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.framework.redis.core.utils.RedisMaps;
|
||||
import org.dromara.visor.framework.redis.core.utils.barrier.CacheBarriers;
|
||||
import org.dromara.visor.module.asset.convert.HostConvert;
|
||||
|
||||
@@ -28,11 +28,11 @@ import cn.orionsec.kit.lang.utils.collect.Lists;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.utils.SqlUtils;
|
||||
import org.dromara.visor.common.utils.Valid;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.framework.security.core.utils.SecurityUtils;
|
||||
import org.dromara.visor.module.asset.convert.TerminalConnectLogConvert;
|
||||
import org.dromara.visor.module.asset.dao.TerminalConnectLogDAO;
|
||||
|
||||
@@ -37,10 +37,10 @@ import cn.orionsec.kit.web.servlet.web.Servlets;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.constant.ExtraFieldConst;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.framework.redis.core.utils.RedisStrings;
|
||||
import org.dromara.visor.framework.security.core.utils.SecurityUtils;
|
||||
import org.dromara.visor.module.asset.convert.TerminalSftpLogConvert;
|
||||
|
||||
@@ -35,7 +35,6 @@ import cn.orionsec.kit.lang.utils.time.Dates;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.common.constant.ErrorMessage;
|
||||
import org.dromara.visor.common.enums.EndpointDefine;
|
||||
@@ -43,6 +42,7 @@ import org.dromara.visor.common.interfaces.FileClient;
|
||||
import org.dromara.visor.common.security.LoginUser;
|
||||
import org.dromara.visor.common.utils.SqlUtils;
|
||||
import org.dromara.visor.common.utils.Valid;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.framework.mybatis.core.query.Conditions;
|
||||
import org.dromara.visor.framework.security.core.utils.SecurityUtils;
|
||||
import org.dromara.visor.module.asset.convert.HostConvert;
|
||||
|
||||
@@ -16,80 +16,65 @@
|
||||
<url>https://github.com/dromara/orion-visor</url>
|
||||
|
||||
<dependencies>
|
||||
<!-- common -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- infra provider -->
|
||||
<!-- module provider -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-module-infra-provider</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- asset provider -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-module-asset-provider</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- web -->
|
||||
<!-- framework starter -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- websocket -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- log -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- operator-log -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-biz-operator-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- desensitize -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-desensitize</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- security -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- redis -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- mybatis -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-mybatis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- storage -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-storage</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- test -->
|
||||
<dependency>
|
||||
<groupId>org.dromara.visor</groupId>
|
||||
<artifactId>orion-visor-spring-boot-starter-test</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user