mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
1.13.3
This commit is contained in:
@@ -14,7 +14,6 @@ import com.gitee.sop.adminserver.api.service.param.ConfigIpBlackForm;
|
|||||||
import com.gitee.sop.adminserver.api.service.param.ConfigIpBlacklistPageParam;
|
import com.gitee.sop.adminserver.api.service.param.ConfigIpBlacklistPageParam;
|
||||||
import com.gitee.sop.adminserver.api.service.result.ConfigIpBlacklistVO;
|
import com.gitee.sop.adminserver.api.service.result.ConfigIpBlacklistVO;
|
||||||
import com.gitee.sop.adminserver.bean.ChannelMsg;
|
import com.gitee.sop.adminserver.bean.ChannelMsg;
|
||||||
import com.gitee.sop.adminserver.bean.ConfigLimitDto;
|
|
||||||
import com.gitee.sop.adminserver.bean.ZookeeperContext;
|
import com.gitee.sop.adminserver.bean.ZookeeperContext;
|
||||||
import com.gitee.sop.adminserver.common.BizException;
|
import com.gitee.sop.adminserver.common.BizException;
|
||||||
import com.gitee.sop.adminserver.entity.ConfigIpBlacklist;
|
import com.gitee.sop.adminserver.entity.ConfigIpBlacklist;
|
||||||
@@ -93,6 +92,13 @@ public class IPBlacklistApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum BlacklistMsgType {
|
enum BlacklistMsgType {
|
||||||
ADD, DELETE
|
/**
|
||||||
|
* 黑名单消息类型:添加
|
||||||
|
*/
|
||||||
|
ADD,
|
||||||
|
/**
|
||||||
|
* 黑名单消息类型:删除
|
||||||
|
*/
|
||||||
|
DELETE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -40,6 +40,7 @@ public class LogApi {
|
|||||||
|
|
||||||
public static final String LOG_MONITOR_INSTANCE = "log.monitor.instance";
|
public static final String LOG_MONITOR_INSTANCE = "log.monitor.instance";
|
||||||
public static final String CODE_SUCCESS = "10000";
|
public static final String CODE_SUCCESS = "10000";
|
||||||
|
private static final String CODE_KEY = "code";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
ConfigCommonMapper configCommonMapper;
|
ConfigCommonMapper configCommonMapper;
|
||||||
@@ -135,7 +136,7 @@ public class LogApi {
|
|||||||
try {
|
try {
|
||||||
String json = this.requestLogServer(ipPort, "listErrors");
|
String json = this.requestLogServer(ipPort, "listErrors");
|
||||||
JSONObject jsonObject = JSON.parseObject(json);
|
JSONObject jsonObject = JSON.parseObject(json);
|
||||||
if (!CODE_SUCCESS.equals(jsonObject.getString("code"))) {
|
if (!CODE_SUCCESS.equals(jsonObject.getString(CODE_KEY))) {
|
||||||
log.error("请求结果:{}", json);
|
log.error("请求结果:{}", json);
|
||||||
throw new BizException("添加失败");
|
throw new BizException("添加失败");
|
||||||
}
|
}
|
||||||
@@ -147,7 +148,7 @@ public class LogApi {
|
|||||||
|
|
||||||
private String requestLogServer(String ipPort, String path) throws Exception {
|
private String requestLogServer(String ipPort, String path) throws Exception {
|
||||||
DefaultMd5Verifier md5Verifier = new DefaultMd5Verifier();
|
DefaultMd5Verifier md5Verifier = new DefaultMd5Verifier();
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>(16);
|
||||||
params.put("time", System.currentTimeMillis());
|
params.put("time", System.currentTimeMillis());
|
||||||
String sign = md5Verifier.buildSign(params, secret);
|
String sign = md5Verifier.buildSign(params, secret);
|
||||||
params.put("sign", sign);
|
params.put("sign", sign);
|
||||||
|
@@ -115,7 +115,7 @@ public class ServiceApi {
|
|||||||
List<ServiceInstanceVO> listService(ServiceSearchParam param) {
|
List<ServiceInstanceVO> listService(ServiceSearchParam param) {
|
||||||
List<ServiceInfo> serviceInfos;
|
List<ServiceInfo> serviceInfos;
|
||||||
try {
|
try {
|
||||||
serviceInfos = registryService.listAllService(1, 99999/* 获取所有实例 */);
|
serviceInfos = registryService.listAllService(1, 99999);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("获取服务实例失败", e);
|
log.error("获取服务实例失败", e);
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
@@ -9,7 +9,7 @@ import lombok.Data;
|
|||||||
public class LogMonitorInstanceVO {
|
public class LogMonitorInstanceVO {
|
||||||
private String id;
|
private String id;
|
||||||
private int treeId;
|
private int treeId;
|
||||||
// 表主键
|
/** 表主键 */
|
||||||
private long rawId;
|
private long rawId;
|
||||||
private String name;
|
private String name;
|
||||||
private String version;
|
private String version;
|
||||||
|
@@ -22,6 +22,7 @@ import org.springframework.util.Assert;
|
|||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
import static com.gitee.sop.adminserver.bean.SopAdminConstants.SOP_MSG_CHANNEL_PATH;
|
import static com.gitee.sop.adminserver.bean.SopAdminConstants.SOP_MSG_CHANNEL_PATH;
|
||||||
|
|
||||||
@@ -307,7 +308,7 @@ public class ZookeeperContext {
|
|||||||
String data = new String(nodeData);
|
String data = new String(nodeData);
|
||||||
if (StringUtils.isNotBlank(data) && !initData.equals(data)) {
|
if (StringUtils.isNotBlank(data) && !initData.equals(data)) {
|
||||||
listenCallback.onError(data);
|
listenCallback.onError(data);
|
||||||
new Thread(new ZKClose(cache, client)).start();
|
Executors.newSingleThreadExecutor().execute(() -> new ZKClose(cache, client));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -9,7 +9,8 @@ import com.gitee.easyopen.message.ErrorMeta;
|
|||||||
public class AdminErrors {
|
public class AdminErrors {
|
||||||
private AdminErrors(){}
|
private AdminErrors(){}
|
||||||
|
|
||||||
static String isvModule = "isv.error_"; // error_zh_CN2.properties内容前缀
|
/** error_zh_CN2.properties内容前缀 */
|
||||||
|
static String isvModule = "isv.error_";
|
||||||
|
|
||||||
|
|
||||||
public static final ErrorMeta NO_LOGIN = new ErrorMeta(isvModule, "-100", "用户未登录");
|
public static final ErrorMeta NO_LOGIN = new ErrorMeta(isvModule, "-100", "用户未登录");
|
||||||
|
@@ -124,9 +124,9 @@ public class IdGen {
|
|||||||
lastTimestamp = timestamp;
|
lastTimestamp = timestamp;
|
||||||
|
|
||||||
//移位并通过或运算拼到一起组成64位的ID
|
//移位并通过或运算拼到一起组成64位的ID
|
||||||
return ((timestamp - twepoch) << timestampLeftShift) //
|
return ((timestamp - twepoch) << timestampLeftShift)
|
||||||
| (datacenterId << datacenterIdShift) //
|
| (datacenterId << datacenterIdShift)
|
||||||
| (workerId << workerIdShift) //
|
| (workerId << workerIdShift)
|
||||||
| sequence;
|
| sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -309,7 +309,14 @@ public class RSATool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum KeyLength {
|
public enum KeyLength {
|
||||||
LENGTH_1024(1024), LENGTH_2048(2048);
|
/**
|
||||||
|
* 秘钥长度:1024
|
||||||
|
*/
|
||||||
|
LENGTH_1024(1024),
|
||||||
|
/**
|
||||||
|
* 秘钥长度:2048
|
||||||
|
*/
|
||||||
|
LENGTH_2048(2048);
|
||||||
private int length;
|
private int length;
|
||||||
|
|
||||||
KeyLength(int length) {
|
KeyLength(int length) {
|
||||||
|
@@ -28,7 +28,7 @@ public class IsvInfo {
|
|||||||
/** appKey, 数据库字段:app_key */
|
/** appKey, 数据库字段:app_key */
|
||||||
private String appKey;
|
private String appKey;
|
||||||
|
|
||||||
// 不再使用,转移到isv_keys表
|
/** 不再使用,转移到isv_keys表 */
|
||||||
private String secret = "";
|
private String secret = "";
|
||||||
|
|
||||||
/** 公钥,不再使用,转移到isv_keys表 数据库字段:pub_key */
|
/** 公钥,不再使用,转移到isv_keys表 数据库字段:pub_key */
|
||||||
|
@@ -15,6 +15,8 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
*/
|
*/
|
||||||
public class LoginInterceptor extends ApiInterceptorAdapter {
|
public class LoginInterceptor extends ApiInterceptorAdapter {
|
||||||
|
|
||||||
|
public static final String PREFIX = "nologin.";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object serviceObj, Object argu)
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object serviceObj, Object argu)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
@@ -28,7 +30,8 @@ public class LoginInterceptor extends ApiInterceptorAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public boolean match(ApiMeta apiMeta) {
|
public boolean match(ApiMeta apiMeta) {
|
||||||
String name = apiMeta.getName();
|
String name = apiMeta.getName();
|
||||||
if (name.startsWith("nologin.")) { // 以‘nologin.’开头的接口不拦截
|
// 以‘nologin.’开头的接口不拦截
|
||||||
|
if (name.startsWith(PREFIX)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
@@ -13,6 +13,11 @@ import org.apache.ibatis.annotations.Select;
|
|||||||
*/
|
*/
|
||||||
public interface IsvInfoMapper extends CrudMapper<IsvInfo, Long> {
|
public interface IsvInfoMapper extends CrudMapper<IsvInfo, Long> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取isv详细信息
|
||||||
|
* @param appKey appKey
|
||||||
|
* @return 返回详细信息,没有返回null
|
||||||
|
*/
|
||||||
@Select("SELECT " +
|
@Select("SELECT " +
|
||||||
" t.app_key appKey " +
|
" t.app_key appKey " +
|
||||||
" ,t.status " +
|
" ,t.status " +
|
||||||
|
@@ -4,5 +4,8 @@ package com.gitee.sop.gatewaycommon.bean;
|
|||||||
* @author tanghc
|
* @author tanghc
|
||||||
*/
|
*/
|
||||||
public interface BeanInitializer {
|
public interface BeanInitializer {
|
||||||
|
/**
|
||||||
|
* 执行加载操作
|
||||||
|
*/
|
||||||
void load();
|
void load();
|
||||||
}
|
}
|
||||||
|
@@ -13,6 +13,9 @@ import java.util.Date;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author thc
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class ConfigLimitDto {
|
public class ConfigLimitDto {
|
||||||
|
|
||||||
|
@@ -6,6 +6,9 @@ import lombok.ToString;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author thc
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ToString
|
@ToString
|
||||||
@@ -19,8 +22,12 @@ public class ErrorEntity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) {
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
return true;
|
||||||
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
ErrorEntity that = (ErrorEntity) o;
|
ErrorEntity that = (ErrorEntity) o;
|
||||||
return id.equals(that.id);
|
return id.equals(that.id);
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class RouteConfig {
|
public class RouteConfig {
|
||||||
|
|
||||||
public static final byte STATUS_ENABLE = 1;
|
private static final byte STATUS_ENABLE = RouteStatus.ENABLE.getStatus();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 路由id
|
* 路由id
|
||||||
|
@@ -1,22 +1,33 @@
|
|||||||
package com.gitee.sop.gatewaycommon.bean;
|
package com.gitee.sop.gatewaycommon.bean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 路由状态
|
||||||
|
*
|
||||||
* @author tanghc
|
* @author tanghc
|
||||||
*/
|
*/
|
||||||
public enum RouteStatus {
|
public enum RouteStatus {
|
||||||
|
/**
|
||||||
|
* 路由状态,0:待审核
|
||||||
|
*/
|
||||||
AUDIT(0, "待审核"),
|
AUDIT(0, "待审核"),
|
||||||
|
/**
|
||||||
|
* 路由状态,1:已启用
|
||||||
|
*/
|
||||||
ENABLE(1, "已启用"),
|
ENABLE(1, "已启用"),
|
||||||
|
/**
|
||||||
|
* 路由状态,2:已禁用
|
||||||
|
*/
|
||||||
DISABLE(2, "已禁用"),
|
DISABLE(2, "已禁用"),
|
||||||
;
|
;
|
||||||
private int status;
|
private byte status;
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
RouteStatus(int status, String description) {
|
RouteStatus(Integer status, String description) {
|
||||||
this.status = status;
|
this.status = status.byteValue();
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStatus() {
|
public byte getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,9 +4,25 @@ package com.gitee.sop.gatewaycommon.bean;
|
|||||||
* @author tanghc
|
* @author tanghc
|
||||||
*/
|
*/
|
||||||
public interface TargetRoute<R extends BaseServiceRouteInfo, E extends BaseRouteDefinition, T> {
|
public interface TargetRoute<R extends BaseServiceRouteInfo, E extends BaseRouteDefinition, T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回服务信息
|
||||||
|
*
|
||||||
|
* @return 返回服务信息
|
||||||
|
*/
|
||||||
R getServiceRouteInfo();
|
R getServiceRouteInfo();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回微服务路由对象
|
||||||
|
*
|
||||||
|
* @return 返回微服务路由对象
|
||||||
|
*/
|
||||||
E getRouteDefinition();
|
E getRouteDefinition();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回网关路由对象
|
||||||
|
*
|
||||||
|
* @return 返回网关路由对象
|
||||||
|
*/
|
||||||
T getTargetRouteDefinition();
|
T getTargetRouteDefinition();
|
||||||
}
|
}
|
||||||
|
@@ -44,7 +44,7 @@ public class ReadBodyRoutePredicateFactory extends AbstractRoutePredicateFactory
|
|||||||
|
|
||||||
private static final String TEST_ATTRIBUTE = "read_body_predicate_test_attribute";
|
private static final String TEST_ATTRIBUTE = "read_body_predicate_test_attribute";
|
||||||
private static final String CACHE_REQUEST_BODY_OBJECT_KEY = "cachedRequestBodyObject";
|
private static final String CACHE_REQUEST_BODY_OBJECT_KEY = "cachedRequestBodyObject";
|
||||||
private static final List<HttpMessageReader<?>> messageReaders = HandlerStrategies.withDefaults().messageReaders();
|
private static final List<HttpMessageReader<?>> HTTP_MESSAGE_READERS = HandlerStrategies.withDefaults().messageReaders();
|
||||||
|
|
||||||
|
|
||||||
public ReadBodyRoutePredicateFactory() {
|
public ReadBodyRoutePredicateFactory() {
|
||||||
@@ -108,7 +108,7 @@ public class ReadBodyRoutePredicateFactory extends AbstractRoutePredicateFactory
|
|||||||
return cachedFlux;
|
return cachedFlux;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return ServerRequest.create(exchange.mutate().request(mutatedRequest).build(), messageReaders)
|
return ServerRequest.create(exchange.mutate().request(mutatedRequest).build(), HTTP_MESSAGE_READERS)
|
||||||
.bodyToMono(inClass)
|
.bodyToMono(inClass)
|
||||||
.doOnNext(objectValue -> {
|
.doOnNext(objectValue -> {
|
||||||
exchange.getAttributes().put(CACHE_REQUEST_BODY_OBJECT_KEY, objectValue);
|
exchange.getAttributes().put(CACHE_REQUEST_BODY_OBJECT_KEY, objectValue);
|
||||||
|
@@ -7,10 +7,26 @@ import com.gitee.sop.gatewaycommon.bean.BeanInitializer;
|
|||||||
*/
|
*/
|
||||||
public interface IPBlacklistManager extends BeanInitializer {
|
public interface IPBlacklistManager extends BeanInitializer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加IP
|
||||||
|
*
|
||||||
|
* @param ip ip
|
||||||
|
*/
|
||||||
void add(String ip);
|
void add(String ip);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除黑名单IP
|
||||||
|
*
|
||||||
|
* @param ip ip
|
||||||
|
*/
|
||||||
void remove(String ip);
|
void remove(String ip);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ip是否在黑名单中
|
||||||
|
*
|
||||||
|
* @param ip ip
|
||||||
|
* @return true:在黑名单中
|
||||||
|
*/
|
||||||
boolean contains(String ip);
|
boolean contains(String ip);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,15 @@ import com.gitee.sop.gatewaycommon.bean.IsvRoutePermission;
|
|||||||
* @author tanghc
|
* @author tanghc
|
||||||
*/
|
*/
|
||||||
public interface RoutePermissionManager {
|
public interface RoutePermissionManager {
|
||||||
|
/**
|
||||||
|
* 加载路由授权
|
||||||
|
*/
|
||||||
void load();
|
void load();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新路由授权信息
|
||||||
|
*
|
||||||
|
* @param isvRoutePermission 授权信息
|
||||||
|
*/
|
||||||
void update(IsvRoutePermission isvRoutePermission);
|
void update(IsvRoutePermission isvRoutePermission);
|
||||||
}
|
}
|
||||||
|
@@ -17,8 +17,18 @@ import java.util.Optional;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public abstract class BaseParamBuilder<T> implements ParamBuilder<T> {
|
public abstract class BaseParamBuilder<T> implements ParamBuilder<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建请求参数
|
||||||
|
* @param ctx 请求request
|
||||||
|
* @return 返回请求参数
|
||||||
|
*/
|
||||||
public abstract Map<String, String> buildRequestParams(T ctx);
|
public abstract Map<String, String> buildRequestParams(T ctx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回客户端ip
|
||||||
|
* @param ctx 请求request
|
||||||
|
* @return 返回ip
|
||||||
|
*/
|
||||||
public abstract String getIP(T ctx);
|
public abstract String getIP(T ctx);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -275,6 +275,13 @@ public abstract class BaseExecutorAdapter<T, R> implements ResultExecutor<T, R>
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum ErrorType {
|
enum ErrorType {
|
||||||
UNKNOWN, BIZ
|
/**
|
||||||
|
* 未知错误
|
||||||
|
*/
|
||||||
|
UNKNOWN,
|
||||||
|
/**
|
||||||
|
* 业务错误
|
||||||
|
*/
|
||||||
|
BIZ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,14 +5,31 @@ import com.gitee.sop.gatewaycommon.bean.Isv;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Isv管理
|
* Isv管理
|
||||||
|
*
|
||||||
* @author tanghc
|
* @author tanghc
|
||||||
*/
|
*/
|
||||||
public interface IsvManager<T extends Isv> extends BeanInitializer {
|
public interface IsvManager<T extends Isv> extends BeanInitializer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新isv
|
||||||
|
*
|
||||||
|
* @param t isv
|
||||||
|
*/
|
||||||
void update(T t);
|
void update(T t);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除isv
|
||||||
|
*
|
||||||
|
* @param appKey isv对应的appKey
|
||||||
|
*/
|
||||||
void remove(String appKey);
|
void remove(String appKey);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取isv
|
||||||
|
*
|
||||||
|
* @param appKey isv对应的key
|
||||||
|
* @return 返回isv
|
||||||
|
*/
|
||||||
T getIsv(String appKey);
|
T getIsv(String appKey);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -105,7 +105,7 @@ public class RequestUtil {
|
|||||||
DiskFileItemFactory factory = new DiskFileItemFactory();
|
DiskFileItemFactory factory = new DiskFileItemFactory();
|
||||||
//2、创建一个文件上传解析器
|
//2、创建一个文件上传解析器
|
||||||
ServletFileUpload upload = new ServletFileUpload(factory);
|
ServletFileUpload upload = new ServletFileUpload(factory);
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>(16);
|
||||||
try {
|
try {
|
||||||
List<FileItem> fileItems = upload.parseRequest(request);
|
List<FileItem> fileItems = upload.parseRequest(request);
|
||||||
for (FileItem fileItem : fileItems) {
|
for (FileItem fileItem : fileItems) {
|
||||||
|
@@ -21,6 +21,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 限流拦截器
|
* 限流拦截器
|
||||||
|
*
|
||||||
* @author tanghc
|
* @author tanghc
|
||||||
*/
|
*/
|
||||||
public class PreLimitFilter extends BaseZuulFilter {
|
public class PreLimitFilter extends BaseZuulFilter {
|
||||||
@@ -36,8 +37,7 @@ public class PreLimitFilter extends BaseZuulFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object doRun(RequestContext requestContext) throws ZuulException
|
protected Object doRun(RequestContext requestContext) throws ZuulException {
|
||||||
{
|
|
||||||
ApiConfig apiConfig = ApiConfig.getInstance();
|
ApiConfig apiConfig = ApiConfig.getInstance();
|
||||||
// 限流功能未开启,直接返回
|
// 限流功能未开启,直接返回
|
||||||
if (!apiConfig.isOpenLimit()) {
|
if (!apiConfig.isOpenLimit()) {
|
||||||
@@ -75,14 +75,21 @@ public class PreLimitFilter extends BaseZuulFilter {
|
|||||||
|
|
||||||
// 最多7种情况
|
// 最多7种情况
|
||||||
String[] limitKeys = new String[]{
|
String[] limitKeys = new String[]{
|
||||||
routeId, // 根据路由ID限流
|
// 根据路由ID限流
|
||||||
appKey, // 根据appKey限流
|
routeId,
|
||||||
routeId + appKey, // 根据路由ID + appKey限流
|
// 根据appKey限流
|
||||||
|
appKey,
|
||||||
|
// 根据路由ID + appKey限流
|
||||||
|
routeId + appKey,
|
||||||
|
|
||||||
ip, // 根据ip限流
|
// 根据ip限流
|
||||||
ip + routeId, // 根据ip+路由id限流
|
ip,
|
||||||
ip + appKey, // 根据ip+appKey限流
|
// 根据ip+路由id限流
|
||||||
ip + routeId + appKey, // 根据ip+路由id+appKey限流
|
ip + routeId,
|
||||||
|
// 根据ip+appKey限流
|
||||||
|
ip + appKey,
|
||||||
|
// 根据ip+路由id+appKey限流
|
||||||
|
ip + routeId + appKey,
|
||||||
};
|
};
|
||||||
|
|
||||||
List<ConfigLimitDto> limitConfigList = new ArrayList<>();
|
List<ConfigLimitDto> limitConfigList = new ArrayList<>();
|
||||||
|
@@ -2,6 +2,9 @@ package com.gitee.sop.registryapi.bean;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author thc
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class ServiceInstance {
|
public class ServiceInstance {
|
||||||
/**
|
/**
|
||||||
|
@@ -15,6 +15,7 @@ public interface RegistryService {
|
|||||||
* @param pageNo 当前页码
|
* @param pageNo 当前页码
|
||||||
* @param pageSize 分页大小
|
* @param pageSize 分页大小
|
||||||
* @return 返回服务列表
|
* @return 返回服务列表
|
||||||
|
* @throws Exception 获取失败抛出异常
|
||||||
*/
|
*/
|
||||||
List<ServiceInfo> listAllService(int pageNo, int pageSize) throws Exception;
|
List<ServiceInfo> listAllService(int pageNo, int pageSize) throws Exception;
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ public interface RegistryService {
|
|||||||
* 服务上线
|
* 服务上线
|
||||||
*
|
*
|
||||||
* @param serviceInstance
|
* @param serviceInstance
|
||||||
|
* @throws Exception 服务上线失败抛出异常
|
||||||
*/
|
*/
|
||||||
void onlineInstance(ServiceInstance serviceInstance) throws Exception;
|
void onlineInstance(ServiceInstance serviceInstance) throws Exception;
|
||||||
|
|
||||||
@@ -29,6 +31,7 @@ public interface RegistryService {
|
|||||||
* 服务下线
|
* 服务下线
|
||||||
*
|
*
|
||||||
* @param serviceInstance
|
* @param serviceInstance
|
||||||
|
* @throws Exception 服务下线失败抛出异常
|
||||||
*/
|
*/
|
||||||
void offlineInstance(ServiceInstance serviceInstance) throws Exception;
|
void offlineInstance(ServiceInstance serviceInstance) throws Exception;
|
||||||
|
|
||||||
|
@@ -73,7 +73,7 @@ public class RegistryServiceNacos implements RegistryService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onlineInstance(ServiceInstance serviceInstance) throws Exception {
|
public void onlineInstance(ServiceInstance serviceInstance) throws Exception {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>(8);
|
||||||
// 上线,把权重设置成1
|
// 上线,把权重设置成1
|
||||||
params.put("weight", "1");
|
params.put("weight", "1");
|
||||||
this.updateInstance(serviceInstance, params);
|
this.updateInstance(serviceInstance, params);
|
||||||
@@ -81,7 +81,7 @@ public class RegistryServiceNacos implements RegistryService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void offlineInstance(ServiceInstance serviceInstance) throws Exception {
|
public void offlineInstance(ServiceInstance serviceInstance) throws Exception {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>(8);
|
||||||
// 下线,把权重设置成0
|
// 下线,把权重设置成0
|
||||||
params.put("weight", "0");
|
params.put("weight", "0");
|
||||||
this.updateInstance(serviceInstance, params);
|
this.updateInstance(serviceInstance, params);
|
||||||
|
@@ -73,7 +73,11 @@ public class BaseServiceConfiguration extends WebMvcConfigurationSupport
|
|||||||
doAfter();
|
doAfter();
|
||||||
}
|
}
|
||||||
|
|
||||||
// springboot启动完成后执行
|
/**
|
||||||
|
* springboot启动完成后执行
|
||||||
|
* @param args 启动参数
|
||||||
|
* @throws Exception 出错异常
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
log.info("-----服务器启动完毕-----");
|
log.info("-----服务器启动完毕-----");
|
||||||
|
@@ -19,6 +19,10 @@ public abstract class EasyopenDocSupportController {
|
|||||||
|
|
||||||
private SwaggerValidator swaggerValidator;
|
private SwaggerValidator swaggerValidator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文档标题
|
||||||
|
* @return 返回文档标题
|
||||||
|
*/
|
||||||
public abstract String getDocTitle();
|
public abstract String getDocTitle();
|
||||||
|
|
||||||
public EasyopenDocSupportController() {
|
public EasyopenDocSupportController() {
|
||||||
|
@@ -7,5 +7,11 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
|
|||||||
* @author tanghc
|
* @author tanghc
|
||||||
*/
|
*/
|
||||||
public interface SopHandlerMethodArgumentResolver extends HandlerMethodArgumentResolver {
|
public interface SopHandlerMethodArgumentResolver extends HandlerMethodArgumentResolver {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置requestMappingHandlerAdapter
|
||||||
|
*
|
||||||
|
* @param requestMappingHandlerAdapter requestMappingHandlerAdapter
|
||||||
|
*/
|
||||||
void setRequestMappingHandlerAdapter(RequestMappingHandlerAdapter requestMappingHandlerAdapter);
|
void setRequestMappingHandlerAdapter(RequestMappingHandlerAdapter requestMappingHandlerAdapter);
|
||||||
}
|
}
|
||||||
|
@@ -10,8 +10,15 @@ import springfox.documentation.service.ApiInfo;
|
|||||||
import springfox.documentation.spi.DocumentationType;
|
import springfox.documentation.spi.DocumentationType;
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author thc
|
||||||
|
*/
|
||||||
public abstract class SwaggerSupport {
|
public abstract class SwaggerSupport {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文档标题
|
||||||
|
* @return 返回文档标题
|
||||||
|
*/
|
||||||
protected abstract String getDocTitle();
|
protected abstract String getDocTitle();
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@@ -12,6 +12,10 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 传统web开发入口
|
||||||
|
* @author thc
|
||||||
|
*/
|
||||||
@WebServlet(urlPatterns = "/rest/*")
|
@WebServlet(urlPatterns = "/rest/*")
|
||||||
public class RestServlet extends HttpServlet {
|
public class RestServlet extends HttpServlet {
|
||||||
|
|
||||||
|
@@ -15,6 +15,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 限流配置管理
|
* 限流配置管理
|
||||||
|
*
|
||||||
* @author tanghc
|
* @author tanghc
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -52,6 +53,8 @@ public class DbIPBlacklistManager extends DefaultIPBlacklistManager {
|
|||||||
log.info("移除IP黑名单,ip:{}", ip);
|
log.info("移除IP黑名单,ip:{}", ip);
|
||||||
remove(ip);
|
remove(ip);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
log.error("IP黑名单,错误的消息指令,nodeData:{}", nodeData);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -56,6 +56,8 @@ public class DbIsvManager extends CacheIsvManager {
|
|||||||
log.info("删除ISV,isvDefinition:{}", isvDefinition);
|
log.info("删除ISV,isvDefinition:{}", isvDefinition);
|
||||||
remove(isvDefinition.getAppKey());
|
remove(isvDefinition.getAppKey());
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
log.error("ISV信息,错误的消息指令,nodeData:{}", nodeData);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -60,6 +60,8 @@ public class DbLimitConfigManager extends DefaultLimitConfigManager {
|
|||||||
log.info("更新限流配置信息,configLimitDto:{}", configLimitDto);
|
log.info("更新限流配置信息,configLimitDto:{}", configLimitDto);
|
||||||
update(configLimitDto);
|
update(configLimitDto);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
log.error("限流配置信息,错误的消息指令,nodeData:{}", nodeData);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -84,6 +84,8 @@ public class DbRouteConfigManager extends DefaultRouteConfigManager {
|
|||||||
log.info("更新路由配置信息,routeConfigDto:{}", routeConfig);
|
log.info("更新路由配置信息,routeConfigDto:{}", routeConfig);
|
||||||
update(routeConfig);
|
update(routeConfig);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
log.error("路由配置信息,错误的消息指令,nodeData:{}", nodeData);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -13,6 +13,10 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface IsvInfoMapper extends CrudMapper<IsvInfo, Long> {
|
public interface IsvInfoMapper extends CrudMapper<IsvInfo, Long> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有的isv信息
|
||||||
|
* @return 所有的isv信息
|
||||||
|
*/
|
||||||
@Select("SELECT " +
|
@Select("SELECT " +
|
||||||
" t.app_key appKey " +
|
" t.app_key appKey " +
|
||||||
" ,t.status " +
|
" ,t.status " +
|
||||||
|
@@ -44,14 +44,17 @@ public class OpenHttp {
|
|||||||
|
|
||||||
protected void initHttpClient(OpenConfig openConfig) {
|
protected void initHttpClient(OpenConfig openConfig) {
|
||||||
httpClient = new OkHttpClient.Builder()
|
httpClient = new OkHttpClient.Builder()
|
||||||
.connectTimeout(openConfig.getConnectTimeoutSeconds(), TimeUnit.SECONDS) // 设置链接超时时间,默认10秒
|
// 设置链接超时时间
|
||||||
|
.connectTimeout(openConfig.getConnectTimeoutSeconds(), TimeUnit.SECONDS)
|
||||||
.readTimeout(openConfig.getReadTimeoutSeconds(), TimeUnit.SECONDS)
|
.readTimeout(openConfig.getReadTimeoutSeconds(), TimeUnit.SECONDS)
|
||||||
.writeTimeout(openConfig.getWriteTimeoutSeconds(), TimeUnit.SECONDS)
|
.writeTimeout(openConfig.getWriteTimeoutSeconds(), TimeUnit.SECONDS)
|
||||||
.cookieJar(new CookieJar() {
|
.cookieJar(new CookieJar() {
|
||||||
|
@Override
|
||||||
public void saveFromResponse(HttpUrl httpUrl, List<Cookie> list) {
|
public void saveFromResponse(HttpUrl httpUrl, List<Cookie> list) {
|
||||||
cookieStore.put(httpUrl.host(), list);
|
cookieStore.put(httpUrl.host(), list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<Cookie> loadForRequest(HttpUrl httpUrl) {
|
public List<Cookie> loadForRequest(HttpUrl httpUrl) {
|
||||||
List<Cookie> cookies = cookieStore.get(httpUrl.host());
|
List<Cookie> cookies = cookieStore.get(httpUrl.host());
|
||||||
return cookies != null ? cookies : new ArrayList<Cookie>();
|
return cookies != null ? cookies : new ArrayList<Cookie>();
|
||||||
@@ -79,8 +82,9 @@ public class OpenHttp {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求json数据,contentType=application/json
|
* 请求json数据,contentType=application/json
|
||||||
* @param url 请求路径
|
*
|
||||||
* @param json json数据
|
* @param url 请求路径
|
||||||
|
* @param json json数据
|
||||||
* @param header header
|
* @param header header
|
||||||
* @return 返回响应结果
|
* @return 返回响应结果
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
@@ -188,9 +192,14 @@ public class OpenHttp {
|
|||||||
bodyBuilder.setType(MultipartBody.FORM);
|
bodyBuilder.setType(MultipartBody.FORM);
|
||||||
|
|
||||||
for (UploadFile uploadFile : files) {
|
for (UploadFile uploadFile : files) {
|
||||||
bodyBuilder.addFormDataPart(uploadFile.getName(), // 请求的名字
|
|
||||||
uploadFile.getFileName(), // 文件的文字,服务器端用来解析的
|
bodyBuilder.addFormDataPart(
|
||||||
RequestBody.create(null, uploadFile.getFileData()) // 创建RequestBody,把上传的文件放入
|
// 请求的名字
|
||||||
|
uploadFile.getName(),
|
||||||
|
// 文件的文字,服务器端用来解析的
|
||||||
|
uploadFile.getFileName(),
|
||||||
|
// 创建RequestBody,把上传的文件放入
|
||||||
|
RequestBody.create(null, uploadFile.getFileData())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,6 +6,10 @@ import lombok.Setter;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求form
|
||||||
|
* @author thc
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class RequestForm {
|
public class RequestForm {
|
||||||
|
@@ -1,5 +1,9 @@
|
|||||||
package com.gitee.sop.sdk.common;
|
package com.gitee.sop.sdk.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求方法枚举
|
||||||
|
* @author thc
|
||||||
|
*/
|
||||||
public enum RequestMethod {
|
public enum RequestMethod {
|
||||||
|
|
||||||
GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE
|
GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE
|
||||||
|
@@ -2,6 +2,7 @@ package com.gitee.sop.sdk.common;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated 已废弃,使用com.gitee.sop.sdk.common.OpenConfig
|
* @deprecated 已废弃,使用com.gitee.sop.sdk.common.OpenConfig
|
||||||
|
* @author thc
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class SdkConfig {
|
public class SdkConfig {
|
||||||
|
@@ -1,5 +1,8 @@
|
|||||||
package com.gitee.sop.sdk.common;
|
package com.gitee.sop.sdk.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author thc
|
||||||
|
*/
|
||||||
public class SopSdkConstants {
|
public class SopSdkConstants {
|
||||||
public static String DATA_SUFFIX = "_response";
|
public static String DATA_SUFFIX = "_response";
|
||||||
|
|
||||||
|
@@ -1,5 +1,8 @@
|
|||||||
package com.gitee.sop.sdk.exception;
|
package com.gitee.sop.sdk.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author thc
|
||||||
|
*/
|
||||||
public class SdkException extends RuntimeException {
|
public class SdkException extends RuntimeException {
|
||||||
|
|
||||||
private static final long serialVersionUID = -1108392076700488161L;
|
private static final long serialVersionUID = -1108392076700488161L;
|
||||||
|
@@ -31,6 +31,8 @@ import java.util.Map;
|
|||||||
* biz_content String 是 请求参数的集合,最大长度不限,除公共参数外所有请求参数都必须放在这个参数中传递,具体参照各产品快速接入文档
|
* biz_content String 是 请求参数的集合,最大长度不限,除公共参数外所有请求参数都必须放在这个参数中传递,具体参照各产品快速接入文档
|
||||||
*
|
*
|
||||||
* @param <T> 对应的Response对象
|
* @param <T> 对应的Response对象
|
||||||
|
*
|
||||||
|
* @author thc
|
||||||
*/
|
*/
|
||||||
public abstract class BaseRequest<T extends BaseResponse> {
|
public abstract class BaseRequest<T extends BaseResponse> {
|
||||||
|
|
||||||
@@ -47,6 +49,10 @@ public abstract class BaseRequest<T extends BaseResponse> {
|
|||||||
|
|
||||||
private Class<T> responseClass = (Class<T>) ClassUtil.getSuperClassGenricType(this.getClass(), 0);;
|
private Class<T> responseClass = (Class<T>) ClassUtil.getSuperClassGenricType(this.getClass(), 0);;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定义接口名称
|
||||||
|
* @return 接口名称
|
||||||
|
*/
|
||||||
protected abstract String method();
|
protected abstract String method();
|
||||||
|
|
||||||
public BaseRequest() {
|
public BaseRequest() {
|
||||||
@@ -80,7 +86,7 @@ public abstract class BaseRequest<T extends BaseResponse> {
|
|||||||
|
|
||||||
public RequestForm createRequestForm(OpenConfig openConfig) {
|
public RequestForm createRequestForm(OpenConfig openConfig) {
|
||||||
// 公共请求参数
|
// 公共请求参数
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
Map<String, String> params = new HashMap<String, String>(16);
|
||||||
params.put(openConfig.getMethodName(), this.method);
|
params.put(openConfig.getMethodName(), this.method);
|
||||||
params.put(openConfig.getFormatName(), openConfig.getFormatType());
|
params.put(openConfig.getFormatName(), openConfig.getFormatType());
|
||||||
params.put(openConfig.getCharsetName(), openConfig.getCharset());
|
params.put(openConfig.getCharsetName(), openConfig.getCharset());
|
||||||
|
@@ -16,7 +16,7 @@ import lombok.Setter;
|
|||||||
* },
|
* },
|
||||||
* "sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE"
|
* "sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE"
|
||||||
* }
|
* }
|
||||||
*
|
* @author thc
|
||||||
*/
|
*/
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
|
@@ -77,6 +77,7 @@ public abstract class BaseNCodec {
|
|||||||
* @return a String useful for debugging.
|
* @return a String useful for debugging.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("boxing") // OK to ignore boxing here
|
@SuppressWarnings("boxing") // OK to ignore boxing here
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("%s[buffer=%s, currentLinePos=%s, eof=%s, ibitWorkArea=%s, lbitWorkArea=%s, " +
|
return String.format("%s[buffer=%s, currentLinePos=%s, eof=%s, ibitWorkArea=%s, lbitWorkArea=%s, " +
|
||||||
"modulus=%s, pos=%s, readPos=%s]", this.getClass().getSimpleName(), Arrays.toString(buffer),
|
"modulus=%s, pos=%s, readPos=%s]", this.getClass().getSimpleName(), Arrays.toString(buffer),
|
||||||
|
@@ -7,6 +7,10 @@ import java.io.FileNotFoundException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件工具类
|
||||||
|
* @author thc
|
||||||
|
*/
|
||||||
public class FileUtil {
|
public class FileUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,5 +1,9 @@
|
|||||||
package com.gitee.sop.sdk.util;
|
package com.gitee.sop.sdk.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hex工具类
|
||||||
|
* @author thc
|
||||||
|
*/
|
||||||
public class HexUtil {
|
public class HexUtil {
|
||||||
private static final String ZERO = "0";
|
private static final String ZERO = "0";
|
||||||
private static final String CHARS = "0123456789ABCDEF";
|
private static final String CHARS = "0123456789ABCDEF";
|
||||||
@@ -30,7 +34,7 @@ public class HexUtil {
|
|||||||
* @return byte[]
|
* @return byte[]
|
||||||
*/
|
*/
|
||||||
public static byte[] hex2bytes(String hexString) {
|
public static byte[] hex2bytes(String hexString) {
|
||||||
if (hexString == null || hexString.equals("")) {
|
if (hexString == null || "".equalsIgnoreCase(hexString)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
hexString = hexString.toUpperCase();
|
hexString = hexString.toUpperCase();
|
||||||
|
@@ -2,6 +2,10 @@ package com.gitee.sop.sdk.util;
|
|||||||
|
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MD5工具类
|
||||||
|
* @author thc
|
||||||
|
*/
|
||||||
public class MD5Util {
|
public class MD5Util {
|
||||||
|
|
||||||
private static final String MD5 = "MD5";
|
private static final String MD5 = "MD5";
|
||||||
|
Reference in New Issue
Block a user