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