修复秘钥生产的url传递错误问题

This commit is contained in:
xuetao.li
2023-05-16 18:37:24 +08:00
parent af48dbe48a
commit d75607102a
2 changed files with 19 additions and 10 deletions
@@ -133,7 +133,7 @@ huawei.OBS.fileMaxSize=10 #\u6587\u4EF6\u4E0A\u4F20\u6700\u5927M\u6570
logging.level.com.adc: debug
# CMP???????????
cmp.url=https://cmp-uat.faw-vw.in/employee/v1/
cmp.url=https://cmp-uat.faw-vw.in/
cmp.appkey=TI062S001Uat
cmp.appSecret=ee493505524d4f628e52058f4df3a4fb
@@ -40,7 +40,7 @@ public class SyncIAMTimer {
* IAM的前缀地址
*/
@Value("${cmp.url}")
private String cmpUrl="https://cmp-uat.faw-vw.in/employee/v1/";
private String cmpUrl="https://cmp-uat.faw-vw.in/";
@Value("${cmp.appkey}")
private String appkey = "TI062S001Uat";
@@ -53,12 +53,12 @@ public class SyncIAMTimer {
/**
* 组织机构增量同步接口地址
*/
public static final String ORG_INCREMENT_URL = "/pageOrgs";
public static final String ORG_INCREMENT_URL = "employee/v1/pageOrgs";
/**
* 用户增量同步接口地址
*/
public static final String USER_INCREMENT_URL = "/pageEmployees";
public static final String USER_INCREMENT_URL = "employee/v1/pageEmployees";
@Resource
SyncIAMLogDao syncIAMLogDao;
@@ -81,10 +81,11 @@ public class SyncIAMTimer {
* @Param pageSize 每页条数,默认10,小于1按1处 于1000按1000处理
*/
public void syncOrgIncrData(int pageIndex, int pageSize){
String syncUrl = this.cmpUrl + ORG_INCREMENT_URL + "?pageIndex=" + pageIndex + "&pageSize=" + pageSize;
String suffixUrl = ORG_INCREMENT_URL + "?pageIndex=" + pageIndex + "&pageSize=" + pageSize;
String syncUrl = this.cmpUrl + suffixUrl;
String gmtDate = SignUtils.getGMTDate();
String sign = SignUtils.generate(HttpMethod.GET, syncUrl, this.xCustom, this.appkey, gmtDate, this.appSecret);
String sign = SignUtils.generate(HttpMethod.GET, suffixUrl, this.xCustom, this.appkey, gmtDate, this.appSecret);
String orgDataStr = HttpRequest.get(syncUrl)
.header("Content-Type", "application/json")
@@ -120,16 +121,24 @@ public class SyncIAMTimer {
* @Param syncModel 同步模式
*/
public void syncUserIncrData(int pageIndex, int pageSize, String enterTime){
String syncUrl = this.cmpUrl + USER_INCREMENT_URL + "?pageIndex=" + pageIndex + "&pageSize=" + pageSize;
String suffixUrl = USER_INCREMENT_URL + "?pageIndex=" + pageIndex + "&pageSize=" + pageSize;
if (StringUtils.isNotEmpty(enterTime)){
syncUrl += "&enterTime=" + enterTime;
suffixUrl += "&enterTime=" + enterTime;
}
String jwtToken = this.getJwtToken(appkey, appSecret);
String syncUrl = this.cmpUrl + suffixUrl;
String gmtDate = SignUtils.getGMTDate();
String sign = SignUtils.generate(HttpMethod.GET, syncUrl, this.xCustom, this.appkey, gmtDate, this.appSecret);
String userDataStr = HttpRequest.post(syncUrl)
.header("Content-Type", "application/json")
.header("Authorization", jwtToken)//头信息,多个头信息多次调用此方法即可
.header("Date", gmtDate)
.header("X-HMAC-ACCESS-KEY", this.appkey)
.header("X-HMAC-ALGORITHM", "hmac-sha256")
.header("X-HMAC-SIGNED-HEADERS", "x-custom")
.header("x-custom", this.xCustom)
.header("X-HMAC-SIGNATURE", sign)
.timeout(10 * 60 * 1000) //超时,毫秒
.execute().body();