新增河南转发功能

dev
liuguijing 1 year ago
parent 845eaf3b6f
commit 1af0bdb6b8

@ -151,11 +151,11 @@
<!-- <version>3.14.9</version>--> <!-- <version>3.14.9</version>-->
<!-- </dependency>--> <!-- </dependency>-->
<!-- <dependency>--> <dependency>
<!-- <groupId>io.github.admin4j</groupId>--> <groupId>io.github.admin4j</groupId>
<!-- <artifactId>http</artifactId>--> <artifactId>http</artifactId>
<!-- <version>0.4.0</version>--> <version>0.4.0</version>
<!-- </dependency>--> </dependency>
<!-- <dependency>--> <!-- <dependency>-->

@ -1,183 +0,0 @@
## Spring配置
#spring:
# # 数据源配置
# datasource:
# type: com.alibaba.druid.pool.DruidDataSource
# driverClassName: com.mysql.cj.jdbc.Driver
# druid:
# # 主库数据源
# master:
# url: jdbc:mysql://139.196.98.172:3306/fc_medicialkit?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# username: root
# password: Root*123
# # 从库数据源
# slave:
# # 从数据源开关/默认关闭
# enabled: false
# url:
# username:
# password:
# # 初始连接数
# initialSize: 5
# # 最小连接池数量
# minIdle: 10
# # 最大连接池数量
# maxActive: 20
# # 配置获取连接等待超时的时间
# maxWait: 60000
# # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
# timeBetweenEvictionRunsMillis: 60000
# # 配置一个连接在池中最小生存的时间,单位是毫秒
# minEvictableIdleTimeMillis: 300000
# # 配置一个连接在池中最大生存的时间,单位是毫秒
# maxEvictableIdleTimeMillis: 900000
# # 配置检测连接是否有效
# validationQuery: SELECT 1 FROM DUAL
# testWhileIdle: true
# testOnBorrow: false
# testOnReturn: false
# webStatFilter:
# enabled: true
# statViewServlet:
# enabled: true
# # 设置白名单,不填则允许所有访问
# allow:
# url-pattern: /druid/*
# # 控制台管理用户名和密码
# login-username: root
# login-password: 123456
# filter:
# stat:
# enabled: true
# # 慢SQL记录
# log-slow-sql: true
# slow-sql-millis: 1000
# merge-sql: true
# wall:
# config:
# multi-statement-allow: true
## # 资源信息
## messages:
## # 国际化资源文件路径
## basename: i18n/messages
## # 文件上传
## servlet:
## multipart:
## # 单个文件大小
## max-file-size: 20MB
## # 设置总上传的文件大小
## max-request-size: 20MB
## # 服务模块
## devtools:
## restart:
## # 热部署开关
## enabled: true
# # redis 配置
## redis:
## # 地址
## host: localhost
## # 端口默认为6379
## port: 6379
## # 数据库索引
## database: 0
## # 密码
## password:
## # 连接超时时间
## timeout: 10s
## lettuce:
## pool:
## # 连接池中的最小空闲连接
## min-idle: 0
## # 连接池中的最大空闲连接
## max-idle: 8
## # 连接池的最大数据库连接数
## max-active: 8
## # #连接池最大阻塞等待时间(使用负值表示没有限制)
## max-wait: -1ms
#
## 项目相关配置
##shop-backend:
## # 名称
## name: 知青人电商后端管理系统
## # 版本
## version: 1.0.0
## # 版权年份
## copyrightYear: 2021
## # 实例演示开关
## demoEnabled: true
## # 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath
## profile: D:/shop-backend/uploadPath
## # 获取ip地址开关
## addressEnabled: false
## # 验证码类型 math 数组计算 char 字符验证
## captchaType: math
#
## 开发环境配置
#server:
# # 服务器的HTTP端口默认为8080
# port: 8087
# servlet:
# # 应用的访问路径
# context-path: /zqrssb
# tomcat:
# # tomcat的URI编码
# uri-encoding: UTF-8
# # 连接数满后的排队数默认为100
# accept-count: 1000
# max-swallow-size: -1 # tomcat默认大小2M超过2M的文件不会被捕获需要调整此处大小为100MB或者-1即可
# threads:
# # tomcat最大线程数默认为200
# max: 800
# # Tomcat启动初始化的线程数默认值10
# min-spare: 100
#
### 日志配置
##logging:
## config: classpath:log4j2ss.xml
## level:
## com.fc: debug
## org.springframework: warn
#
## token配置
#token:
# # 令牌自定义标识
# header: Authorization
# # 令牌密钥
# secret: abcdefghijklmnopqrstuvwxyz
# # 令牌有效期默认30分钟
# expireTime: 30
#
## MyBatis配置
#mybatis:
# # 搜索指定包别名
# type-aliases-package: com.fc.**.model
# # 配置mapper的扫描找到所有的mapper.xml映射文件
# mapper-locations: classpath*:mappers/**/*Dao.xml
# # 加载全局的配置文件
# configLocation: classpath:mybatis/mybatis-config.xml
#
##mybatis:
## mapper-locations: classpath:mappers/**/*.xml
## type-aliases-package: com.fuchang.entity
#
### PageHelper分页插件
##pagehelper:
## helperDialect: mysql
## supportMethodsArguments: true
## params: count=countSql
##
## Swagger配置
#swagger2:
# # 是否开启swagger
# enabled: true
# # 请求前缀
## pathMapping: /dev-api
##
### 防止XSS攻击
##xss:
## # 过滤开关
## enabled: true
## # 排除链接(多个用逗号分隔)
## excludes: /system/notice
## # 匹配链接
## urlPatterns: /system/*,/monitor/*,/tool/*

