Merge remote-tracking branch 'origin/master_金山WPS' into master_金山WPS
This commit is contained in:
@ -0,0 +1,18 @@
|
|||||||
|
package com.chinaunicom.mall.ebtp.extend.feign.client;
|
||||||
|
|
||||||
|
import com.chinaunicom.mall.ebtp.cloud.security.starter.entity.SecurityEntity;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 认证中心数据服务客户端
|
||||||
|
*
|
||||||
|
* @author Ajaxfan
|
||||||
|
*/
|
||||||
|
@FeignClient(value = "${user.auth.resource.serviceId:mall-auth}")
|
||||||
|
public interface UnicomOAuthClient {
|
||||||
|
|
||||||
|
@GetMapping("oauth/check_token")
|
||||||
|
SecurityEntity get(@RequestParam("token") String token);
|
||||||
|
}
|
@ -1,10 +1,12 @@
|
|||||||
package com.chinaunicom.mall.ebtp.extend.wps.controller;
|
package com.chinaunicom.mall.ebtp.extend.wps.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.chinaunicom.mall.ebtp.cloud.security.starter.entity.SecurityEntity;
|
||||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
||||||
import com.chinaunicom.mall.ebtp.common.log.OperationLogDetail;
|
import com.chinaunicom.mall.ebtp.common.log.OperationLogDetail;
|
||||||
import com.chinaunicom.mall.ebtp.common.log.enums.EbtpLogBusinessModule;
|
import com.chinaunicom.mall.ebtp.common.log.enums.EbtpLogBusinessModule;
|
||||||
import com.chinaunicom.mall.ebtp.common.log.enums.EbtpLogType;
|
import com.chinaunicom.mall.ebtp.common.log.enums.EbtpLogType;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.feign.client.UnicomOAuthClient;
|
||||||
import com.chinaunicom.mall.ebtp.extend.wps.entity.KingSoftFileSaveVo;
|
import com.chinaunicom.mall.ebtp.extend.wps.entity.KingSoftFileSaveVo;
|
||||||
import com.chinaunicom.mall.ebtp.extend.wps.service.WpsService;
|
import com.chinaunicom.mall.ebtp.extend.wps.service.WpsService;
|
||||||
import com.chinaunicom.mall.ebtp.extend.wps.vo.WpsClientInVo;
|
import com.chinaunicom.mall.ebtp.extend.wps.vo.WpsClientInVo;
|
||||||
@ -34,6 +36,9 @@ public class WpsController {
|
|||||||
@Resource
|
@Resource
|
||||||
private WpsService wpsService;
|
private WpsService wpsService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UnicomOAuthClient unicomOAuthClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得编辑或查看链接
|
* 获得编辑或查看链接
|
||||||
*
|
*
|
||||||
@ -109,8 +114,8 @@ public class WpsController {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("(金山)沃文档回调-查询文档")
|
@ApiOperation("(金山)沃文档回调-查询文档")
|
||||||
@GetMapping("/kingSoft/file")
|
@GetMapping("/kingSoft/file")
|
||||||
public BaseResponse<byte[]> getKSFile(@RequestParam("key") String key) {
|
public byte[] getKSFile(@RequestParam("key") String key) {
|
||||||
return BaseResponse.success(this.wpsService.getKSWpsFile(key));
|
return this.wpsService.getKSWpsFile(key);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 沃文档回调-保存文档
|
* 沃文档回调-保存文档
|
||||||
@ -122,4 +127,19 @@ public class WpsController {
|
|||||||
public Object saveKSFile(@RequestBody KingSoftFileSaveVo vo) {
|
public Object saveKSFile(@RequestBody KingSoftFileSaveVo vo) {
|
||||||
return this.wpsService.saveKSFile(vo);
|
return this.wpsService.saveKSFile(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* token
|
||||||
|
* 编辑 permission=write
|
||||||
|
* 预览 permission=read
|
||||||
|
* @param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation("token")
|
||||||
|
@GetMapping("/kingSoft/getToken")
|
||||||
|
public BaseResponse getToken(@RequestParam("token") String token) {
|
||||||
|
SecurityEntity s = unicomOAuthClient.get(token);
|
||||||
|
log.info("SecurityEntity:"+s);
|
||||||
|
return BaseResponse.success(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import com.chinaunicom.mall.ebtp.common.log.service.OperationLogService;
|
|||||||
import com.chinaunicom.mall.ebtp.common.uniBss.constant.UniBssConstant;
|
import com.chinaunicom.mall.ebtp.common.uniBss.constant.UniBssConstant;
|
||||||
import com.chinaunicom.mall.ebtp.common.uniBss.entity.UniBssAttached;
|
import com.chinaunicom.mall.ebtp.common.uniBss.entity.UniBssAttached;
|
||||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.util.SslUtil;
|
import com.chinaunicom.mall.ebtp.extend.crypconfigure.util.SslUtil;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.feign.client.UnicomOAuthClient;
|
||||||
import com.chinaunicom.mall.ebtp.extend.shortmessage.utils.RSA;
|
import com.chinaunicom.mall.ebtp.extend.shortmessage.utils.RSA;
|
||||||
import com.chinaunicom.mall.ebtp.extend.uniBss.UniBssUtil;
|
import com.chinaunicom.mall.ebtp.extend.uniBss.UniBssUtil;
|
||||||
import com.chinaunicom.mall.ebtp.extend.wps.entity.KingSoftFileSaveVo;
|
import com.chinaunicom.mall.ebtp.extend.wps.entity.KingSoftFileSaveVo;
|
||||||
@ -44,6 +45,7 @@ import java.io.*;
|
|||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.URLDecoder;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
@ -73,6 +75,8 @@ public class WpsServiceImpl implements WpsService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private AttachmentClient attachmentClient;
|
private AttachmentClient attachmentClient;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UnicomOAuthClient unicomOAuthClient;
|
||||||
|
|
||||||
@Value("${mconfig.wps.bssAppId}")
|
@Value("${mconfig.wps.bssAppId}")
|
||||||
private String bss_app_id;
|
private String bss_app_id;
|
||||||
@ -115,9 +119,6 @@ public class WpsServiceImpl implements WpsService {
|
|||||||
@Value("${KingSoftWps.kswpsurl}")
|
@Value("${KingSoftWps.kswpsurl}")
|
||||||
private String kswpsurl;
|
private String kswpsurl;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UnifastOAuthClient client;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RedisTemplate<String, Object> redisTemplate;
|
private RedisTemplate<String, Object> redisTemplate;
|
||||||
|
|
||||||
@ -498,6 +499,7 @@ public class WpsServiceImpl implements WpsService {
|
|||||||
public String getKSWpsUrl(WpsClientInVo in){
|
public String getKSWpsUrl(WpsClientInVo in){
|
||||||
|
|
||||||
KingSoftWpsVo vo = new KingSoftWpsVo();
|
KingSoftWpsVo vo = new KingSoftWpsVo();
|
||||||
|
vo.setSrcId(1);
|
||||||
vo.setStaffCode("ebtp");
|
vo.setStaffCode("ebtp");
|
||||||
vo.setFileKey(in.getFileId());
|
vo.setFileKey(in.getFileId());
|
||||||
String fileName = in.getFileName();
|
String fileName = in.getFileName();
|
||||||
@ -562,7 +564,7 @@ public class WpsServiceImpl implements WpsService {
|
|||||||
CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName("令牌无效",!o_key.substring(0,md.length()).equals(md));
|
CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName("令牌无效",!o_key.substring(0,md.length()).equals(md));
|
||||||
|
|
||||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
|
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||||
long newDateLong = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
long newDateLong = System.currentTimeMillis();
|
||||||
long inDateLong = 0;
|
long inDateLong = 0;
|
||||||
try {
|
try {
|
||||||
Date inDate = format.parse(time);
|
Date inDate = format.parse(time);
|
||||||
@ -572,12 +574,15 @@ public class WpsServiceImpl implements WpsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//time_limit = "120000";
|
//time_limit = "120000";
|
||||||
|
log.info("newDateLong:"+newDateLong);
|
||||||
|
log.info("inDateLong:"+inDateLong);
|
||||||
if(newDateLong-inDateLong>Long.valueOf(kswTimeLimit)){//
|
if(newDateLong-inDateLong>Long.valueOf(kswTimeLimit)){//
|
||||||
CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName("令牌已失效-",true);
|
CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName("令牌已失效-",true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SecurityEntity securityEntity = client.get(token);
|
SecurityEntity securityEntity = unicomOAuthClient.get(token);
|
||||||
CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName("令牌无效",securityEntity.getUserid()==null||"".equals(securityEntity.getUserid()));
|
log.info("securityEntity:"+securityEntity);
|
||||||
|
CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName("令牌无效",securityEntity.getStaffId()==null||"".equals(securityEntity.getStaffId()));
|
||||||
|
|
||||||
return fileId;
|
return fileId;
|
||||||
}
|
}
|
||||||
@ -642,23 +647,37 @@ public class WpsServiceImpl implements WpsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String args[]) throws UnsupportedEncodingException {
|
public static void main(String args[]) throws UnsupportedEncodingException {
|
||||||
// WpsServiceImpl wpsService = new WpsServiceImpl();
|
WpsServiceImpl wpsService = new WpsServiceImpl();
|
||||||
// wpsService.ksw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7CeLn5xjKP1/cuGakeOBL8cNaw";
|
||||||
// wpsService.appName = "biz-service-ebtp-extend";
|
// wpsService.appName = "biz-service-ebtp-extend";
|
||||||
// String key = wpsService.getDownloadEncrypt("1679764839191080961","3a1f5aae-3cd2-4599-87b0-712e40625c7c");
|
// String key = wpsService.getDownloadEncrypt("1679764839191080961","3a1f5aae-3cd2-4599-87b0-712e40625c7c");
|
||||||
// String val = RSA.decrypt(key,wpsService.kswprivateKey);
|
String key = URLDecoder.decode( "FkvDifsfK8frde0ywRzdPMmOlR4%2FO8C4VORaw%2FwshgBt%2B49Z2%2B0al4KwyQ97Js8Yh24%2ByMT%2Fln4Aqx%2BVZNkGqOh0OxP1H3qj%2BP%2BlP1Sybvs5I0q%2BtFpW9nMQcGAsenFNLgcFtUtsQAJG4ALG4cH34TnDnSjuivM9tmA1Gt%2BzsJU%3D","utf-8");
|
||||||
// System.out.println("val:"+val);
|
String val = RSA.decrypt(key,wpsService.kswprivateKey);
|
||||||
// String[] value = val.split("_");
|
System.out.println("val:"+val);
|
||||||
// String fileId = value[0];
|
String[] value = val.split("_");
|
||||||
// String token = value[1];
|
String fileId = value[0];
|
||||||
// String time = value[2];
|
String token = value[1];
|
||||||
// String md = value[3];
|
String time = value[2];
|
||||||
// System.out.println("md:"+md);
|
String md = value[3];
|
||||||
// String o_key = MdConstants.getSha256(time+fileId+wpsService.appName+token);
|
System.out.println("md:"+md);
|
||||||
// System.out.println("o_key:"+o_key);
|
String o_key = MdConstants.getSha256(time+fileId+wpsService.appName+token);
|
||||||
// System.out.println("o_key:"+o_key.substring(0,md.length()));
|
System.out.println("o_key:"+o_key);
|
||||||
|
System.out.println("o_key:"+o_key.substring(0,md.length()));
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||||
|
long newDateLong = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||||
|
System.out.println("newDateLong:"+newDateLong);
|
||||||
|
|
||||||
System.out.println(URLEncoder.encode("hVLFkQhQkXI8w4RFE25zvCP9TKRZwT8Dqhxmi/PgDalGayE5SIjtyFBRpu6wuEqr7HvAIHm2Kc8+ahIUF7l8sc1PHYeCuEmgYEwzeosl1pT1yDyQ+KV6Q8REiufarAbZ1W9LEx70SBrtTXPKnEPi82njSv+CVrYqZCf6XZ/BINU=","utf-8"));
|
long inDateLong = 0;
|
||||||
|
try {
|
||||||
|
Date inDate = format.parse(time);
|
||||||
|
inDateLong = inDate.getTime();
|
||||||
|
System.out.println("inDateLong:"+inDateLong);
|
||||||
|
System.out.println(newDateLong-inDateLong);
|
||||||
|
}catch (Exception e){
|
||||||
|
CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName("令牌时间戳错误",true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//System.out.println(URLEncoder.encode("hVLFkQhQkXI8w4RFE25zvCP9TKRZwT8Dqhxmi/PgDalGayE5SIjtyFBRpu6wuEqr7HvAIHm2Kc8+ahIUF7l8sc1PHYeCuEmgYEwzeosl1pT1yDyQ+KV6Q8REiufarAbZ1W9LEx70SBrtTXPKnEPi82njSv+CVrYqZCf6XZ/BINU=","utf-8"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user