|
@@ -191,6 +191,7 @@ public class DeviceController {
|
|
|
public void token(HttpServletRequest request, HttpServletResponse response){
|
|
|
String idChannel = request.getParameter("idChannel");
|
|
|
String idDevice = request.getParameter("idDevice");
|
|
|
+ String ts = request.getParameter("x-ts");
|
|
|
String sign = request.getParameter("sign");
|
|
|
|
|
|
if(StringUtils.isBlank(idChannel) || StringUtils.isBlank(idDevice) || StringUtils.isBlank(sign)){
|
|
@@ -200,16 +201,17 @@ public class DeviceController {
|
|
|
Map<String,String> param = new HashMap<>();
|
|
|
param.put("idChannel",idChannel);
|
|
|
param.put("idDevice",idDevice);
|
|
|
- String test = Encrypt.createSHA256Sign(param,signKey);
|
|
|
+ param.put("x-ts",ts);
|
|
|
+ String test = Encrypt.createHMACSHA256(param,signKey);
|
|
|
+ if (StringUtils.isBlank(ts)) {
|
|
|
+ test = Encrypt.createSHA256Sign(param,signKey);
|
|
|
+ }
|
|
|
|
|
|
if (!sign.equalsIgnoreCase(test)) {
|
|
|
HttpUtil.responseApiCode(request, response, ApiCode.SIGN_FAIL);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
Channel channel = channelService.SearchById(Long.valueOf(idChannel));
|
|
|
if(Objects.isNull(channel)){
|
|
|
HttpUtil.responseApiCode(request, response, ApiCode.CHANNEL_NOT_FOUND_ERROR);
|