配置文件加密、token解析401

This commit is contained in:
haozq 2024-04-23 16:06:31 +08:00
parent 1653c295fe
commit 19c08e6e90
38 changed files with 222 additions and 88 deletions

View File

@ -75,7 +75,6 @@
<artifactId>fastdfs-client</artifactId> <artifactId>fastdfs-client</artifactId>
<version>${tobato.version}</version> <version>${tobato.version}</version>
</dependency> </dependency>
<!-- Mybatis 依赖配置 --> <!-- Mybatis 依赖配置 -->
<dependency> <dependency>
<groupId>org.mybatis.spring.boot</groupId> <groupId>org.mybatis.spring.boot</groupId>

View File

@ -12,6 +12,7 @@
<artifactId>securitycontrol-auth</artifactId> <artifactId>securitycontrol-auth</artifactId>
<dependencies> <dependencies>
<!-- SpringCloud Alibaba Nacos --> <!-- SpringCloud Alibaba Nacos -->
<dependency> <dependency>
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
@ -25,6 +26,11 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-loadbalancer</artifactId> <artifactId>spring-cloud-loadbalancer</artifactId>

View File

@ -1,5 +1,6 @@
package com.securitycontrol.auth; package com.securitycontrol.auth;
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@ -12,6 +13,7 @@ import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
* @author czc * @author czc
*/ */
@EnableRyFeignClients @EnableRyFeignClients
@EnableEncryptableProperties
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class,MongoAutoConfiguration.class }) @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class,MongoAutoConfiguration.class })
public class VscAuthApplication public class VscAuthApplication
{ {

View File

@ -23,9 +23,9 @@ public class SysPasswordService
@Resource @Resource
private RedisService redisService; private RedisService redisService;
public int ERROR_TIMES=5; public final static int ERROR_TIMES=5;
public int LOCK_TIMES=5*60; public final static int LOCK_TIMES=300;
private int maxRetryCount = CacheConstants.PASSWORD_MAX_RETRY_COUNT; private int maxRetryCount = CacheConstants.PASSWORD_MAX_RETRY_COUNT;
@ -62,7 +62,6 @@ public class SysPasswordService
throw new ServiceException("用户不存在/密码错误",201); throw new ServiceException("用户不存在/密码错误",201);
} else { } else {
// redisService.deleteObject(username);
clearLoginRecordCache(username); clearLoginRecordCache(username);
} }
} }

View File

@ -16,13 +16,13 @@ spring:
nacos: nacos:
discovery: discovery:
username: nacos username: nacos
password: Jjsp@nacos2023 password: ENC(F5JW7y8V4MGKsimz8gTPeKInjs3A8ool76KS4TVMFHhN94dB76BaWvMbM+6PZKwD)
namespace: jjzhgd namespace: jjzhgd
# 服务注册地址 # 服务注册地址
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
config: config:
username: nacos username: nacos
password: Jjsp@nacos2023 password: ENC(F5JW7y8V4MGKsimz8gTPeKInjs3A8ool76KS4TVMFHhN94dB76BaWvMbM+6PZKwD)
namespace: jjzhgd namespace: jjzhgd
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
# 配置文件格式 # 配置文件格式
@ -30,3 +30,7 @@ spring:
# 共享配置 # 共享配置
shared-configs: shared-configs:
- vsc-dev.yml - vsc-dev.yml
#加密组件
jasypt:
encryptor:
password: Encrypt

View File

