防篡改问题修复
This commit is contained in:
parent
8de5f463f8
commit
9d76e73a49
@ -134,7 +134,6 @@ public class CommonUtil {
|
|||||||
buf.append(Integer.toHexString(i));
|
buf.append(Integer.toHexString(i));
|
||||||
}
|
}
|
||||||
return Base64.encodeBase64String(buf.toString().getBytes(StandardCharsets.UTF_8));
|
return Base64.encodeBase64String(buf.toString().getBytes(StandardCharsets.UTF_8));
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
return Strings.EMPTY;
|
return Strings.EMPTY;
|
||||||
|
|||||||
@ -95,12 +95,12 @@ public class CryptoUtils {
|
|||||||
// 示例用法
|
// 示例用法
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
String appKey = "d68397c4fb671bc024e24e1964b067cc35388818";
|
String appKey = "ae1d3f9a-3b4c-4d6e-7f8a-9b0c1d2e3f6b";
|
||||||
String sign = "d68397c4fb671bc024e24e1964b067cc35388818";
|
String appSecret = "H2tH3gJ4kL2sP2wR8yU0iO4pL7cV2bN4c";
|
||||||
String storeId = "1";
|
String storeId = "1";
|
||||||
|
|
||||||
// 打包加密
|
// 打包加密
|
||||||
String encrypted = packAndEncrypt(appKey, sign, storeId);
|
String encrypted = packAndEncrypt(appKey, appSecret, storeId);
|
||||||
System.out.println("加密结果: " + encrypted);
|
System.out.println("加密结果: " + encrypted);
|
||||||
|
|
||||||
// 解密解包
|
// 解密解包
|
||||||
|
|||||||
@ -31,7 +31,16 @@ public class WebController {
|
|||||||
public void synBrand(){
|
public void synBrand(){
|
||||||
log.info("synBrand");
|
log.info("synBrand");
|
||||||
// sxDataService.getAppSign();
|
// sxDataService.getAppSign();
|
||||||
sxDataService.SyncBranchList(new DataBaseInfo(),sxDataService.getCommentModel());
|
CommentModel commentModel= sxDataService.getCommentModel();
|
||||||
|
DataBaseInfo dataBaseInfo=sxDataService.getDataBaseInfo(commentModel);
|
||||||
|
if(dataBaseInfo==null){
|
||||||
|
log.error("syncGoods dataBaseInfo is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(ObjectUtil.isNotEmpty(dataBaseInfo.getRefreshTime())){
|
||||||
|
commentModel.setSyncTime(DateUtil.formatDateTime(dataBaseInfo.getRefreshTime()));
|
||||||
|
}
|
||||||
|
sxDataService.SyncBranchList(dataBaseInfo,sxDataService.getCommentModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/syncCategory")
|
@RequestMapping("/syncCategory")
|
||||||
|
|||||||
@ -75,7 +75,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void SyncCategory(DataBaseInfo dataBaseInfo, CommentModel commentModel) {
|
public void SyncCategory(DataBaseInfo dataBaseInfo, CommentModel commentModel) {
|
||||||
dataBaseInfo= getDataBaseInfo(commentModel);
|
// dataBaseInfo= getDataBaseInfo(commentModel);
|
||||||
// 记录总数
|
// 记录总数
|
||||||
Integer total = sxDataDao.getTBdItemClsTotal(dataBaseInfo);
|
Integer total = sxDataDao.getTBdItemClsTotal(dataBaseInfo);
|
||||||
if(total==0){
|
if(total==0){
|
||||||
@ -100,7 +100,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
String sign=CommonUtil.generateOpenSign(jsonString,commentModel.getAppId(),commentModel.getAppKey());
|
String sign=CommonUtil.generateOpenSign(jsonString,commentModel.getAppKey(),commentModel.getAppId());
|
||||||
log.info("sign:{}",sign);
|
log.info("sign:{}",sign);
|
||||||
String code= HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_CATEGORY
|
String code= HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_CATEGORY
|
||||||
+"?appKey="+commentModel.getAppKey()
|
+"?appKey="+commentModel.getAppKey()
|
||||||
@ -150,7 +150,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void SyncBranchList(DataBaseInfo dataBaseInfo, CommentModel commentModel) {
|
public void SyncBranchList(DataBaseInfo dataBaseInfo, CommentModel commentModel) {
|
||||||
dataBaseInfo= getDataBaseInfo(commentModel);
|
// dataBaseInfo= getDataBaseInfo(commentModel);
|
||||||
List<BrandModel> brandModels= sxDataDao.getBdBrandList(dataBaseInfo);
|
List<BrandModel> brandModels= sxDataDao.getBdBrandList(dataBaseInfo);
|
||||||
if(brandModels!=null&&brandModels.size()>0){
|
if(brandModels!=null&&brandModels.size()>0){
|
||||||
String jsonString ="";
|
String jsonString ="";
|
||||||
@ -163,7 +163,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
String sign=CommonUtil.generateOpenSign(jsonArray.toString(),commentModel.getAppId(),commentModel.getAppKey());
|
String sign=CommonUtil.generateOpenSign(jsonString,commentModel.getAppKey(),commentModel.getAppId());
|
||||||
log.info("sign={}",sign);
|
log.info("sign={}",sign);
|
||||||
String code= HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_BRAND
|
String code= HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_BRAND
|
||||||
+"?appKey="+commentModel.getAppKey()
|
+"?appKey="+commentModel.getAppKey()
|
||||||
@ -184,7 +184,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void SyncVipList(DataBaseInfo dataBaseInfo, CommentModel commentModel) {
|
public void SyncVipList(DataBaseInfo dataBaseInfo, CommentModel commentModel) {
|
||||||
dataBaseInfo= getDataBaseInfo(commentModel);
|
// dataBaseInfo= getDataBaseInfo(commentModel);
|
||||||
String where="where mobile is not null and mobile <>'' ";
|
String where="where mobile is not null and mobile <>'' ";
|
||||||
if(StringUtils.isNotEmpty(commentModel.getSyncTime())){
|
if(StringUtils.isNotEmpty(commentModel.getSyncTime())){
|
||||||
where+="and oper_date > '"+commentModel.getSyncTime()+"'";
|
where+="and oper_date > '"+commentModel.getSyncTime()+"'";
|
||||||
@ -207,7 +207,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
|||||||
memberList=ConverList(sxSyncVipList);
|
memberList=ConverList(sxSyncVipList);
|
||||||
Gson gson=new Gson();
|
Gson gson=new Gson();
|
||||||
String jsonString = gson.toJson(memberList);
|
String jsonString = gson.toJson(memberList);
|
||||||
String sign=CommonUtil.generateOpenSign(jsonString,commentModel.getAppId(),commentModel.getAppKey());
|
String sign=CommonUtil.generateOpenSign(jsonString,commentModel.getAppKey(),commentModel.getAppId());
|
||||||
String code= HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_MEMBER
|
String code= HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_MEMBER
|
||||||
+"?appKey="+commentModel.getAppKey()
|
+"?appKey="+commentModel.getAppKey()
|
||||||
+"&sign="+sign,memberList);//todo 后期改为文件传输
|
+"&sign="+sign,memberList);//todo 后期改为文件传输
|
||||||
@ -386,7 +386,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
|||||||
String fileName=fileUtils.getFileName(syncType,page,FileUtils.txtEnd);
|
String fileName=fileUtils.getFileName(syncType,page,FileUtils.txtEnd);
|
||||||
String filePath=file.getAbsolutePath();
|
String filePath=file.getAbsolutePath();
|
||||||
fileUtils.writeFile(filePath,fileName,content);
|
fileUtils.writeFile(filePath,fileName,content);
|
||||||
String sign=CommonUtil.generateOpenSign(content,commentModel.getAppId(),commentModel.getAppKey());
|
String sign=CommonUtil.generateOpenSign(content,commentModel.getAppKey(),commentModel.getAppId());
|
||||||
commentModel.setSign(sign);
|
commentModel.setSign(sign);
|
||||||
return webClientService.uploudSxData(filePath+FileUtils.pathSeparator+fileName,commentModel,page.toString(),syncType);
|
return webClientService.uploudSxData(filePath+FileUtils.pathSeparator+fileName,commentModel,page.toString(),syncType);
|
||||||
}
|
}
|
||||||
@ -729,7 +729,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
|||||||
.create();
|
.create();
|
||||||
String jsonString= gson.toJson(activeDtos);
|
String jsonString= gson.toJson(activeDtos);
|
||||||
JSONArray jsonArray = JSONUtil.parseArray(jsonString);
|
JSONArray jsonArray = JSONUtil.parseArray(jsonString);
|
||||||
String sign=CommonUtil.generateOpenSign(jsonString,commentModel.getAppId(),commentModel.getAppKey());
|
String sign=CommonUtil.generateOpenSign(jsonString,commentModel.getAppKey(),commentModel.getAppId());
|
||||||
String code= HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_ACTIVE
|
String code= HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_ACTIVE
|
||||||
+"?appKey="+commentModel.getAppKey()
|
+"?appKey="+commentModel.getAppKey()
|
||||||
+"&sign="+sign, jsonArray);
|
+"&sign="+sign, jsonArray);
|
||||||
@ -771,7 +771,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
|
|||||||
.create();
|
.create();
|
||||||
String jsonString=gson.toJson(activeDtos);
|
String jsonString=gson.toJson(activeDtos);
|
||||||
JSONArray jsonArray = JSONUtil.parseArray(jsonString);
|
JSONArray jsonArray = JSONUtil.parseArray(jsonString);
|
||||||
String sign=CommonUtil.generateOpenSign(jsonString,commentModel.getAppId(),commentModel.getAppKey());
|
String sign=CommonUtil.generateOpenSign(jsonString,commentModel.getAppKey(),commentModel.getAppId());
|
||||||
String code= HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_ACTIVE_SHOP
|
String code= HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_ACTIVE_SHOP
|
||||||
+"?appKey="+commentModel.getAppKey()
|
+"?appKey="+commentModel.getAppKey()
|
||||||
+"&sign="+sign, jsonArray);
|
+"&sign="+sign, jsonArray);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user