/**url中的签名**/
String msgSignature = request.getParameter("signature");
/**url中的时间戳**/
String timeStamp = request.getParameter("timestamp");
/**url中的随机字符串**/
String nonce = request.getParameter("nonce");
/**对encrypt进行解密**/
DingTalkEncryptor dingTalkEncryptor = null;
try {
dingTalkEncryptor = new DingTalkEncryptor(GlobalConstant.ding_token, GlobalConstant.ding_aes_key, GlobalConstant.ding_CorpID);
//dingTalkEncryptor = new DingTalkEncryptor("123456", "4g5j64qlyl3zvetqxz5jiocdr586fn2zvjpa8zls3ij", "suite4xxxxxxxxxxxxxxx");
/**post数据包数据中的加密数据**/
ServletInputStream sis = request.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(sis));
String line = null;
StringBuilder sb = new StringBuilder();
while((line = br.readLine())!=null){
sb.append(line);
}
System.out.println("sb:"+sb.toString());
JSONObject jsonEncrypt = JSONObject.parseObject(sb.toString());
String encrypt = jsonEncrypt.getString("encrypt");
if(encrypt!=null && !"".equals(encrypt)){
//对于DingTalkEncryptor的第三个参数,ISV进行配置的时候传对应套件的SUITE_KEY,普通企业传Corpid
System.out.println("msgSignature:"+msgSignature+";timeStamp:"+timeStamp+";nonce:"+nonce);
System.out.println("encrypt:"+encrypt);
String plainText = dingTalkEncryptor.getDecryptMsg(msgSignature, timeStamp, nonce, encrypt);
JSONObject plainTextJson = JSONObject.parseObject(plainText);
String eventType = plainTextJson.getString("EventType");
System.out.println("eventType:"+eventType);
switch (eventType){
case "bpms_instance_change"://流程实例监控 "processInstanceId": "ad253df6-e175caf-68085c60ba8a",
System.out.println("Instance"+plainTextJson.getString("title")+":"+plainTextJson.getString("bizCategoryId")+":"+plainTextJson.getString("type")+":"+plainTextJson.getString("staffId"));
break;
case "bpms_task_change"://流程实例监控 "processInstanceId": "ad253df6-e175caf-68085c60ba8a",
System.out.println("Task"+plainTextJson.getString("title")+":"+plainTextJson.getString("bizCategoryId")+":"+plainTextJson.getString("type")+":"+plainTextJson.getString("staffId"));
break;
case "check_url":
{
System.out.println("check_url");
break;
}
default : //do something
System.out.println("bpms_instance_change Errrrrrrrrrrrrror");
break;
}
}
/**对返回信息进行加密**/
long timeStampLong = Long.parseLong(timeStamp);
Map<String,String> jsonMap = null;
try {
jsonMap = dingTalkEncryptor.getEncryptedMap("success", timeStampLong, nonce);
} catch (DingTalkEncryptException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
JSONObject json = new JSONObject();
json.putAll(jsonMap);
response.getWriter().append(json.toString());
} catch (Exception e) {
e.printStackTrace();
}
上面是回调接口的代码,首次注册的时候已经打印check_url并且返回了加密的“”success“”字符串,但是我在钉钉中发起流程,回调接口并没有监控流程事件,求大神指教指教 哪里出现问题了
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。