Skip to content

Commit

Permalink
ABHA - Address Search API changes (#56)
Browse files Browse the repository at this point in the history
* Modified tnxId keyword to txnId

* Abha-address search API changes

---------

Co-authored-by: KA40094929 <KA40094929@APL-5CD1394ZJT>
  • Loading branch information
helenKaryamsetty and KA40094929 authored Dec 16, 2024
1 parent a9624ae commit dfe5ec6
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 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 @@ -92,6 +92,8 @@ printAbhaCard = @env.ABDM_BASE_URL@/abha/api/v3/profile/account/abha-card
abhaLoginRequestOtp = @env.ABDM_BASE_URL@/abha/api/v3/profile/login/request/otp
verifyAbhaLogin = @env.ABDM_BASE_URL@/abha/api/v3/profile/login/verify
requestAuthByAbdm = @env.ABDM_BASE_URL@/abha/api/v3/enrollment/auth/byAbdm
webLoginAbhaRequestOtp = @env.ABDM_BASE_URL@/abha/api/v3/phr/web/login/abha/request/otp
webLoginAbhaVerify = @env.ABDM_BASE_URL@/abha/api/v3/phr/web/login/abha/verify


abhaMode=sbx
Expand Down
2 changes: 2 additions & 0 deletions src/main/environment/common_dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ printAbhaCard = https://abhasbx.abdm.gov.in/abha/api/v3/profile/account/abha-car
abhaLoginRequestOtp = https://abhasbx.abdm.gov.in/abha/api/v3/profile/login/request/otp
verifyAbhaLogin = https://abhasbx.abdm.gov.in/abha/api/v3/profile/login/verify
requestAuthByAbdm = https://abhasbx.abdm.gov.in/abha/api/v3/enrollment/auth/byAbdm
webLoginAbhaRequestOtp = https://abhasbx.abdm.gov.in/abha/api/v3/phr/web/login/abha/request/otp
webLoginAbhaVerify = https://abhasbx.abdm.gov.in/abha/api/v3/phr/web/login/abha/verify

abhaMode=sbx

Expand Down
2 changes: 2 additions & 0 deletions src/main/environment/common_example.properties
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ abdmCheckAndGenerateMobileOTP= https://healthidsbx.abdm.gov.in/api/v2/registrati
abdmVerifyMobileOTP= https://healthidsbx.abdm.gov.in/api/v1/registration/aadhaar/verifyMobileOTP
abdmcreateHealthIdWithPreVerified= https://healthidsbx.abdm.gov.in/api/v1/registration/aadhaar/createHealthIdWithPreVerified
requestAuthByAbdm = https://abhasbx.abdm.gov.in/abha/api/v3/enrollment/auth/byAbdm
webLoginAbhaRequestOtp = https://abhasbx.abdm.gov.in/abha/api/v3/phr/web/login/abha/request/otp
webLoginAbhaVerify = https://abhasbx.abdm.gov.in/abha/api/v3/phr/web/login/abha/verify

##CareContext Creation API
generateOTPForCareContext=https://dev.abdm.gov.in/gateway/v0.5/users/auth/init
Expand Down
2 changes: 2 additions & 0 deletions src/main/environment/common_test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ printAbhaCard = https://abhasbx.abdm.gov.in/abha/api/v3/profile/account/abha-car
abhaLoginRequestOtp = https://abhasbx.abdm.gov.in/abha/api/v3/profile/login/request/otp
verifyAbhaLogin = https://abhasbx.abdm.gov.in/abha/api/v3/profile/login/verify
requestAuthByAbdm = https://abhasbx.abdm.gov.in/abha/api/v3/enrollment/auth/byAbdm
webLoginAbhaRequestOtp = https://abhasbx.abdm.gov.in/abha/api/v3/phr/web/login/abha/request/otp
webLoginAbhaVerify = https://abhasbx.abdm.gov.in/abha/api/v3/phr/web/login/abha/verify

abhaMode=sbx

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ public class LoginAbhaV3ServiceImpl implements LoginAbhaV3Service {
@Value("${abhaLoginRequestOtp}")
String abhaLoginRequestOtp;

@Value("${webLoginAbhaRequestOtp}")
String webLoginAbhaRequestOtp;

@Value("${webLoginAbhaVerify}")
String webLoginAbhaVerify;

@Value("${verifyAbhaLogin}")
String verifyAbhaLoginUrl;

Expand All @@ -65,6 +71,7 @@ public String requestOtpForAbhaLogin(String request) throws FHIRException {
RestTemplate restTemplate = new RestTemplate();
String encryptedLoginId = null;
String publicKeyString = null;
ResponseEntity<String> responseEntity;

try {
String ndhmAuthToken = generateSession_NDHM.getNDHMAuthToken();
Expand All @@ -89,16 +96,22 @@ public String requestOtpForAbhaLogin(String request) throws FHIRException {
reqOtpEnrollment.setLoginId(encryptedLoginId);
}

if ("AADHAAR".equalsIgnoreCase(loginAbhaRequest.getLoginMethod()) &&
("abha-number".equalsIgnoreCase(loginAbhaRequest.getLoginHint()) || "abha-address".equalsIgnoreCase(loginAbhaRequest.getLoginHint()) )) {
if ("AADHAAR".equalsIgnoreCase(loginAbhaRequest.getLoginMethod()) && "abha-number".equalsIgnoreCase(loginAbhaRequest.getLoginHint() )) {
reqOtpEnrollment.setScope(new String[] { "abha-login", "aadhaar-verify" });
reqOtpEnrollment.setLoginHint(loginAbhaRequest.getLoginHint());
reqOtpEnrollment.setOtpSystem("aadhaar");
} else if ("mobile".equalsIgnoreCase(loginAbhaRequest.getLoginMethod())
&& ("abha-number".equalsIgnoreCase(loginAbhaRequest.getLoginHint()) || "abha-address".equalsIgnoreCase(loginAbhaRequest.getLoginHint()) )) {
} else if ("mobile".equalsIgnoreCase(loginAbhaRequest.getLoginMethod()) && "abha-number".equalsIgnoreCase(loginAbhaRequest.getLoginHint() )) {
reqOtpEnrollment.setScope(new String[] { "abha-login", "mobile-verify" });
reqOtpEnrollment.setLoginHint(loginAbhaRequest.getLoginHint());
reqOtpEnrollment.setOtpSystem("abdm");
} else if ("aadhaar".equalsIgnoreCase(loginAbhaRequest.getLoginMethod()) && "abha-address".equalsIgnoreCase(loginAbhaRequest.getLoginHint() )) {
reqOtpEnrollment.setScope(new String[] { "abha-address-login", "aadhaar-verify" });
reqOtpEnrollment.setLoginHint(loginAbhaRequest.getLoginHint());
reqOtpEnrollment.setOtpSystem("aadhaar");
} else if ("mobile".equalsIgnoreCase(loginAbhaRequest.getLoginMethod()) && "abha-address".equalsIgnoreCase(loginAbhaRequest.getLoginHint() )) {
reqOtpEnrollment.setScope(new String[] { "abha-address-login", "mobile-verify" });
reqOtpEnrollment.setLoginHint(loginAbhaRequest.getLoginHint());
reqOtpEnrollment.setOtpSystem("abdm");
} else if ("mobile".equalsIgnoreCase(loginAbhaRequest.getLoginMethod()) && "mobile".equalsIgnoreCase(loginAbhaRequest.getLoginMethod()) ) {
reqOtpEnrollment.setScope(new String[] { "abha-login", "mobile-verify" });
reqOtpEnrollment.setLoginHint("mobile");
Expand All @@ -115,8 +128,13 @@ public String requestOtpForAbhaLogin(String request) throws FHIRException {
logger.info("ABDM reqobj for request otp for Abha login: " + requestOBJ);

HttpEntity<String> httpEntity = new HttpEntity<>(requestOBJ, headers);
ResponseEntity<String> responseEntity = restTemplate.exchange(abhaLoginRequestOtp, HttpMethod.POST,
if("abha-address".equalsIgnoreCase(loginAbhaRequest.getLoginHint())) {
responseEntity = restTemplate.exchange(webLoginAbhaRequestOtp, HttpMethod.POST,
httpEntity, String.class);
} else {
responseEntity = restTemplate.exchange(abhaLoginRequestOtp, HttpMethod.POST,
httpEntity, String.class);
}

logger.info("ABDM response for response otp for Abha login: " + responseEntity);
String responseStrLogin = common_NDHMService.getBody(responseEntity);
Expand Down Expand Up @@ -145,6 +163,7 @@ public String verifyAbhaLogin(String request) throws FHIRException {
String encryptedLoginId = null;
String publicKeyString = null;
HealthIDResponse health = new HealthIDResponse();
ResponseEntity<String> responseEntity;

try {
String ndhmAuthToken = generateSession_NDHM.getNDHMAuthToken();
Expand Down Expand Up @@ -185,14 +204,25 @@ public String verifyAbhaLogin(String request) throws FHIRException {
} else if ("MOBILE".equalsIgnoreCase(loginData.getLoginMethod())) {
verifyAbhaLogin.setScope(new String[] {"abha-login", "mobile-verify" } );

} else if ("abha-mobile".equalsIgnoreCase(loginData.getLoginMethod())) {
verifyAbhaLogin.setScope(new String[] {"abha-address-login", "mobile-verify" } );

} else if ("abha-aadhaar".equalsIgnoreCase(loginData.getLoginMethod())) {
verifyAbhaLogin.setScope(new String[] {"abha-address-login", "aadhaar-verify" } );
}

String requestObj = new Gson().toJson(verifyAbhaLogin);
logger.info("ABDM request for verify abha login: " + requestObj);

HttpEntity<String> httpEntity = new HttpEntity<>(requestObj, headers);
ResponseEntity<String> responseEntity = restTemplate.exchange(verifyAbhaLoginUrl, HttpMethod.POST,

if("abha-aadhaar".equalsIgnoreCase(loginData.getLoginMethod()) || "abha-mobile".equalsIgnoreCase(loginData.getLoginMethod())) {
responseEntity = restTemplate.exchange(webLoginAbhaVerify, HttpMethod.POST,
httpEntity, String.class);
} else {
responseEntity = restTemplate.exchange(verifyAbhaLoginUrl, HttpMethod.POST,
httpEntity, String.class);
}

logger.info("ABDM response for verify abha login: " + httpEntity);
String responseStrLogin = common_NDHMService.getBody(responseEntity);
Expand Down

0 comments on commit dfe5ec6

Please sign in to comment.