diff options
Diffstat (limited to 'src/main/java/org/onap')
-rw-r--r-- | src/main/java/org/onap/crud/service/CrudRestService.java | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/main/java/org/onap/crud/service/CrudRestService.java b/src/main/java/org/onap/crud/service/CrudRestService.java index 5539374..2cbb87c 100644 --- a/src/main/java/org/onap/crud/service/CrudRestService.java +++ b/src/main/java/org/onap/crud/service/CrudRestService.java @@ -790,16 +790,29 @@ public class CrudRestService { return false; } - String sourceOfTruth = null; - if (headers.getRequestHeaders().containsKey("X-FromAppId")) { - sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId"); - } + validateRequestHeader(headers); + + return isValid; + } + + public void validateRequestHeader(HttpHeaders headers) throws CrudException { + String sourceOfTruth = null; + if (headers.getRequestHeaders().containsKey("X-FromAppId")) { + sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId"); + } - if (sourceOfTruth == null || sourceOfTruth.trim() == "") { - throw new CrudException("Invalid request, Missing X-FromAppId header", Status.BAD_REQUEST); - } + if (sourceOfTruth == null || sourceOfTruth.trim() == "") { + throw new CrudException("Invalid request, Missing X-FromAppId header", Status.BAD_REQUEST); + } + + String transId = null; + if (headers.getRequestHeaders().containsKey("X-TransactionId")) { + transId = headers.getRequestHeaders().getFirst("X-TransactionId"); + } - return isValid; + if (transId == null || transId.trim() == "") { + throw new CrudException("Invalid request, Missing X-TransactionId header", Status.BAD_REQUEST); + } } void logResult(Action op, String uri, Exception e) { |