|
@@ -80,7 +80,7 @@ public class DhServiceImpl implements IDhService {
|
|
|
String realm = postOneJson.getStr("realm");
|
|
|
String encryptType = postOneJson.getStr("encryptType");
|
|
|
// 第二次交互
|
|
|
- String password = "dh123456";
|
|
|
+ String password = "Dahua@4002";
|
|
|
String signature = SecureUtil.md5(
|
|
|
SecureUtil.md5(userName + ":" + realm + ":" +
|
|
|
SecureUtil.md5(
|
|
@@ -121,17 +121,17 @@ public class DhServiceImpl implements IDhService {
|
|
|
*
|
|
|
* @param token
|
|
|
*/
|
|
|
- public void tokenKeepalive(String token, int duration) {
|
|
|
+ public void tokenKeepalive(String token, int duration, String tokenKey) {
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.set("token", token);
|
|
|
json.set("duration", duration);
|
|
|
- String put = HttpRequest.put(keepaliveUrl).timeout(-1).body(json.toString()).execute().body();
|
|
|
- JSONObject putJson = JSONUtil.parseObj(put);
|
|
|
- if (putJson.getInt("code") == 200) {
|
|
|
+ String put = HttpRequest.put(keepaliveUrl).header("X-Subject-Token", token).contentType("application/json").timeout(-1).body(json.toString()).execute().body();
|
|
|
+
|
|
|
+ if ("".equals(put)) {
|
|
|
// 存入redis缓存
|
|
|
- RedisUtils.setCacheObject(Constants.CACHE_DH_TOKEN, token, duration, TimeUnit.SECONDS);
|
|
|
+ RedisUtils.expire(tokenKey, Convert.toInt(duration), TimeUnit.SECONDS);
|
|
|
} else {
|
|
|
- log.info("保活失败:{}。重新获取", putJson);
|
|
|
+ log.info("保活失败:{}。入参:{}", put, json);
|
|
|
// authorize();
|
|
|
}
|
|
|
}
|
|
@@ -215,7 +215,7 @@ public class DhServiceImpl implements IDhService {
|
|
|
String realm = postOneJson.getStr("realm");
|
|
|
String encryptType = postOneJson.getStr("encryptType");
|
|
|
// 第二次交互
|
|
|
- String password = "huashe123";
|
|
|
+ String password = "Dahua@4002";
|
|
|
String signature = SecureUtil.md5(
|
|
|
SecureUtil.md5(account + ":" + realm + ":" +
|
|
|
SecureUtil.md5(
|