@ -1,183 +0,0 @@
## Spring配置
#spring:
# # 数据源配置
# datasource:
# type: com.alibaba.druid.pool.DruidDataSource
# driverClassName: com.mysql.cj.jdbc.Driver
# druid:
# # 主库数据源
# master:
# url: jdbc:mysql://139.196.98.172:3306/fc_medicialkit?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# username: root
# password: Root*123
# # 从库数据源
# slave:
# # 从数据源开关/默认关闭
# enabled: false
# url:
# username:
# password:
# # 初始连接数
# initialSize: 5
# # 最小连接池数量
# minIdle: 10
# # 最大连接池数量
# maxActive: 20
# # 配置获取连接等待超时的时间
# maxWait: 60000
# # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
# timeBetweenEvictionRunsMillis: 60000
# # 配置一个连接在池中最小生存的时间,单位是毫秒
# minEvictableIdleTimeMillis: 300000
# # 配置一个连接在池中最大生存的时间,单位是毫秒
# maxEvictableIdleTimeMillis: 900000
# # 配置检测连接是否有效
# validationQuery: SELECT 1 FROM DUAL
# testWhileIdle: true
# testOnBorrow: false
# testOnReturn: false
# webStatFilter:
# enabled: true
# statViewServlet:
# enabled: true
# # 设置白名单,不填则允许所有访问
# allow:
# url-pattern: /druid/*
# # 控制台管理用户名和密码
# login-username: root
# login-password: 123456
# filter:
# stat:
# enabled: true
# # 慢SQL记录
# log-slow-sql: true
# slow-sql-millis: 1000
# merge-sql: true
# wall:
# config:
# multi-statement-allow: true
## # 资源信息
## messages:
## # 国际化资源文件路径
## basename: i18n/messages
## # 文件上传
## servlet:
## multipart:
## # 单个文件大小
## max-file-size: 20MB
## # 设置总上传的文件大小
## max-request-size: 20MB
## # 服务模块
## devtools:
## restart:
## # 热部署开关
## enabled: true
# # redis 配置
## redis:
## # 地址
## host: localhost
## # 端口默认为6379
## port: 6379
## # 数据库索引
## database: 0
## # 密码
## password:
## # 连接超时时间
## timeout: 10s
## lettuce:
## pool:
## # 连接池中的最小空闲连接
## min-idle: 0
## # 连接池中的最大空闲连接
## max-idle: 8
## # 连接池的最大数据库连接数
## max-active: 8
## # #连接池最大阻塞等待时间(使用负值表示没有限制)
## max-wait: -1ms
#
## 项目相关配置
##shop-backend:
## # 名称
## name: 知青人电商后端管理系统
## # 版本
## version: 1.0.0
## # 版权年份
## copyrightYear: 2021
## # 实例演示开关
## demoEnabled: true
## # 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath
## profile: D:/shop-backend/uploadPath
## # 获取ip地址开关
## addressEnabled: false
## # 验证码类型 math 数组计算 char 字符验证
## captchaType: math
#
## 开发环境配置
#server:
# # 服务器的HTTP端口默认为8080
# port: 8087
# servlet:
# # 应用的访问路径
# context-path: /zqrssb
# tomcat:
# # tomcat的URI编码
# uri-encoding: UTF-8
# # 连接数满后的排队数默认为100
# accept-count: 1000
# max-swallow-size: -1 # tomcat默认大小2M超过2M的文件不会被捕获需要调整此处大小为100MB或者-1即可
# threads:
# # tomcat最大线程数默认为200
# max: 800
# # Tomcat启动初始化的线程数默认值10
# min-spare: 100
#
### 日志配置
##logging:
## config: classpath:log4j2ss.xml
## level:
## com.fc: debug
## org.springframework: warn
#
## token配置
#token:
# # 令牌自定义标识
# header: Authorization
# # 令牌密钥
# secret: abcdefghijklmnopqrstuvwxyz
# # 令牌有效期默认30分钟
# expireTime: 30
#
## MyBatis配置
#mybatis:
# # 搜索指定包别名
# type-aliases-package: com.fc.**.model
# # 配置mapper的扫描找到所有的mapper.xml映射文件
# mapper-locations: classpath*:mappers/**/*Dao.xml
# # 加载全局的配置文件
# configLocation: classpath:mybatis/mybatis-config.xml
#
##mybatis:
## mapper-locations: classpath:mappers/**/*.xml
## type-aliases-package: com.fuchang.entity
#
### PageHelper分页插件
##pagehelper:
## helperDialect: mysql
## supportMethodsArguments: true
## params: count=countSql
##
## Swagger配置
#swagger2:
# # 是否开启swagger
# enabled: true
# # 请求前缀
## pathMapping: /dev-api
##
### 防止XSS攻击
##xss:
## # 过滤开关
## enabled: true
## # 排除链接(多个用逗号分隔)
## excludes: /system/notice
## # 匹配链接
## urlPatterns: /system/*,/monitor/*,/tool/*

