Compare commits
2 Commits
zjut/1.1.2
...
1.1.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6caecf140 | ||
|
|
fdcb1614cc |
@@ -1,25 +0,0 @@
|
|||||||
## 工作流触发时机
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- '*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
|
|
||||||
## 任务名称
|
|
||||||
local-deploy:
|
|
||||||
|
|
||||||
## 任务执行的服务器
|
|
||||||
runs-on: tiesheng-local
|
|
||||||
|
|
||||||
## 任务步骤
|
|
||||||
steps:
|
|
||||||
|
|
||||||
## 检出代码(固定配置)
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: https://git.tieshengkeji.com/actions/checkout@v4
|
|
||||||
|
|
||||||
## maven打包
|
|
||||||
- name: Maven deploy
|
|
||||||
run: |
|
|
||||||
mvn deploy
|
|
||||||
31
pom.xml
31
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>springboot-parent</name>
|
<name>springboot-parent</name>
|
||||||
<description>杭州铁晟科技有限公司基础依赖</description>
|
<description>杭州铁晟科技有限公司基础依赖</description>
|
||||||
@@ -57,55 +57,55 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-database</artifactId>
|
<artifactId>springboot-database</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-login</artifactId>
|
<artifactId>springboot-login</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-web</artifactId>
|
<artifactId>springboot-web</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-util</artifactId>
|
<artifactId>springboot-util</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-platform</artifactId>
|
<artifactId>springboot-platform</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-message</artifactId>
|
<artifactId>springboot-message</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-encrypt</artifactId>
|
<artifactId>springboot-encrypt</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-annotation</artifactId>
|
<artifactId>springboot-annotation</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-poi</artifactId>
|
<artifactId>springboot-poi</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -123,17 +123,10 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<distributionManagement>
|
|
||||||
<repository>
|
|
||||||
<id>gitea</id>
|
|
||||||
<url>https://git.tieshengkeji.com/api/packages/tieshengkeji/maven</url>
|
|
||||||
</repository>
|
|
||||||
</distributionManagement>
|
|
||||||
|
|
||||||
<pluginRepositories>
|
<pluginRepositories>
|
||||||
<pluginRepository>
|
<pluginRepository>
|
||||||
<id>tiesheng-repo-plugin</id>
|
<id>kepai-repo-plugin</id>
|
||||||
<url>https://git.tieshengkeji.com/api/packages/tieshengkeji/maven</url>
|
<url>http://git.kepai365.com/tiesheng/repository/raw/master</url>
|
||||||
</pluginRepository>
|
</pluginRepository>
|
||||||
</pluginRepositories>
|
</pluginRepositories>
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-ademo</artifactId>
|
<artifactId>springboot-ademo</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
//package com.tiesheng.demo.config;
|
||||||
|
//
|
||||||
|
//import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
|
//import org.springframework.security.core.GrantedAuthority;
|
||||||
|
//import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
|
//import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
//import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
|
||||||
|
//import org.springframework.web.filter.OncePerRequestFilter;
|
||||||
|
//
|
||||||
|
//import javax.servlet.FilterChain;
|
||||||
|
//import javax.servlet.ServletException;
|
||||||
|
//import javax.servlet.http.HttpServletRequest;
|
||||||
|
//import javax.servlet.http.HttpServletResponse;
|
||||||
|
//import java.io.IOException;
|
||||||
|
//import java.util.ArrayList;
|
||||||
|
//import java.util.List;
|
||||||
|
//
|
||||||
|
//public class JWTAuthenticationFilter extends OncePerRequestFilter {
|
||||||
|
//
|
||||||
|
// public JWTAuthenticationFilter(JwtTokenProvider tokenProvider) {
|
||||||
|
// this.tokenProvider = tokenProvider;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||||
|
// String authHeader = request.getHeader("Authorization");
|
||||||
|
// if (authHeader != null && authHeader.startsWith("Bearer ")) {
|
||||||
|
// String token = authHeader.substring(7);
|
||||||
|
// String username = tokenProvider.getUsername(token);
|
||||||
|
// if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
|
||||||
|
// if (tokenProvider.validateToken(token)) {
|
||||||
|
// List<GrantedAuthority> authorities = new ArrayList<>();
|
||||||
|
// // 根据你的应用程序需求设置权限
|
||||||
|
// authorities.add(new SimpleGrantedAuthority("ROLE_USER"));
|
||||||
|
// UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, null, authorities);
|
||||||
|
// authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
|
||||||
|
// SecurityContextHolder.getContext().setAuthentication(authenticationToken);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// filterChain.doFilter(request, response);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
//package com.tiesheng.demo.config;
|
||||||
|
//
|
||||||
|
//import cn.hutool.extra.spring.SpringUtil;
|
||||||
|
//import org.springframework.context.annotation.Configuration;
|
||||||
|
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
|
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
|
//import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||||
|
//
|
||||||
|
//import javax.servlet.http.HttpServletResponse;
|
||||||
|
//
|
||||||
|
//@Configuration
|
||||||
|
//@EnableWebSecurity
|
||||||
|
//public class TieshengSecurityAdapter extends WebSecurityConfigurerAdapter {
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected void configure(HttpSecurity http) throws Exception {
|
||||||
|
// SpringUtil.getBeanFactory().getA
|
||||||
|
// http.csrf().disable() // JWT 通常与状态无关,因此 CSRF 保护不适用
|
||||||
|
// .authorizeRequests()
|
||||||
|
// .antMatchers("/login").permitAll() // 登录接口允许所有人访问
|
||||||
|
// .anyRequest().authenticated() // 其他所有请求需要认证
|
||||||
|
// .and()
|
||||||
|
// .exceptionHandling()
|
||||||
|
// .authenticationEntryPoint((request, response, authException) -> response.sendError(HttpServletResponse.SC_UNAUTHORIZED))
|
||||||
|
// .and()
|
||||||
|
// .addFilterBefore(new JWTAuthenticationFilter(tokenProvider), UsernamePasswordAuthenticationFilter.class);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@@ -58,7 +58,6 @@ public class TestController {
|
|||||||
|
|
||||||
@RequestMapping("/index")
|
@RequestMapping("/index")
|
||||||
public ApiResp<String> index() {
|
public ApiResp<String> index() {
|
||||||
dbBackupConfig.dbBackup();
|
|
||||||
return ApiResp.respOK("hello world");
|
return ApiResp.respOK("hello world");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +93,7 @@ public class TestController {
|
|||||||
public ApiResp<MessageReqResp> sendMessage() {
|
public ApiResp<MessageReqResp> sendMessage() {
|
||||||
|
|
||||||
MessageReqResp reqResp = coreMessageService.send(new UserChannel("13567116463", "sms"),
|
MessageReqResp reqResp = coreMessageService.send(new UserChannel("13567116463", "sms"),
|
||||||
JSONUtil.createObj().putOpt("code", "123456").putOpt("template_code", "SMS_154950909"));
|
JSONUtil.createObj().putOpt("action", "sms-visitor-invite"));
|
||||||
|
|
||||||
return ApiResp.respOK(reqResp);
|
return ApiResp.respOK(reqResp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.tiesheng.demo.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.tiesheng.message.config.aliyun.AliyunSmsHandler;
|
||||||
|
import com.tiesheng.message.pojos.AliyunTempParam;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class DemoSmsHandler implements AliyunSmsHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AliyunTempParam handler(JSONObject obj) {
|
||||||
|
|
||||||
|
String action = obj.getStr("action");
|
||||||
|
|
||||||
|
AliyunTempParam param = new AliyunTempParam();
|
||||||
|
param.setSignName("智慧校园");
|
||||||
|
|
||||||
|
if (Objects.equals(action, "sms-visitor-invite")) {
|
||||||
|
param.setTemplateCode("SMS_276125463");
|
||||||
|
param.setTemplateParam(JSONUtil.createObj()
|
||||||
|
.putOpt("date", DateUtil.today())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return param;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,4 +25,5 @@ tiesheng:
|
|||||||
aliyun:
|
aliyun:
|
||||||
access-key-id: LTAI5tJtbgBCnTY5eS4SmrTf
|
access-key-id: LTAI5tJtbgBCnTY5eS4SmrTf
|
||||||
access-key-secret: JIHqpRUFffCHhXaJEVvWN31WcexWqG
|
access-key-secret: JIHqpRUFffCHhXaJEVvWN31WcexWqG
|
||||||
sign-name: 阿里云短信测试
|
encrypt:
|
||||||
|
body: true
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ spring:
|
|||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
max-file-size: 20MB
|
max-file-size: 20MB
|
||||||
|
max-request-size: 20MB
|
||||||
web:
|
web:
|
||||||
resources:
|
resources:
|
||||||
static-locations: classpath:/static/,file:static/
|
static-locations: classpath:/static/,file:static/
|
||||||
@@ -24,3 +25,4 @@ tiesheng:
|
|||||||
token:
|
token:
|
||||||
ignore-paths:
|
ignore-paths:
|
||||||
- /test/index
|
- /test/index
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-annotation</artifactId>
|
<artifactId>springboot-annotation</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-database</artifactId>
|
<artifactId>springboot-database</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-encrypt</artifactId>
|
<artifactId>springboot-encrypt</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-login</artifactId>
|
<artifactId>springboot-login</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-message</artifactId>
|
<artifactId>springboot-message</artifactId>
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package com.tiesheng.message.config.aliyun;
|
|||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.lang.Validator;
|
import cn.hutool.core.lang.Validator;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.ReUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.crypto.SecureUtil;
|
||||||
import cn.hutool.extra.validation.ValidationUtil;
|
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
@@ -18,7 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@@ -103,7 +100,16 @@ public class AliyunSmsSender implements TieshengMessageSender {
|
|||||||
String signature = specialUrlEncode(digest);
|
String signature = specialUrlEncode(digest);
|
||||||
queryMap.put("Signature", signature);
|
queryMap.put("Signature", signature);
|
||||||
|
|
||||||
return HttpUtil.get(ENDPOINT + "?Signature=" + signature + sortQueryStringTmp, 10 * 1000);
|
String respBody = "";
|
||||||
|
try {
|
||||||
|
respBody = HttpUtil.get(ENDPOINT + "?Signature=" + signature + sortQueryStringTmp, 10 * 1000);
|
||||||
|
} catch (Exception e) {
|
||||||
|
respBody = JSONUtil.createObj()
|
||||||
|
.putOpt("Code", "Error")
|
||||||
|
.putOpt("Message", "消息通道异常")
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
return respBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-platform</artifactId>
|
<artifactId>springboot-platform</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-poi</artifactId>
|
<artifactId>springboot-poi</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-util</artifactId>
|
<artifactId>springboot-util</artifactId>
|
||||||
|
|||||||
@@ -23,26 +23,17 @@ public class EncryptConfig {
|
|||||||
/**
|
/**
|
||||||
* 加解密对象
|
* 加解密对象
|
||||||
*/
|
*/
|
||||||
private static SM4 sm4;
|
private final SM4 sm4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加密密钥
|
* 加密密钥
|
||||||
*/
|
*/
|
||||||
private String key = "Z1mn6fKe6ubnm5762KR3Cg==";
|
private String key = "WmdUzPJXbngVNiaSsQrihg==";
|
||||||
private Integer saltSize = 8;
|
private Integer saltSize = 8;
|
||||||
private boolean body = false;
|
private boolean body = false;
|
||||||
|
|
||||||
|
public EncryptConfig() {
|
||||||
/**
|
sm4 = SmUtil.sm4(Base64.decode(getKey()));
|
||||||
* 获取SM4对象
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private SM4 getSm4() {
|
|
||||||
if (sm4 == null) {
|
|
||||||
sm4 = SmUtil.sm4(Base64.decode(getKey()));
|
|
||||||
}
|
|
||||||
return sm4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,7 +46,7 @@ public class EncryptConfig {
|
|||||||
if (StrUtil.isEmpty(content)) {
|
if (StrUtil.isEmpty(content)) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return getSm4().encryptBase64(content);
|
return sm4.encryptBase64(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -67,7 +58,7 @@ public class EncryptConfig {
|
|||||||
*/
|
*/
|
||||||
public String decrypt(String base64) {
|
public String decrypt(String base64) {
|
||||||
try {
|
try {
|
||||||
return getSm4().decryptStr(base64);
|
return sm4.decryptStr(base64);
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
}
|
}
|
||||||
return base64;
|
return base64;
|
||||||
@@ -126,8 +117,7 @@ public class EncryptConfig {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// setter\getter
|
// setter\getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
/// ////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return key;
|
return key;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||||
<artifactId>springboot-parent</artifactId>
|
<artifactId>springboot-parent</artifactId>
|
||||||
<version>zjut-1.1.2</version>
|
<version>1.1.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>springboot-web</artifactId>
|
<artifactId>springboot-web</artifactId>
|
||||||
|
|||||||
Reference in New Issue
Block a user