vod普通加密
This commit is contained in:
@@ -39,5 +39,7 @@ public class CourseCatalogueChapterVideoEntity {
|
||||
@TableField(exist = false)
|
||||
private String Mp4Url;
|
||||
@TableField(exist = false)
|
||||
private String m3u8Url;
|
||||
@TableField(exist = false)
|
||||
private String MtsHlsUriToken;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.peanut.modules.master.controller;
|
||||
|
||||
import com.aliyun.vod20170321.models.GenerateKMSDataKeyResponseBody;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.SpdbUtil;
|
||||
import com.peanut.modules.common.dao.VideoM3u8Dao;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.to.EditCourseRecordDto;
|
||||
import com.peanut.modules.common.to.ParamTo;
|
||||
@@ -35,6 +38,8 @@ public class CourseController {
|
||||
private SysCourseDirectService sysCourseDirectService;
|
||||
@Autowired
|
||||
private ShopProductService shopProductService;
|
||||
@Autowired
|
||||
private VideoM3u8Dao videoM3u8Dao;
|
||||
|
||||
|
||||
@RequestMapping("/getCourseList")
|
||||
@@ -60,6 +65,19 @@ public class CourseController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/pushM3u8Video")
|
||||
public R pushM3u8Video(@RequestBody Map<String,String> map) throws Exception {
|
||||
String s = map.get("vid");
|
||||
GenerateKMSDataKeyResponseBody kms = SpdbUtil.KMS();
|
||||
VideoM3u8Entity videoM3u8Entity = new VideoM3u8Entity();
|
||||
assert kms != null;
|
||||
videoM3u8Entity.setEdk(kms.getCiphertextBlob());
|
||||
videoM3u8Entity.setVid(s);
|
||||
videoM3u8Dao.insert(videoM3u8Entity);
|
||||
SpdbUtil.startM3u8(s,kms.getCiphertextBlob());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/getCoursedetail")
|
||||
public R getCoursedetail(@RequestBody ParamTo param){
|
||||
CourseEntity course = courseService.getById(param.getId());
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.peanut.modules.master.service.impl;
|
||||
|
||||
import com.aliyun.vod20170321.models.GetPlayInfoResponseBody;
|
||||
import com.aliyun.vod20170321.models.GetVideoPlayAuthResponse;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -109,7 +110,10 @@ public class CourseCatalogueChapterVideoServiceImpl extends ServiceImpl<CourseCa
|
||||
String playAuth = p.getBody().getPlayAuth();
|
||||
video.setPlayAuth(playAuth);
|
||||
String s = playToken.generateToken();
|
||||
GetPlayInfoResponseBody urlBody = SpdbUtil.getUrl(video.getVideo());
|
||||
String url = urlBody==null?null:urlBody.getPlayInfoList().getPlayInfo().get(0).getPlayURL()+"?MtsHlsUriToken="+s;
|
||||
video.setMtsHlsUriToken(s);
|
||||
video.setM3u8Url(url);
|
||||
}
|
||||
UserCourseVideoPositionEntity videoPosition = getVideoPosition(video, uId);
|
||||
video.setUserCourseVideoPositionEntity(videoPosition);
|
||||
|
||||
@@ -218,6 +218,14 @@ public class CourseController {
|
||||
return R.ok().put("result",decryptKMSDataKeyResponseBody);
|
||||
}
|
||||
|
||||
@RequestMapping("/mytt2")
|
||||
public R mytt2(@RequestBody Map<String,String> map){
|
||||
GetPlayInfoResponseBody urlbody = SpdbUtil.getUrl(map.get("vid"));
|
||||
String url = urlbody==null?null:urlbody.getPlayInfoList().getPlayInfo().get(0).getPlayURL();
|
||||
return R.ok().put("result",url);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/ttt")
|
||||
@SneakyThrows
|
||||
public R ttt(){
|
||||
|
||||
@@ -1,20 +1,39 @@
|
||||
package com.peanut.modules.sys.controller;
|
||||
|
||||
import com.aliyun.vod20170321.models.DecryptKMSDataKeyResponseBody;
|
||||
import com.peanut.common.utils.PlayToken;
|
||||
import com.peanut.common.utils.SpdbUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/sys/vodAli")
|
||||
public class VodAliController {
|
||||
@Autowired
|
||||
private PlayToken playToken;
|
||||
|
||||
@GetMapping("/vodAliVideoRe")
|
||||
public String vodAliVideoRe(@RequestParam("CipherText") String cipherText,
|
||||
@RequestParam("MtsHlsUriToken") String mtsHlsUriToken){
|
||||
|
||||
@RequestMapping("/vodAliVideoRe")
|
||||
public void vodAliVideoRe(@RequestBody Map<String,Object> map){
|
||||
boolean validRe = false;
|
||||
try {
|
||||
validRe = playToken.validateToken(mtsHlsUriToken);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (!validRe) {
|
||||
return "Illegal access";
|
||||
}
|
||||
if (null == cipherText)
|
||||
return "Illegal access";
|
||||
|
||||
DecryptKMSDataKeyResponseBody decryptKMSDataKeyResponseBody = SpdbUtil.enKMS(cipherText);
|
||||
return decryptKMSDataKeyResponseBody.getPlaintext();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user