🎨 优化项目模块.

This commit is contained in:
lijiahang
2025-01-08 10:52:36 +08:00
parent 4119dbad6a
commit 35733e80eb
45 changed files with 377 additions and 99 deletions

View File

@@ -0,0 +1,50 @@
package org.dromara.visor.common.config;
import lombok.extern.slf4j.Slf4j;
import java.util.function.Function;
/**
* 配置引用
*
* @author Jiahang Li
* @version 1.0.0
* @since 2025/1/6 18:01
*/
@Slf4j
public class ConfigRef<T> {
public final String key;
private final Function<String, T> convert;
public T value;
public ConfigRef(String key, Function<String, T> convert) {
this.key = key;
this.convert = convert;
}
/**
* 覆盖配置
*
* @param value value
*/
public void override(String value) {
try {
this.value = convert.apply(value);
} catch (Exception e) {
log.error("ConfigRef trigger override error key: {}, value: {}", key, value, e);
}
}
/**
* 设置值
*
* @param value value
*/
public void set(T value) {
this.value = value;
}
}

View File

@@ -0,0 +1,157 @@
package org.dromara.visor.common.config;
import java.util.function.Function;
/**
* 配置中心
*
* @author Jiahang Li
* @version 1.0.0
* @since 2025/1/5 21:30
*/
public interface ConfigStore {
/**
* 获取配置
*
* @param key key
* @return conf
*/
String getConfig(String key);
/**
* 获取配置
*
* @param key key
* @param defaultValue defaultValue
* @return conf
*/
String getConfig(String key, String defaultValue);
/**
* 获取配置
*
* @param key key
* @param convert convert
* @param <T> T
* @return conf
*/
<T> T getConfig(String key, Function<String, T> convert);
/**
* 获取配置
*
* @param key key
* @param defaultValue defaultValue
* @param <T> T
* @return conf
*/
<T> T getConfig(String key, Function<String, T> convert, T defaultValue);
/**
* 获取 string 配置
*
* @param key key
* @return ref
*/
ConfigRef<String> string(String key);
/**
* 获取 string 配置
*
* @param key key
* @param defaultValue defaultValue
* @return ref
*/
ConfigRef<String> string(String key, String defaultValue);
/**
* 获取 int 配置
*
* @param key key
* @return ref
*/
ConfigRef<Integer> int32(String key);
/**
* 获取 int 配置
*
* @param key key
* @param defaultValue defaultValue
* @return ref
*/
ConfigRef<Integer> int32(String key, Integer defaultValue);
/**
* 获取 long 配置
*
* @param key key
* @return ref
*/
ConfigRef<Long> int64(String key);
/**
* 获取 long 配置
*
* @param key key
* @param defaultValue defaultValue
* @return ref
*/
ConfigRef<Long> int64(String key, Long defaultValue);
/**
* 获取 double 配置
*
* @param key key
* @return ref
*/
ConfigRef<Double> float64(String key);
/**
* 获取 double 配置
*
* @param key key
* @param defaultValue defaultValue
* @return ref
*/
ConfigRef<Double> float64(String key, Double defaultValue);
/**
* 获取 boolean 配置
*
* @param key key
* @return ref
*/
ConfigRef<Boolean> bool(String key);
/**
* 获取 boolean 配置
*
* @param key key
* @param defaultValue defaultValue
* @return ref
*/
ConfigRef<Boolean> bool(String key, Boolean defaultValue);
/**
* 获取配置
*
* @param key key
* @param convert convert
* @param <T> T
* @return ref
*/
<T> ConfigRef<T> ref(String key, Function<String, T> convert);
/**
* 获取配置
*
* @param key key
* @param convert convert
* @param defaultValue defaultValue
* @param <T> T
* @return ref
*/
<T> ConfigRef<T> ref(String key, Function<String, T> convert, T defaultValue);
}

View File

