mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
秘钥管理改造,服务端返回sign
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package com.gitee.sop.gateway.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author tanghc
|
||||
*/
|
||||
@Data
|
||||
public class IsvDetailDTO {
|
||||
|
||||
/** appKey, 数据库字段:app_key */
|
||||
private String appKey;
|
||||
|
||||
/** 0启用,1禁用, 数据库字段:status */
|
||||
private Byte status;
|
||||
|
||||
// keys
|
||||
|
||||
/** secret, 数据库字段:secret */
|
||||
private String secret;
|
||||
|
||||
/** 开发者生成的公钥, 数据库字段:public_key_isv */
|
||||
private String publicKeyIsv;
|
||||
|
||||
/** 平台生成的私钥, 数据库字段:private_key_platform */
|
||||
private String privateKeyPlatform;
|
||||
|
||||
private Byte signType;
|
||||
}
|
@@ -1,14 +1,12 @@
|
||||
package com.gitee.sop.gateway.manager;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.gitee.fastmybatis.core.query.Query;
|
||||
import com.gitee.sop.gateway.entity.IsvInfo;
|
||||
import com.gitee.sop.gateway.entity.IsvDetailDTO;
|
||||
import com.gitee.sop.gateway.mapper.IsvInfoMapper;
|
||||
import com.gitee.sop.gatewaycommon.bean.ChannelMsg;
|
||||
import com.gitee.sop.gatewaycommon.bean.IsvDefinition;
|
||||
import com.gitee.sop.gatewaycommon.manager.ZookeeperContext;
|
||||
import com.gitee.sop.gatewaycommon.secret.CacheIsvManager;
|
||||
import com.gitee.sop.gatewaycommon.secret.SecretContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -16,7 +14,6 @@ import org.springframework.core.env.Environment;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @author tanghc
|
||||
@@ -33,14 +30,11 @@ public class DbIsvManager extends CacheIsvManager {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
List<IsvInfo> isvInfoList = isvInfoMapper.list(new Query());
|
||||
Function<IsvDefinition, String> secretGetter = SecretContext.getSecretGetter();
|
||||
List<IsvDetailDTO> isvInfoList = isvInfoMapper.listIsvDetail();
|
||||
isvInfoList.stream()
|
||||
.forEach(isvInfo -> {
|
||||
IsvDefinition isvDefinition = new IsvDefinition();
|
||||
BeanUtils.copyProperties(isvInfo, isvDefinition);
|
||||
String secret = secretGetter.apply(isvDefinition);
|
||||
isvDefinition.setSecret(secret);
|
||||
this.getIsvCache().put(isvDefinition.getAppKey(), isvDefinition);
|
||||
});
|
||||
}
|
||||
|
@@ -1,11 +1,26 @@
|
||||
package com.gitee.sop.gateway.mapper;
|
||||
|
||||
import com.gitee.fastmybatis.core.mapper.CrudMapper;
|
||||
import com.gitee.sop.gateway.entity.IsvDetailDTO;
|
||||
import com.gitee.sop.gateway.entity.IsvInfo;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author tanghc
|
||||
*/
|
||||
public interface IsvInfoMapper extends CrudMapper<IsvInfo, Long> {
|
||||
|
||||
@Select("SELECT " +
|
||||
" t.app_key appKey " +
|
||||
" ,t.status " +
|
||||
" ,t2.sign_type signType " +
|
||||
" ,t2.secret " +
|
||||
" ,t2.public_key_isv publicKeyIsv " +
|
||||
" ,t2.private_key_platform privateKeyPlatform " +
|
||||
"FROM isv_info t " +
|
||||
"INNER JOIN isv_keys t2 ON t.app_key = t2.app_key")
|
||||
List<IsvDetailDTO> listIsvDetail();
|
||||
}
|
||||
|
Reference in New Issue
Block a user