headerContainsSecretKey
parent
f814a2faf1
commit
16111ff14f
|
|
@ -6,6 +6,7 @@ import com.czcb.scfs.api.core.exception.TimestampException;
|
||||||
import com.czcb.scfs.api.core.exception.ValidationException;
|
import com.czcb.scfs.api.core.exception.ValidationException;
|
||||||
import com.czcb.scfs.api.core.http.HttpLogger;
|
import com.czcb.scfs.api.core.http.HttpLogger;
|
||||||
import com.czcb.scfs.api.core.http.OriginalResponse;
|
import com.czcb.scfs.api.core.http.OriginalResponse;
|
||||||
|
import com.czcb.scfs.api.core.util.Strings;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
@ -63,6 +64,10 @@ public final class DefaultValidator implements Validator {
|
||||||
// 校验时间戳
|
// 校验时间戳
|
||||||
validateTimestamp(response);
|
validateTimestamp(response);
|
||||||
|
|
||||||
|
if (!headerContainsSecretKey(response)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 待签名串
|
// 待签名串
|
||||||
String message = profile.getSignature().getCredential().buildResponseMessage(response, channel);
|
String message = profile.getSignature().getCredential().buildResponseMessage(response, channel);
|
||||||
try {
|
try {
|
||||||
|
|
@ -82,4 +87,8 @@ public final class DefaultValidator implements Validator {
|
||||||
response.getHttpHeaders().getHeader(REQUEST_ID)), e);
|
response.getHttpHeaders().getHeader(REQUEST_ID)), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean headerContainsSecretKey(OriginalResponse response) {
|
||||||
|
return Strings.isEmpty(response.getHttpHeaders().getHeader(SECRET_KEY));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,43 @@
|
||||||
package com.czcb.scfs.api.service.health.model;
|
package com.czcb.scfs.api.service.health.model;
|
||||||
|
|
||||||
import com.czcb.scfs.api.core.ApiResponse;
|
import com.czcb.scfs.api.core.ApiResponse;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wangwei
|
* @author wangwei
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@Data
|
||||||
public class EchoResponse implements ApiResponse {
|
public class EchoResponse implements ApiResponse {
|
||||||
|
@SerializedName("message")
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
public String getMessage() {
|
/**
|
||||||
return message;
|
* 000000:表示成功
|
||||||
}
|
*/
|
||||||
|
@SerializedName("recode")
|
||||||
|
private String recode;
|
||||||
|
|
||||||
public void setMessage(String message) {
|
/**
|
||||||
this.message = message;
|
* 结果信息
|
||||||
}
|
*/
|
||||||
|
@SerializedName("recode_info")
|
||||||
|
private String recodeInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统日期(YYYY-MM-DD)
|
||||||
|
*/
|
||||||
|
@SerializedName("sys_date")
|
||||||
|
private String sysDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统时间(YYYY-MM-DD hh:mm:ss)
|
||||||
|
*/
|
||||||
|
@SerializedName("sys_time")
|
||||||
|
private String sysTime;
|
||||||
|
|
||||||
public boolean ok() {
|
public boolean ok() {
|
||||||
return "ok".equals(getMessage());
|
return "ok".equals(getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue