开发者社区> 问答> 正文

验证URL有效性,返回字符串不匹配

java版接入isv 创建套件时回调URL提示 错误原因: 返回字符串不匹配
1. 按照 https://bbs.aliyun.com/read/291640.html?spm=5176.bbsl276.0.0.i3kF8H 这里的文档,下载了 [font="]ISV版Demo https://github.com/hetaoZhong/ding-isv-access
2. 编写修改 SuiteCallBackController:
·@ResponseBody
    @RequestMapping(value = "/suite/callback", method = { RequestMethod.POST })
    public Map<String, String> suiteCallback(
            @RequestParam(value = "signature", required = false) String signature,
            @RequestParam(value = "timestamp", required = false) String timestamp,
            @RequestParam(value = "nonce", required = false) String nonce,
            @RequestBody(required = false) JSONObject json) {
        try {
            String token = "HRSSCdingtoken";
            String aseKey = "501c90wn13nkc799vv58h1boefaezw7tuu3q8u20twz";
            String suitkey="suite4xxxxxxxxxxxxxxx";
            
            DingTalkEncryptor dingTalkEncryptor = new DingTalkEncryptor(token,aseKey, suitkey);
            String encryptMsg = json.getString("encrypt");
            String plainText = dingTalkEncryptor.getDecryptMsg(signature,timestamp, nonce, encryptMsg);
            JSONObject callbackMsgJson = JSONObject.parseObject(plainText);
            String random = callbackMsgJson.getString("Random");
            String responseEncryMsg = random;
            Map<String, String> encryptedMap = dingTalkEncryptor.getEncryptedMap(
                    responseEncryMsg,
                    System.currentTimeMillis(),
                    com.dingtalk.oapi.lib.aes.Utils.getRandomStr(8));
            return encryptedMap;
        } catch (Exception e) {
            e.printStackTrace();
            Map<String, String> errmap =new HashMap<String, String>();
            errmap.put("error", e.getMessage());
            return errmap;
        }
3.替换jdk 7的 local_policy.jar, US_export_policy.jar
4.开发者平台验证url有效性:
[attachment=122904]

提示 错误原因: 返回字符创不匹配
后台日志:

输入参数
signature: 948bcf4badf14ca07a7adc61b39a013df9888662
timestamp: 1490342383125
nonce: B26fpDKl
json:  
{
"encrypt": "PGXmyG3F7FvVm9ezRzjujy20FlMj8dP+b4r1MKW4O2rTxQpna/B942i6fSuoY1ZTTLS0hie5Si0aC4KNYT/mOZ1Upv+X1DeLGLsJ2XoE1kOVubx9ZUHQg6pw3O5IfqKZcQrCdgfYDmE/dyOKvzankNktNSuuSyxOzXnKYNtxhfPh7u5IJ04VBwcqVjn7aTbPVWyh3URZDtBCOVc7htM+kg=="
}
token: HRSSCdingtoken
aseKey: 501c90wn13nkc799vv58h1boefaezw7tuu3q8u20twz
suitkey: suite4xxxxxxxxxxxxxxx


返回的参数:
encryptedMap
{
timeStamp=1490343658926,
nonce=AGq8nznr, encrypt=F93VGofK/hTysDyjoCeO1rXa2cibpzt6EPB+3Tuol4uTYsBjz7riLeFTq4jjnEdjQedPxDOuH1k4uV5CYYdolg==, msg_signature=3c1b3cbe0c40eb99b29d1dc3dacfc09c25e6e61a
}
已经搞了一天了,求大神解决!



展开
收起
fred000 2017-03-24 16:41:57 3528 0
1 条回答
写回答
取消 提交回答
  • Re验证URL有效性,返回字符串不匹配
    解决了,要用字节流输出:
    HttpServletResponse response

    response.getWriter().print(JSON.toJSONString(encryptedMap));
    demo给出的 return encryptedMap; 在实际验证url的时候就会提示 错误原因: 返回字符创不匹配
    2017-03-24 17:09:24
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载