@ -2,7 +2,7 @@
spring: spring:
datasource: datasource:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/xymp?allowMultiQueries=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://192.168.1.190:3306/xymp?allowMultiQueries=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root username: root
password: 123456 password: 123456
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
@ -10,87 +10,6 @@ spring:
multipart: multipart:
# 指定自定义上传目录 # 指定自定义上传目录
location: /usr/local/home/manager/temp/ location: /usr/local/home/manager/temp/
#spring:
# # 数据源配置
# datasource:
# type: com.alibaba.druid.pool.DruidDataSource
# driverClassName: com.mysql.cj.jdbc.Driver
# druid:
# # 主库数据源
# master:
# url: jdbc:mysql://192.168.200.63:3306/xymp?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# username: xymp
# password: xymp@123
# # 从库数据源
# slave:
# # 从数据源开关/默认关闭
# enabled: false
# url:
# username:
# password:
# # 初始连接数
# initialSize: 5
# # 最小连接池数量
# minIdle: 10
# # 最大连接池数量
# maxActive: 20
# # 配置获取连接等待超时的时间
# maxWait: 60000
# # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
# timeBetweenEvictionRunsMillis: 60000
# # 配置一个连接在池中最小生存的时间,单位是毫秒
# minEvictableIdleTimeMillis: 300000
# # 配置一个连接在池中最大生存的时间,单位是毫秒
# maxEvictableIdleTimeMillis: 900000
# # 配置检测连接是否有效
# validationQuery: SELECT 1 FROM DUAL
# testWhileIdle: true
# testOnBorrow: false
# testOnReturn: false
# webStatFilter:
# enabled: true
# statViewServlet:
# enabled: true
# # 设置白名单,不填则允许所有访问
# allow:
# url-pattern: /druid/*
# # 控制台管理用户名和密码
# login-username: root
# login-password: 123456
# filter:
# stat:
# enabled: true
# # 慢SQL记录
# log-slow-sql: true
# slow-sql-millis: 1000
# merge-sql: true
# wall:
# config:
# multi-statement-allow: true
# # # 资源信息
# # messages:
# # # 国际化资源文件路径
# # basename: i18n/messages
# # # 文件上传
# # servlet:
# # multipart:
# # # 单个文件大小
# # max-file-size: 20MB
# # # 设置总上传的文件大小
# # max-request-size: 20MB
# # # 服务模块
# # devtools:
# # restart:
# # # 热部署开关
# # enabled: true
# mvc:
# view:
# suffix: .html
# # redis 配置
# servlet:
# multipart:
# max-file-size: 10MB #单个数据大小
# max-request-size: 50MB #总数据大小
# MyBatis配置 # MyBatis配置
mybatis: mybatis:
# 搜索指定包别名 # 搜索指定包别名
@ -152,7 +71,6 @@ token:
# 令牌有效期默认30分钟 # 令牌有效期默认30分钟
expireTime: 1 expireTime: 1
# Swagger配置 # Swagger配置
swagger2: swagger2:
# 是否开启swagger # 是否开启swagger

