Skip to content

Commit

Permalink
Biometric changes
Browse files Browse the repository at this point in the history
  • Loading branch information
indraniBan authored and indraniBan committed Aug 13, 2024
1 parent 0d040e0 commit 7e2d47d
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 15 deletions.
2 changes: 2 additions & 0 deletions src/main/environment/common_ci.properties
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ [email protected]_HEALTH_ID_BASE_URL@/api/v1/auth/confirmWithMobileOTP
verifyOTP_ForCard_Aadhaar=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/auth/confirmWithAadhaarOtp
## print ABHA card - PNG
generateHealthCard=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/health/facility/getPngCard
generateHealthIDCard=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/account/getPngCard

## Generate Notify SMS once episode completed
generateABDM_NotifySMS=@env.ABDM_BASE_URL@/gateway/v1/patients/sms/notify2
Expand All @@ -74,6 +75,7 @@ [email protected]_BASE_URL@/gateway/v1/patients/sms/notify2
abdmVerifyBio=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/registration/aadhaar/verifyBio
abdmGenerateMobileOTP=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/registration/aadhaar/generateMobileOTP
abdmConfirmAadhaarBio=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/auth/confirmWithAadhaarBio
abdmAccountProfile=@env.ABDM_Account_ID_BASE_URL@/api/v1/account/profile

abhaMode=sbx

Expand Down
8 changes: 5 additions & 3 deletions src/main/environment/common_dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@ verifyOTP_ForCard=https://healthidsbx.abdm.gov.in/api/v1/auth/confirmWithMobileO
verifyOTP_ForCard_Aadhaar=https://healthidsbx.abdm.gov.in/api/v1/auth/confirmWithAadhaarOtp
## print ABHA card - PNG
generateHealthCard=https://healthidsbx.abdm.gov.in/api/v1/health/facility/getPngCard
generateHealthIDCard=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/account/getPngCard

## Generate Notify SMS once episode completed
generateABDM_NotifySMS=https://dev.abdm.gov.in/gateway/v1/patients/sms/notify2

##verifyBio
abdmVerifyBio=https://healthidsbx.abdm.gov.in/api/v1/registration/aadhaar/verifyBio
abdmGenerateMobileOTP=https://healthidsbx.abdm.gov.in/api/v1/registration/aadhaar/generateMobileOTP
abdmConfirmAadhaarBio=https://healthidsbx.abdm.gov.in/api/v1/auth/confirmWithAadhaarBio
abdmVerifyBio=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/registration/aadhaar/verifyBio
abdmGenerateMobileOTP=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/registration/aadhaar/generateMobileOTP
abdmConfirmAadhaarBio=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/auth/confirmWithAadhaarBio
abdmAccountProfile=@env.ABDM_Account_ID_BASE_URL@/api/v1/account/profile

abhaMode=sbx

Expand Down
8 changes: 5 additions & 3 deletions src/main/environment/common_example.properties
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@ verifyOTP_ForCard=https://healthidsbx.abdm.gov.in/api/v1/auth/confirmWithMobileO
verifyOTP_ForCard_Aadhaar=https://healthidsbx.abdm.gov.in/api/v1/auth/confirmWithAadhaarOtp
## print ABHA card - PNG
generateHealthCard=https://healthidsbx.abdm.gov.in/api/v1/health/facility/getPngCard
generateHealthIDCard=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/account/getPngCard

## Generate Notify SMS once episode completed
generateABDM_NotifySMS=https://dev.abdm.gov.in/gateway/v1/patients/sms/notify2

##verifyBio
abdmVerifyBio=https://healthidsbx.abdm.gov.in/api/v1/registration/aadhaar/verifyBio
abdmGenerateMobileOTP=https://healthidsbx.abdm.gov.in/api/v1/registration/aadhaar/generateMobileOTP
abdmConfirmAadhaarBio=https://healthidsbx.abdm.gov.in/api/v1/auth/confirmWithAadhaarBio
abdmVerifyBio=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/registration/aadhaar/verifyBio
abdmGenerateMobileOTP=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/registration/aadhaar/generateMobileOTP
abdmConfirmAadhaarBio=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/auth/confirmWithAadhaarBio
abdmAccountProfile=@env.ABDM_Account_ID_BASE_URL@/api/v1/account/profile

abhaMode=sbx

