mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
update 联联
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
@@ -181,7 +182,7 @@ public class SpringBootTestController {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLianLian(){
|
||||
public void testLianLian() throws UnsupportedEncodingException {
|
||||
// 获取令牌
|
||||
// LianLianGetTokenDTO dto = new LianLianGetTokenDTO();
|
||||
// dto.setOperatorId("MA1JLFUU8");
|
||||
@@ -189,6 +190,45 @@ public class SpringBootTestController {
|
||||
String token = lianLianService.getToken("", "MA1JLFUU8", "fGwLsxW1HdzLw7jp");
|
||||
System.out.println("token:" + token);
|
||||
|
||||
String operatorId = "I4XLPQPV";
|
||||
String operatorSecret = "3DSBTWHVIC6KVCKI";
|
||||
// 请求data
|
||||
Map<String, String> data = new HashMap<>();
|
||||
data.put("OperatorID", operatorId);
|
||||
data.put("OperatorSecret", operatorSecret);
|
||||
String dataJson = JSONUtil.toJsonStr(data);
|
||||
|
||||
// 加密
|
||||
byte[] encryptText = Cryptos.aesEncrypt(dataJson.getBytes("UTF-8"),
|
||||
operatorSecret.getBytes(), operatorSecret.getBytes());
|
||||
String strData = Encodes.encodeBase64(encryptText);
|
||||
String timeStamp = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, new Date());
|
||||
Map<String, String> request = new LinkedHashMap<>();
|
||||
request.put("OperatorID", operatorId);
|
||||
request.put("Data", strData);
|
||||
request.put("TimeStamp", timeStamp);
|
||||
request.put("Seq", "0001");
|
||||
|
||||
// 生成签名
|
||||
String sig = GBSignUtils.sign(request, operatorSecret);
|
||||
request.put("Sig", sig);
|
||||
|
||||
QueryTokenDTO dto = new QueryTokenDTO();
|
||||
dto.setOperatorID(operatorId);
|
||||
dto.setData(strData);
|
||||
dto.setTimeStamp(timeStamp);
|
||||
dto.setSeq("0001");
|
||||
dto.setSig(sig);
|
||||
Map<String, String> map = lianLianService.generateToken(dto);
|
||||
String data1 = map.get("Data");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(data1),
|
||||
operatorSecret.getBytes(), operatorSecret.getBytes());
|
||||
String dataStr = new String(plainText, "UTF-8");
|
||||
Map<String, String> resultMap = (Map<String, String>) JSON.parse(dataStr);
|
||||
token = resultMap.get("AccessToken");
|
||||
System.out.println("解密后token:" + token);
|
||||
|
||||
|
||||
// LianLianPushStationInfoDTO dto1 = LianLianPushStationInfoDTO.builder()
|
||||
// .OperatorID("MA1JLFUU8")
|
||||
|
||||
Reference in New Issue
Block a user