Spaces:
Sleeping
Sleeping
Merged in feature/sarvenDev (pull request #11)
Browse files- pom.xml +10 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/controller/BaseController.java +6 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/model/RequestHeader.java +2 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/response/BaseValidResponse.java +27 -0
- src/main/java/com/artandscience/webbff/webbff/common/constants/HeaderConstant.java +2 -0
- src/main/java/com/artandscience/webbff/webbff/common/exception/ForbiddenException.java +23 -0
- src/main/java/com/artandscience/webbff/webbff/common/exception/ProviderValidateException.java +20 -0
- src/main/java/com/artandscience/webbff/webbff/common/helper/JsonMapper.java +36 -0
- src/main/java/com/artandscience/webbff/webbff/common/interceptor/ResponseErrorHandler.java +24 -3
- src/main/java/com/artandscience/webbff/webbff/common/interceptor/TransactionFilter.java +11 -0
- src/main/java/com/artandscience/webbff/webbff/common/utils/ProviderValidUtil.java +28 -0
- src/main/java/com/artandscience/webbff/webbff/domain/mapper/SlideModelMapper.java +0 -1
- src/main/java/com/artandscience/webbff/webbff/integration/config/FeignClientSecurityConfiguration.java +30 -0
- src/main/java/com/artandscience/webbff/webbff/integration/decoder/FeignSecurityErrorDecoder.java +69 -0
- src/main/java/com/artandscience/webbff/webbff/integration/interceptor/FeignClientInterceptor.java +26 -11
- src/main/java/com/artandscience/webbff/webbff/integration/interceptor/providerValid/FeignClientSecurityInterceptor.java +39 -0
- src/main/java/com/artandscience/webbff/webbff/integration/service/ProviderClientService.java +23 -0
- src/main/java/com/artandscience/webbff/webbff/integration/service/request/ValidateProviderClientRequest.java +14 -0
- src/main/java/com/artandscience/webbff/webbff/integration/service/response/base/BaseProviderValidClientResponse.java +18 -0
- src/main/java/com/artandscience/webbff/webbff/integration/service/util/DecoderUtil.java +26 -0
- src/main/resources/application.yml +18 -1
pom.xml
CHANGED
|
@@ -58,6 +58,16 @@
|
|
| 58 |
<artifactId>spring-boot-starter-web</artifactId>
|
| 59 |
</dependency>
|
| 60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
<!-- OpenFeign -->
|
| 62 |
<dependency>
|
| 63 |
<groupId>org.springframework.cloud</groupId>
|
|
|
|
| 58 |
<artifactId>spring-boot-starter-web</artifactId>
|
| 59 |
</dependency>
|
| 60 |
|
| 61 |
+
<dependency>
|
| 62 |
+
<groupId>org.springframework.boot</groupId>
|
| 63 |
+
<artifactId>spring-boot-starter-actuator</artifactId>
|
| 64 |
+
</dependency>
|
| 65 |
+
|
| 66 |
+
<dependency>
|
| 67 |
+
<groupId>io.micrometer</groupId>
|
| 68 |
+
<artifactId>micrometer-registry-prometheus</artifactId>
|
| 69 |
+
</dependency>
|
| 70 |
+
|
| 71 |
<!-- OpenFeign -->
|
| 72 |
<dependency>
|
| 73 |
<groupId>org.springframework.cloud</groupId>
|
src/main/java/com/artandscience/webbff/webbff/common/base/controller/BaseController.java
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
package com.artandscience.webbff.webbff.common.base.controller;
|
| 2 |
|
| 3 |
|
|
|
|
| 4 |
import com.artandscience.webbff.webbff.common.base.response.MessageBox;
|
| 5 |
import com.artandscience.webbff.webbff.common.base.response.MessageResponse;
|
| 6 |
import com.artandscience.webbff.webbff.common.base.response.builder.MsgResponseBuilder;
|
|
@@ -21,4 +22,9 @@ public abstract class BaseController {
|
|
| 21 |
return MsgResponseBuilder.build(true,messageBox,data);
|
| 22 |
}
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
}
|
|
|
|
| 1 |
package com.artandscience.webbff.webbff.common.base.controller;
|
| 2 |
|
| 3 |
|
| 4 |
+
import com.artandscience.webbff.webbff.common.base.response.BaseValidResponse;
|
| 5 |
import com.artandscience.webbff.webbff.common.base.response.MessageBox;
|
| 6 |
import com.artandscience.webbff.webbff.common.base.response.MessageResponse;
|
| 7 |
import com.artandscience.webbff.webbff.common.base.response.builder.MsgResponseBuilder;
|
|
|
|
| 22 |
return MsgResponseBuilder.build(true,messageBox,data);
|
| 23 |
}
|
| 24 |
|
| 25 |
+
protected BaseValidResponse validResponseFail(BaseValidResponse baseValidResponse) {
|
| 26 |
+
return new BaseValidResponse(baseValidResponse.getErrorDescription(),
|
| 27 |
+
baseValidResponse.getErrorFunction());
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/model/RequestHeader.java
CHANGED
|
@@ -18,5 +18,7 @@ public class RequestHeader {
|
|
| 18 |
private String diamondUsername;
|
| 19 |
private String diamondPassword;
|
| 20 |
private String customerNumber;
|
|
|
|
|
|
|
| 21 |
|
| 22 |
}
|
|
|
|
| 18 |
private String diamondUsername;
|
| 19 |
private String diamondPassword;
|
| 20 |
private String customerNumber;
|
| 21 |
+
private String requestFlowId;
|
| 22 |
+
private String deviceAppId;
|
| 23 |
|
| 24 |
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/response/BaseValidResponse.java
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.response;
|
| 2 |
+
|
| 3 |
+
import lombok.AllArgsConstructor;
|
| 4 |
+
import lombok.Data;
|
| 5 |
+
import lombok.NoArgsConstructor;
|
| 6 |
+
|
| 7 |
+
import java.time.ZonedDateTime;
|
| 8 |
+
import java.time.format.DateTimeFormatter;
|
| 9 |
+
|
| 10 |
+
@Data
|
| 11 |
+
@AllArgsConstructor
|
| 12 |
+
@NoArgsConstructor
|
| 13 |
+
public class BaseValidResponse {
|
| 14 |
+
|
| 15 |
+
private Boolean isValid;
|
| 16 |
+
private String executionDate;
|
| 17 |
+
private String errorDescription;
|
| 18 |
+
private String errorFunction;
|
| 19 |
+
|
| 20 |
+
public BaseValidResponse(String errorDescription, String errorFunction) {
|
| 21 |
+
this.isValid = false;
|
| 22 |
+
this.errorFunction = errorFunction;
|
| 23 |
+
this.errorDescription = errorDescription;
|
| 24 |
+
this.executionDate = ZonedDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/constants/HeaderConstant.java
CHANGED
|
@@ -10,6 +10,8 @@ public class HeaderConstant {
|
|
| 10 |
public static String HEADER_SESSION_ID = "x-b3-session-id";
|
| 11 |
public static String HEADER_CORRELATION_ID = "x-correlation-id";
|
| 12 |
public static String HEADER_CUSTOMER_NUMBER = "x-customer-number";
|
|
|
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
}
|
|
|
|
| 10 |
public static String HEADER_SESSION_ID = "x-b3-session-id";
|
| 11 |
public static String HEADER_CORRELATION_ID = "x-correlation-id";
|
| 12 |
public static String HEADER_CUSTOMER_NUMBER = "x-customer-number";
|
| 13 |
+
public static String HEADER_DEVICE_APP_ID = "x-device-app-id";
|
| 14 |
+
public static String HEADER_REQUEST_FLOW_ID = "x-request-flow-id";
|
| 15 |
|
| 16 |
|
| 17 |
}
|
src/main/java/com/artandscience/webbff/webbff/common/exception/ForbiddenException.java
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.exception;
|
| 2 |
+
|
| 3 |
+
import lombok.Getter;
|
| 4 |
+
|
| 5 |
+
import java.io.Serial;
|
| 6 |
+
import java.io.Serializable;
|
| 7 |
+
|
| 8 |
+
@Getter
|
| 9 |
+
public class ForbiddenException extends RuntimeException implements Serializable {
|
| 10 |
+
|
| 11 |
+
@Serial
|
| 12 |
+
private static final long serialVersionUID = -7123456789012345678L;
|
| 13 |
+
private final String code;
|
| 14 |
+
private final String serviceName;
|
| 15 |
+
private final String message;
|
| 16 |
+
|
| 17 |
+
public ForbiddenException(String code, String serviceName, String message) {
|
| 18 |
+
this.code = code;
|
| 19 |
+
this.serviceName = serviceName;
|
| 20 |
+
this.message = message;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/exception/ProviderValidateException.java
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.exception;
|
| 2 |
+
|
| 3 |
+
import lombok.Getter;
|
| 4 |
+
|
| 5 |
+
import java.io.Serial;
|
| 6 |
+
import java.io.Serializable;
|
| 7 |
+
|
| 8 |
+
@Getter
|
| 9 |
+
public class ProviderValidateException extends RuntimeException implements Serializable {
|
| 10 |
+
|
| 11 |
+
@Serial
|
| 12 |
+
private static final long serialVersionUID = -7123456789012345678L;
|
| 13 |
+
|
| 14 |
+
private final String serviceName;
|
| 15 |
+
|
| 16 |
+
public ProviderValidateException(String serviceName) {
|
| 17 |
+
this.serviceName = serviceName;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/helper/JsonMapper.java
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.helper;
|
| 2 |
+
|
| 3 |
+
import com.fasterxml.jackson.core.JsonProcessingException;
|
| 4 |
+
import com.fasterxml.jackson.databind.DeserializationFeature;
|
| 5 |
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
| 6 |
+
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
| 7 |
+
import lombok.extern.slf4j.Slf4j;
|
| 8 |
+
|
| 9 |
+
@Slf4j
|
| 10 |
+
public class JsonMapper {
|
| 11 |
+
|
| 12 |
+
private static final ObjectMapper MAPPER = new ObjectMapper()
|
| 13 |
+
.registerModule(new JavaTimeModule())
|
| 14 |
+
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
| 15 |
+
|
| 16 |
+
public static <T> T convertToData(String jsonBody, Class<T> clazz) {
|
| 17 |
+
try {
|
| 18 |
+
return MAPPER.readValue(jsonBody, clazz);
|
| 19 |
+
} catch (JsonProcessingException e) {
|
| 20 |
+
log.error("JSON convert error. targetClass: {}, body: {}, message: {}",
|
| 21 |
+
clazz.getSimpleName(), jsonBody, e.getMessage());
|
| 22 |
+
|
| 23 |
+
throw new IllegalArgumentException("JSON could not be converted to " + clazz.getSimpleName(), e);
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
public static <T> String convertToJson(T data) {
|
| 28 |
+
try {
|
| 29 |
+
return MAPPER.writeValueAsString(data);
|
| 30 |
+
} catch (JsonProcessingException e) {
|
| 31 |
+
log.error("An error has occurrence: {}",e.getMessage());
|
| 32 |
+
throw new IllegalArgumentException("An error has occurrence: {}",e);
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/interceptor/ResponseErrorHandler.java
CHANGED
|
@@ -3,10 +3,12 @@ package com.artandscience.webbff.webbff.common.interceptor;
|
|
| 3 |
import com.artandscience.webbff.webbff.common.base.controller.BaseController;
|
| 4 |
import com.artandscience.webbff.webbff.common.base.model.MessageModel;
|
| 5 |
import com.artandscience.webbff.webbff.common.base.model.RequestHeader;
|
|
|
|
| 6 |
import com.artandscience.webbff.webbff.common.base.response.MessageBox;
|
| 7 |
import com.artandscience.webbff.webbff.common.base.response.MessageResponse;
|
| 8 |
import com.artandscience.webbff.webbff.common.exception.BusinessException;
|
| 9 |
import com.artandscience.webbff.webbff.common.exception.SessionException;
|
|
|
|
| 10 |
import com.artandscience.webbff.webbff.common.exception.enums.UnhandledErrorType;
|
| 11 |
import com.artandscience.webbff.webbff.common.scope.RequestHeaderScope;
|
| 12 |
import com.artandscience.webbff.webbff.common.service.ExternalAttributeService;
|
|
@@ -54,7 +56,10 @@ public class ResponseErrorHandler extends BaseController {
|
|
| 54 |
public MessageResponse<Void> handleSessionExceptionError(SessionException e) {
|
| 55 |
log.error("SessionException occurred: " + e.getMessage() + " Error code: " + e.getCode(), e);
|
| 56 |
var messageModel = MessageModel.builder().code(e.getCode()).build();
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
| 58 |
List<MessageBox> messageBoxList = new ArrayList<>();
|
| 59 |
messageBoxList.add(messageBox);
|
| 60 |
return responseFail(messageBoxList);
|
|
@@ -65,7 +70,10 @@ public class ResponseErrorHandler extends BaseController {
|
|
| 65 |
public MessageResponse<Void> handleBusinessExceptionError(BusinessException e) {
|
| 66 |
log.error("BusinessException occurred: " + e.getMessage() + " Error code: " + e.getCode(), e);
|
| 67 |
var messageModel = MessageModel.builder().code(e.getCode()).build();
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
| 69 |
List<MessageBox> messageBoxList = new ArrayList<>();
|
| 70 |
messageBoxList.add(messageBox);
|
| 71 |
return responseFail(messageBoxList);
|
|
@@ -79,12 +87,25 @@ public class ResponseErrorHandler extends BaseController {
|
|
| 79 |
.orElseGet(UnhandledErrorType.UNHANDLED_ERROR_TYPE::getCode);
|
| 80 |
log.error("MethodArgumentNotValidException occurred: " + fieldErrorMessage);
|
| 81 |
var messageModel = MessageModel.builder().code(fieldErrorMessage).build();
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
| 83 |
List<MessageBox> messageBoxList = new ArrayList<>();
|
| 84 |
messageBoxList.add(messageBox);
|
| 85 |
return responseFail(messageBoxList);
|
| 86 |
}
|
| 87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
private MessageModel getDefaultMessageModel(HandlerMethod handlerMethod){
|
| 89 |
var methodName = getErrorFunction(handlerMethod);
|
| 90 |
return StringUtils.isNotEmpty(methodName) ?
|
|
|
|
| 3 |
import com.artandscience.webbff.webbff.common.base.controller.BaseController;
|
| 4 |
import com.artandscience.webbff.webbff.common.base.model.MessageModel;
|
| 5 |
import com.artandscience.webbff.webbff.common.base.model.RequestHeader;
|
| 6 |
+
import com.artandscience.webbff.webbff.common.base.response.BaseValidResponse;
|
| 7 |
import com.artandscience.webbff.webbff.common.base.response.MessageBox;
|
| 8 |
import com.artandscience.webbff.webbff.common.base.response.MessageResponse;
|
| 9 |
import com.artandscience.webbff.webbff.common.exception.BusinessException;
|
| 10 |
import com.artandscience.webbff.webbff.common.exception.SessionException;
|
| 11 |
+
import com.artandscience.webbff.webbff.common.exception.ForbiddenException;
|
| 12 |
import com.artandscience.webbff.webbff.common.exception.enums.UnhandledErrorType;
|
| 13 |
import com.artandscience.webbff.webbff.common.scope.RequestHeaderScope;
|
| 14 |
import com.artandscience.webbff.webbff.common.service.ExternalAttributeService;
|
|
|
|
| 56 |
public MessageResponse<Void> handleSessionExceptionError(SessionException e) {
|
| 57 |
log.error("SessionException occurred: " + e.getMessage() + " Error code: " + e.getCode(), e);
|
| 58 |
var messageModel = MessageModel.builder().code(e.getCode()).build();
|
| 59 |
+
var messageBox = externalAttributeService.getMessageBox(messageModel);
|
| 60 |
+
if (Objects.isNull(messageBox)) {
|
| 61 |
+
messageBox = getDefaultMessageBox();
|
| 62 |
+
}
|
| 63 |
List<MessageBox> messageBoxList = new ArrayList<>();
|
| 64 |
messageBoxList.add(messageBox);
|
| 65 |
return responseFail(messageBoxList);
|
|
|
|
| 70 |
public MessageResponse<Void> handleBusinessExceptionError(BusinessException e) {
|
| 71 |
log.error("BusinessException occurred: " + e.getMessage() + " Error code: " + e.getCode(), e);
|
| 72 |
var messageModel = MessageModel.builder().code(e.getCode()).build();
|
| 73 |
+
var messageBox = externalAttributeService.getMessageBox(messageModel);
|
| 74 |
+
if (Objects.isNull(messageBox)) {
|
| 75 |
+
messageBox = getDefaultMessageBox();
|
| 76 |
+
}
|
| 77 |
List<MessageBox> messageBoxList = new ArrayList<>();
|
| 78 |
messageBoxList.add(messageBox);
|
| 79 |
return responseFail(messageBoxList);
|
|
|
|
| 87 |
.orElseGet(UnhandledErrorType.UNHANDLED_ERROR_TYPE::getCode);
|
| 88 |
log.error("MethodArgumentNotValidException occurred: " + fieldErrorMessage);
|
| 89 |
var messageModel = MessageModel.builder().code(fieldErrorMessage).build();
|
| 90 |
+
var messageBox = externalAttributeService.getMessageBox(messageModel);
|
| 91 |
+
if (Objects.isNull(messageBox)) {
|
| 92 |
+
messageBox = getDefaultMessageBox();
|
| 93 |
+
}
|
| 94 |
List<MessageBox> messageBoxList = new ArrayList<>();
|
| 95 |
messageBoxList.add(messageBox);
|
| 96 |
return responseFail(messageBoxList);
|
| 97 |
}
|
| 98 |
|
| 99 |
+
@ExceptionHandler(value = ForbiddenException.class)
|
| 100 |
+
@ResponseStatus(HttpStatus.FORBIDDEN)
|
| 101 |
+
public BaseValidResponse handleForbiddenExceptionError(ForbiddenException e) {
|
| 102 |
+
log.error("Forbidden exception occurred: " + e.getMessage() + " ErrorCode: " + e.getCode(), e);
|
| 103 |
+
BaseValidResponse baseValidResponse = new BaseValidResponse();
|
| 104 |
+
baseValidResponse.setErrorFunction(e.getCode());
|
| 105 |
+
baseValidResponse.setErrorDescription(e.getMessage());
|
| 106 |
+
return validResponseFail(baseValidResponse);
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
private MessageModel getDefaultMessageModel(HandlerMethod handlerMethod){
|
| 110 |
var methodName = getErrorFunction(handlerMethod);
|
| 111 |
return StringUtils.isNotEmpty(methodName) ?
|
src/main/java/com/artandscience/webbff/webbff/common/interceptor/TransactionFilter.java
CHANGED
|
@@ -2,6 +2,7 @@ package com.artandscience.webbff.webbff.common.interceptor;
|
|
| 2 |
|
| 3 |
import com.artandscience.webbff.webbff.common.base.model.RequestHeader;
|
| 4 |
import com.artandscience.webbff.webbff.common.scope.RequestHeaderScope;
|
|
|
|
| 5 |
import jakarta.servlet.FilterChain;
|
| 6 |
import jakarta.servlet.ServletException;
|
| 7 |
import jakarta.servlet.annotation.WebFilter;
|
|
@@ -12,6 +13,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
| 12 |
import org.springframework.core.annotation.Order;
|
| 13 |
import org.springframework.stereotype.Component;
|
| 14 |
import org.springframework.web.filter.OncePerRequestFilter;
|
|
|
|
| 15 |
|
| 16 |
import java.io.IOException;
|
| 17 |
|
|
@@ -21,6 +23,8 @@ import static com.artandscience.webbff.webbff.common.constants.HeaderConstant.HE
|
|
| 21 |
import static com.artandscience.webbff.webbff.common.constants.HeaderConstant.HEADER_SESSION_ID;
|
| 22 |
import static com.artandscience.webbff.webbff.common.constants.HeaderConstant.HEADER_CORRELATION_ID;
|
| 23 |
import static com.artandscience.webbff.webbff.common.constants.HeaderConstant.HEADER_CUSTOMER_NUMBER;
|
|
|
|
|
|
|
| 24 |
|
| 25 |
|
| 26 |
|
|
@@ -32,6 +36,8 @@ import static com.artandscience.webbff.webbff.common.constants.HeaderConstant.HE
|
|
| 32 |
public class TransactionFilter extends OncePerRequestFilter {
|
| 33 |
|
| 34 |
private final RequestHeaderScope requestHeaderScope;
|
|
|
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
@Override
|
|
@@ -39,10 +45,13 @@ public class TransactionFilter extends OncePerRequestFilter {
|
|
| 39 |
throws ServletException, IOException {
|
| 40 |
|
| 41 |
try {
|
|
|
|
| 42 |
RequestHeader requestHeader = fillRequestHeader(request);
|
| 43 |
requestHeaderScope.setRequestHeader(requestHeader);
|
| 44 |
} catch (Exception e) {
|
| 45 |
log.error("Transaction Filter exception " + e.getMessage(), e);
|
|
|
|
|
|
|
| 46 |
}
|
| 47 |
filterChain.doFilter(request,response);
|
| 48 |
}
|
|
@@ -55,6 +64,8 @@ public class TransactionFilter extends OncePerRequestFilter {
|
|
| 55 |
.sessionId(request.getHeader(HEADER_SESSION_ID))
|
| 56 |
.correlationId(request.getHeader(HEADER_CORRELATION_ID))
|
| 57 |
.customerNumber(request.getHeader(HEADER_CUSTOMER_NUMBER))
|
|
|
|
|
|
|
| 58 |
.build();
|
| 59 |
}
|
| 60 |
|
|
|
|
| 2 |
|
| 3 |
import com.artandscience.webbff.webbff.common.base.model.RequestHeader;
|
| 4 |
import com.artandscience.webbff.webbff.common.scope.RequestHeaderScope;
|
| 5 |
+
import com.artandscience.webbff.webbff.common.utils.ProviderValidUtil;
|
| 6 |
import jakarta.servlet.FilterChain;
|
| 7 |
import jakarta.servlet.ServletException;
|
| 8 |
import jakarta.servlet.annotation.WebFilter;
|
|
|
|
| 13 |
import org.springframework.core.annotation.Order;
|
| 14 |
import org.springframework.stereotype.Component;
|
| 15 |
import org.springframework.web.filter.OncePerRequestFilter;
|
| 16 |
+
import org.springframework.web.servlet.HandlerExceptionResolver;
|
| 17 |
|
| 18 |
import java.io.IOException;
|
| 19 |
|
|
|
|
| 23 |
import static com.artandscience.webbff.webbff.common.constants.HeaderConstant.HEADER_SESSION_ID;
|
| 24 |
import static com.artandscience.webbff.webbff.common.constants.HeaderConstant.HEADER_CORRELATION_ID;
|
| 25 |
import static com.artandscience.webbff.webbff.common.constants.HeaderConstant.HEADER_CUSTOMER_NUMBER;
|
| 26 |
+
import static com.artandscience.webbff.webbff.common.constants.HeaderConstant.HEADER_REQUEST_FLOW_ID;
|
| 27 |
+
import static com.artandscience.webbff.webbff.common.constants.HeaderConstant.HEADER_DEVICE_APP_ID;
|
| 28 |
|
| 29 |
|
| 30 |
|
|
|
|
| 36 |
public class TransactionFilter extends OncePerRequestFilter {
|
| 37 |
|
| 38 |
private final RequestHeaderScope requestHeaderScope;
|
| 39 |
+
private final ProviderValidUtil providerValidUtil;
|
| 40 |
+
private final HandlerExceptionResolver handlerExceptionResolver;
|
| 41 |
|
| 42 |
|
| 43 |
@Override
|
|
|
|
| 45 |
throws ServletException, IOException {
|
| 46 |
|
| 47 |
try {
|
| 48 |
+
providerValidUtil.valid(request.getHeader(HEADER_REQUEST_FLOW_ID),request.getHeader(HEADER_DEVICE_APP_ID));
|
| 49 |
RequestHeader requestHeader = fillRequestHeader(request);
|
| 50 |
requestHeaderScope.setRequestHeader(requestHeader);
|
| 51 |
} catch (Exception e) {
|
| 52 |
log.error("Transaction Filter exception " + e.getMessage(), e);
|
| 53 |
+
handlerExceptionResolver.resolveException(request,response,null,e);
|
| 54 |
+
return;
|
| 55 |
}
|
| 56 |
filterChain.doFilter(request,response);
|
| 57 |
}
|
|
|
|
| 64 |
.sessionId(request.getHeader(HEADER_SESSION_ID))
|
| 65 |
.correlationId(request.getHeader(HEADER_CORRELATION_ID))
|
| 66 |
.customerNumber(request.getHeader(HEADER_CUSTOMER_NUMBER))
|
| 67 |
+
.requestFlowId(request.getHeader(HEADER_REQUEST_FLOW_ID))
|
| 68 |
+
.deviceAppId(request.getHeader(HEADER_DEVICE_APP_ID))
|
| 69 |
.build();
|
| 70 |
}
|
| 71 |
|
src/main/java/com/artandscience/webbff/webbff/common/utils/ProviderValidUtil.java
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.utils;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.integration.service.ProviderClientService;
|
| 4 |
+
import com.artandscience.webbff.webbff.integration.service.request.ValidateProviderClientRequest;
|
| 5 |
+
import lombok.RequiredArgsConstructor;
|
| 6 |
+
import lombok.extern.slf4j.Slf4j;
|
| 7 |
+
import org.springframework.stereotype.Component;
|
| 8 |
+
|
| 9 |
+
@Slf4j
|
| 10 |
+
@RequiredArgsConstructor
|
| 11 |
+
@Component
|
| 12 |
+
public class ProviderValidUtil {
|
| 13 |
+
|
| 14 |
+
private final ProviderClientService providerClientService;
|
| 15 |
+
private static final String SERVICE_NAME = "arts-web-bff-service";
|
| 16 |
+
|
| 17 |
+
public void valid(String requestFlowId, String deviceAppId) {
|
| 18 |
+
|
| 19 |
+
ValidateProviderClientRequest clientRequest = ValidateProviderClientRequest
|
| 20 |
+
.builder()
|
| 21 |
+
.serviceName(SERVICE_NAME)
|
| 22 |
+
.build();
|
| 23 |
+
|
| 24 |
+
providerClientService.validateProvider(clientRequest,"tr",requestFlowId,deviceAppId);
|
| 25 |
+
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/domain/mapper/SlideModelMapper.java
CHANGED
|
@@ -4,7 +4,6 @@ import com.artandscience.webbff.webbff.domain.model.campaign.CampaignModel;
|
|
| 4 |
import com.artandscience.webbff.webbff.domain.model.heroModel.SlideModel;
|
| 5 |
import lombok.extern.slf4j.Slf4j;
|
| 6 |
|
| 7 |
-
import java.util.ArrayList;
|
| 8 |
import java.util.List;
|
| 9 |
|
| 10 |
@Slf4j
|
|
|
|
| 4 |
import com.artandscience.webbff.webbff.domain.model.heroModel.SlideModel;
|
| 5 |
import lombok.extern.slf4j.Slf4j;
|
| 6 |
|
|
|
|
| 7 |
import java.util.List;
|
| 8 |
|
| 9 |
@Slf4j
|
src/main/java/com/artandscience/webbff/webbff/integration/config/FeignClientSecurityConfiguration.java
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.integration.config;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.integration.decoder.FeignSecurityErrorDecoder;
|
| 4 |
+
import com.artandscience.webbff.webbff.integration.interceptor.FeignClientInterceptor;
|
| 5 |
+
import feign.Client;
|
| 6 |
+
import feign.Retryer;
|
| 7 |
+
import feign.codec.ErrorDecoder;
|
| 8 |
+
import lombok.RequiredArgsConstructor;
|
| 9 |
+
import org.springframework.context.annotation.Bean;
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@RequiredArgsConstructor
|
| 13 |
+
public class FeignClientSecurityConfiguration {
|
| 14 |
+
|
| 15 |
+
@Bean
|
| 16 |
+
public Client client() {
|
| 17 |
+
return new FeignClientInterceptor(null,null);
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
@Bean
|
| 21 |
+
public Retryer retryer() {
|
| 22 |
+
return Retryer.NEVER_RETRY;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
@Bean
|
| 26 |
+
public ErrorDecoder errorDecoder() {
|
| 27 |
+
return new FeignSecurityErrorDecoder();
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/integration/decoder/FeignSecurityErrorDecoder.java
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.integration.decoder;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.exception.ForbiddenException;
|
| 4 |
+
import com.artandscience.webbff.webbff.common.helper.JsonMapper;
|
| 5 |
+
import com.artandscience.webbff.webbff.integration.service.response.base.BaseProviderValidClientResponse;
|
| 6 |
+
import com.artandscience.webbff.webbff.integration.service.util.DecoderUtil;
|
| 7 |
+
import feign.Request;
|
| 8 |
+
import feign.RequestTemplate;
|
| 9 |
+
import feign.Response;
|
| 10 |
+
import feign.Target;
|
| 11 |
+
import feign.codec.ErrorDecoder;
|
| 12 |
+
import lombok.extern.slf4j.Slf4j;
|
| 13 |
+
import org.apache.logging.log4j.util.Strings;
|
| 14 |
+
import org.springframework.stereotype.Component;
|
| 15 |
+
|
| 16 |
+
import java.util.Optional;
|
| 17 |
+
|
| 18 |
+
@Slf4j
|
| 19 |
+
@Component
|
| 20 |
+
public class FeignSecurityErrorDecoder implements ErrorDecoder {
|
| 21 |
+
|
| 22 |
+
@Override
|
| 23 |
+
public Exception decode(String methodKey, Response response) {
|
| 24 |
+
String responseBody = DecoderUtil.readBody(response);
|
| 25 |
+
|
| 26 |
+
String serviceName = Optional.ofNullable(response)
|
| 27 |
+
.map(Response::request)
|
| 28 |
+
.map(Request::requestTemplate)
|
| 29 |
+
.map(RequestTemplate::feignTarget)
|
| 30 |
+
.map(Target::name)
|
| 31 |
+
.orElse(Strings.EMPTY);
|
| 32 |
+
|
| 33 |
+
int status = response != null ? response.status() : 500;
|
| 34 |
+
String reason = response != null ? response.reason() : Strings.EMPTY;
|
| 35 |
+
|
| 36 |
+
log.error("Feign security error. methodKey: {}, status: {}, reason: {}, serviceName: {}, body: {}",
|
| 37 |
+
methodKey,
|
| 38 |
+
status,
|
| 39 |
+
reason,
|
| 40 |
+
serviceName,
|
| 41 |
+
responseBody
|
| 42 |
+
);
|
| 43 |
+
|
| 44 |
+
try {
|
| 45 |
+
String normalizedBody = responseBody.replace("\n", "");
|
| 46 |
+
|
| 47 |
+
BaseProviderValidClientResponse baseResponse =
|
| 48 |
+
JsonMapper.convertToData(
|
| 49 |
+
normalizedBody,
|
| 50 |
+
BaseProviderValidClientResponse.class
|
| 51 |
+
);
|
| 52 |
+
|
| 53 |
+
return new ForbiddenException(
|
| 54 |
+
baseResponse.getErrorFunction(),
|
| 55 |
+
baseResponse.getServiceName(),
|
| 56 |
+
baseResponse.getErrorDescription()
|
| 57 |
+
);
|
| 58 |
+
|
| 59 |
+
} catch (Exception exception) {
|
| 60 |
+
log.error("Feign error body parse failed. Raw body: {}", responseBody, exception);
|
| 61 |
+
|
| 62 |
+
return new ForbiddenException(
|
| 63 |
+
"PROVIDER_VALIDATE",
|
| 64 |
+
serviceName,
|
| 65 |
+
responseBody
|
| 66 |
+
);
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/integration/interceptor/FeignClientInterceptor.java
CHANGED
|
@@ -14,25 +14,40 @@ import java.io.InputStream;
|
|
| 14 |
import java.nio.charset.StandardCharsets;
|
| 15 |
|
| 16 |
@Slf4j
|
| 17 |
-
public class FeignClientInterceptor extends Client.Default{
|
| 18 |
|
| 19 |
-
public FeignClientInterceptor(SSLSocketFactory sslContextFactory,
|
| 20 |
-
|
|
|
|
| 21 |
}
|
| 22 |
|
| 23 |
@Override
|
| 24 |
public Response execute(Request request, Request.Options options) throws IOException {
|
| 25 |
-
|
| 26 |
-
try(Response response = super.execute(request,options)) {
|
| 27 |
-
if (response.body() != null) {
|
| 28 |
-
InputStream bodyStream = response.body().asInputStream();
|
| 29 |
-
responseBody = StreamUtils.copyToString(bodyStream, StandardCharsets.UTF_8);
|
| 30 |
-
}
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
}
|
| 37 |
|
| 38 |
private void handleException(String responseBody) throws CoreException, IOException {
|
|
|
|
| 14 |
import java.nio.charset.StandardCharsets;
|
| 15 |
|
| 16 |
@Slf4j
|
| 17 |
+
public class FeignClientInterceptor extends Client.Default {
|
| 18 |
|
| 19 |
+
public FeignClientInterceptor(SSLSocketFactory sslContextFactory,
|
| 20 |
+
HostnameVerifier hostnameVerifier) {
|
| 21 |
+
super(sslContextFactory, hostnameVerifier);
|
| 22 |
}
|
| 23 |
|
| 24 |
@Override
|
| 25 |
public Response execute(Request request, Request.Options options) throws IOException {
|
| 26 |
+
Response response = super.execute(request, options);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
log.error("Feign raw response status: {}", response.status());
|
| 29 |
+
log.error("Feign raw response reason: {}", response.reason());
|
| 30 |
+
log.error("Feign raw response headers: {}", response.headers());
|
| 31 |
+
log.error("Feign raw response body null: {}", response.body() == null);
|
| 32 |
|
| 33 |
+
if (response.body() == null) {
|
| 34 |
+
log.warn("Feign response body is null. status: {}, reason: {}, url: {}, headers: {}",
|
| 35 |
+
response.status(),
|
| 36 |
+
response.reason(),
|
| 37 |
+
request.url(),
|
| 38 |
+
response.headers());
|
| 39 |
+
|
| 40 |
+
return response;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
String responseBody;
|
| 44 |
+
try (InputStream bodyStream = response.body().asInputStream()) {
|
| 45 |
+
responseBody = StreamUtils.copyToString(bodyStream, StandardCharsets.UTF_8);
|
| 46 |
}
|
| 47 |
+
|
| 48 |
+
return response.toBuilder()
|
| 49 |
+
.body(responseBody, StandardCharsets.UTF_8)
|
| 50 |
+
.build();
|
| 51 |
}
|
| 52 |
|
| 53 |
private void handleException(String responseBody) throws CoreException, IOException {
|
src/main/java/com/artandscience/webbff/webbff/integration/interceptor/providerValid/FeignClientSecurityInterceptor.java
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.integration.interceptor.providerValid;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.exception.CoreException;
|
| 4 |
+
import feign.Client;
|
| 5 |
+
import feign.Request;
|
| 6 |
+
import feign.Response;
|
| 7 |
+
import org.springframework.util.StreamUtils;
|
| 8 |
+
|
| 9 |
+
import javax.net.ssl.HostnameVerifier;
|
| 10 |
+
import javax.net.ssl.SSLSocketFactory;
|
| 11 |
+
import java.io.IOException;
|
| 12 |
+
import java.io.InputStream;
|
| 13 |
+
import java.nio.charset.StandardCharsets;
|
| 14 |
+
|
| 15 |
+
public class FeignClientSecurityInterceptor extends Client.Default{
|
| 16 |
+
|
| 17 |
+
public FeignClientSecurityInterceptor(SSLSocketFactory sslContextFactory, HostnameVerifier hostnameVerifier) {
|
| 18 |
+
super(sslContextFactory,hostnameVerifier);
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
@Override
|
| 22 |
+
public Response execute(Request request, Request.Options options) throws IOException {
|
| 23 |
+
String responseBody = "";
|
| 24 |
+
try(Response response = super.execute(request,options)) {
|
| 25 |
+
if (response.body() != null) {
|
| 26 |
+
InputStream bodyStream = response.body().asInputStream();
|
| 27 |
+
responseBody = StreamUtils.copyToString(bodyStream, StandardCharsets.UTF_8);
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
handleException(responseBody);
|
| 31 |
+
|
| 32 |
+
return response.toBuilder().body(responseBody, StandardCharsets.UTF_8).build();
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
private void handleException(String responseBody) throws CoreException, IOException {
|
| 37 |
+
|
| 38 |
+
}
|
| 39 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/integration/service/ProviderClientService.java
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.integration.service;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.integration.config.FeignClientConfiguration;
|
| 4 |
+
import com.artandscience.webbff.webbff.integration.config.FeignClientSecurityConfiguration;
|
| 5 |
+
import com.artandscience.webbff.webbff.integration.service.request.ValidateProviderClientRequest;
|
| 6 |
+
import com.artandscience.webbff.webbff.integration.service.response.base.BaseProviderValidClientResponse;
|
| 7 |
+
import org.springframework.cloud.openfeign.FeignClient;
|
| 8 |
+
import org.springframework.http.MediaType;
|
| 9 |
+
import org.springframework.web.bind.annotation.PostMapping;
|
| 10 |
+
import org.springframework.web.bind.annotation.RequestHeader;
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
@FeignClient(name = "${provider-service.name}", url = "${provider-service.base-url}",
|
| 14 |
+
configuration = FeignClientSecurityConfiguration.class)
|
| 15 |
+
public interface ProviderClientService {
|
| 16 |
+
|
| 17 |
+
@PostMapping(path = "${provider-service.validate-provider}", produces = MediaType.APPLICATION_JSON_VALUE)
|
| 18 |
+
BaseProviderValidClientResponse validateProvider(ValidateProviderClientRequest request,
|
| 19 |
+
@RequestHeader("x-language")String language,
|
| 20 |
+
@RequestHeader("x-request-flow-id")String requestFlowId,
|
| 21 |
+
@RequestHeader("x-device-app-id")String deviceAppId);
|
| 22 |
+
|
| 23 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/integration/service/request/ValidateProviderClientRequest.java
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.integration.service.request;
|
| 2 |
+
|
| 3 |
+
import lombok.AllArgsConstructor;
|
| 4 |
+
import lombok.Builder;
|
| 5 |
+
import lombok.Data;
|
| 6 |
+
import lombok.NoArgsConstructor;
|
| 7 |
+
|
| 8 |
+
@Data
|
| 9 |
+
@Builder
|
| 10 |
+
@AllArgsConstructor
|
| 11 |
+
@NoArgsConstructor
|
| 12 |
+
public class ValidateProviderClientRequest {
|
| 13 |
+
private String serviceName;
|
| 14 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/integration/service/response/base/BaseProviderValidClientResponse.java
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.integration.service.response.base;
|
| 2 |
+
|
| 3 |
+
import lombok.AllArgsConstructor;
|
| 4 |
+
import lombok.Data;
|
| 5 |
+
import lombok.NoArgsConstructor;
|
| 6 |
+
|
| 7 |
+
@Data
|
| 8 |
+
@AllArgsConstructor
|
| 9 |
+
@NoArgsConstructor
|
| 10 |
+
public class BaseProviderValidClientResponse {
|
| 11 |
+
|
| 12 |
+
private Boolean isValid;
|
| 13 |
+
private String serviceName;
|
| 14 |
+
private String errorDescription;
|
| 15 |
+
private String errorFunction;
|
| 16 |
+
private String transactionId;
|
| 17 |
+
|
| 18 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/integration/service/util/DecoderUtil.java
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.integration.service.util;
|
| 2 |
+
|
| 3 |
+
import feign.Response;
|
| 4 |
+
import feign.Util;
|
| 5 |
+
|
| 6 |
+
import java.io.IOException;
|
| 7 |
+
import java.io.Reader;
|
| 8 |
+
import java.nio.charset.StandardCharsets;
|
| 9 |
+
|
| 10 |
+
public final class DecoderUtil {
|
| 11 |
+
|
| 12 |
+
private DecoderUtil() {
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
public static String readBody(Response response) {
|
| 16 |
+
if (response == null || response.body() == null) {
|
| 17 |
+
return "";
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
try (Reader reader = response.body().asReader(StandardCharsets.UTF_8)) {
|
| 21 |
+
return Util.toString(reader);
|
| 22 |
+
} catch (IOException exception) {
|
| 23 |
+
throw new RuntimeException("Feign response body could not be read", exception);
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
}
|
src/main/resources/application.yml
CHANGED
|
@@ -37,7 +37,7 @@ artandscience-web:
|
|
| 37 |
configmodel-cache-expire-time: 0 0 3 * * *
|
| 38 |
|
| 39 |
server:
|
| 40 |
-
port:
|
| 41 |
servlet:
|
| 42 |
context-path: /arts-web-bff-service
|
| 43 |
|
|
@@ -45,3 +45,20 @@ campaign-core-service:
|
|
| 45 |
name: "campaign-service"
|
| 46 |
base-url: "${BASE_CORE_SERVICE_URL}/api/v1/campaign"
|
| 47 |
session-start: "/startSession"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
configmodel-cache-expire-time: 0 0 3 * * *
|
| 38 |
|
| 39 |
server:
|
| 40 |
+
port: 9494
|
| 41 |
servlet:
|
| 42 |
context-path: /arts-web-bff-service
|
| 43 |
|
|
|
|
| 45 |
name: "campaign-service"
|
| 46 |
base-url: "${BASE_CORE_SERVICE_URL}/api/v1/campaign"
|
| 47 |
session-start: "/startSession"
|
| 48 |
+
|
| 49 |
+
provider-service:
|
| 50 |
+
name: "provider-service"
|
| 51 |
+
base-url: "${BASE_SECURITY_SERVICE_URL}/api/v1/provider"
|
| 52 |
+
validate-provider: "validate-provider"
|
| 53 |
+
|
| 54 |
+
management:
|
| 55 |
+
endpoints:
|
| 56 |
+
web:
|
| 57 |
+
exposure:
|
| 58 |
+
include: health,info,prometheus
|
| 59 |
+
endpoint:
|
| 60 |
+
prometheus:
|
| 61 |
+
enabled: true
|
| 62 |
+
metrics:
|
| 63 |
+
tags:
|
| 64 |
+
application: webbff-service
|