Expand Down
8 changes: 5 additions & 3 deletions src/main/environment/common_test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@ verifyOTP_ForCard=https://healthidsbx.abdm.gov.in/api/v1/auth/confirmWithMobileO
verifyOTP_ForCard_Aadhaar=https://healthidsbx.abdm.gov.in/api/v1/auth/confirmWithAadhaarOtp
## print ABHA card - PNG
generateHealthCard=https://healthidsbx.abdm.gov.in/api/v1/health/facility/getPngCard
generateHealthIDCard=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/account/getPngCard

## Generate Notify SMS once episode completed
generateABDM_NotifySMS=https://dev.abdm.gov.in/gateway/v1/patients/sms/notify2

##verifyBio
abdmVerifyBio=https://healthidsbx.abdm.gov.in/api/v1/registration/aadhaar/verifyBio
abdmGenerateMobileOTP=https://healthidsbx.abdm.gov.in/api/v1/registration/aadhaar/generateMobileOTP
abdmConfirmAadhaarBio=https://healthidsbx.abdm.gov.in/api/v1/auth/confirmWithAadhaarBio
abdmVerifyBio=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/registration/aadhaar/verifyBio
abdmGenerateMobileOTP=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/registration/aadhaar/generateMobileOTP
abdmConfirmAadhaarBio=@env.ABDM_HEALTH_ID_BASE_URL@/api/v1/auth/confirmWithAadhaarBio
abdmAccountProfile=@env.ABDM_Account_ID_BASE_URL@/api/v1/account/profile

abhaMode=sbx

Expand Down
33 changes: 33 additions & 0 deletions src/main/java/com/wipro/fhir/data/healthID/VerifyBiometric.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.wipro.fhir.data.healthID;

