From 668a4c44914f56a539a9c6c45d4e724fe141a384 Mon Sep 17 00:00:00 2001 From: ananjaykumar2 Date: Thu, 7 Mar 2024 14:14:01 +0530 Subject: [PATCH 1/2] fixed: null value for ppbNumber --- examples/configs/config-dev.json | 10 +++--- .../iudx/rs/proxy/apiserver/AsyncRestApi.java | 4 +++ .../rs/proxy/apiserver/ParamsValidator.java | 3 +- .../proxy/apiserver/handlers/AuthHandler.java | 31 +++++++++++++------ 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/examples/configs/config-dev.json b/examples/configs/config-dev.json index a1d92ef..d202d15 100644 --- a/examples/configs/config-dev.json +++ b/examples/configs/config-dev.json @@ -23,6 +23,8 @@ { "id": "iudx.rs.proxy.authenticator.AuthenticationVerticle", "verticleInstances": 1, + "keystore": "", + "keystorePassword": "", "audience": "", "authServerHost": "", "jwtIgnoreExpiry": true @@ -59,7 +61,10 @@ "verticleInstances": 1, "dataBrokerIP": "", "dataBrokerPort": 1234, + "prodVhost": "", "internalVhost": "", + "externalVhost": "", + "adapterQueryPublishExchange": "", "dataBrokerUserName": "", "dataBrokerPassword": "", "dataBrokerManagementPort": 30042, @@ -68,13 +73,10 @@ "handshakeTimeout": 6000, "requestedChannelMax": 5, "networkRecoveryInterval": 500, - "automaticRecoveryEnabled": "", - "adapterQueryPublishExchange": "", - "adapterQueryReplyQueue": "" + "automaticRecoveryEnabled": "" }, { "id": "iudx.rs.proxy.optional.consentlogs.ConsentLoggingVerticle", - "isWorkerVerticle": true, "verticleInstances": 1, "certFileName": "", "password": "" diff --git a/src/main/java/iudx/rs/proxy/apiserver/AsyncRestApi.java b/src/main/java/iudx/rs/proxy/apiserver/AsyncRestApi.java index b8a8493..9932809 100644 --- a/src/main/java/iudx/rs/proxy/apiserver/AsyncRestApi.java +++ b/src/main/java/iudx/rs/proxy/apiserver/AsyncRestApi.java @@ -127,6 +127,8 @@ private Future logConsentResponse(RoutingContext routingContext) { consentLog = "DATA_DENIED"; break; } + default: + consentLog = "DATA_DENIED"; } LOGGER.info("response ended : {}", routingContext.response()); LOGGER.info("consent log : {}", consentLog); @@ -320,6 +322,8 @@ private void adapterResponseForSearchQuery(RoutingContext context, JsonObject js if (isAdexInstance) { json.put("ppbNumber", extractPPBNo(authInfo)); // this is exclusive for ADeX deployment. } + + LOGGER.debug("publishing async query into rmq :" + json); databrokerService.executeAdapterQueryRPC(json, handler -> { if (handler.succeeded()) { JsonObject adapterResponse = handler.result(); diff --git a/src/main/java/iudx/rs/proxy/apiserver/ParamsValidator.java b/src/main/java/iudx/rs/proxy/apiserver/ParamsValidator.java index 564815c..101af35 100644 --- a/src/main/java/iudx/rs/proxy/apiserver/ParamsValidator.java +++ b/src/main/java/iudx/rs/proxy/apiserver/ParamsValidator.java @@ -177,7 +177,8 @@ private Future isValidQueryWithFilters(MultiMap paramsMap) { filtersFuture.onComplete(handler -> { if (handler.succeeded()) { JsonObject catItemJson = filtersFuture.result(); - List filters = new ArrayList<>(catItemJson.getJsonArray("iudxResourceAPIs").getList()); + LOGGER.debug("for filters:: "+catItemJson); + List filters = new ArrayList<>(catItemJson.getJsonArray("iudxResourceAPIs",new JsonArray()).getList()); if (isTemporalQuery(paramsMap) && !filters.contains("TEMPORAL")) { promise.fail("Temporal parameters are not supported by RS group/Item."); return; diff --git a/src/main/java/iudx/rs/proxy/apiserver/handlers/AuthHandler.java b/src/main/java/iudx/rs/proxy/apiserver/handlers/AuthHandler.java index b791ba8..80f5a5a 100644 --- a/src/main/java/iudx/rs/proxy/apiserver/handlers/AuthHandler.java +++ b/src/main/java/iudx/rs/proxy/apiserver/handlers/AuthHandler.java @@ -80,9 +80,14 @@ public void handle(RoutingContext context) { LOGGER.debug("Info :" + context.request().path()); String id = getId(context, ID); + LOGGER.error("ID : {}", id); + if (isAdexInstance) { - String ppbNumber = getId(context, NGSLILDQUERY_Q); - authInfo.put(PPB_NUMBER, ppbNumber); + String ppbNumber = getId(context, NGSLILDQUERY_Q); + LOGGER.debug("ppbNumber :{}", ppbNumber); + if(ppbNumber!=null){ + authInfo.put(PPB_NUMBER, ppbNumber); + } } authInfo.put(ID, id); @@ -91,6 +96,7 @@ public void handle(RoutingContext context) { for (String i : idArray) { ids.add(i); } + LOGGER.debug("authInfo: "+authInfo); requestJson.put(IDS, ids); authenticator.tokenIntrospect( requestJson, @@ -162,7 +168,7 @@ private String getId(RoutingContext context, String option) { private String getId4rmRequest(String option) { if (option.equalsIgnoreCase(NGSLILDQUERY_Q)) { - String ppbnoValue = null; + String ppbnoValue = ""; try { ppbnoValue = extractPpbno(request.getParam(option)); @@ -177,7 +183,7 @@ private String getId4rmRequest(String option) { private String getId4rmBody(RoutingContext context, String option) { JsonObject body = context.body().asJsonObject(); if (option.equalsIgnoreCase(NGSLILDQUERY_Q) && body != null) { - String ppbnoValue = null; + String ppbnoValue = ""; try { ppbnoValue = extractPpbno(body.getString(NGSLILDQUERY_Q)); @@ -201,11 +207,18 @@ private String getId4rmBody(RoutingContext context, String option) { private String extractPpbno(String q) { LOGGER.info("q: " + q); - int PpbIndex = q.indexOf("Ppbno=="); - int firstSemiIndex = q.indexOf(';', PpbIndex); - firstSemiIndex = firstSemiIndex == -1 ? q.length() : firstSemiIndex; - String ppbno = q.substring(PpbIndex + 7, firstSemiIndex); - return ppbno; + try{ + int PpbIndex = q.indexOf("Ppbno=="); + int firstSemiIndex = q.indexOf(';', PpbIndex); + firstSemiIndex = firstSemiIndex == -1 ? q.length() : firstSemiIndex; + String ppbno = q.substring(PpbIndex + 7, firstSemiIndex); + LOGGER.debug("ppbno:: "+ppbno); + return ppbno; + }catch (Exception e){ + e.printStackTrace(); + return null; + } + } From 8c077296a5523f3b70845784f4b614518a93d550 Mon Sep 17 00:00:00 2001 From: Ananjay <78589053+ananjaykumar2@users.noreply.github.com> Date: Mon, 11 Mar 2024 12:20:20 +0530 Subject: [PATCH 2/2] Update AuthHandler.java --- src/main/java/iudx/rs/proxy/apiserver/handlers/AuthHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/iudx/rs/proxy/apiserver/handlers/AuthHandler.java b/src/main/java/iudx/rs/proxy/apiserver/handlers/AuthHandler.java index 80f5a5a..65d41ff 100644 --- a/src/main/java/iudx/rs/proxy/apiserver/handlers/AuthHandler.java +++ b/src/main/java/iudx/rs/proxy/apiserver/handlers/AuthHandler.java @@ -80,7 +80,7 @@ public void handle(RoutingContext context) { LOGGER.debug("Info :" + context.request().path()); String id = getId(context, ID); - LOGGER.error("ID : {}", id); + LOGGER.debug("ID : {}", id); if (isAdexInstance) { String ppbNumber = getId(context, NGSLILDQUERY_Q);