提交 82f64b92 编写于 作者: Chongwen.jiang's avatar Chongwen.jiang

加解密接口提供方便测试,仅dev、test1环境可以正常使用

上级 6008524c
流水线 #22654 已失败 于阶段
in 0 second
...@@ -13,6 +13,9 @@ public class PropertiesConfiguration { ...@@ -13,6 +13,9 @@ public class PropertiesConfiguration {
@Value("${pica.cloud.message.url}") @Value("${pica.cloud.message.url}")
private String messageUrl; private String messageUrl;
@Value("${environment.name}")
private String environment;
public String getMessageUrl() { public String getMessageUrl() {
return messageUrl; return messageUrl;
...@@ -22,4 +25,8 @@ public class PropertiesConfiguration { ...@@ -22,4 +25,8 @@ public class PropertiesConfiguration {
this.messageUrl = messageUrl; this.messageUrl = messageUrl;
} }
public String getEnvironment(){
return environment;
}
} }
package com.pica.cloud.account.account.server.controller; package com.pica.cloud.account.account.server.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.pica.cloud.account.account.server.configuration.PropertiesConfiguration;
import com.pica.cloud.account.account.server.constants.Constants; import com.pica.cloud.account.account.server.constants.Constants;
import com.pica.cloud.account.account.server.entity.AccountUnionEntity; import com.pica.cloud.account.account.server.entity.AccountUnionEntity;
import com.pica.cloud.account.account.server.entity.EncryptEntity; import com.pica.cloud.account.account.server.entity.EncryptEntity;
...@@ -55,27 +56,40 @@ public class AutoCodeController extends AccountBaseController { ...@@ -55,27 +56,40 @@ public class AutoCodeController extends AccountBaseController {
@Autowired @Autowired
private AuthCodeService authCodeService; private AuthCodeService authCodeService;
@Autowired
private PropertiesConfiguration propertiesConfiguration;
@GetMapping("/ip") @GetMapping("/ip")
public PicaResponse getIp(HttpServletRequest request){ public PicaResponse getIp(HttpServletRequest request) {
return PicaResponse.toResponse(IPUtil.getIpAdrress(request)); return PicaResponse.toResponse(IPUtil.getIpAdrress(request));
} }
@ApiOperation("数据加密-方便测试")
@PostMapping("/encryptedParams") @PostMapping("/encryptedParams")
public String getEncryptedParams(@RequestBody BaseRequest request) throws Exception { public String getEncryptedParams(@RequestBody BaseRequest request) throws Exception {
String publicKey = "1234567890123456"; if ("dev".equals(propertiesConfiguration.getEnvironment()) ||
String content = AESUtil.aesEncrypt(JSON.toJSONString(request), publicKey); "test1".equals(propertiesConfiguration.getEnvironment())) {
String encryptKey = RSAUtil.encrypt(publicKey); String publicKey = "1234567890123456";
Map<String, Object> map = new HashMap<>(2); String content = AESUtil.aesEncrypt(JSON.toJSONString(request), publicKey);
map.put("key", encryptKey); String encryptKey = RSAUtil.encrypt(publicKey);
map.put("content", content); Map<String, Object> map = new HashMap<>(2);
return JSON.toJSONString(map); map.put("key", encryptKey);
map.put("content", content);
return JSON.toJSONString(map);
}
return null;
} }
@ApiOperation("数据解密-方便测试")
@PostMapping("/decryptedParams") @PostMapping("/decryptedParams")
public String getDecryptedParams(@RequestBody EncryptEntity entity) throws Exception { public String getDecryptedParams(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class); if("dev".equals(propertiesConfiguration.getEnvironment()) ||
return JSON.toJSONString(request); "test1".equals(propertiesConfiguration.getEnvironment())) {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
return JSON.toJSONString(request);
}
return null;
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册