|
@@ -5,20 +5,21 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.zhiqiyun.open.core.video.VideoDockingService;
|
|
import com.zhiqiyun.open.core.video.VideoDockingService;
|
|
|
import com.zhiqiyun.open.exception.ServiceException;
|
|
import com.zhiqiyun.open.exception.ServiceException;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import okhttp3.FormBody;
|
|
|
|
|
-import okhttp3.OkHttpClient;
|
|
|
|
|
-import okhttp3.Request;
|
|
|
|
|
-import okhttp3.Response;
|
|
|
|
|
|
|
+import okhttp3.*;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.data.redis.core.BoundValueOperations;
|
|
import org.springframework.data.redis.core.BoundValueOperations;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
+import javax.net.ssl.*;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.rmi.ServerException;
|
|
import java.rmi.ServerException;
|
|
|
|
|
+import java.security.SecureRandom;
|
|
|
|
|
+import java.security.cert.CertificateException;
|
|
|
|
|
+import java.security.cert.X509Certificate;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
@@ -31,9 +32,9 @@ import java.util.concurrent.TimeUnit;
|
|
|
@Service
|
|
@Service
|
|
|
public class VideoDockingServiceImpl implements VideoDockingService {
|
|
public class VideoDockingServiceImpl implements VideoDockingService {
|
|
|
|
|
|
|
|
- private final static String USER_NAME = "";
|
|
|
|
|
- private final static String PASSWORD = "";
|
|
|
|
|
- private final static String URI = "";
|
|
|
|
|
|
|
+ private final static String USER_NAME = "duijie";
|
|
|
|
|
+ private final static String PASSWORD = "Huawei@12#$";
|
|
|
|
|
+ private final static String URI = "https://172.169.12.21:18531";
|
|
|
private final static String RESULT_CODE = "resultCode";
|
|
private final static String RESULT_CODE = "resultCode";
|
|
|
|
|
|
|
|
private final static String VIDEO_JSESSIONID_TOKEN = "VIDEO_JSESSIONID_TOKEN";
|
|
private final static String VIDEO_JSESSIONID_TOKEN = "VIDEO_JSESSIONID_TOKEN";
|
|
@@ -41,7 +42,7 @@ public class VideoDockingServiceImpl implements VideoDockingService {
|
|
|
@Resource
|
|
@Resource
|
|
|
private RedisTemplate<String, String> redisTemplate;
|
|
private RedisTemplate<String, String> redisTemplate;
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
|
|
+ @Resource
|
|
|
private OkHttpClient okHttpClient;
|
|
private OkHttpClient okHttpClient;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -54,7 +55,12 @@ public class VideoDockingServiceImpl implements VideoDockingService {
|
|
|
paramValues.put("password", PASSWORD);
|
|
paramValues.put("password", PASSWORD);
|
|
|
|
|
|
|
|
Response response = okHttpPost("/loginInfo/login/v1.0", paramValues);
|
|
Response response = okHttpPost("/loginInfo/login/v1.0", paramValues);
|
|
|
- analysisRequestSuccess(response);
|
|
|
|
|
|
|
+ log.info(JSONObject.toJSONString(response));
|
|
|
|
|
+// analysisRequestSuccess(response);
|
|
|
|
|
+ List<String> cookies = response.headers().values("Set-Cookie");
|
|
|
|
|
+ cookies.forEach(s -> {
|
|
|
|
|
+ log.info("name:{}", s);
|
|
|
|
|
+ });
|
|
|
token = response.header("Set-Cookie");
|
|
token = response.header("Set-Cookie");
|
|
|
log.info("用户登录TOKEN:{}", token);
|
|
log.info("用户登录TOKEN:{}", token);
|
|
|
if (StringUtils.isNotBlank(token)) {
|
|
if (StringUtils.isNotBlank(token)) {
|
|
@@ -72,6 +78,15 @@ public class VideoDockingServiceImpl implements VideoDockingService {
|
|
|
analysisRequestSuccess(response);
|
|
analysisRequestSuccess(response);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void loadDeviceList() throws IOException {
|
|
|
|
|
+ Map<String, String> paramValues = new HashMap<>(1);
|
|
|
|
|
+ paramValues.put("Cookie", getValidToken());
|
|
|
|
|
+ Response response = okHttpPost("/device/deviceList/v1.0?deviceType=33&fromIndex=1&toIndex=10", paramValues);
|
|
|
|
|
+ analysisRequestSuccess(response);
|
|
|
|
|
+ log.info("获取到的设备列表:" + Objects.requireNonNull(response.body()).string());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 统一POST请求方法
|
|
* 统一POST请求方法
|
|
|
*
|
|
*
|
|
@@ -88,7 +103,9 @@ public class VideoDockingServiceImpl implements VideoDockingService {
|
|
|
paramValues.forEach(formBuilder::add);
|
|
paramValues.forEach(formBuilder::add);
|
|
|
|
|
|
|
|
Request.Builder builder = new Request.Builder();
|
|
Request.Builder builder = new Request.Builder();
|
|
|
- builder.url(String.format("%s" + uri, URI));
|
|
|
|
|
|
|
+ String url = String.format("%s" + uri, URI);
|
|
|
|
|
+ log.info("URL:{}", url);
|
|
|
|
|
+ builder.url(url);
|
|
|
builder.header("Content-Type", "application/json;charset=UTF-8");
|
|
builder.header("Content-Type", "application/json;charset=UTF-8");
|
|
|
if (StringUtils.isNotBlank(cookie)) {
|
|
if (StringUtils.isNotBlank(cookie)) {
|
|
|
builder.header("Cookie", cookie);
|
|
builder.header("Cookie", cookie);
|