@ -139,10 +139,10 @@
<!-- <artifactId>okhttp</artifactId>--> <!-- <artifactId>okhttp</artifactId>-->
<!-- </dependency>--> <!-- </dependency>-->
<!-- <dependency>--> <dependency>
<!-- <groupId>io.github.admin4j</groupId>--> <groupId>io.github.admin4j</groupId>
<!-- <artifactId>http</artifactId>--> <artifactId>http</artifactId>
<!-- </dependency>--> </dependency>
<!-- &lt;!&ndash;shiro&ndash;&gt;--> <!-- &lt;!&ndash;shiro&ndash;&gt;-->
<!-- <dependency>--> <!-- <dependency>-->

@ -1,48 +1,20 @@
//package com.shxy.xymanager_common.entity; package com.shxy.xymanager_common.entity;
//
//import java.io.Serializable; import lombok.Data;
//import java.util.Date;
// import java.io.Serializable;
//public class ThirdUser implements Serializable { import java.util.Date;
// private Integer name;
// @Data
// private String password; public class ThirdUser implements Serializable {
// private Integer name;
// private Date tokenEffectTime;
// private String password;
// private String token;
// private Date tokenEffectTime;
// private static final long serialVersionUID = 1L;
// private String token;
// public Integer getName() {
// return name; private static final long serialVersionUID = 1L;
// }
// }
// public void setName(Integer name) {
// this.name = name;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password == null ? null : password.trim();
// }
//
// public Date getTokenEffectTime() {
// return tokenEffectTime;
// }
//
// public void setTokenEffectTime(Date tokenEffectTime) {
// this.tokenEffectTime = tokenEffectTime;
// }
//
// public String getToken() {
// return token;
// }
//
// public void setToken(String token) {
// this.token = token == null ? null : token.trim();
// }
//}