@@ -37,8 +37,6 @@ public interface AutoConfigureOrderConst {
int FRAMEWORK_SECURITY = Integer.MIN_VALUE + 1200;
int FRAMEWORK_SECURITY_CRYPTO = Integer.MIN_VALUE + 1250;
int FRAMEWORK_WEBSOCKET = Integer.MIN_VALUE + 1300;
int FRAMEWORK_DESENSITIZE = Integer.MIN_VALUE + 1400;
@@ -53,19 +51,23 @@ public interface AutoConfigureOrderConst {
int FRAMEWORK_REDIS = Integer.MIN_VALUE + 1900;
int FRAMEWORK_REDIS_CACHE = Integer.MIN_VALUE + 1950;
int FRAMEWORK_REDIS_CACHE = Integer.MIN_VALUE + 2000;
int FRAMEWORK_STORAGE = Integer.MIN_VALUE + 2000;
int FRAMEWORK_CONFIG = Integer.MIN_VALUE + 2100;
int FRAMEWORK_JOB = Integer.MIN_VALUE + 2100;
int FRAMEWORK_ENCRYPT = Integer.MIN_VALUE + 2200;
int FRAMEWORK_JOB_QUARTZ = Integer.MIN_VALUE + 2130;
int FRAMEWORK_STORAGE = Integer.MIN_VALUE + 2300;
int FRAMEWORK_JOB_ASYNC = Integer.MIN_VALUE + 2160;
int FRAMEWORK_JOB = Integer.MIN_VALUE + 2400;
int FRAMEWORK_MONITOR = Integer.MIN_VALUE + 2200;
int FRAMEWORK_JOB_QUARTZ = Integer.MIN_VALUE + 2500;
int FRAMEWORK_BIZ_OPERATOR_LOG = Integer.MIN_VALUE + 3000;
int FRAMEWORK_JOB_ASYNC = Integer.MIN_VALUE + 2600;
int FRAMEWORK_MONITOR = Integer.MIN_VALUE + 2700;
int FRAMEWORK_BIZ_OPERATOR_LOG = Integer.MIN_VALUE + 2800;
int FRAMEWORK_BANNER = Integer.MIN_VALUE + 10000;

View File

@@ -20,24 +20,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.visor.common.crypto;
package org.dromara.visor.common.interfaces;
import cn.orionsec.kit.lang.utils.codec.Base62s;
import cn.orionsec.kit.lang.utils.crypto.symmetric.SymmetricCrypto;
/**
* 数据加密器
* aes 加密器
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023/7/8 0:20
*/
public interface ValueCrypto extends SymmetricCrypto {
/**
* 初始化
*/
void init();
public interface AesEncryptor extends SymmetricCrypto {
/**
* 加密后 base62 编码

View File

@@ -20,7 +20,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.visor.common.file;
package org.dromara.visor.common.interfaces;
import java.io.InputStream;
import java.io.OutputStream;

View File

@@ -20,7 +20,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.visor.common.lock;
package org.dromara.visor.common.interfaces;
import java.util.function.Supplier;

View File

@@ -0,0 +1,28 @@
package org.dromara.visor.common.interfaces;
/**
* rsa 加密器
*
* @author Jiahang Li
* @version 1.0.0
* @since 2025/1/5 20:58
*/
public interface RsaEncryptor {
/**
* 加密
*
* @param value value
* @return value
*/
String encrypt(String value);
/**
* 解密
*
* @param value value
* @return value
*/
String decrypt(String value);
}

View File

@@ -20,7 +20,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.visor.common.json.filter;
package org.dromara.visor.common.json;
import cn.orionsec.kit.lang.utils.Desensitizes;
import cn.orionsec.kit.lang.utils.Objects1;

View File

@@ -20,7 +20,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.visor.common.json.filter;
package org.dromara.visor.common.json;
import cn.orionsec.kit.lang.utils.collect.Lists;
import com.alibaba.fastjson.serializer.PropertyFilter;

View File

@@ -25,7 +25,7 @@ package org.dromara.visor.common.security;
import cn.orionsec.kit.lang.utils.Booleans;
import cn.orionsec.kit.lang.utils.Strings;
import org.dromara.visor.common.constant.Const;
import org.dromara.visor.common.utils.CryptoUtils;
import org.dromara.visor.common.utils.AesEncryptUtils;
/**
* 密码修改器
@@ -52,7 +52,7 @@ public class PasswordModifier {
if (Strings.isBlank(password)) {
return Const.EMPTY;
} else {
return CryptoUtils.encryptAsString(password);
return AesEncryptUtils.encryptAsString(password);
}
} else {
return null;

View File

@@ -20,7 +20,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.visor.common.meta;
package org.dromara.visor.common.trace;
import cn.orionsec.kit.lang.id.UUIds;
import com.alibaba.ttl.TransmittableThreadLocal;

View File

@@ -23,22 +23,20 @@
package org.dromara.visor.common.utils;
import cn.orionsec.kit.lang.utils.Exceptions;
import org.dromara.visor.common.crypto.ValueCrypto;
import org.dromara.visor.common.interfaces.AesEncryptor;
/**
* 加密工具类
* <p>
* PrimaryValueCrypto 代理类工具
* aes 数据加密工具类
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023/7/8 0:05
*/
public class CryptoUtils {
public class AesEncryptUtils {
private static ValueCrypto delegate;
private static AesEncryptor delegate;
private CryptoUtils() {
private AesEncryptUtils() {
}
/**
@@ -163,12 +161,12 @@ public class CryptoUtils {
return delegate.decryptBase62(text);
}
public static void setDelegate(ValueCrypto delegate) {
if (CryptoUtils.delegate != null) {
public static void setDelegate(AesEncryptor delegate) {
if (AesEncryptUtils.delegate != null) {
// unmodified
throw Exceptions.state();
}
CryptoUtils.delegate = delegate;
AesEncryptUtils.delegate = delegate;
}
}

View File

@@ -24,7 +24,7 @@ package org.dromara.visor.common.utils;
import cn.orionsec.kit.lang.utils.Exceptions;
import lombok.extern.slf4j.Slf4j;
import org.dromara.visor.common.lock.Locker;
import org.dromara.visor.common.interfaces.Locker;
import java.util.function.Supplier;

View File

@@ -0,0 +1,48 @@
package org.dromara.visor.common.utils;
import cn.orionsec.kit.lang.utils.Exceptions;
import org.dromara.visor.common.interfaces.RsaEncryptor;
/**
* rsa 加密工具类
*
* @author Jiahang Li
* @version 1.0.0
* @since 2025/1/5 21:13
*/
public class RsaEncryptorUtils {
private static RsaEncryptor delegate;
private RsaEncryptorUtils() {
}
/**
* 加密
*
* @param value value
* @return value
*/
public static String encrypt(String value) {
return delegate.encrypt(value);
}
/**
* 解密
*
* @param value value
* @return value
*/
public static String decrypt(String value) {
return delegate.decrypt(value);
}
public static void setDelegate(RsaEncryptor delegate) {
if (RsaEncryptorUtils.delegate != null) {
// unmodified
throw Exceptions.state();
}
RsaEncryptorUtils.delegate = delegate;
}
}

View File

@@ -22,7 +22,7 @@
*/
package org.dromara.visor.common.utils;
import org.dromara.visor.common.meta.TraceIdHolder;
import org.dromara.visor.common.trace.TraceIdHolder;
import org.slf4j.MDC;
import java.util.Map;

View File

@@ -20,7 +20,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.visor.common.web.filter;
package org.dromara.visor.common.web;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
@@ -33,9 +33,9 @@ import javax.servlet.Filter;
* @version 1.0.0
* @since 2023/6/25 15:05
*/
public class FilterCreator {
public class WebFilterCreator {
private FilterCreator() {
private WebFilterCreator() {
}
/**

View File

@@ -25,8 +25,8 @@ package org.dromara.visor.framework.biz.operator.log.configuration;
import com.alibaba.fastjson.serializer.SerializeFilter;
import com.alibaba.fastjson.serializer.ValueFilter;
import org.dromara.visor.common.constant.AutoConfigureOrderConst;
import org.dromara.visor.common.json.filter.FieldDesensitizeFilter;
import org.dromara.visor.common.json.filter.FieldIgnoreFilter;
import org.dromara.visor.common.json.FieldDesensitizeFilter;
import org.dromara.visor.common.json.FieldIgnoreFilter;
import org.dromara.visor.framework.biz.operator.log.configuration.config.OperatorLogConfig;
import org.dromara.visor.framework.biz.operator.log.core.aspect.OperatorLogAspect;
import org.dromara.visor.framework.biz.operator.log.core.service.OperatorLogFrameworkService;

View File

@@ -31,7 +31,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializeFilter;
import org.dromara.visor.common.entity.RequestIdentity;
import org.dromara.visor.common.enums.BooleanBit;
import org.dromara.visor.common.meta.TraceIdHolder;
import org.dromara.visor.common.trace.TraceIdHolder;
import org.dromara.visor.common.security.LoginUser;
import org.dromara.visor.common.utils.Requests;
import org.dromara.visor.framework.biz.operator.log.configuration.config.OperatorLogConfig;

View File

@@ -29,9 +29,9 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.SerializeFilter;
import com.alibaba.fastjson.serializer.ValueFilter;
import org.aopalliance.intercept.MethodInvocation;
import org.dromara.visor.common.json.filter.FieldDesensitizeFilter;
import org.dromara.visor.common.json.filter.FieldIgnoreFilter;
import org.dromara.visor.common.meta.TraceIdHolder;
import org.dromara.visor.common.json.FieldDesensitizeFilter;
import org.dromara.visor.common.json.FieldIgnoreFilter;
import org.dromara.visor.common.trace.TraceIdHolder;
import org.dromara.visor.common.security.SecurityHolder;
import org.dromara.visor.framework.log.configuration.config.LogPrinterConfig;
import org.dromara.visor.framework.log.core.annotation.IgnoreLog;

View File

@@ -23,7 +23,7 @@
package org.dromara.visor.framework.redis.configuration;
import org.dromara.visor.common.constant.AutoConfigureOrderConst;
import org.dromara.visor.common.lock.Locker;
import org.dromara.visor.common.interfaces.Locker;
import org.dromara.visor.common.utils.LockerUtils;
import org.dromara.visor.framework.redis.configuration.config.RedissonConfig;
import org.dromara.visor.framework.redis.core.lock.RedisLocker;

View File

@@ -24,7 +24,7 @@ package org.dromara.visor.framework.redis.core.lock;
import cn.orionsec.kit.lang.utils.Exceptions;
import lombok.extern.slf4j.Slf4j;
import org.dromara.visor.common.lock.Locker;
import org.dromara.visor.common.interfaces.Locker;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;

View File

@@ -23,10 +23,10 @@
package org.dromara.visor.framework.security.configuration;
import org.dromara.visor.common.constant.AutoConfigureOrderConst;
import org.dromara.visor.common.crypto.ValueCrypto;
import org.dromara.visor.common.utils.CryptoUtils;
import org.dromara.visor.common.interfaces.AesEncryptor;
import org.dromara.visor.common.utils.AesEncryptUtils;
import org.dromara.visor.framework.security.configuration.config.AesCryptoConfig;
import org.dromara.visor.framework.security.core.crypto.PrimaryValueCrypto;
import org.dromara.visor.framework.security.core.crypto.PrimaryAesEncryptor;
import org.dromara.visor.framework.security.core.crypto.processor.AesCryptoProcessor;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
@@ -52,11 +52,11 @@ public class OrionCryptoAutoConfiguration {
*/
@Bean(name = "valueCrypto")
@Primary
public ValueCrypto primaryValueCrypto() {
public AesEncryptor primaryValueCrypto() {
// 创建加密器
PrimaryValueCrypto valueCrypto = new PrimaryValueCrypto();
PrimaryAesEncryptor valueCrypto = new PrimaryAesEncryptor();
// 设置工具类
CryptoUtils.setDelegate(valueCrypto);
AesEncryptUtils.setDelegate(valueCrypto);
return valueCrypto;
}
@@ -65,7 +65,7 @@ public class OrionCryptoAutoConfiguration {
*/
@Bean(initMethod = "init")
@ConditionalOnProperty(value = "orion.crypto.aes.enabled", havingValue = "true")
public ValueCrypto aesValueCrypto(AesCryptoConfig config) {
public AesEncryptor aesValueCrypto(AesCryptoConfig config) {
return new AesCryptoProcessor(config);
}

View File

@@ -22,7 +22,7 @@
*/
package org.dromara.visor.framework.security.core.crypto;
import org.dromara.visor.common.crypto.ValueCrypto;
import org.dromara.visor.common.interfaces.AesEncryptor;
/**
* 数据加密器
@@ -31,7 +31,7 @@ import org.dromara.visor.common.crypto.ValueCrypto;
* @version 1.0.0
* @since 2023/7/7 22:48
*/
public abstract class CryptoProcessor<Config extends CryptoConfig> implements ValueCrypto {
public abstract class CryptoProcessor<Config extends CryptoConfig> implements AesEncryptor {
protected final Config config;
@@ -39,7 +39,7 @@ public abstract class CryptoProcessor<Config extends CryptoConfig> implements Va
this.config = config;
// 设置为默认加密器
if (config.isPrimary()) {
PrimaryValueCrypto.setDelegate(this);
PrimaryAesEncryptor.setDelegate(this);
}
}

View File

@@ -23,7 +23,7 @@
package org.dromara.visor.framework.security.core.crypto;
import cn.orionsec.kit.lang.utils.Exceptions;
import org.dromara.visor.common.crypto.ValueCrypto;
import org.dromara.visor.common.interfaces.AesEncryptor;
/**
* 默认加密器
@@ -32,9 +32,9 @@ import org.dromara.visor.common.crypto.ValueCrypto;
* @version 1.0.0
* @since 2023/7/21 12:11
*/
public class PrimaryValueCrypto implements ValueCrypto {
public class PrimaryAesEncryptor implements AesEncryptor {
private static ValueCrypto delegate;
private static AesEncryptor delegate;
@Override
public void init() {
@@ -50,12 +50,12 @@ public class PrimaryValueCrypto implements ValueCrypto {
return delegate.decrypt(text);
}
protected static void setDelegate(ValueCrypto delegate) {
if (PrimaryValueCrypto.delegate != null) {
protected static void setDelegate(AesEncryptor delegate) {
if (PrimaryAesEncryptor.delegate != null) {
// unmodified
throw Exceptions.state();
}
PrimaryValueCrypto.delegate = delegate;
PrimaryAesEncryptor.delegate = delegate;
}
}

View File

@@ -23,7 +23,7 @@
package org.dromara.visor.framework.storage.configuration;
import org.dromara.visor.common.constant.AutoConfigureOrderConst;
import org.dromara.visor.common.file.FileClient;
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;

View File

@@ -26,7 +26,7 @@ import cn.orionsec.kit.lang.utils.io.Files1;
import cn.orionsec.kit.lang.utils.io.Streams;
import cn.orionsec.kit.lang.utils.time.Dates;
import org.dromara.visor.common.constant.Const;
import org.dromara.visor.common.file.FileClient;
import org.dromara.visor.common.interfaces.FileClient;
import java.io.InputStream;
import java.io.OutputStream;

View File

@@ -23,7 +23,7 @@
package org.dromara.visor.framework.storage.core.client;
import cn.orionsec.kit.lang.utils.Exceptions;
import org.dromara.visor.common.file.FileClient;
import org.dromara.visor.common.interfaces.FileClient;
import java.io.InputStream;
import java.io.OutputStream;

View File

@@ -23,7 +23,7 @@
package org.dromara.visor.framework.storage.core.utils;
import cn.orionsec.kit.lang.utils.Exceptions;
import org.dromara.visor.common.file.FileClient;
import org.dromara.visor.common.interfaces.FileClient;
import java.io.InputStream;
import java.io.OutputStream;

View File

@@ -23,7 +23,7 @@
package org.dromara.visor.framework.test.configuration;
import com.github.fppt.jedismock.RedisServer;
import org.dromara.visor.common.lock.Locker;
import org.dromara.visor.common.interfaces.Locker;
import org.dromara.visor.common.utils.LockerUtils;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

View File

@@ -27,7 +27,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.dromara.visor.common.constant.AutoConfigureOrderConst;
import org.dromara.visor.common.constant.FilterOrderConst;
import org.dromara.visor.common.web.filter.FilterCreator;
import org.dromara.visor.common.web.WebFilterCreator;
import org.dromara.visor.framework.web.core.aspect.DemoDisableApiAspect;
import org.dromara.visor.framework.web.core.filter.TraceIdFilter;
import org.dromara.visor.framework.web.core.handler.GlobalExceptionHandler;
@@ -151,7 +151,7 @@ public class OrionWebAutoConfiguration implements WebMvcConfigurer {
// 创建 UrlBasedCorsConfigurationSource 对象
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config);
return FilterCreator.create(new CorsFilter(source), FilterOrderConst.CORS_FILTER);
return WebFilterCreator.create(new CorsFilter(source), FilterOrderConst.CORS_FILTER);
}
/**
@@ -159,7 +159,7 @@ public class OrionWebAutoConfiguration implements WebMvcConfigurer {
*/
@Bean
public FilterRegistrationBean<TraceIdFilter> traceIdFilterBean() {
return FilterCreator.create(new TraceIdFilter(), FilterOrderConst.TRICE_ID_FILTER);
return WebFilterCreator.create(new TraceIdFilter(), FilterOrderConst.TRICE_ID_FILTER);
}
/**

View File

@@ -22,7 +22,7 @@
*/
package org.dromara.visor.framework.web.core.filter;
import org.dromara.visor.common.meta.TraceIdHolder;
import org.dromara.visor.common.trace.TraceIdHolder;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;

View File

@@ -40,7 +40,7 @@ import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.dromara.visor.common.constant.ErrorMessage;
import org.dromara.visor.common.file.FileClient;
import org.dromara.visor.common.interfaces.FileClient;
import org.dromara.visor.common.utils.PathUtils;
import org.dromara.visor.module.asset.dao.ExecHostLogDAO;
import org.dromara.visor.module.asset.entity.domain.ExecHostLogDO;

View File

@@ -25,7 +25,7 @@ package org.dromara.visor.module.asset.handler.host.exec.log;
import cn.orionsec.kit.lang.annotation.Keep;
import lombok.extern.slf4j.Slf4j;
import org.dromara.visor.common.constant.ExtraFieldConst;
import org.dromara.visor.common.file.FileClient;
import org.dromara.visor.common.interfaces.FileClient;
import org.dromara.visor.framework.websocket.core.utils.WebSockets;
import org.dromara.visor.module.asset.define.AssetThreadPools;
import org.dromara.visor.module.asset.entity.dto.ExecHostLogTailDTO;

View File

@@ -32,7 +32,7 @@ import cn.orionsec.kit.net.host.SessionStore;
import lombok.extern.slf4j.Slf4j;
import org.dromara.visor.common.constant.AppConst;
import org.dromara.visor.common.constant.Const;
import org.dromara.visor.common.utils.CryptoUtils;
import org.dromara.visor.common.utils.AesEncryptUtils;
import org.dromara.visor.module.asset.entity.dto.TerminalConnectDTO;
import java.util.Optional;
@@ -94,13 +94,13 @@ public class SessionStores {
if (useKey) {
// 加载密钥
String publicKey = Optional.ofNullable(conn.getPublicKey())
.map(CryptoUtils::decryptAsString)
.map(AesEncryptUtils::decryptAsString)
.orElse(null);
String privateKey = Optional.ofNullable(conn.getPrivateKey())
.map(CryptoUtils::decryptAsString)
.map(AesEncryptUtils::decryptAsString)
.orElse(null);
String password = Optional.ofNullable(conn.getPrivateKeyPassword())
.map(CryptoUtils::decryptAsString)
.map(AesEncryptUtils::decryptAsString)
.orElse(null);
sessionHolder.addIdentityValue(String.valueOf(conn.getKeyId()),
privateKey,
@@ -113,7 +113,7 @@ public class SessionStores {
if (!useKey) {
String password = conn.getPassword();
if (!Strings.isEmpty(password)) {
session.password(CryptoUtils.decryptAsString(password));
session.password(AesEncryptUtils.decryptAsString(password));
}
}
// 超时时间

View File

@@ -35,7 +35,7 @@ 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.common.enums.EndpointDefine;
import org.dromara.visor.common.file.FileClient;
import org.dromara.visor.common.interfaces.FileClient;
import org.dromara.visor.common.utils.PathUtils;
import org.dromara.visor.module.asset.dao.UploadTaskFileDAO;
import org.dromara.visor.module.asset.define.config.AppSftpConfig;

View File

@@ -25,7 +25,7 @@ package org.dromara.visor.module.asset.interceptor;
import cn.orionsec.kit.lang.utils.Urls;
import lombok.extern.slf4j.Slf4j;
import org.dromara.visor.common.constant.ExtraFieldConst;
import org.dromara.visor.common.meta.TraceIdHolder;
import org.dromara.visor.common.trace.TraceIdHolder;
import org.dromara.visor.common.utils.Requests;
import org.dromara.visor.module.asset.entity.dto.TerminalAccessDTO;
import org.dromara.visor.module.asset.service.TerminalService;

View File

@@ -25,7 +25,7 @@ package org.dromara.visor.module.asset.interceptor;
import cn.orionsec.kit.lang.utils.Urls;
import lombok.extern.slf4j.Slf4j;
import org.dromara.visor.common.constant.ExtraFieldConst;
import org.dromara.visor.common.meta.TraceIdHolder;
import org.dromara.visor.common.trace.TraceIdHolder;
import org.dromara.visor.common.utils.Requests;
import org.dromara.visor.module.asset.entity.dto.TerminalTransferDTO;
import org.dromara.visor.module.asset.service.TerminalService;

View File

@@ -39,7 +39,7 @@ import org.dromara.visor.common.constant.Const;
import org.dromara.visor.common.constant.ErrorMessage;
import org.dromara.visor.common.constant.FileConst;
import org.dromara.visor.common.enums.EndpointDefine;
import org.dromara.visor.common.file.FileClient;
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;

View File

@@ -41,7 +41,7 @@ import org.dromara.visor.common.constant.Const;
import org.dromara.visor.common.constant.ErrorMessage;
import org.dromara.visor.common.constant.FileConst;
import org.dromara.visor.common.enums.EndpointDefine;
import org.dromara.visor.common.file.FileClient;
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.redis.core.utils.RedisStrings;

View File

@@ -34,7 +34,7 @@ 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.CryptoUtils;
import org.dromara.visor.common.utils.AesEncryptUtils;
import org.dromara.visor.common.utils.Valid;
import org.dromara.visor.framework.redis.core.utils.RedisMaps;
import org.dromara.visor.framework.redis.core.utils.RedisUtils;
@@ -104,7 +104,7 @@ public class HostIdentityServiceImpl implements HostIdentityService {
// 加密密码
String password = record.getPassword();
if (!Strings.isBlank(password)) {
record.setPassword(CryptoUtils.encryptAsString(password));
record.setPassword(AesEncryptUtils.encryptAsString(password));
}
// 插入
int effect = hostIdentityDAO.insert(record);

View File

@@ -32,7 +32,7 @@ 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.CryptoUtils;
import org.dromara.visor.common.utils.AesEncryptUtils;
import org.dromara.visor.common.utils.Valid;
import org.dromara.visor.framework.redis.core.utils.RedisMaps;
import org.dromara.visor.framework.redis.core.utils.RedisUtils;
@@ -97,7 +97,7 @@ public class HostKeyServiceImpl implements HostKeyService {
this.encryptKey(record);
String password = record.getPassword();
if (!Strings.isBlank(password)) {
record.setPassword(CryptoUtils.encryptAsString(password));
record.setPassword(AesEncryptUtils.encryptAsString(password));
}
// 插入
int effect = hostKeyDAO.insert(record);
@@ -154,7 +154,7 @@ public class HostKeyServiceImpl implements HostKeyService {
// 解密密码
String password = record.getPassword();
if (!Strings.isBlank(password)) {
record.setPassword(CryptoUtils.decryptAsString(password));
record.setPassword(AesEncryptUtils.decryptAsString(password));
}
return record;
}
@@ -278,11 +278,11 @@ public class HostKeyServiceImpl implements HostKeyService {
private void encryptKey(HostKeyDO record) {
String publicKey = record.getPublicKey();
if (!Strings.isBlank(publicKey)) {
record.setPublicKey(CryptoUtils.encryptAsString(publicKey));
record.setPublicKey(AesEncryptUtils.encryptAsString(publicKey));
}
String privateKey = record.getPrivateKey();
if (!Strings.isBlank(privateKey)) {
record.setPrivateKey(CryptoUtils.encryptAsString(privateKey));
record.setPrivateKey(AesEncryptUtils.encryptAsString(privateKey));
}
}
@@ -294,11 +294,11 @@ public class HostKeyServiceImpl implements HostKeyService {
private void decryptKey(HostKeyDO record) {
String publicKey = record.getPublicKey();
if (!Strings.isBlank(publicKey)) {
record.setPublicKey(CryptoUtils.decryptAsString(publicKey));
record.setPublicKey(AesEncryptUtils.decryptAsString(publicKey));
}
String privateKey = record.getPrivateKey();
if (!Strings.isBlank(privateKey)) {
record.setPrivateKey(CryptoUtils.decryptAsString(privateKey));
record.setPrivateKey(AesEncryptUtils.decryptAsString(privateKey));
}
}

View File

@@ -39,7 +39,7 @@ 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;
import org.dromara.visor.common.file.FileClient;
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;

View File

@@ -27,7 +27,7 @@ import cn.orionsec.kit.lang.utils.io.Streams;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.dromara.visor.common.constant.ExtraFieldConst;
import org.dromara.visor.common.file.FileClient;
import org.dromara.visor.common.interfaces.FileClient;
import org.dromara.visor.framework.websocket.core.utils.WebSockets;
import org.dromara.visor.module.infra.entity.dto.FileUploadTokenDTO;
import org.dromara.visor.module.infra.handler.upload.enums.FileUploadOperatorType;

View File

@@ -25,7 +25,7 @@ package org.dromara.visor.module.infra.handler.upload.handler;
import cn.orionsec.kit.lang.utils.io.Streams;
import com.alibaba.fastjson.JSON;
import org.dromara.visor.common.constant.Const;
import org.dromara.visor.common.file.FileClient;
import org.dromara.visor.common.interfaces.FileClient;
import org.dromara.visor.framework.websocket.core.utils.WebSockets;
import org.dromara.visor.module.infra.handler.upload.enums.FileUploadReceiverType;
import org.dromara.visor.module.infra.handler.upload.model.FileUploadResponse;

View File

@@ -36,7 +36,7 @@ import org.dromara.visor.common.constant.ErrorMessage;
import org.dromara.visor.common.constant.ExtraFieldConst;
import org.dromara.visor.common.security.LoginUser;
import org.dromara.visor.common.security.UserRole;
import org.dromara.visor.common.utils.CryptoUtils;
import org.dromara.visor.common.utils.AesEncryptUtils;
import org.dromara.visor.common.utils.IpUtils;
import org.dromara.visor.common.utils.Valid;
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
@@ -329,7 +329,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
return null;
}
try {
String value = CryptoUtils.decryptBase62(loginToken);
String value = AesEncryptUtils.decryptBase62(loginToken);
String[] pair = value.split(":");
return Pair.of(Long.valueOf(pair[0]), Long.valueOf(pair[1]));
} catch (Exception e) {
@@ -426,7 +426,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
RedisStrings.setJson(refreshKey, UserCacheKeyDefine.LOGIN_REFRESH, loginValue);
}
// 返回token
return CryptoUtils.encryptBase62(id + ":" + loginTime);
return AesEncryptUtils.encryptBase62(id + ":" + loginTime);
}
}