recode_Info 字段修复

main
13009 2024-03-25 08:55:47 +08:00
parent 16111ff14f
commit 42d85c2de1
45 changed files with 66 additions and 53 deletions

View File

@ -10,7 +10,6 @@ import com.czcb.scfs.api.core.util.Strings;
import java.time.Duration;
import java.time.Instant;
import java.util.Objects;
import static com.czcb.scfs.api.core.Constants.*;
import static java.net.HttpURLConnection.HTTP_MULT_CHOICE;
@ -38,32 +37,35 @@ public final class DefaultValidator implements Validator {
}
private void validateTimestamp(OriginalResponse response) {
String timestamp = response.getHttpHeaders().getHeader(TIMESTAMP);
try {
Objects.requireNonNull(timestamp);
String timestamp = response.getHttpHeaders().getHeader(TIMESTAMP);
if (Strings.isEmpty(timestamp)) {
throw new TimestampException(String.format("响应头时间戳校验失败, 响应头[%s=%s]不存在, Request-Id=%s", TIMESTAMP,
timestamp, response.getHttpHeaders().getHeader(REQUEST_ID)));
}
Instant responseTime = Instant.ofEpochSecond(Long.parseLong(timestamp));
// 拒绝过期请求
if (Duration.between(responseTime, Instant.now()).abs().toMinutes() >= RESPONSE_EXPIRED_MINUTES) {
throw new TimestampException(String.format("响应校验失败, 响应头[%s=%s]已过期, Request-Id=%s", TIMESTAMP,
throw new TimestampException(String.format("响应头时间戳校验失败, 响应头[%s=%s]已过期, Request-Id=%s", TIMESTAMP,
timestamp, response.getHttpHeaders().getHeader(REQUEST_ID)));
}
} catch (Exception e) {
throw new TimestampException(String.format("响应校验失败, 响应头[%s=%s]无效, Request-Id=%s", TIMESTAMP,
timestamp, response.getHttpHeaders().getHeader(REQUEST_ID)));
httpLogger.logResponseError(response);
throw new TimestampException(e.getMessage(), e);
}
}
@Override
public void validate(OriginalResponse response, Channel channel) {
if (isInvalidHttpCode(response.getStatusCode())) {
httpLogger.logResponseError(response);
throw new ValidationException(String.format("响应校验失败, 响应状态码[%s]", response.getStatusCode()));
httpLogger.logHttpStatus(response);
}
// 校验时间戳
validateTimestamp(response);
// 请求头包含 SecretKey 进行验签
if (!headerContainsSecretKey(response)) {
return;
}
@ -73,7 +75,7 @@ public final class DefaultValidator implements Validator {
try {
String signature = response.getHttpHeaders().getHeader(SIGNATURE);
if (signature == null || signature.isEmpty()) {
throw new ValidationException(String.format("响应校验失败, 签名不存在, Request-Id[%s]",
throw new ValidationException(String.format("响应校验失败, 签名不存在, Request-Id=%s",
response.getHttpHeaders().getHeader(REQUEST_ID)));
}
@ -89,6 +91,6 @@ public final class DefaultValidator implements Validator {
}
private boolean headerContainsSecretKey(OriginalResponse response) {
return Strings.isEmpty(response.getHttpHeaders().getHeader(SECRET_KEY));
return Strings.isNotEmpty(response.getHttpHeaders().getHeader(SECRET_KEY));
}
}

View File

@ -79,4 +79,8 @@ public class HttpLogger {
logger.info("响应头:{}", Strings.removeSuffix(sb.toString(), ";"));
logger.info("响应原始报文:{}", Strings.toStr((originalResponse.getBody())));
}
public void logHttpStatus(OriginalResponse response) {
// TODO 打印状态码说明
}
}

View File

@ -23,6 +23,10 @@ public class Strings {
return Objects.isNull(value) || value.isEmpty();
}
public static boolean isNotEmpty(String value) {
return !isEmpty(value);
}
public static String requireNotEmpty(String value, String message) {
if (isEmpty(value)) {
throw new IllegalArgumentException(message);
@ -35,6 +39,9 @@ public class Strings {
return new String(bytes, StandardCharsets.UTF_8);
}
/**
*
*/
public static String removeSuffix(String text, String suffix) {
if (isEmpty(text) || isEmpty(suffix)) {
return "";

View File

@ -21,7 +21,7 @@ public class AddPrimAccCompanyResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -21,7 +21,7 @@ public class AddPrimAccPersonResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -19,7 +19,7 @@ public class ClosedAccResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -21,7 +21,7 @@ public class DelPrimAccResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -25,7 +25,7 @@ public class InqPrimAccResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -19,7 +19,7 @@ public class ModAccCompanyResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -19,7 +19,7 @@ public class ModAccPersonResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -19,7 +19,7 @@ public class OpenAccAllCompanyResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**
*

View File

@ -19,7 +19,7 @@ public class OpenAccAllPersonResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**
*

View File

@ -19,7 +19,7 @@ public class OpenAccCompanyResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -19,7 +19,7 @@ public class OpenAccPersonResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**
*

View File

@ -22,7 +22,7 @@ public class QueryBalanceResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -19,7 +19,7 @@ public class QueryCardInfoResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -21,7 +21,7 @@ public class SetPrimAccResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -19,7 +19,7 @@ public class ApplyBmdAddResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -21,7 +21,7 @@ public class ApplyBmdDelResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -25,7 +25,7 @@ public class ApplyBmdQueryResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
@SerializedName("recode_list")

View File

@ -19,7 +19,7 @@ public class BmdAddResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -19,7 +19,7 @@ public class BmdDelResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -22,7 +22,7 @@ public class BmdListResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -20,7 +20,7 @@ public class FaceFileResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -22,7 +22,7 @@ public class DownloadFileResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
@SerializedName("file_list")

View File

@ -22,7 +22,7 @@ public class UploadFileResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
@SerializedName("file_list")

View File

@ -21,7 +21,7 @@ public class ApplyCompanyResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -21,7 +21,7 @@ public class ApplyNotifyResponse implements ApiRequest {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -21,7 +21,7 @@ public class ApplyPersonResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -25,7 +25,7 @@ public class ApplyQueryResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
@SerializedName("recode_list")

View File

@ -25,7 +25,7 @@ public class ApplyQueryV2Response implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
@SerializedName("recode_list")

View File

@ -25,7 +25,7 @@ public class RepayQueryResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
@SerializedName("recode_list")

View File

@ -21,7 +21,7 @@ public class RepayResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -24,7 +24,7 @@ public class SignFlowsUrlsResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
@SerializedName("recode_list")

View File

@ -19,7 +19,7 @@ public class OcrFileResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -21,7 +21,7 @@ public class EarnestInsureResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -21,7 +21,7 @@ public class EarnestReleaseResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -21,7 +21,7 @@ public class MerDepositCheckResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -23,7 +23,7 @@ public class MerDepositResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -21,7 +21,7 @@ public class MerWithdrawCheckResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -23,7 +23,7 @@ public class MerWithdrawResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -21,7 +21,7 @@ public class TransferSelfAccResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -19,7 +19,7 @@ public class SendVerifySignResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -21,7 +21,7 @@ public class QueryTradeInfoResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**

View File

@ -25,7 +25,7 @@ public class QueryTradeListResponse implements ApiResponse {
/**
*
*/
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String recodeInfo;
/**
@ -99,7 +99,7 @@ public class QueryTradeListResponse implements ApiResponse {
@Data
public static class DetailList implements Serializable {
@SerializedName("recode_Info")
@SerializedName("recode_info")
private String id;
@SerializedName("account_date")