vod普通加密

This commit is contained in:
wangjinlei
2024-07-19 09:46:02 +08:00
parent 10796fe6c6
commit 2228ed148d
7 changed files with 122 additions and 13 deletions

View File

@@ -25,11 +25,7 @@ import java.net.URI;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Slf4j
@Service
public class HlsDecryptService {
@Autowired
private PlayToken playToken;
private static DefaultAcsClient client;
static {
@@ -79,7 +75,7 @@ public class HlsDecryptService {
String token = getMtsHlsUriToken(httpExchange);
boolean validRe = false;
try {
validRe = playToken.validateToken(token);
// validRe = playToken.validateToken(token);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -201,7 +197,6 @@ public class HlsDecryptService {
// System.out.println("hls decrypt server started");
}
@PostConstruct
public void init() throws IOException {
// HlsDecryptService server = new HlsDecryptService();
serviceBootStrap();

View File

@@ -1,5 +1,6 @@
package com.peanut.common.utils;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.tea.TeaException;
import com.aliyun.teautil.models.RuntimeOptions;
import com.aliyun.vod20170321.Client;
@@ -150,6 +151,68 @@ public class SpdbUtil {
}
public static void startM3u8(String vid,String edk){
com.aliyun.vod20170321.models.SubmitTranscodeJobsRequest submitTranscodeJobsRequest = new com.aliyun.vod20170321.models.SubmitTranscodeJobsRequest();
submitTranscodeJobsRequest.setVideoId(vid);
submitTranscodeJobsRequest.setTemplateGroupId("d346d2609a058b9dfd9b8bb392175721");
JSONObject jsonObject = new JSONObject();
jsonObject.put("CipherText",edk);
jsonObject.put("DecryptKeyUri","http://59.110.212.44:8099?CipherText="+edk);
jsonObject.put("KeyServiceType","KMS");
submitTranscodeJobsRequest.setEncryptConfig(jsonObject.toJSONString());
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try {
// 复制代码运行请自行打印 API 的返回值
client.submitTranscodeJobsWithOptions(submitTranscodeJobsRequest, runtime);
} catch (TeaException error) {
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
// 错误 message
System.out.println(error.getMessage());
// 诊断地址
System.out.println(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message);
} catch (Exception _error) {
TeaException error = new TeaException(_error.getMessage(), _error);
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
// 错误 message
System.out.println(error.getMessage());
// 诊断地址
System.out.println(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message);
}
}
public static GetPlayInfoResponseBody getUrl(String vid){
com.aliyun.vod20170321.models.GetPlayInfoRequest getPlayInfoRequest = new com.aliyun.vod20170321.models.GetPlayInfoRequest();
getPlayInfoRequest.setVideoId(vid);
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try {
// 复制代码运行请自行打印 API 的返回值
GetPlayInfoResponse playInfoWithOptions = client.getPlayInfoWithOptions(getPlayInfoRequest, runtime);
GetPlayInfoResponseBody body = playInfoWithOptions.getBody();
return body;
} catch (TeaException error) {
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
// 错误 message
System.out.println(error.getMessage());
// 诊断地址
System.out.println(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message);
return null;
} catch (Exception _error) {
TeaException error = new TeaException(_error.getMessage(), _error);
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
// 错误 message
System.out.println(error.getMessage());
// 诊断地址
System.out.println(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message);
return null;
}
}
public static AssumeRoleResponse assumeRole() throws ClientException {