Skip to content

Commit

Permalink
Merge pull request #73 from ananjaykumar2/modify/pii-access-policy
Browse files Browse the repository at this point in the history
fixed: null value for ppbNumber
  • Loading branch information
pranavrd authored Mar 11, 2024
2 parents 695bd85 + 8c07729 commit b35d7b3
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 14 deletions.
10 changes: 6 additions & 4 deletions examples/configs/config-dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
{
"id": "iudx.rs.proxy.authenticator.AuthenticationVerticle",
"verticleInstances": 1,
"keystore": "",
"keystorePassword": "",
"audience": "",
"authServerHost": "",
"jwtIgnoreExpiry": true
Expand Down Expand Up @@ -59,7 +61,10 @@
"verticleInstances": 1,
"dataBrokerIP": "",
"dataBrokerPort": 1234,
"prodVhost": "",
"internalVhost": "",
"externalVhost": "",
"adapterQueryPublishExchange": "",
"dataBrokerUserName": "",
"dataBrokerPassword": "",
"dataBrokerManagementPort": 30042,
Expand All @@ -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": ""
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/iudx/rs/proxy/apiserver/AsyncRestApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ private Future<Void> logConsentResponse(RoutingContext routingContext) {
consentLog = "DATA_DENIED";
break;
}
default:
consentLog = "DATA_DENIED";
}
LOGGER.info("response ended : {}", routingContext.response());
LOGGER.info("consent log : {}", consentLog);
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/iudx/rs/proxy/apiserver/ParamsValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ private Future<Boolean> isValidQueryWithFilters(MultiMap paramsMap) {
filtersFuture.onComplete(handler -> {
if (handler.succeeded()) {
JsonObject catItemJson = filtersFuture.result();
List<String> filters = new ArrayList<>(catItemJson.getJsonArray("iudxResourceAPIs").getList());
LOGGER.debug("for filters:: "+catItemJson);
List<String> 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;
Expand Down
31 changes: 22 additions & 9 deletions src/main/java/iudx/rs/proxy/apiserver/handlers/AuthHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,14 @@ public void handle(RoutingContext context) {

LOGGER.debug("Info :" + context.request().path());
String id = getId(context, ID);
LOGGER.debug("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);
Expand All @@ -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,
Expand Down Expand Up @@ -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));

Expand All @@ -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));

Expand All @@ -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;
}

}


Expand Down

0 comments on commit b35d7b3

Please sign in to comment.