@ -80,7 +80,6 @@ public class ExcelStyleUtil implements IExcelExportStyler {
*/ */
@Override @Override
public CellStyle getStyles(boolean parity, ExcelExportEntity entity) { public CellStyle getStyles(boolean parity, ExcelExportEntity entity) {
return styles; return styles;
} }

View File

@ -38,7 +38,11 @@ public class JwtUtils
*/ */
public static Claims parseToken(String token) public static Claims parseToken(String token)
{ {
return Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody(); try{
return Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
}catch (Exception e){
return null;
}
} }
/** /**

View File

@ -37,7 +37,7 @@ public class WordUtils {
private static Configuration configuration = null; private static Configuration configuration = null;
static { static {
configuration = new Configuration(); configuration = new Configuration(Configuration.VERSION_2_3_30);
configuration.setDefaultEncoding("utf-8"); configuration.setDefaultEncoding("utf-8");
configuration.setClassForTemplateLoading(WordUtils.class, "/download/"); configuration.setClassForTemplateLoading(WordUtils.class, "/download/");

View File

@ -159,13 +159,14 @@ public class OperLogAspect {
sysLog.setResult(0); sysLog.setResult(0);
} }
if(StringHelper.isEmpty(msg)){ if(StringHelper.isEmpty(msg)){
sysLog.setFailureReason("查询成功"); sysLog.setFailureReason("操作成功");
}else{ }else{
sysLog.setFailureReason(msg); sysLog.setFailureReason(msg);
} }
} }
}else { }else {
sysLog.setFailureReason("查询成功"); sysLog.setResult(1);
sysLog.setFailureReason("操作成功");
} }
} }
asyncLogService.addSaveSysLog(sysLog); asyncLogService.addSaveSysLog(sysLog);

View File

@ -93,6 +93,8 @@ public class RedisService
} }
/** /**
* 获取有效时间 * 获取有效时间
* *
@ -101,14 +103,18 @@ public class RedisService
*/ */
public long getExpireTimes(final String key) { public long getExpireTimes(final String key) {
try{ try{
long maxTime=240;
long maxTime2=180;
long maxTime3=120;
long maxTime4=60;
long time= redisTemplate.getExpire(key); long time= redisTemplate.getExpire(key);
if(time>240){ if(time>maxTime){
return 5; return 5;
}else if(time>180){ }else if(time>maxTime2){
return 4; return 4;
}else if(time>120){ }else if(time>maxTime3){
return 3; return 3;
}else if(time>60){ }else if(time>maxTime4){
return 2; return 2;
}else{ }else{
return 1; return 1;

View File

@ -48,6 +48,8 @@ public class ParamSecureHandler implements AsyncHandlerInterceptor {
private String rnd = null; private String rnd = null;
public static String ur="/"; public static String ur="/";
public static int max_length=4;
/** /**
* 越权 放权的请求 指定的前缀 -公共的请求+数据接口 * 越权 放权的请求 指定的前缀 -公共的请求+数据接口
*/ */
@ -192,7 +194,7 @@ public class ParamSecureHandler implements AsyncHandlerInterceptor {
return true; return true;
} }
String[] urls=requestUri.split(ur); String[] urls=requestUri.split(ur);
if(urls.length>4){ if(urls.length>max_length){
requestUri=ur+urls[1]+ur+urls[2]+ur+urls[3]; requestUri=ur+urls[1]+ur+urls[2]+ur+urls[3];
}else { }else {
String selected=ur+urls[1]+ur+urls[2]+ur; String selected=ur+urls[1]+ur+urls[2]+ur;

View File

@ -22,7 +22,11 @@
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId> <artifactId>spring-cloud-starter-gateway</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>
<!-- SpringCloud Alibaba Nacos --> <!-- SpringCloud Alibaba Nacos -->
<dependency> <dependency>
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>

View File

@ -1,5 +1,6 @@
package com.securitycontrol.gateway; package com.securitycontrol.gateway;
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@ -8,7 +9,9 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
* springboot 网关服务 * springboot 网关服务
* @author HeiZi * @author HeiZi
*/ */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class }) @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
@EnableEncryptableProperties
public class GatewayApplication { public class GatewayApplication {
public static void main(String[] args) public static void main(String[] args)

View File

@ -36,6 +36,8 @@ public class AuthFilter implements GlobalFilter, Ordered
{ {
private static final Logger log = LoggerFactory.getLogger(AuthFilter.class); private static final Logger log = LoggerFactory.getLogger(AuthFilter.class);
public static final String NULL_TOKEN="null";
/** /**
* *
*/ */
@ -56,7 +58,7 @@ public class AuthFilter implements GlobalFilter, Ordered
return chain.filter(exchange); return chain.filter(exchange);
} }
String token = getToken(request); String token = getToken(request);
if (StringUtils.isEmpty(token)) if (StringUtils.isEmpty(token) || NULL_TOKEN.equals(token))
{ {
return unauthorizedResponse(exchange, "令牌不能为空"); return unauthorizedResponse(exchange, "令牌不能为空");
} }

View File

@ -40,6 +40,8 @@ import java.util.Map;
@Slf4j @Slf4j
public class RequestCoverFilter implements GlobalFilter, Ordered { public class RequestCoverFilter implements GlobalFilter, Ordered {
public final static String APPLICATION_JSON_UTF8="application/json;charset=UTF-8";
/** /**
* default HttpMessageReader * default HttpMessageReader
*/ */
@ -222,7 +224,7 @@ public class RequestCoverFilter implements GlobalFilter, Ordered {
MediaType contentType = headers.getContentType(); MediaType contentType = headers.getContentType();
long contentLength = headers.getContentLength(); long contentLength = headers.getContentLength();
if (contentLength > 0) { if (contentLength > 0) {
if (MediaType.APPLICATION_JSON.equals(contentType) || MediaType.APPLICATION_JSON_UTF8.equals(contentType)) { if (MediaType.APPLICATION_JSON.equals(contentType) || APPLICATION_JSON_UTF8.equals(contentType)) {
return readBody(exchange, chain, gatewayContext); return readBody(exchange, chain, gatewayContext);
} }
if (MediaType.APPLICATION_FORM_URLENCODED.equals(contentType)) { if (MediaType.APPLICATION_FORM_URLENCODED.equals(contentType)) {
@ -233,4 +235,8 @@ public class RequestCoverFilter implements GlobalFilter, Ordered {
log.debug("[GatewayContext]ContentType:{},Gateway context is set with {}", contentType, gatewayContext); log.debug("[GatewayContext]ContentType:{},Gateway context is set with {}", contentType, gatewayContext);
return chain.filter(exchange); return chain.filter(exchange);
} }
} public static void main(String[] args) {
System.err.println(APPLICATION_JSON_UTF8);
}
}

View File

@ -82,7 +82,7 @@ class RsaDecryptResponseGatewayFilterFactory extends AbstractGatewayFilterFactor
updateRequestParam(exchange); updateRequestParam(exchange);
}catch (Exception e){ }catch (Exception e){
log.error(e.toString(),e); log.error(e.toString(),e);
return CommonConstant.buildResponse(exchange, HttpStatus.BAD_REQUEST.value(), "求参数异常"); return CommonConstant.buildResponse(exchange, HttpStatus.BAD_REQUEST.value(), "输入正确的请求参数");
} }
} }
//未强制加密 //未强制加密
@ -98,7 +98,7 @@ class RsaDecryptResponseGatewayFilterFactory extends AbstractGatewayFilterFactor
decrypBytes = decryptMsg.getBytes(); decrypBytes = decryptMsg.getBytes();
} catch (Exception e) { } catch (Exception e) {
log.error("数据 解密失败:{}", e); log.error("数据 解密失败:{}", e);
return CommonConstant.buildResponse(exchange, 201, "求参数异常!"); return CommonConstant.buildResponse(exchange, 201, "输入正确的请求参数!");
} }
// 根据解密后的参数重新构建请求 // 根据解密后的参数重新构建请求
DataBufferFactory dataBufferFactory = exchange.getResponse().bufferFactory(); DataBufferFactory dataBufferFactory = exchange.getResponse().bufferFactory();

View File

@ -17,7 +17,7 @@ spring:
nacos: nacos:
discovery: discovery:
username: nacos username: nacos
password: nacos password: ENC(F5JW7y8V4MGKsimz8gTPeKInjs3A8ool76KS4TVMFHhN94dB76BaWvMbM+6PZKwD)
namespace: jjzhgd namespace: jjzhgd
# 服务注册地址 # 服务注册地址
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
@ -32,7 +32,7 @@ spring:
shared-configs: shared-configs:
- vsc-dev.yml - vsc-dev.yml
username: nacos username: nacos
password: nacos password: ENC(F5JW7y8V4MGKsimz8gTPeKInjs3A8ool76KS4TVMFHhN94dB76BaWvMbM+6PZKwD)
namespace: jjzhgd namespace: jjzhgd
# server-addr: 10.138.132.188:18848 # server-addr: 10.138.132.188:18848
management: management:
@ -50,4 +50,7 @@ endpoints:
enable: false enable: false
system: system:
jm: true jm: true
#加密组件
jasypt:
encryptor:
password: Encrypt

View File

@ -33,6 +33,11 @@
<groupId>com.securitycontrol</groupId> <groupId>com.securitycontrol</groupId>
<artifactId>securitycontrol-commons-security</artifactId> <artifactId>securitycontrol-commons-security</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>
<dependency> <dependency>
<groupId>com.securitycontrol</groupId> <groupId>com.securitycontrol</groupId>
<artifactId>securitycontrol-commons-swagger</artifactId> <artifactId>securitycontrol-commons-swagger</artifactId>

View File

@ -4,6 +4,7 @@ package com.securitycontrol.inter;
import com.securitycontrol.common.security.annotation.EnableCustomConfig; import com.securitycontrol.common.security.annotation.EnableCustomConfig;
import com.securitycontrol.common.security.annotation.EnableRyFeignClients; import com.securitycontrol.common.security.annotation.EnableRyFeignClients;
import com.securitycontrol.common.swagger.annotation.EnableCustomSwagger2; import com.securitycontrol.common.swagger.annotation.EnableCustomSwagger2;
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
@ -19,6 +20,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@EnableRyFeignClients @EnableRyFeignClients
@SpringBootApplication(exclude = MongoAutoConfiguration.class ) @SpringBootApplication(exclude = MongoAutoConfiguration.class )
@EnableScheduling @EnableScheduling
@EnableEncryptableProperties
public class VscInterApplication { public class VscInterApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(VscInterApplication.class, args); SpringApplication.run(VscInterApplication.class, args);

View File

@ -19,12 +19,12 @@ spring:
nacos: nacos:
discovery: discovery:
username: nacos username: nacos
password: Jjsp@nacos2023 password: ENC(F5JW7y8V4MGKsimz8gTPeKInjs3A8ool76KS4TVMFHhN94dB76BaWvMbM+6PZKwD)
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
namespace: jjzhgd namespace: jjzhgd
config: config:
username: nacos username: nacos
password: Jjsp@nacos2023 password: ENC(F5JW7y8V4MGKsimz8gTPeKInjs3A8ool76KS4TVMFHhN94dB76BaWvMbM+6PZKwD)
namespace: jjzhgd namespace: jjzhgd
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
# 配置文件格式 # 配置文件格式
@ -35,10 +35,7 @@ spring:
#加密组件 #加密组件
jasypt: jasypt:
encryptor: encryptor:
bean: codeSheepEncryptorBean3 password: Encrypt
property:
prefix: CodeSheep(
suffix: )
logging: logging:
config: classpath:logback.xml config: classpath:logback.xml
log: log:

View File

@ -3,6 +3,7 @@ package com.securitycontrol.background;
import com.securitycontrol.common.security.annotation.EnableCustomConfig; import com.securitycontrol.common.security.annotation.EnableCustomConfig;
import com.securitycontrol.common.security.annotation.EnableRyFeignClients; import com.securitycontrol.common.security.annotation.EnableRyFeignClients;
import com.securitycontrol.common.swagger.annotation.EnableCustomSwagger2; import com.securitycontrol.common.swagger.annotation.EnableCustomSwagger2;
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
@ -18,6 +19,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@EnableRyFeignClients @EnableRyFeignClients
@SpringBootApplication(exclude = MongoAutoConfiguration.class ) @SpringBootApplication(exclude = MongoAutoConfiguration.class )
@EnableScheduling @EnableScheduling
@EnableEncryptableProperties
public class VscBackgroundApplication { public class VscBackgroundApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(VscBackgroundApplication.class, args); SpringApplication.run(VscBackgroundApplication.class, args);

View File

@ -255,19 +255,19 @@ public class TbAreaServiceImpl implements TbAreaService {
if(files==null || files.length<1){ if(files==null || files.length<1){
return Result.fail("三维文件未上传"); return Result.fail("三维文件未上传");
} }
long allSIz=0; long allSize=0;
for (int i = 0; i <files.length ; i++) { for (int i = 0; i <files.length ; i++) {
MultipartFile file=files[i]; MultipartFile file=files[i];
String fileName=file.getOriginalFilename(); String fileName=file.getOriginalFilename();
long size= file.getSize(); long size= file.getSize();
allSIz+=size; allSize+=size;
String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1); String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1);
if(!allowedExtensions.equals(fileExtension)){ if(!allowedExtensions.equals(fileExtension)){
return Result.fail("文件类型不正确,文件格式应该是glb类型"); return Result.fail("文件类型不正确,文件格式应该是glb类型");
} }
} }
if (allSIz>max_size){ if (allSize>max_size){
return Result.fail("文件过大,不允许超过30M"); return Result.fail("文件过大,不允许超过40M");
} }
String result=checkData(dto); String result=checkData(dto);

View File

@ -21,12 +21,12 @@ spring:
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
namespace: jjzhgd namespace: jjzhgd
username: nacos username: nacos
password: Jjsp@nacos2023 password: ENC(F5JW7y8V4MGKsimz8gTPeKInjs3A8ool76KS4TVMFHhN94dB76BaWvMbM+6PZKwD)
config: config:
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
namespace: jjzhgd namespace: jjzhgd
username: nacos username: nacos
password: Jjsp@nacos2023 password: ENC(F5JW7y8V4MGKsimz8gTPeKInjs3A8ool76KS4TVMFHhN94dB76BaWvMbM+6PZKwD)
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置
@ -35,10 +35,8 @@ spring:
#加密组件 #加密组件
jasypt: jasypt:
encryptor: encryptor:
bean: codeSheepEncryptorBean3 password: Encrypt
property:
prefix: CodeSheep(
suffix: )
file: file:
# upload_path: /data/ahsbs/file # upload_path: /data/ahsbs/file
temp_file_path: E:\\tempFile temp_file_path: E:\\tempFile

View File

@ -28,6 +28,11 @@
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-loadbalancer</artifactId> <artifactId>spring-cloud-loadbalancer</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>
<dependency> <dependency>
<groupId>com.securitycontrol</groupId> <groupId>com.securitycontrol</groupId>
<artifactId>securitycontrol-commons-security</artifactId> <artifactId>securitycontrol-commons-security</artifactId>

View File

@ -4,6 +4,7 @@ import com.securitycontrol.common.security.annotation.EnableCustomConfig;
import com.securitycontrol.common.security.annotation.EnableRyFeignClients; import com.securitycontrol.common.security.annotation.EnableRyFeignClients;
import com.securitycontrol.common.swagger.annotation.EnableCustomSwagger2; import com.securitycontrol.common.swagger.annotation.EnableCustomSwagger2;
import com.securitycontrol.files.mongodb.config.MongoConfig; import com.securitycontrol.files.mongodb.config.MongoConfig;
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
@ -20,6 +21,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@EnableRyFeignClients @EnableRyFeignClients
@SpringBootApplication @SpringBootApplication
@EnableScheduling @EnableScheduling
@EnableEncryptableProperties
public class VscFileApplication public class VscFileApplication
{ {
public static void main(String[] args) public static void main(String[] args)

View File

@ -20,36 +20,32 @@ spring:
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
namespace: jjzhgd namespace: jjzhgd
username: nacos username: nacos
password: Jjsp@nacos2023 password: ENC(F5JW7y8V4MGKsimz8gTPeKInjs3A8ool76KS4TVMFHhN94dB76BaWvMbM+6PZKwD)
config: config:
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
namespace: jjzhgd namespace: jjzhgd
username: nacos username: nacos
password: Jjsp@nacos2023 password: ENC(F5JW7y8V4MGKsimz8gTPeKInjs3A8ool76KS4TVMFHhN94dB76BaWvMbM+6PZKwD)
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置
shared-configs: shared-configs:
- vsc-dev.yml - vsc-dev.yml
# data:
# mongodb:
# host: 192.168.0.56
# port: 27017
# database: zhgd
# username: zhgd
# password: Bonus@admin123
data: data:
mongodb: mongodb:
host: 47.115.207.135 host: 192.168.0.56
port: 27017 port: 27017
database: admin database: zhgd
username: admin username: zhgd
password: Bonus@admin123! password: ENC(ci7FU+lq7Z9eEAUJLDFTEO/zXVfGN4g1iPHc5Mh5iIWONtM4wcl0lC1+t3nxiaEl)
# data:
# mongodb:
# host: 47.115.207.135
# port: 27017
# database: admin
# username: admin
# password: Bonus@admin123!
#加密组件 #加密组件
jasypt: jasypt:
encryptor: encryptor:
bean: codeSheepEncryptorBean3 password: Encrypt
property:
prefix: CodeSheep(
suffix: )

View File

@ -90,6 +90,11 @@
<groupId>com.securitycontrol</groupId> <groupId>com.securitycontrol</groupId>
<artifactId>securitycontrol-commons-entity</artifactId> <artifactId>securitycontrol-commons-entity</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>
<dependency> <dependency>
<groupId>com.securitycontrol</groupId> <groupId>com.securitycontrol</groupId>
<artifactId>securitycontrol-system</artifactId> <artifactId>securitycontrol-system</artifactId>

View File

@ -3,11 +3,19 @@ package com.securitycontrol.screen;
import com.securitycontrol.common.security.annotation.EnableCustomConfig; import com.securitycontrol.common.security.annotation.EnableCustomConfig;
import com.securitycontrol.common.security.annotation.EnableRyFeignClients; import com.securitycontrol.common.security.annotation.EnableRyFeignClients;
import com.securitycontrol.common.swagger.annotation.EnableCustomSwagger2; import com.securitycontrol.common.swagger.annotation.EnableCustomSwagger2;
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.jasypt.encryption.StringEncryptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import javax.annotation.Resource;
/** /**
* 系统模块 * 系统模块
* *
@ -18,9 +26,48 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@EnableRyFeignClients @EnableRyFeignClients
@SpringBootApplication(exclude = MongoAutoConfiguration.class ) @SpringBootApplication(exclude = MongoAutoConfiguration.class )
@EnableScheduling @EnableScheduling
public class VscScreenApplication { @EnableEncryptableProperties
public class VscScreenApplication implements CommandLineRunner {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(VscScreenApplication.class, args); SpringApplication.run(VscScreenApplication.class, args);
System.out.println("智慧工地大屏管理模块启动成功!"); System.out.println("智慧工地大屏管理模块启动成功!");
} }
@Resource
private StringEncryptor encryptor;
@Autowired
private ApplicationContext applicationContext;
@Override
public void run(String... args) throws Exception {
Environment environment = applicationContext.getBean(Environment.class);
// 首先获取配置文件里的原始明文信息
// 根据自己配置文件中的密码读取路径自行更改
String oldPassword = environment.getProperty("spring.datasource.dynamic.datasource.master.password");
String nacosPwd = environment.getProperty("spring.cloud.nacos.discovery.password");
// 加密
String encryptPassword = encrypt( oldPassword );
String nacsopwdPass = encrypt( nacosPwd );
String mogodb = encrypt("Bonus@admin123" );
System.out.println( "mogodb原始明文密码加密后的结果为" + mogodb );
// 打印加密前后的结果对比
System.out.println( "MySQL原始明文密码为" + oldPassword );
System.out.println( "Nacos原始明文密码为" + nacosPwd );
System.out.println( "====================================" );
System.out.println( "MySQL原始明文密码加密后的结果为" + encryptPassword );
System.out.println( "Nacos原始明文密码加密后的结果为" + nacsopwdPass );
}
private String encrypt( String originPassord ) {
return encryptor.encrypt( originPassord );
}
private String decrypt( String encryptedPassword ) {
return encryptor.decrypt( encryptedPassword );
}
} }

View File

@ -0,0 +1,32 @@
package com.securitycontrol.screen.config;
import org.jasypt.encryption.StringEncryptor;
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 自定义密码加密
* @author 黑子
*/
//@Configuration
public class CodeSheepEncryptorCfg {
@Bean(name = "codeSheepEncryptorBean" )
public StringEncryptor codesheepStringEncryptor() {
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
config.setPassword("CodeSheep");
config.setAlgorithm("PBEWITHHMACSHA512ANDAES_256");
config.setKeyObtentionIterations("1000");
config.setPoolSize("1");
config.setProviderName("SunJCE");
config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
config.setIvGeneratorClassName("org.jasypt.iv.RandomIvGenerator");
config.setStringOutputType("base64");
encryptor.setConfig(config);
return encryptor;
}
}

View File

@ -107,9 +107,11 @@ public class ConstructionQualityImpl implements ConstructionQualityService {
* @author jjLv * @author jjLv
* @date 2024/3/27 19:54 * @date 2024/3/27 19:54
*/ */
public final static int NUM_MONTHS_IN_YEAR = 12;
@Override @Override
public List<ConstructionQualityVo> getDetectionRecord(ConstructionQualityDto dto) { public List<ConstructionQualityVo> getDetectionRecord(ConstructionQualityDto dto) {
final int NUM_MONTHS_IN_YEAR = 12;
YearMonth currentYearMonth = YearMonth.now(); YearMonth currentYearMonth = YearMonth.now();
YearMonth[] lastTwelveMonths = new YearMonth[12]; YearMonth[] lastTwelveMonths = new YearMonth[12];
for (int i = 0; i < NUM_MONTHS_IN_YEAR; i++) { for (int i = 0; i < NUM_MONTHS_IN_YEAR; i++) {

View File

@ -21,24 +21,23 @@ spring:
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
namespace: jjzhgd namespace: jjzhgd
username: nacos username: nacos
password: Jjsp@nacos2023 password: ENC(F5JW7y8V4MGKsimz8gTPeKInjs3A8ool76KS4TVMFHhN94dB76BaWvMbM+6PZKwD)
config: config:
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
namespace: jjzhgd namespace: jjzhgd
username: nacos username: nacos
password: Jjsp@nacos2023 password: ENC(F5JW7y8V4MGKsimz8gTPeKInjs3A8ool76KS4TVMFHhN94dB76BaWvMbM+6PZKwD)
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置
shared-configs: shared-configs:
- vsc-dev.yml - vsc-dev.yml
#加密组件 #加密组件
jasypt: jasypt:
encryptor: encryptor:
bean: codeSheepEncryptorBean3 password: Encrypt
property:
prefix: CodeSheep(
suffix: )

View File

@ -29,7 +29,8 @@
tcm.bid_code AS bidCode, tcm.bid_code AS bidCode,
tcm.work_manager AS workManager tcm.work_manager AS workManager
FROM t_class_metting tcm FROM t_class_metting tcm
WHERE tcm.work_day = CURRENT_DATE AND tcm.del_flag = 0 WHERE tcm.del_flag = 0
<!-- AND tcm.work_day = CURRENT_DATE -->
</select> </select>
<!--施工质量--> <!--施工质量-->
<select id="constrQuality" resultType="com.securitycontrol.entity.screen.vo.ConstrQuality"> <select id="constrQuality" resultType="com.securitycontrol.entity.screen.vo.ConstrQuality">
@ -130,8 +131,9 @@
WHERE tw.warn_time BETWEEN #{params.startTime} AND #{params.endTime} WHERE tw.warn_time BETWEEN #{params.startTime} AND #{params.endTime}
GROUP BY tw.bid_code GROUP BY tw.bid_code
) a ON jwp.bid_no = a.bid_code ) a ON jwp.bid_no = a.bid_code
WHERE jwp.start_date BETWEEN #{params.startTime} AND #{params.endTime} AND jwp.end_date BETWEEN #{params.startTime} AND #{params.endTime} WHERE jwp.build_no = #{orgId}
AND jwp.build_no = #{orgId} AND jwp.start_date BETWEEN #{params.startTime} AND #{params.endTime} AND jwp.end_date BETWEEN #{params.startTime} AND #{params.endTime}
</select> </select>
<select id="getGtList" resultType="com.securitycontrol.entity.background.vo.GtVo"> <select id="getGtList" resultType="com.securitycontrol.entity.background.vo.GtVo">
select gt_name gtName,lat,lon,tp.pro_name proName select gt_name gtName,lat,lon,tp.pro_name proName

View File

@ -29,6 +29,7 @@
select count(1) num select count(1) num
from tb_warn from tb_warn
where DATE_FORMAT(warn_time, '%Y-%m-%d')=#{startTime} where DATE_FORMAT(warn_time, '%Y-%m-%d')=#{startTime}
AND bid_code=#{bidCode}
</select> </select>
<!--项目进度--> <!--项目进度-->

View File

@ -91,7 +91,11 @@
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId> <artifactId>spring-web</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>
<!-- logstash --> <!-- logstash -->
<dependency> <dependency>
<groupId>net.logstash.logback</groupId> <groupId>net.logstash.logback</groupId>

View File

@ -1,9 +1,8 @@
package com.securitycontrol.system; package com.securitycontrol.system;
import com.securitycontrol.common.security.annotation.EnableCustomConfig; import com.securitycontrol.common.security.annotation.EnableCustomConfig;
import com.securitycontrol.common.security.annotation.EnableRyFeignClients; import com.securitycontrol.common.security.annotation.EnableRyFeignClients;
import com.securitycontrol.common.swagger.annotation.EnableCustomSwagger2; import com.securitycontrol.common.swagger.annotation.EnableCustomSwagger2;
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
@ -19,6 +18,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@EnableRyFeignClients @EnableRyFeignClients
@EnableScheduling @EnableScheduling
@SpringBootApplication(exclude = MongoAutoConfiguration.class ) @SpringBootApplication(exclude = MongoAutoConfiguration.class )
@EnableEncryptableProperties
public class VscSystemApplication { public class VscSystemApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(VscSystemApplication.class, args); SpringApplication.run(VscSystemApplication.class, args);

View File

@ -38,11 +38,6 @@ public class ExportSqlService {
@Value("${sql.filePath}") @Value("${sql.filePath}")
private String filePath; private String filePath;
/**
* 数据库名
*/
@Value("${sql.dbname}")
private String database_name;
@Resource @Resource

View File

@ -170,9 +170,8 @@ public class SysLogServiceImpl implements ISysLogService {
} }
return Result.ok("设置成功","'设置成功'"); return Result.ok("设置成功","'设置成功'");
} }
public final static String SUCCESS="成功";
/** /**
*
* @param dto * @param dto
* @return * @return
*/ */
@ -180,7 +179,7 @@ public class SysLogServiceImpl implements ISysLogService {
public Result<Map<String, Object>> getLogStatistics(SysLog dto) { public Result<Map<String, Object>> getLogStatistics(SysLog dto) {
Map<String,Object> map= Maps.newHashMap(); Map<String,Object> map= Maps.newHashMap();
String SUCCESS="成功";
try{ try{
if (StringHelper.isNotEmpty(dto.getOperTime())) { if (StringHelper.isNotEmpty(dto.getOperTime())) {
dto.setStartTime(dto.getOperTime().split(" - ")[0].trim()); dto.setStartTime(dto.getOperTime().split(" - ")[0].trim());

View File

@ -19,12 +19,12 @@ spring:
nacos: nacos:
discovery: discovery:
username: nacos username: nacos
password: Jjsp@nacos2023 password: ENC(F5JW7y8V4MGKsimz8gTPeKInjs3A8ool76KS4TVMFHhN94dB76BaWvMbM+6PZKwD)
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
namespace: jjzhgd namespace: jjzhgd
config: config:
username: nacos username: nacos
password: Jjsp@nacos2023 password: ENC(F5JW7y8V4MGKsimz8gTPeKInjs3A8ool76KS4TVMFHhN94dB76BaWvMbM+6PZKwD)
namespace: jjzhgd namespace: jjzhgd
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848
# 配置文件格式 # 配置文件格式
@ -35,10 +35,8 @@ spring:
#加密组件 #加密组件
jasypt: jasypt:
encryptor: encryptor:
bean: codeSheepEncryptorBean3 password: Encrypt
property:
prefix: CodeSheep(
suffix: )
logging: logging:
config: classpath:logback.xml config: classpath:logback.xml
log: log:
@ -47,7 +45,10 @@ log:
my: debug my: debug
file: logs/sys-back.log file: logs/sys-back.log
maxsize: 30MB maxsize: 30MB
file:
# upload_path: /data/ahsbs/file
temp_file_path: E:\\tempFile
# 导出sql文件的位置
sql: sql:
dbname: jj_zhgd # 数据库名 dbname: jj_zhgd # 数据库名
filePath: F:\\File\\ #导出sql文件的位置 win下会直接在项目所在磁盘下建立 data/sql文件 filePath: F:\\File\\ #导出sql文件的位置 win下会直接在项目所在磁盘下建立 data/sql文件