TA的每日心情 | 无聊 3 天前 |
---|
签到天数: 530 天 连续签到: 2 天 [LV.9]测试副司令
|
1测试积点
问题:
- public static void testPassInfo(){
- try {
- Map<String,String> map=new HashMap<String, String>();
- // String url="http://localhost:8087/service/dataService/invoke";
- //String url="http://192.168.1.2:8081/dataService/invoke";
- String url="http://117.78.49.154:18089/UdataService/dataService/invoke";
- String tradeNo="411121199011074513"; //请求编号 ,要求每次不同,长度位22
-
- String aesKey= AESUtil.getAutoCreateAESKey();
- System.out.println("aesKey:"+aesKey);
- String bodyInfo="{\n" +
- " \"name\": \"关星\",\n" +
- " \"idno\": \"411121199011074511\",\n" +
- " \"idtype\": \"IDENTITY_CARD\",\n" +
- " \"mobile\": \"18616777353\",\n" +
- " \"cardno\": \"6212261001037530688\"\n" +
- "}";
- String headInfo="{\n" +
- " \"merchantCode\": \""+MERCHANTCODE+"\",\n" +
- " \"loginName\": \""+LOGINNAME+"\",\n" +
- " \"password\": \""+ RSAUtil.encryptByPublicKey(PASSWORD,PUBKEY)+"\",\n" +
- " \"tradeNo\": \""+tradeNo+"\",\n" +
- " \"serviceCode\": \""+SERVICECODE+"\",\n" +
- " \"aesKey\": \""+ RSAUtil.encryptByPublicKey(aesKey,PUBKEY)+"\"\n" +
- "}";
- bodyInfo=AESUtil.encryptByAES(bodyInfo,aesKey);
- String data="{\"body\":\""+bodyInfo+"\",\"head\":"+headInfo+"}";
- System.out.println("data:"+data);
- map.put("data",data);
- String str=sendPostSSLRequest(url,map,"UTF-8");
- System.out.println("加解密测试str:"+str);
- //解密body信息
- JSONObject strJson=JSONObject.parseObject(str);
- String bodyAesInfo=strJson.getString("body");
- JSONObject headJson=JSONObject.parseObject(strJson.getString("head"));
- aesKey=RSAUtil.decryptByPublicKey(headJson.getString("aesKey"),PUBKEY);
- System.out.println("bodyAesInfo:"+bodyAesInfo+",aesKey:"+aesKey);
- bodyAesInfo=AESUtil.decryptByAES(bodyAesInfo,aesKey);
- System.out.println("bodyAesInfo:"+bodyAesInfo);
- } catch (Exception e) {
- //异常根据实际情况处理
- e.printStackTrace();
- }
- }
复制代码
|
|