recode_Info 字段修复
parent
16111ff14f
commit
42d85c2de1
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 打印状态码说明
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 "";
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class AddPrimAccCompanyResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class AddPrimAccPersonResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class ClosedAccResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class DelPrimAccResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class InqPrimAccResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class ModAccCompanyResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class ModAccPersonResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class OpenAccAllCompanyResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
/**
|
||||
* 原交易流水号
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class OpenAccAllPersonResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
/**
|
||||
* 原交易流水号
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class OpenAccCompanyResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class OpenAccPersonResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
/**
|
||||
* 原交易流水号
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class QueryBalanceResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class QueryCardInfoResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class SetPrimAccResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class ApplyBmdAddResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class ApplyBmdDelResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class ApplyBmdQueryResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
@SerializedName("recode_list")
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class BmdAddResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class BmdDelResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class BmdListResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class FaceFileResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class DownloadFileResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
@SerializedName("file_list")
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class UploadFileResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
@SerializedName("file_list")
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class ApplyCompanyResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class ApplyNotifyResponse implements ApiRequest {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class ApplyPersonResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class ApplyQueryResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
@SerializedName("recode_list")
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class ApplyQueryV2Response implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
@SerializedName("recode_list")
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class RepayQueryResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
@SerializedName("recode_list")
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class RepayResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class SignFlowsUrlsResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
@SerializedName("recode_list")
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class OcrFileResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class EarnestInsureResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class EarnestReleaseResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class MerDepositCheckResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class MerDepositResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class MerWithdrawCheckResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class MerWithdrawResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class TransferSelfAccResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class SendVerifySignResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class QueryTradeInfoResponse implements ApiResponse {
|
|||
/**
|
||||
* 结果信息
|
||||
*/
|
||||
@SerializedName("recode_Info")
|
||||
@SerializedName("recode_info")
|
||||
private String recodeInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Reference in New Issue