-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abdm M1 V3 Changes #52
Changes from all commits
3814860
a2224b4
1a28c2b
fea418b
9d30d46
583594a
8d206ef
4c76193
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,7 +82,15 @@ [email protected]_HEALTH_ID_BASE_URL@/api/v1/auth/confirmWithAadha | |
[email protected]_Account_ID_BASE_URL@/api/v1/account/profile | ||
|
||
##ABDM Facility services | ||
getAbdmFacilityServicies= @env.ABDM_HEALTH_ID_BASE_URL@/devservice/v1/bridges/getServices | ||
getAbdmFacilityServicies= @env.ABDM_BASE_URL@/devservice/v1/bridges/getServices | ||
|
||
##ABDM V3 APIs | ||
getAuthCertPublicKey = @env.ABDM_HEALTH_ID_BASE_URL@/api/v1/auth/cert | ||
requestOtpForEnrollment = @env.ABDM_BASE_URL@/abha/api/v3/enrollment/request/otp | ||
abhaEnrollByAadhaar = @env.ABDM_BASE_URL@/abha/api/v3/enrollment/enrol/byAadhaar | ||
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 | ||
|
||
|
||
abhaMode=sbx | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,13 @@ [email protected]_Account_ID_BASE_URL@/api/v1/account/profile | |
##ABDM Facility services | ||
getAbdmFacilityServicies= https://dev.abdm.gov.in/devservice/v1/bridges/getServices | ||
|
||
##ABDM V3 APIs | ||
getAuthCertPublicKey = https://healthidsbx.abdm.gov.in/api/v1/auth/cert | ||
requestOtpForEnrollment = https://abhasbx.abdm.gov.in/abha/api/v3/enrollment/request/otp | ||
abhaEnrollByAadhaar = https://abhasbx.abdm.gov.in/abha/api/v3/enrollment/enrol/byAadhaar | ||
printAbhaCard = https://abhasbx.abdm.gov.in/abha/api/v3/profile/account/abha-card | ||
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 | ||
|
||
abhaMode=sbx | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,14 @@ [email protected]_Account_ID_BASE_URL@/api/v1/account/profile | |
##ABDM Facility services | ||
getAbdmFacilityServicies= https://dev.abdm.gov.in/devservice/v1/bridges/getServices | ||
|
||
##ABDM V3 APIs | ||
getAuthCertPublicKey = https://healthidsbx.abdm.gov.in/api/v1/auth/cert | ||
requestOtpForEnrollment = https://abhasbx.abdm.gov.in/abha/api/v3/enrollment/request/otp | ||
abhaEnrollByAadhaar = https://abhasbx.abdm.gov.in/abha/api/v3/enrollment/enrol/byAadhaar | ||
printAbhaCard = https://abhasbx.abdm.gov.in/abha/api/v3/profile/account/abha-card | ||
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 | ||
|
||
|
||
abhaMode=sbx | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,14 @@ [email protected]_Account_ID_BASE_URL@/api/v1/account/profile | |
##ABDM Facility services | ||
getAbdmFacilityServicies= https://dev.abdm.gov.in/devservice/v1/bridges/getServices | ||
|
||
##ABDM V3 APIs | ||
getAuthCertPublicKey = https://healthidsbx.abdm.gov.in/api/v1/auth/cert | ||
requestOtpForEnrollment = https://abhasbx.abdm.gov.in/abha/api/v3/enrollment/request/otp | ||
abhaEnrollByAadhaar = https://abhasbx.abdm.gov.in/abha/api/v3/enrollment/enrol/byAadhaar | ||
printAbhaCard = https://abhasbx.abdm.gov.in/abha/api/v3/profile/account/abha-card | ||
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 | ||
|
||
|
||
abhaMode=sbx | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,110 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
package com.wipro.fhir.controller.v3.abha; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.slf4j.Logger; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.slf4j.LoggerFactory; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.springframework.beans.factory.annotation.Autowired; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.springframework.web.bind.annotation.CrossOrigin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.springframework.web.bind.annotation.PostMapping; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.springframework.web.bind.annotation.RequestBody; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.springframework.web.bind.annotation.RequestMapping; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.springframework.web.bind.annotation.RestController; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import com.wipro.fhir.service.ndhm.GenerateHealthID_CardServiceImpl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import com.wipro.fhir.service.v3.abha.CreateAbhaV3Service; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import com.wipro.fhir.utils.exception.FHIRException; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import com.wipro.fhir.utils.response.OutputResponse; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import io.swagger.v3.oas.annotations.Operation; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@CrossOrigin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@RestController | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@RequestMapping(value = "/abhaCreation", headers = "Authorization") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public class CreateAbhaV3Controller { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@Autowired | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
private CreateAbhaV3Service createAbhaV3Service; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@CrossOrigin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@Operation(summary = "Generate OTP for ABHA enrollment") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@PostMapping(value = { "/requestOtpForAbhaEnrollment" }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public String requestOtpForEnrollment(@RequestBody String request) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logger.info("Generate OTP for ABHA enrollment API request " + request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OutputResponse response = new OutputResponse(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (request != null) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
String s = createAbhaV3Service.getOtpForEnrollment(request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
response.setResponse(s); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
throw new FHIRException("NDHM_FHIR Empty request object"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} catch (FHIRException e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
response.setError(5000, e.getMessage()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logger.error(e.toString()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logger.info("NDHM_FHIR generate OTP for ABHA card API response " + response.toString()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return response.toString(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
helenKaryamsetty marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@CrossOrigin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@Operation(summary = "ABHA enrollment by Aadhaar") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@PostMapping(value = { "/abhaEnrollmentByAadhaar" }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public String abhaEnrollmentByAadhaar(@RequestBody String request) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logger.info("ABHA enrollment BY Aadhaar API request " + request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OutputResponse response = new OutputResponse(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
String res = null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (request != null) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
res = createAbhaV3Service.enrollmentByAadhaar(request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
response.setResponse(res); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
throw new FHIRException("NDHM_FHIR Empty request object"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} catch (FHIRException e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
response.setError(5000, e.getMessage()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logger.error(e.toString()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logger.info("NDHM_FHIR generate OTP for ABHA card API response " + response.toString()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return response.toString(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+51
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix logging and remove redundant variable in Aadhaar enrollment endpoint.
@PostMapping(value = { "/abhaEnrollmentByAadhaar" })
public String abhaEnrollmentByAadhaar(@RequestBody String request) {
- logger.info("ABHA enrollment BY Aadhaar API request " + request);
+ logger.info("ABHA enrollment by Aadhaar API request received");
OutputResponse response = new OutputResponse();
- String res = null;
try {
if (request != null) {
- res = createAbhaV3Service.enrollmentByAadhaar(request);
- response.setResponse(res);
+ response.setResponse(createAbhaV3Service.enrollmentByAadhaar(request));
} else
- throw new FHIRException("NDHM_FHIR Empty request object");
+ throw new FHIRException("ABHA-002: Empty request object");
} catch (FHIRException e) {
- response.setError(5000, e.getMessage());
+ response.setError(4002, "Aadhaar Enrollment Failed: " + e.getMessage());
logger.error(e.toString());
}
- logger.info("NDHM_FHIR generate OTP for ABHA card API response " + response.toString());
+ logger.info("Aadhaar enrollment completed with status: {}", response.hasError() ? "ERROR" : "SUCCESS");
return response.toString();
} π Committable suggestion
Suggested change
π§° Toolsπͺ GitHub Check: SonarCloud[notice] 53-53: Logging should not be vulnerable to injection attacks Change this code to not log user-controlled data.See more on SonarQube Cloud There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @coderabbitai kindly ignore all the logs related suggestions. Those are given according to our debugging usage There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @helenKaryamsetty, understood. I will ignore log-related suggestions in future reviews. (γ»xγ»`) βοΈ Learnings added
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@CrossOrigin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@Operation(summary = "Verify Mobile OTP for ABHA enrollment") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@PostMapping(value = { "/verifyAuthByMobile" }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public String verifyMobileForAuth(@RequestBody String request) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logger.info("Verify Mobile OTP for ABHA enrollment " + request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OutputResponse response = new OutputResponse(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (request != null) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
String s = createAbhaV3Service.verifyAuthByMobile(request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
response.setResponse(s); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
throw new FHIRException("NDHM_FHIR Empty request object"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} catch (FHIRException e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
response.setError(5000, e.getMessage()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logger.error(e.toString()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logger.info("NDHM_FHIR generate OTP for ABHA card API response " + response.toString()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return response.toString(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
helenKaryamsetty marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@CrossOrigin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@Operation(summary = "Print Abha card") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@PostMapping(value = { "/printAbhaCard" }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public String printAbhaCard(@RequestBody String request) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OutputResponse response = new OutputResponse(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (request != null) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
String s = createAbhaV3Service.getAbhaCardPrinted(request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
response.setResponse(s); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
throw new FHIRException("NDHM_FHIR Empty request object"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} catch (FHIRException e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
response.setError(5000, e.getMessage()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logger.error(e.toString()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logger.info("NDHM_FHIR generate OTP for ABHA card API respponse " + response.toString()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return response.toString(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
helenKaryamsetty marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.wipro.fhir.controller.v3.abha; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.CrossOrigin; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.wipro.fhir.service.v3.abha.LoginAbhaV3Service; | ||
import com.wipro.fhir.utils.exception.FHIRException; | ||
import com.wipro.fhir.utils.response.OutputResponse; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
|
||
@CrossOrigin | ||
@RestController | ||
@RequestMapping(value = "/abhaLogin", headers = "Authorization") | ||
Comment on lines
+18
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Review security implications of unrestricted CORS. The -@CrossOrigin
+@CrossOrigin(origins = "${allowed.origins}", allowedHeaders = "Authorization")
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @coderabbitai all over the project we are maintaining only crossOrigin only to maintain the commonality using it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @helenKaryamsetty Understood, thank you for the clarification. I will note that in this project, the βοΈ Learnings added
|
||
public class LoginAbhaV3Controller { | ||
|
||
private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); | ||
|
||
@Autowired | ||
private LoginAbhaV3Service loginAbhaV3Service; | ||
|
||
@CrossOrigin | ||
@Operation(summary = "Request OTP for Abha LOgin") | ||
@PostMapping(value = { "/abhaLoginRequestOtp" }) | ||
public String requestOtpForAbhaLogin(@RequestBody String request) { | ||
logger.info("Generate OTP for ABHA Login API request " + request); | ||
|
||
OutputResponse response = new OutputResponse(); | ||
try { | ||
if (request != null) { | ||
String s = loginAbhaV3Service.requestOtpForAbhaLogin(request); | ||
response.setResponse(s); | ||
} else | ||
throw new FHIRException("NDHM_FHIR Empty request object"); | ||
} catch (FHIRException e) { | ||
response.setError(5000, e.getMessage()); | ||
logger.error(e.toString()); | ||
} | ||
logger.info("NDHM_FHIR generate OTP for ABHA login API response " + response.toString()); | ||
return response.toString(); | ||
} | ||
helenKaryamsetty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@CrossOrigin | ||
@Operation(summary = "verify OTP for Abha LOgin") | ||
@PostMapping(value = { "/verifyAbhaLogin" }) | ||
public String verifyAbhaLogin(@RequestBody String request) { | ||
logger.info("verify OTP for ABHA Login API request " + request); | ||
|
||
OutputResponse response = new OutputResponse(); | ||
try { | ||
if (request != null) { | ||
String s = loginAbhaV3Service.verifyAbhaLogin(request); | ||
response.setResponse(s); | ||
} else | ||
throw new FHIRException("NDHM_FHIR Empty request object"); | ||
} catch (FHIRException e) { | ||
response.setError(5000, e.getMessage()); | ||
logger.error(e.toString()); | ||
} | ||
logger.info("NDHM_FHIR Verify abha login API response " + response.toString()); | ||
return response.toString(); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.wipro.fhir.data.v3.abhaCard; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class BioRequest { | ||
|
||
private String timestamp; | ||
private String txnId; | ||
private String aadhaar; | ||
private Object fingerPrintAuthPid; | ||
private String mobile; | ||
|
||
Comment on lines
+5
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add input validation and security measures for sensitive data. This class handles sensitive PII data (Aadhaar, mobile, biometric). Consider the following improvements:
Apply these changes: +import javax.validation.constraints.Pattern;
+import javax.validation.constraints.NotNull;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+@ApiModel(description = "Request object for biometric authentication")
@Data
public class BioRequest {
+ @ApiModelProperty(value = "Timestamp of the request", required = true)
+ @NotNull(message = "Timestamp cannot be null")
private String timestamp;
+ @ApiModelProperty(value = "Transaction ID", required = true)
+ @NotNull(message = "Transaction ID cannot be null")
private String txnId;
+ @ApiModelProperty(value = "Aadhaar number", required = true)
+ @NotNull(message = "Aadhaar cannot be null")
+ @Pattern(regexp = "^[0-9]{12}$", message = "Invalid Aadhaar format")
private String aadhaar;
+ @ApiModelProperty(value = "Fingerprint authentication PID", required = true)
+ @NotNull(message = "Fingerprint auth PID cannot be null")
- private Object fingerPrintAuthPid;
+ private BiometricPID fingerPrintAuthPid;
+ @ApiModelProperty(value = "Mobile number", required = true)
+ @NotNull(message = "Mobile cannot be null")
+ @Pattern(regexp = "^[0-9]{10}$", message = "Invalid mobile number format")
private String mobile;
}
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.wipro.fhir.data.v3.abhaCard; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class ConsentRequest { | ||
|
||
private String code; | ||
private String version; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.wipro.fhir.data.v3.abhaCard; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class EnrollByAadhaar{ | ||
public Map<String, Object> authData; | ||
public ConsentRequest consent; | ||
} | ||
Comment on lines
+10
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion Enhance encapsulation and add field validation
@Data
public class EnrollByAadhaar{
- public Map<String, Object> authData;
- public ConsentRequest consent;
+ @NotNull(message = "Authentication data is required")
+ private Map<String, Object> authData;
+
+ @NotNull(message = "Consent request is required")
+ private ConsentRequest consent;
} Don't forget to add the import: import javax.validation.constraints.NotNull; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those are not required fields and can be public There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @coderabbitai Those are not required fields and can be public There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @helenKaryamsetty, understood, thank you for the clarification. I'll note that the fields βοΈ Learnings added
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.wipro.fhir.data.v3.abhaCard; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class LoginAbhaRequest { | ||
|
||
private String loginId; | ||
private String loginMethod; | ||
private String loginHint; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.wipro.fhir.data.v3.abhaCard; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class LoginMethod { | ||
|
||
private String loginId; | ||
private String loginMethod; | ||
private String pId; | ||
private String tnxId; | ||
private String mobileNumber; | ||
private String createdBy; | ||
private int providerServiceMapId; | ||
|
||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,15 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
package com.wipro.fhir.data.v3.abhaCard; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import java.sql.Timestamp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import lombok.Data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@Data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public class OtpRequest { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
private String timestamp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
private String txnId; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
private String otpValue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
private String mobile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+7
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion Add field validations and documentation. Consider enhancing the class with:
Here's the suggested implementation: +import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Pattern;
+import java.time.LocalDateTime;
import lombok.Data;
+/**
+ * Data Transfer Object for OTP request operations in ABHA card services.
+ */
@Data
public class OtpRequest {
- private String timestamp;
- private String txnId;
- private String otpValue;
- private String mobile;
+ private LocalDateTime timestamp;
+
+ @NotBlank(message = "Transaction ID is required")
+ private String txnId;
+
+ @NotBlank(message = "OTP value is required")
+ @Pattern(regexp = "^[0-9]{6}$", message = "OTP must be 6 digits")
+ private String otpValue;
+
+ @NotBlank(message = "Mobile number is required")
+ @Pattern(regexp = "^[0-9]{10}$", message = "Mobile number must be 10 digits")
+ private String mobile; π Committable suggestion
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pattern and not blank validations are all not required to check here they are validated in UI repos. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @helenKaryamsetty, understood. Thank you for the clarification. I've noted this for future reviews. βοΈ Learnings added
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
helenKaryamsetty marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.wipro.fhir.data.v3.abhaCard; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class RequestOTPEnrollment { | ||
|
||
String tnxId; | ||
String[] scope; | ||
String loginHint; | ||
String loginId; | ||
String otpSystem; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.wipro.fhir.data.v3.abhaCard; | ||
|
||
import java.util.Map; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class VerifyAbhaLogin { | ||
|
||
public String[] scope; | ||
public Map<String, Object> authData; | ||
Comment on lines
+10
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion Use Private Fields with Accessors The fields Modify the field declarations: - public String[] scope;
- public Map<String, Object> authData;
+ private String[] scope;
+ private Map<String, Object> authData; Since Lombok's
|
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π οΈ Refactor suggestion
Consider extracting base URLs to environment variables
The new ABDM V3 API endpoints use hardcoded URLs with sandbox domains. For better environment management and security, consider:
Apply this pattern for better configuration management:
π Committable suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai other urls are not maintained with variables so not maintaining these also with variables and using direct urls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@helenKaryamsetty Thank you for the clarification.
βοΈ Learnings added