|
@@ -262,6 +262,72 @@ public class DhServiceImpl implements IDhService {
|
|
|
RedisUtils.deleteObject(key);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getTestToken() {
|
|
|
+ Map<String, Object> token = RedisUtils.getCacheMap(Constants.CACHE_DH_TEST_TOKEN);
|
|
|
+ if (token.isEmpty()) {
|
|
|
+ token = new HashMap<>();
|
|
|
+ // 从大华接口获取token
|
|
|
+ JSONObject jsonOne = new JSONObject();
|
|
|
+ String account = "system";
|
|
|
+ jsonOne.set("userName", account);
|
|
|
+ jsonOne.set("clientType", "winpc");
|
|
|
+ String postOne = "";
|
|
|
+ try {
|
|
|
+ postOne = HttpUtil.post("http://10.55.134.30:8314/videoService/accounts/authorize", jsonOne.toString());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("【视频测试】大华接口请求异常,账号:{}:{}", account, e.getMessage());
|
|
|
+ throw new ServiceException("【视频测试】大华融合通信平台无法连接,请联系大华融合通信平台维护人员检查!");
|
|
|
+ }
|
|
|
+ JSONObject postOneJson = JSONUtil.parseObj(postOne);
|
|
|
+ log.info("【视频测试】大华创建会话,,账号:{}的返回结果:{}", account, postOneJson);
|
|
|
+ if (postOneJson.containsKey("realm")) {
|
|
|
+ String randomKey = postOneJson.getStr("randomKey");
|
|
|
+ String realm = postOneJson.getStr("realm");
|
|
|
+ String encryptType = postOneJson.getStr("encryptType");
|
|
|
+ // 第二次交互
|
|
|
+ String password = "Admin123";
|
|
|
+ String signature = SecureUtil.md5(
|
|
|
+ SecureUtil.md5(account + ":" + realm + ":" +
|
|
|
+ SecureUtil.md5(
|
|
|
+ SecureUtil.md5(
|
|
|
+ account +
|
|
|
+ SecureUtil.md5(password)))) + ":" + randomKey);
|
|
|
+ jsonOne.set("signature", signature);
|
|
|
+ jsonOne.set("randomKey", randomKey);
|
|
|
+ jsonOne.set("encryptType", encryptType);
|
|
|
+ jsonOne.set("pid", 2548);
|
|
|
+ jsonOne.set("expiredTime", 120);
|
|
|
+ String postTwo = HttpUtil.post("http://10.55.134.30:8314/videoService/accounts/authorize", jsonOne.toString());
|
|
|
+ JSONObject postTwoJson = JSONUtil.parseObj(postTwo);
|
|
|
+ if (postTwoJson.containsKey("token")) {
|
|
|
+ String tokenStr = postTwoJson.getStr("token");
|
|
|
+ int duration = postTwoJson.getInt("duration");
|
|
|
+ String userId = postTwoJson.getStr("userId");
|
|
|
+ token.put("userId", userId);
|
|
|
+ token.put("token", tokenStr);
|
|
|
+ token.put("userName", postTwoJson.getStr("userName"));
|
|
|
+ log.info("【视频测试】大华创建会话,账号:{}的过期时间:{}", account, duration);
|
|
|
+ log.info("【视频测试】大华创建会话,账号:{}的Token:{}", account, token);
|
|
|
+ if (ObjectUtil.isEmpty(duration)) {
|
|
|
+ duration = 120;
|
|
|
+ }
|
|
|
+ // 存入redis缓存
|
|
|
+ RedisUtils.setCacheMap(Constants.CACHE_DH_TEST_TOKEN, token);
|
|
|
+ RedisUtils.expire(Constants.CACHE_DH_TEST_TOKEN, Convert.toInt(duration), TimeUnit.SECONDS);
|
|
|
+ } else {
|
|
|
+ log.error("【视频测试】大华,账号:{}第二次创建会话失败:{}", account, postTwoJson);
|
|
|
+ if ("user is repeated landing".equals(postTwoJson.getStr("message"))) {
|
|
|
+ // 说明已经登录过,那么退出,重新获取
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("【视频测试】大华,账号:{}第一次创建会话失败:{}", account, postOneJson);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return token;
|
|
|
+ }
|
|
|
+
|
|
|
private JSONArray getList(Map<String, Object> param) {
|
|
|
param.put("nodeType", 1);
|
|
|
param.put("typeCode", "01;0;ALL;ALL");
|