@ -1,70 +1,70 @@
//package com.shxy.xymanager_common.util.http; package com.shxy.xymanager_common.util.http;
//import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
//import io.github.admin4j.http.HttpRequest; import io.github.admin4j.http.HttpRequest;
//import io.github.admin4j.http.core.Pair; import io.github.admin4j.http.core.Pair;
//import io.github.admin4j.http.util.HttpUtil; import io.github.admin4j.http.util.HttpUtil;
//import okhttp3.Response; import okhttp3.Response;
//
//import java.io.File; import java.io.File;
//import java.io.IOException; import java.io.IOException;
//import java.util.ArrayList; import java.util.ArrayList;
//import java.util.HashMap; import java.util.HashMap;
//import java.util.List; import java.util.List;
//import java.util.Map; import java.util.Map;
//
//public class OkHttpUtils { public class OkHttpUtils {
//
// public static JSONObject get(String url, Map<String, Object> queryParams) throws IOException { public static JSONObject get(String url, Map<String, Object> queryParams) throws IOException {
// Response response = HttpUtil.get(url, queryParams); Response response = HttpUtil.get(url, queryParams);
// return JSONObject.parseObject(response.body().string()); return JSONObject.parseObject(response.body().string());
// } }
//
// public static JSONObject get(String url, Map<String, Object> queryParams, Map<String, Object> headers) throws IOException { public static JSONObject get(String url, Map<String, Object> queryParams, Map<String, Object> headers) throws IOException {
// HttpRequest httpRequest = HttpRequest.get(url); HttpRequest httpRequest = HttpRequest.get(url);
// setParams(queryParams, httpRequest); setParams(queryParams, httpRequest);
// Response response = httpRequest.queryParams().headers(headers).execute(); Response response = httpRequest.queryParams().headers(headers).execute();
// return JSONObject.parseObject(response.body().string()); return JSONObject.parseObject(response.body().string());
// } }
//
// public static JSONObject post(String url, String json) throws IOException { public static JSONObject post(String url, String json) throws IOException {
// Response response = HttpUtil.post(url, json); Response response = HttpUtil.post(url, json);
// assert response.body() != null; assert response.body() != null;
// return JSONObject.parseObject(response.body().string()); return JSONObject.parseObject(response.body().string());
// } }
//
// public static JSONObject postForm(String url, Map<String, Object> formParams) throws IOException { public static JSONObject postForm(String url, Map<String, Object> formParams) throws IOException {
// Response response = HttpUtil.postForm(url, formParams); Response response = HttpUtil.postForm(url, formParams);
// assert response.body() != null; assert response.body() != null;
// return JSONObject.parseObject(response.body().string()); return JSONObject.parseObject(response.body().string());
// } }
//
// public static JSONObject post(String url, String json, Map<String, Object> headers) throws IOException { public static JSONObject post(String url, String json, Map<String, Object> headers) throws IOException {
// HttpRequest httpRequest = HttpRequest.post(url); HttpRequest httpRequest = HttpRequest.post(url);
// httpRequest.setBody(json); httpRequest.setBody(json);
// Response response = httpRequest.headers(headers).execute(); Response response = httpRequest.headers(headers).execute();
// return JSONObject.parseObject(response.body().string()); return JSONObject.parseObject(response.body().string());
// } }
//
// private static void setParams(Map<String, Object> queryParams, HttpRequest httpRequest) { private static void setParams(Map<String, Object> queryParams, HttpRequest httpRequest) {
// List<Pair> pairs = new ArrayList<>(queryParams.size()); List<Pair> pairs = new ArrayList<>(queryParams.size());
// queryParams.forEach((x, y) -> pairs.add(Pair.of(x, y))); queryParams.forEach((x, y) -> pairs.add(Pair.of(x, y)));
// if (pairs.size() > 0) { if (pairs.size() > 0) {
// pairs.forEach(httpRequest::queryParams); pairs.forEach(httpRequest::queryParams);
// } }
// } }
//
// private static JSONObject upload() throws IOException { private static JSONObject upload() throws IOException {
// File file = new File("C:\\Users\\andanyang\\Downloads\\Sql.txt"); File file = new File("C:\\Users\\andanyang\\Downloads\\Sql.txt");
// Map<String, Object> formParams = new HashMap<>(); Map<String, Object> formParams = new HashMap<>();
// formParams.put("key", "test"); formParams.put("key", "test");
// formParams.put("file", file); formParams.put("file", file);
// formParams.put("token", "WXyUseb-D4sCum-EvTIDYL-mEehwDtrSBg-Zca7t:qgOcR2gUoKmxt-VnsNb657Oatzo=:eyJzY29wZSI6InpoYW56aGkiLCJkZWFkbGluZSI6MTY2NTMwNzUxNH0="); formParams.put("token", "WXyUseb-D4sCum-EvTIDYL-mEehwDtrSBg-Zca7t:qgOcR2gUoKmxt-VnsNb657Oatzo=:eyJzY29wZSI6InpoYW56aGkiLCJkZWFkbGluZSI6MTY2NTMwNzUxNH0=");
// Response response = HttpUtil.upload("https://upload.qiniup.com/", formParams); Response response = HttpUtil.upload("https://upload.qiniup.com/", formParams);
// return JSONObject.parseObject(response.body().string()); return JSONObject.parseObject(response.body().string());
// } }
//
// private static void download() throws IOException { private static void download() throws IOException {
// HttpUtil.down("https://gitee.com/admin4j/common-http","path/"); HttpUtil.down("https://gitee.com/admin4j/common-http","path/");
// } }
//
//} }