public class VerifyBiometric {

String aadhaar;
String pid;
String bioType;

public String getAadhaar() {
return this.aadhaar;
}

public void setAadhaar(String aadhaar) {
this.aadhaar = aadhaar;
}

public String getPid() {
return this.pid;
}

public void setPid(String pid) {
this.pid = pid;
}

public String getBioType() {
return this.bioType;
}

public void setBioType(String bioType) {
this.bioType = bioType;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ public interface Common_NDHMService {
public String getBody(ResponseEntity<String> res) throws FHIRException;
public String getStatusCode(ResponseEntity<String> res) throws FHIRException;
public HttpHeaders getHeadersWithXtoken(String ndhmAuthToken,String X_Token);
public HttpHeaders getHeadersWithAadhaarBioXtoken(String ndhmAuthToken, String X_Token);
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,15 @@ public String getStatusCode(ResponseEntity<String> res) throws FHIRException {
else
throw new FHIRException("NDHM_FHIR Null response returned from API");
}

@Override
public HttpHeaders getHeadersWithAadhaarBioXtoken(String ndhmAuthToken, String X_Token) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
if (ndhmAuthToken != null)
headers.set("Authorization", ndhmAuthToken);
headers.set("X-Token", "Bearer " + X_Token);
return headers;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -93,6 +94,9 @@ public class CreateHealthID_Aadhaar_NDHMServiceImpl implements CreateHealthID_Aa
private Common_NDHMService common_NDHMService;
@Autowired
private GenerateSession_NDHMService generateSession_NDHM;

@Autowired
private GenerateHealthID_CardService generateHealthID_CardService;

@Override
public String generateOTP(String request) throws FHIRException {
Expand Down Expand Up @@ -386,8 +390,9 @@ public String confirmWithAadhaarBio(String request) throws FHIRException {
String requestOBJ = new Gson().toJson(obj);
logger.info("NDHM_FHIR-confirm Aadhaar bio API request Obj " + requestOBJ);
HttpHeaders headers = common_NDHMService.getHeaders(ndhmAuthToken);
HttpEntity<String> httpEntity = new HttpEntity<>(requestOBJ, headers);
ResponseEntity<String> responseEntity = httpUtils.postWithResponseEntity(abdmConfirmAadhaarBio,
requestOBJ, headers);
httpEntity, String.class);
String responseStrLogin = common_NDHMService.getBody(responseEntity);
if (responseStrLogin != null) {
JsonObject jsnOBJ = new JsonObject();
Expand All @@ -396,10 +401,12 @@ public String confirmWithAadhaarBio(String request) throws FHIRException {
jsnOBJ = jsnElmnt.getAsJsonObject();
String X_Token = jsnOBJ.get("x-token").getAsString();
//responseMap.put("aadhaar", obj.getAadhaar());
responseMap.put("x-token", X_Token);
res = new Gson().toJson(responseMap);
} else
if (null != X_Token)
res = this.generateHealthID_CardService.generateHealthCardForBio(requestOBJ, X_Token);
} else {
res = "NDHM_FHIR Error while confirm Aadhaar bio";// throw w
}

}
/**
* @author SH20094090
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ public interface GenerateHealthID_CardService {
public String validateOTP(String request) throws FHIRException;

public String generateCard(String requestOBJ, String NDHM_Auth_TOKEN) throws FHIRException;

public String generateHealthCardForBio(String requestOBJ, String x_Token) throws FHIRException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public class GenerateHealthID_CardServiceImpl implements GenerateHealthID_CardSe
private String verifyOTP_ForCard_Aadhaar;
@Value("${generateHealthCard}")
private String generateHealthCard;
@Value("${generateHealthIDCard}")
private String generateHealthIDCard;
Logger logger = LoggerFactory.getLogger(this.getClass().getName());
@Autowired
HttpUtils httpUtils;
Expand Down Expand Up @@ -260,5 +262,45 @@ public String generateCard(String req, String NDHM_X_TOKEN) throws FHIRException
throw new FHIRException("NDHM_FHIR Error while accessing ABHA card API ");

}

@Override
public String generateHealthCardForBio(String req, String NDHM_X_TOKEN) throws FHIRException {
String res = null;
try {
String ndhmAuthToken = this.generateSession_NDHM.getNDHMAuthToken();
HttpHeaders headers = this.common_NDHMService.getHeadersWithAadhaarBioXtoken(ndhmAuthToken, NDHM_X_TOKEN);
ResponseEntity<byte[]> responseEntity = this.httpUtils.getWithResponseEntityByte(generateHealthIDCard, headers);
byte[] ar = responseEntity.getBody();
if (ar != null) {
res = Base64.getEncoder().encodeToString(ar);
} else {
throw new FHIRException("NDHM_FHIR Error while accessing generate card API");
}
} catch (HttpClientErrorException e) {
String message = null;
if (e.getResponseBodyAsString() != null) {
HealthIDException exception = (HealthIDException)InputMapper.gson().fromJson(e.getResponseBodyAsString(), HealthIDException.class);
if (exception.getDetails() != null && (exception.getDetails()).length > 0) {
Details[] details = exception.getDetails();
if (details[0] != null && details[0].getAttribute() != null && details[0]
.getAttribute().getKey() != null) {
message = details[0].getMessage() + " :" + details[0].getAttribute().getKey();
} else if (details[0] != null) {
message = details[0].getMessage();
}
} else if (exception.getMessage() != null) {
message = exception.getMessage();
}
}
if (message != null)
throw new FHIRException("NDHM_FHIR Error while generating ABHA card : " + message);
throw new FHIRException("NDHM_FHIR Error while generating ABHA card : " + e.getMessage());
} catch (Exception e) {
throw new FHIRException("NDHM_FHIR Error while accessing ABHA card API " + e);
}
if (res != null)
return res;
throw new FHIRException("NDHM_FHIR Error while accessing ABHA card API ");
}

}
8 changes: 8 additions & 0 deletions src/main/java/com/wipro/fhir/utils/http/HttpUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,12 @@ public HttpStatus getStatus() {
public void setStatus(HttpStatus status) {
this.status = status;
}

public ResponseEntity<String> postWithResponseEntity(String abdmConfirmAadhaarBio, HttpEntity<String> httpEntity, Class<String> class1) {
ResponseEntity<String> responseEntity = new ResponseEntity<>(HttpStatus.BAD_REQUEST);
responseEntity = this.rest.exchange(abdmConfirmAadhaarBio, HttpMethod.POST, httpEntity, String.class, new Object[0]);
setStatus((HttpStatus) responseEntity.getStatusCode());
String body = responseEntity.getBody();
return responseEntity;
}
}
4 changes: 2 additions & 2 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
spring.datasource.tomcat.initial-size=5
spring.datasource.tomcat.max-active=30
spring.datasource.tomcat.max-idle=15
spring.datasource.tomcat.min-idle=5
spring.datasource.tomcat.max-idle=5
spring.datasource.tomcat.min-idle=2
spring.datasource.tomcat.min-evictable-idle-time-millis=15000
spring.datasource.tomcat.remove-abandoned=true
spring.datasource.tomcat.remove-abandoned-timeout=1800
Expand Down

0 comments on commit 7e2d47d

Please sign in to comment.