mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-06 17:36:47 +08:00
视频进行工号验证
This commit is contained in:
@@ -59,7 +59,7 @@ public class CourseWareApi extends ApiBaseController {
|
||||
|
||||
/**
|
||||
* 资源地址的加密,返回加密后的地址
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param cfid 资源地址的id
|
||||
@@ -94,14 +94,16 @@ public class CourseWareApi extends ApiBaseController {
|
||||
|
||||
/**
|
||||
* 获取资源,在header中保存
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping("/resource")
|
||||
public JsonResponse<String> getVideo(HttpServletRequest request, HttpServletResponse response, String sign,
|
||||
@CookieValue String token) throws Exception {
|
||||
@CookieValue(name = "token",required = false)String token
|
||||
) throws Exception {
|
||||
|
||||
if (StringUtils.isBlank(sign)) {
|
||||
return badRequest("非法请求");
|
||||
}
|
||||
@@ -120,12 +122,18 @@ public class CourseWareApi extends ApiBaseController {
|
||||
if(!has) {
|
||||
return badRequest("页面不存在");
|
||||
}
|
||||
// String token = request.getHeader("Xboe-Access-Token");
|
||||
// if (StringUtils.isEmpty(token)) {
|
||||
// token = request.getHeader("token");
|
||||
// }
|
||||
// 读取cookies中的时间
|
||||
String cookieTime = getSignTimeCookie(request);
|
||||
if (StringUtils.isBlank(cookieTime)) {
|
||||
return badRequest("不支持的请求");
|
||||
}
|
||||
// String cookieTime = getSignTimeCookie(request);
|
||||
// if (StringUtils.isBlank(cookieTime)) {
|
||||
// return badRequest("不支持的请求");
|
||||
// }
|
||||
String userInfo = CacheName.NAME_INFO + ":"+ token;
|
||||
log.info("请求头里的token值::"+token);
|
||||
log.info("从 Redis 获取的userInfo:"+userInfo);
|
||||
Object o = redisTemplate.opsForValue().get(userInfo);
|
||||
if (o == null) {
|
||||
log.error("从 Redis 获取的值为 null ,", userInfo);
|
||||
@@ -152,12 +160,15 @@ public class CourseWareApi extends ApiBaseController {
|
||||
return badRequest("验证错误");
|
||||
}
|
||||
|
||||
// String time = signStr.substring(0, signStr.indexOf("/"));// 时间字符中,long
|
||||
// String workNum = signStr.substring(2, signStr.indexOf("/"));// 工号,long
|
||||
String[] array = signStr.split("/");
|
||||
String time = signStr.substring(0, signStr.indexOf("/"));// 时间字符中,long
|
||||
String[] split = signStr.split("/");
|
||||
String cfid = signStr.substring(index+1);// 文件路径
|
||||
if (!array[2].equals(userNo)){
|
||||
return badRequest("token验证失败");
|
||||
log.info("解密后的字符串:"+signStr);
|
||||
|
||||
log.info("workNum工号对比:"+split[2]);
|
||||
log.info("userNo工号对比:"+userNo);
|
||||
if (!split[2].equals(userNo)){
|
||||
return badRequest("token验证失效");
|
||||
}
|
||||
// if (!time.equals(cookieTime)) {
|
||||
// log.info("请求头时间和解析后的时间对比:"+"解析时间:"+time+" 请求头时间:"+cookieTime);
|
||||
@@ -190,7 +201,7 @@ public class CourseWareApi extends ApiBaseController {
|
||||
|
||||
/**
|
||||
* 读取cookies值
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user