fix(iam): 返回加密信息

This commit is contained in:
yjz
2023-11-23 11:20:53 +08:00
parent cd8deaf96b
commit b646061cf5
3 changed files with 41 additions and 39 deletions
@@ -28,10 +28,10 @@ public class TestClient {
public static void main(String[] args) throws JsonProcessingException {
TestClient testClient = new TestClient();
// testClient.sendSchemaService(); // 字段映射接口测试
for (int i = 0; i < 1; i++) {
System.out.println(i);
testClient.sendUserCreate(i);
}
// for (int i = 0; i < 1; i++) {
// System.out.println(i);
// testClient.sendUserCreate(i);
// }
// 创建用户接口测试
// testClient.sendUserUpdate(); // 更新用户接口测试
// testClient.sendOrgCreate(); // 组织创建接口测试
@@ -39,6 +39,12 @@ public class TestClient {
// testClient.sendQueryAllOrgIdsService(); // 查询所有组织ID接口测试
// testClient.sendQueryOrgByIdService(); // 查询指定id的组织数据测试
// testClient.sendQueryUserByIdService(); // 查询指定id的用户数据测试
testClient.decryptSting("8rAKWPUwkEZ3yYLy/1TuGGkIGCYtc+MD56pShLi97OmMttoFooo5GXZ/lY4NrQ5DiWmVUX23zqDwyQqufXLZNDU+KuJO/9UonpqUlZxM91w=");
}
private void decryptSting(String encryptString) {
String decrypt = BamboocloudUtils.getPlaintext(encryptString, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
System.out.println("解密后数据:" + decrypt);
}
// 对数据解密
@@ -15,12 +15,12 @@ import com.jero.modules.docking.iam.dto.response.*;
import com.jero.modules.docking.iam.exception.IamGlobalException;
import com.jero.modules.docking.iam.po.MessageHeader;
import com.jero.modules.docking.iam.po.decrypt.AcceptDecryptPo;
import com.jero.modules.docking.iam.po.decrypt.SendPoDecryptPo;
import com.jero.modules.docking.iam.po.encrypt.AcceptEncryptPo;
import com.jero.modules.docking.iam.po.encrypt.SendPoEncryptPo;
import com.jero.modules.docking.iam.service.SyncIamService;
import com.jero.modules.docking.utils.BamboocloudUtils;
import com.jero.modules.docking.utils.DockingConstant;
import com.jero.modules.docking.utils.SHA256Util;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheEvict;
@@ -319,7 +319,7 @@ public class SyncIamController {
* 通过type字段来区分
*/
@PostMapping({"/bpmcCreate"})
public SendPoDecryptPo<BpmcResponseDto> bpmcCreate(@RequestBody AcceptDecryptPo acceptDecryptPo) throws JsonProcessingException {
public SendPoEncryptPo bpmcCreate(@RequestBody AcceptDecryptPo acceptDecryptPo) throws JsonProcessingException {
if (acceptDecryptPo == null
|| acceptDecryptPo.getMessageDecryptTabels() == null
|| acceptDecryptPo.getMessageDecryptTabels().getHeader() == null){
@@ -331,45 +331,45 @@ public class SyncIamController {
BpmcAcceptDto bpmcAcceptDto = objectMapper.readValue(acceptDecryptPo.getMessageDecryptTabels().getHeader().getData(), BpmcAcceptDto.class);
MessageHeader messageHeader = acceptDecryptPo.getMessageHeader();
BpmcResponseDto bpmcResponseDto = BpmcResponseDto.success();
if (CharSequenceUtil.isEmpty(bpmcAcceptDto.getType())){
return new SendPoDecryptPo<BpmcResponseDto>().response(
this.syncIamService.generatorReturnMessageHeader(messageHeader),
BpmcResponseDto.error("接口类型(type)未传参,请检查")
);
bpmcResponseDto.setReturnCode(DockingConstant.IAM_ERROR_RESULT_CODE);
bpmcResponseDto.setMessage("接口类型(type)未传参,请检查");
log.error(bpmcResponseDto.getMessage());
return this.syncIamService.handlerGloablEncryptResponse(messageHeader, bpmcResponseDto);
}
if (CharSequenceUtil.isEmpty(bpmcAcceptDto.getEntity())){
return new SendPoDecryptPo<BpmcResponseDto>().response(
this.syncIamService.generatorReturnMessageHeader(messageHeader),
BpmcResponseDto.error("数据实体(entity)未传参,请检查")
);
bpmcResponseDto.setReturnCode(DockingConstant.IAM_ERROR_RESULT_CODE);
bpmcResponseDto.setMessage("数据实体(entity)未传参,请检查");
log.error(bpmcResponseDto.getMessage());
return this.syncIamService.handlerGloablEncryptResponse(messageHeader, bpmcResponseDto);
}
if (CharSequenceUtil.isEmpty(bpmcAcceptDto.getAction())){
return new SendPoDecryptPo<BpmcResponseDto>().response(
this.syncIamService.generatorReturnMessageHeader(messageHeader),
BpmcResponseDto.error("操作方式(action)未传参,请检查")
);
bpmcResponseDto.setReturnCode(DockingConstant.IAM_ERROR_RESULT_CODE);
bpmcResponseDto.setMessage("操作方式(action)未传参,请检查");
log.error(bpmcResponseDto.getMessage());
return this.syncIamService.handlerGloablEncryptResponse(messageHeader, bpmcResponseDto);
}
if (CharSequenceUtil.isEmpty(bpmcAcceptDto.getSignature())){
return new SendPoDecryptPo<BpmcResponseDto>().response(
this.syncIamService.generatorReturnMessageHeader(messageHeader),
BpmcResponseDto.error("签名(signature)未传参,请检查")
);
bpmcResponseDto.setReturnCode(DockingConstant.IAM_ERROR_RESULT_CODE);
bpmcResponseDto.setMessage("签名(signature)未传参,请检查");
log.error(bpmcResponseDto.getMessage());
return this.syncIamService.handlerGloablEncryptResponse(messageHeader, bpmcResponseDto);
}
// 验证签名
// String validateSign = SHA256Util.getSHA256StrJava(bpmcAcceptDto.getEntity() + bpmcAppkey + bpmcAcceptDto.getTimestamp());
// if (!bpmcAcceptDto.getSignature().equals(validateSign)){
// return new SendPoDecryptPo<BpmcResponseDto>().response(
// this.syncIamService.generatorReturnMessageHeader(messageHeader),
// BpmcResponseDto.error("签名校验不通过,请检查")
// );
// }
String validateSign = SHA256Util.getSHA256StrJava(bpmcAcceptDto.getEntity() + bpmcAppkey + bpmcAcceptDto.getTimestamp());
if (!bpmcAcceptDto.getSignature().equals(validateSign)){
bpmcResponseDto.setReturnCode(DockingConstant.IAM_ERROR_RESULT_CODE);
bpmcResponseDto.setMessage("签名校验不通过,请检查");
log.error(bpmcResponseDto.getMessage());
return this.syncIamService.handlerGloablEncryptResponse(messageHeader, bpmcResponseDto);
}
BpmcResponseDto bpmcResponseDto = BpmcResponseDto.success();
try {
switch (bpmcAcceptDto.getType()){
// 角色
@@ -401,13 +401,9 @@ public class SyncIamController {
log.error(e.getMessage());
bpmcResponseDto = BpmcResponseDto.error(e.getMessage());
}
return new SendPoDecryptPo<BpmcResponseDto>().response(
this.syncIamService.generatorReturnMessageHeader(messageHeader),
bpmcResponseDto
);
log.info(bpmcResponseDto.getMessage());
return this.syncIamService.handlerGloablEncryptResponse(messageHeader, bpmcResponseDto);
}
private BpmcResponseDto bpmcTypeRoleResource(ObjectMapper objectMapper, BpmcAcceptDto bpmcAcceptDto, BpmcResponseDto bpmcResponseDto) throws JsonProcessingException {
List<RoleResourceDto> roleResourceDtoList = objectMapper.readValue(bpmcAcceptDto.getEntity(), new TypeReference<List<RoleResourceDto>>() {});
// 根据新增/删除调用不同的业务处理代码
@@ -7,12 +7,12 @@ public class BpmcResponseDto {
private String returnCode;
private String returnMsg;
private String message;
public static BpmcResponseDto success(){
BpmcResponseDto bpmcResponseDto = new BpmcResponseDto();
bpmcResponseDto.returnCode = "200"; // 成功时固定为200
bpmcResponseDto.returnMsg = "操作成功";
bpmcResponseDto.message = "操作成功";
return bpmcResponseDto;
}
@@ -20,7 +20,7 @@ public class BpmcResponseDto {
public static BpmcResponseDto error(String message){
BpmcResponseDto bpmcResponseDto = new BpmcResponseDto();
bpmcResponseDto.returnCode = "500"; // 失败时固定为500
bpmcResponseDto.returnMsg = message;
bpmcResponseDto.message = message;
return bpmcResponseDto;
}