Browse Source

转发IRS 刷新密钥

tags/24080901
PoffyZhang 1 year ago
parent
commit
d1930032ca
5 changed files with 19 additions and 18 deletions
  1. +3
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java
  2. +8
    -11
      pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/AppIrsManage.java
  3. +3
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/ProjectIrsManage.java
  4. +4
    -4
      pmapi/src/test/java/com/ningdatech/pmapi/irs/CoreTest.java
  5. +1
    -0
      pmapi/src/test/java/com/ningdatech/pmapi/irs/IrsTest.java

+ 3
- 2
pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java View File

@@ -24,6 +24,7 @@ import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;
@@ -201,12 +202,12 @@ public class DingInfoPullController {
long timestamp = System.currentTimeMillis();
String areaCode = "331123";
String appKey = "A331101453557202109017383";
String appScret = "496f0f2a19994f76b4fd9dae087366c7";
String appSecret = "496f0f2a19994f76b4fd9dae087366c7";
String baseProjSys = "初次建设的应用21";
String baseProjSysCode = "A331123467587202307014177";
String baseProjName = "遂昌县-nsl-项目测试004";
String baseProjId = "331123230130123412186";
String requestSecret = RefreshKeyUtil.getRequestSecret(appKey, appScret,timestamp);
String requestSecret = refreshTokenService.refreshToken(appKey, appSecret, govRequestTokenUrl, govRefreshTokenUrl, HttpMethod.POST.name());
String capCode = CryptUtils.encryptHMAC(timestamp + areaCode,"bcb4fc0f517fc168ee543fcf4d231f3b");
String capTime = String.valueOf(timestamp);
String sign = CryptUtils.MD5Encode(appKey + requestSecret + timestamp);


+ 8
- 11
pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/AppIrsManage.java View File

@@ -85,9 +85,6 @@ public class AppIrsManage {
@Value("${irs.push-project-detail.url}")
private String pushProjectUrl;

@Value("${irs.push-project-detail.interfaceName}")
private String pushProjectInterfaceName;

@Value("${irs.push-project-detail.appKey}")
private String pushProjectAppKey;

@@ -134,7 +131,7 @@ public class AppIrsManage {
long timestamp = System.currentTimeMillis();
String areaCode = project.getAreaCode();
String projectName = project.getProjectName();
String requestSecret = RefreshKeyUtil.getRequestSecret(pushAppKey, pushAppScret,timestamp);
String requestSecret = refreshTokenService.refreshToken(pushAppKey, pushAppScret, govRequestTokenUrl, govRefreshTokenUrl, HttpMethod.POST.name());
String capCode = CryptUtils.encryptHMAC(timestamp + areaCode, "bcb4fc0f517fc168ee543fcf4d231f3b");
String capTime = String.valueOf(timestamp);
String sign = CryptUtils.MD5Encode(pushAppKey + requestSecret + timestamp);
@@ -195,7 +192,7 @@ public class AppIrsManage {
public JSONObject searchApp(ApiApplyDTO apply) throws NoSuchAlgorithmException {
long timestamp = System.currentTimeMillis();
String appCode = apply.getAppId();
String requestSecret = RefreshKeyUtil.getRequestSecret(searchAppKey, searchAppScret,timestamp);
String requestSecret = refreshTokenService.refreshToken(searchAppKey, searchAppScret, govRequestTokenUrl, govRefreshTokenUrl, HttpMethod.POST.name());
String sign = CryptUtils.MD5Encode(searchAppKey + requestSecret + timestamp);
String url = searchUrl + "?requestTime=" + timestamp + "&sign=" + sign +
"&appKey=" + searchAppKey + "&" +
@@ -231,7 +228,8 @@ public class AppIrsManage {
long timestamp = System.currentTimeMillis();
String areaCode = StringUtils.isNotBlank(apply.getAreaCode()) ?
convertAreaCode(apply.getAreaCode()) : null;
String requestSecret = RefreshKeyUtil.getRequestSecret(searchAppKey, searchAppScret,timestamp);
String requestSecret = refreshTokenService.refreshToken(searchAppKey, searchAppScret, govRequestTokenUrl, govRefreshTokenUrl,
HttpMethod.POST.name());
String sign = CryptUtils.MD5Encode(searchAppKey + requestSecret + timestamp);
String url = searchUrl + "?requestTime=" + timestamp + "&sign=" + sign +
"&appKey=" + searchAppKey + "&pageSize=1000&" +
@@ -240,7 +238,7 @@ public class AppIrsManage {
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class);

log.info("查询应用目录 : {}", JSON.toJSONString(forEntity));
log.info("查询应用目录 : {}", forEntity.getStatusCode());

if (Objects.nonNull(forEntity.getBody())) {
JSONObject body = JSON.parseObject(forEntity.getBody());
@@ -279,7 +277,7 @@ public class AppIrsManage {
String appKey = "A331101453557202109017383";
String method = "POST";
String interfaceName = "5crv7i4727abLCv0";
String secret = refreshTokenService.refreshToken(appKey, appSecret, govRequestTokenUrl, govRefreshTokenUrl, interfaceName, method);
String secret = refreshTokenService.refreshToken(appKey, appSecret, govRequestTokenUrl, govRefreshTokenUrl, method);
log.info("secret :{}", secret);
String sign = MD5.create().digestHex(appKey + secret + timestamp);
HttpComponentsClientHttpRequestFactory factory = HttpUtil.generateHttpRequestFactory();
@@ -312,8 +310,7 @@ public class AppIrsManage {
String appSecret = pushProjectAppSecret;
String appKey = pushProjectAppKey;
String method = HttpMethod.POST.name();
String interfaceName = pushProjectInterfaceName;
String secret = refreshTokenService.refreshToken(appKey, appSecret, govRequestTokenUrl, govRefreshTokenUrl, interfaceName, method);
String secret = refreshTokenService.refreshToken(appKey, appSecret, govRequestTokenUrl, govRefreshTokenUrl, method);
log.info("secret :{}", secret);
String sign = MD5.create().digestHex(appKey + secret + timestamp);
HttpComponentsClientHttpRequestFactory factory = HttpUtil.generateHttpRequestFactory();
@@ -377,7 +374,7 @@ public class AppIrsManage {
String appKey = driAppKey;
String method = HttpMethod.POST.name();
String interfaceName = driInterfaceName;
String secret = refreshTokenService.refreshToken(appKey, appSecret, govRequestTokenUrl, govRefreshTokenUrl, interfaceName, method);
String secret = refreshTokenService.refreshToken(appKey, appSecret, govRequestTokenUrl, govRefreshTokenUrl, method);
log.info("secret : {}", secret);
String sign = MD5.create().digestHex(appKey + secret + timestamp);
HttpComponentsClientHttpRequestFactory factory = HttpUtil.generateHttpRequestFactory();


+ 3
- 1
pmapi/src/main/java/com/ningdatech/pmapi/irs/manage/ProjectIrsManage.java View File

@@ -9,6 +9,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Component;
@@ -56,7 +57,8 @@ public class ProjectIrsManage {
*/
public JSONObject searchCoreBiz(String businessName,String orgCode,Integer limit,Integer page) {
long timestamp = System.currentTimeMillis();
String secret = RefreshKeyUtil.getRequestSecret(appKey, appSecret,timestamp);
String secret = refreshTokenService.refreshToken(appKey, appSecret, govRequestTokenUrl, govRefreshTokenUrl,
HttpMethod.POST.name());
String sign = null;
try{
sign = CryptUtils.MD5Encode(appKey + secret + timestamp);


+ 4
- 4
pmapi/src/test/java/com/ningdatech/pmapi/irs/CoreTest.java View File

@@ -59,11 +59,11 @@ public class CoreTest {//extends AppTests
Integer limit = 10;
Integer page = 1;

// String secret = refreshTokenService.refreshToken(appKey, appSecret, govRequestTokenUrl, govRefreshTokenUrl,
// interfaceName, HttpMethod.POST.name());
// String secret = "a4cffda647a848279646cbb10a9c297c";
String secret = refreshTokenService.refreshToken(appKey, appSecret, govRequestTokenUrl, govRefreshTokenUrl,
HttpMethod.POST.name());
// String secret = "15345863c0fb4a85a28b2b467e5e6253";
// String secret = appSecret;
String secret = RefreshKeyUtil.getRequestSecret(appKey, appSecret,requestTime);
// String secret = RefreshKeyUtil.getRequestSecret(appKey, appSecret,requestTime);
// String secret = RefreshKeyUtil.refreshSecret(appKey, "78cde959148b4335b8eba556f9c8c7bf",requestTime);
System.out.println("secret:" + secret);
HttpComponentsClientHttpRequestFactory factory = HttpUtil.generateHttpRequestFactory();


+ 1
- 0
pmapi/src/test/java/com/ningdatech/pmapi/irs/IrsTest.java View File

@@ -100,6 +100,7 @@ public class IrsTest extends AppTests {
String baseProjName = "遂昌县-nsl-项目测试004";
String baseProjId = "331123230130123412186";
String requestSecret = RefreshKeyUtil.getRequestSecret(appKey, appScret,timestamp);

String capCode = CryptUtils.MD5Encode(timestamp + areaCode);
String capTime = String.valueOf(timestamp);
String sign = CryptUtils.MD5Encode(appKey + requestSecret + timestamp);


Loading…
Cancel
Save