@ -0,0 +1,162 @@
package com.shxy.xymanager_common.util.xinyin;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
public class AESEncoder {
public static final String jiamiguize = "SHA1PRNG";
/*
* 1. 2.ecnodeRules 3. 4. 5. 6.
*/
public static String AESEncode(String encodeRules, String content) {
try {
// 1.构造密钥生成器指定为AES算法,不区分大小写
KeyGenerator keygen = KeyGenerator.getInstance("AES");
// 2.根据ecnodeRules规则初始化密钥生成器
// 生成一个128位的随机源,根据传入的字节数组
/** 【在linux下ase加密每次生成会不同采用以下方式可避免】 **/
SecureRandom secureRandom = SecureRandom.getInstance(jiamiguize);
secureRandom.setSeed(encodeRules.getBytes());
keygen.init(128, secureRandom);
// 3.产生原始对称密钥
SecretKey original_key = keygen.generateKey();
// 4.获得原始对称密钥的字节数组
byte[] raw = original_key.getEncoded();
// 5.根据字节数组生成AES密钥
SecretKey key = new SecretKeySpec(raw, "AES");
// 6.根据指定算法AES自成密码器
Cipher cipher = Cipher.getInstance("AES");
// 7.初始化密码器,第一个参数为加密(Encrypt_mode)或者解密解密(Decrypt_mode)操作第二个参数为使用的KEY
cipher.init(Cipher.ENCRYPT_MODE, key);
// 8.获取加密内容的字节数组(这里要设置为utf-8)不然内容中如果有中文和英文混合中文就会解密为乱码
byte[] byte_encode = content.getBytes("utf-8");
// 9.根据密码器的初始化方式--加密:将数据加密
byte[] byte_AES = cipher.doFinal(byte_encode);
// 10.将加密后的数据转换为字符串
// 这里用Base64Encoder中会找不到包
// 解决办法:
// 在项目的Build path中先移除JRE System Library再添加库JRE System Library重新编译后就一切正常了。
String AES_encode = new String(new BASE64Encoder().encode(byte_AES));
// 11.将字符串返回
return AES_encode;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
// 如果有错就返加nulll
return null;
}
/*
* 1.1-4 2.byte[] 3.
*/
public static String AESDecode(String encodeRules, String content) {
try {
// 1.构造密钥生成器指定为AES算法,不区分大小写
KeyGenerator keygen = KeyGenerator.getInstance("AES");
// 2.根据ecnodeRules规则初始化密钥生成器
// 生成一个128位的随机源,根据传入的字节数组
/** 【在linux下ase加密每次生成会不同采用以下方式可避免】 **/
SecureRandom secureRandom = SecureRandom.getInstance(jiamiguize);
secureRandom.setSeed(encodeRules.getBytes());
keygen.init(128, secureRandom);
// 3.产生原始对称密钥
SecretKey original_key = keygen.generateKey();
// 4.获得原始对称密钥的字节数组
byte[] raw = original_key.getEncoded();
// 5.根据字节数组生成AES密钥
SecretKey key = new SecretKeySpec(raw, "AES");
// 6.根据指定算法AES自成密码器
Cipher cipher = Cipher.getInstance("AES");
// 7.初始化密码器,第一个参数为加密(Encrypt_mode)或者解密(Decrypt_mode)操作第二个参数为使用的KEY
cipher.init(Cipher.DECRYPT_MODE, key);
// 8.将加密并编码后的内容解码成字节数组
byte[] byte_content = new BASE64Decoder().decodeBuffer(content);
/*
*
*/
byte[] byte_decode = cipher.doFinal(byte_content);
String AES_decode = new String(byte_decode, "utf-8");
return AES_decode;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
}
// 如果有错就返加nulll
return null;
}
/**
* BASE64
*
* @param key
* @return
* @throws Exception
*/
public static String encryptBASE64(byte[] key) throws Exception {
return (new BASE64Encoder()).encodeBuffer(key);
}
public static void main(String[] args) throws Exception {
// 秘钥
String key = "stline1559";
// 账户
String usr = "stline_kshtp";
// 密码
String pwd = "kshtp@2020";
// 一次AES加密
usr = AESEncode(key, usr);
pwd = AESEncode(key, pwd);
// 二次BASE64加密
usr = encryptBASE64(usr.getBytes());
pwd = encryptBASE64(pwd.getBytes());
System.out.println("加密后用户:" + usr);
System.out.println("加密后密码:" + pwd);
// 一次BASE64解密
BASE64Decoder decoder = new BASE64Decoder();
String nameStr = new String(decoder.decodeBuffer(usr));
String pwdStr = new String(decoder.decodeBuffer(pwd));
AESEncoder se = new AESEncoder();
nameStr = se.AESDecode(key, nameStr);// 解密后的账号
pwdStr = se.AESDecode(key, pwdStr);// 解密后的密码
System.out.println("解密后用户:" + nameStr);
System.out.println("解密后密码:" + pwdStr);
}
}

@ -43,37 +43,37 @@ public class JwtInterceptor implements HandlerInterceptor {
@Override @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// 忽略带JwtIgnore注解的请求, 不做后续token认证校验 // 忽略带JwtIgnore注解的请求, 不做后续token认证校验
// if (handler instanceof HandlerMethod) { if (handler instanceof HandlerMethod) {
// HandlerMethod handlerMethod = (HandlerMethod) handler; HandlerMethod handlerMethod = (HandlerMethod) handler;
// JwtIgnore jwtIgnore = handlerMethod.getMethodAnnotation(JwtIgnore.class); JwtIgnore jwtIgnore = handlerMethod.getMethodAnnotation(JwtIgnore.class);
// if (jwtIgnore != null) { if (jwtIgnore != null) {
// return true; return true;
// } }
// } }
// if (HttpMethod.GET.name().equals(request.getMethod())) { if (HttpMethod.GET.name().equals(request.getMethod())) {
// response.setStatus(HttpServletResponse.SC_OK); response.setStatus(HttpServletResponse.SC_OK);
// return true; return true;
// } }
// // 获取请求头信息authorization信息 // 获取请求头信息authorization信息
// final String sessionId = request.getHeader("sessionId"); final String sessionId = request.getHeader("sessionId");
// if (StrUtil.isBlank(sessionId)) { if (StrUtil.isBlank(sessionId)) {
// log.info("sessionId为空登录过期"); log.info("sessionId为空登录过期");
// Asserts.fail(401, "登录过期"); Asserts.fail(401, "登录过期");
// } else { } else {
// SysUserSession user = sysUserService.selectUserById(sessionId); SysUserSession user = sysUserService.selectUserById(sessionId);
// if (user != null) { if (user != null) {
// BigInteger expireTime = user.getExpireTime(); BigInteger expireTime = user.getExpireTime();
//
// long currentTime = MyDateUtils.TimeMillSecond2Second(new DateTime()); long currentTime = MyDateUtils.TimeMillSecond2Second(new DateTime());
// if ((currentTime - expireTime.longValue()) > time.longValue()) { if ((currentTime - expireTime.longValue()) > time.longValue()) {
// user.setExpireTime(BigInteger.valueOf(currentTime).add(time)); user.setExpireTime(BigInteger.valueOf(currentTime).add(time));
// sysUserService.updateUserSession(user); sysUserService.updateUserSession(user);
// } }
// } else { } else {
// log.info("sessionId为空登录过期"); log.info("sessionId为空登录过期");
// Asserts.fail(401, "登录过期"); Asserts.fail(401, "登录过期");
// } }
// } }
return true; return true;
} }

@ -5,6 +5,7 @@
//import com.shxy.xymanager_common.util.StringUtils; //import com.shxy.xymanager_common.util.StringUtils;
//import com.shxy.xymanager_common.util.http.HttpStatus; //import com.shxy.xymanager_common.util.http.HttpStatus;
//import com.shxy.xymanager_common.util.http.OkHttpUtils; //import com.shxy.xymanager_common.util.http.OkHttpUtils;
//import com.shxy.xymanager_common.util.xinyin.AESEncoder;
//import com.shxy.xymanager_service.service.HeNanHttpService; //import com.shxy.xymanager_service.service.HeNanHttpService;
//import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Value; //import org.springframework.beans.factory.annotation.Value;
@ -28,8 +29,6 @@
// @Value("${cma.port}") // @Value("${cma.port}")
// public String dname; // public String dname;
// //
//
//
// /* // /*
// * 推送常态巡查图片数据 // * 推送常态巡查图片数据
// * */ // * */
@ -75,8 +74,20 @@
// * 发送加密的账号密码获取tokentoken有效期自获取开始30分钟 // * 发送加密的账号密码获取tokentoken有效期自获取开始30分钟
// * */ // * */
// @Override // @Override
// public Map<String, String> getToken() { // public Map<String, String> getToken() throws Exception {
// JSONObject jsonObject = new JSONObject(); // JSONObject jsonObject = new JSONObject();
// // 秘钥
// String key = "stline1559";
// // 账户
// String usr = "stline_kshtp";
// // 密码
// String pwd = "kshtp@2020";
// // 一次AES加密
// usr = AESEncoder.AESEncode(key, name);
// pwd = AESEncoder.AESEncode(key, password);
// // 二次BASE64加密
// usr = AESEncoder.encryptBASE64(usr.getBytes());
// pwd = AESEncoder.encryptBASE64(pwd.getBytes());
// jsonObject.put("name", name); // jsonObject.put("name", name);
// jsonObject.put("pwd", password); // jsonObject.put("pwd", password);
// jsonObject.put("d_name", dname); // jsonObject.put("d_name", dname);

@ -21,5 +21,5 @@ public interface HeNanHttpService {
/* /*
* tokentoken30 * tokentoken30
* */ * */
Map<String, String> getToken(); Map<String, String> getToken() throws Exception;
} }

Loading…
Cancel
Save