-
Notifications
You must be signed in to change notification settings - Fork 45
Beneficiaries consent #222
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
Changes from all commits
a7a9518
e1b5318
eddabe3
6e626bb
6cf8550
2303d60
68d0483
b7718c0
f9feef6
019d315
507f830
21be52e
0a90728
ea9ff9e
8825473
2d639c4
b0e039b
9831500
5cb6886
9e8e1f2
67b2f86
7b3b990
d834aa9
734551a
47ceb56
f26b8ff
d3534d9
6b58965
8d97517
b5798d2
abe5bd3
3c8fbb9
ef1021e
3451ad5
fa02a49
822ec19
c8e85ab
6557199
9c8afce
4c4cce0
17a159f
c20c9ab
b2d99be
76bf328
eeaf00d
b36477c
48ac080
3fe65c4
b45a6da
55c469a
e6acf34
584f97e
4a4de76
650e573
45b088e
f9ef91b
0e77f26
aaf8db8
713867e
42f00ce
f2478cd
c1cabf6
d78ac62
b042b3c
8b9059a
2f724d3
9b83271
d7a3c6b
fa2f433
ae716f9
84e0139
8055769
060b808
9f0fbb0
01abcbd
0f0113c
a5b595e
a363c33
ea47470
dbe771c
23cbcca
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 |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package com.iemr.common.controller.beneficiaryConsent; | ||
|
||
import com.iemr.common.data.beneficiaryConsent.BeneficiaryConsentRequest; | ||
import com.iemr.common.data.otp.OTPRequestParsor; | ||
import com.iemr.common.service.beneficiaryOTPHandler.BeneficiaryOTPHandler; | ||
import com.iemr.common.service.otp.OTPHandler; | ||
import com.iemr.common.utils.mapper.InputMapper; | ||
import com.iemr.common.utils.response.OutputResponse; | ||
import io.lettuce.core.dynamic.annotation.Param; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import jakarta.ws.rs.core.MediaType; | ||
import org.json.JSONObject; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
|
||
public class BeneficiaryConsentController { | ||
final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); | ||
|
||
@Autowired | ||
private BeneficiaryOTPHandler beneficiaryOTPHandler; | ||
|
||
@Operation(summary = "Send Consent") | ||
@RequestMapping(value = "/sendConsent", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") | ||
public String sendConsent(@Param(value = "{\"mobNo\":\"String\"}") @RequestBody String requestOBJ) { | ||
logger.info(requestOBJ.toString()); | ||
|
||
OutputResponse response = new OutputResponse(); | ||
|
||
try { | ||
BeneficiaryConsentRequest obj = InputMapper.gson().fromJson(requestOBJ, BeneficiaryConsentRequest.class); | ||
|
||
String success = beneficiaryOTPHandler.sendOTP(obj); // method name unchanged if internal logic still uses 'OTP' | ||
logger.info(success.toString()); | ||
if (success.contains("otp")) | ||
response.setResponse(success); | ||
else | ||
response.setError(500, "failure"); | ||
|
||
} catch (Exception e) { | ||
logger.error("error in sending Consent : " + e); | ||
response.setError(500, "error : " + e); | ||
} | ||
return response.toString(); | ||
} | ||
|
||
@Operation(summary = "Validate Consent") | ||
@RequestMapping(value = "/validateConsent", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") | ||
public String validateConsent(@Param(value = "{\"mobNo\":\"String\",\"otp\":\"Integer\"}") @RequestBody String requestOBJ) { | ||
|
||
OutputResponse response = new OutputResponse(); | ||
|
||
try { | ||
OTPRequestParsor obj = InputMapper.gson().fromJson(requestOBJ, OTPRequestParsor.class); | ||
|
||
JSONObject responseOBJ = beneficiaryOTPHandler.validateOTP(obj); | ||
if (responseOBJ != null) | ||
response.setResponse(responseOBJ.toString()); | ||
else | ||
response.setError(500, "failure"); | ||
|
||
} catch (Exception e) { | ||
logger.error("error in validating Consent : " + e); | ||
response.setError(500, "error : " + e); | ||
} | ||
return response.toString(); | ||
} | ||
|
||
@Operation(summary = "Resend Consent") | ||
@RequestMapping(value = "/resendConsent", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") | ||
public String resendConsent(@Param(value = "{\"mobNo\":\"String\"}") @RequestBody String requestOBJ) { | ||
logger.info(requestOBJ.toString()); | ||
Check noticeCode scanning / SonarCloud Logging should not be vulnerable to injection attacks Low
Change this code to not log user-controlled data. See more on SonarQube Cloud
|
||
|
||
OutputResponse response = new OutputResponse(); | ||
|
||
try { | ||
OTPRequestParsor obj = InputMapper.gson().fromJson(requestOBJ, OTPRequestParsor.class); | ||
|
||
String success = beneficiaryOTPHandler.resendOTP(obj); | ||
logger.info(success.toString()); | ||
|
||
if (success.contains("otp")) | ||
response.setResponse(success); | ||
else | ||
response.setError(500, "failure"); | ||
|
||
} catch (Exception e) { | ||
logger.error("error in re-sending Consent : " + e); | ||
response.setError(500, "error : " + e); | ||
} | ||
return response.toString(); | ||
} | ||
|
||
|
||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,14 +55,16 @@ | |
@Operation(summary = "Send OTP") | ||
@RequestMapping(value = "/sendOTP", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") | ||
public String sendOTP(@Param(value = "{\"mobNo\":\"String\"}") @RequestBody String requestOBJ) { | ||
logger.info(requestOBJ.toString()); | ||
Check noticeCode scanning / SonarCloud Logging should not be vulnerable to injection attacks Low
Change this code to not log user-controlled data. See more on SonarQube Cloud
|
||
|
||
OutputResponse response = new OutputResponse(); | ||
|
||
try { | ||
OTPRequestParsor obj = InputMapper.gson().fromJson(requestOBJ, OTPRequestParsor.class); | ||
|
||
String success = otpHandler.sendOTP(obj); | ||
if (success.equalsIgnoreCase("success")) | ||
logger.info(success.toString()); | ||
if (success.contains("otp")) | ||
response.setResponse(success); | ||
else | ||
response.setError(5000, "failure"); | ||
|
@@ -102,14 +104,17 @@ | |
@Operation(summary = "Resend OTP") | ||
@RequestMapping(value = "/resendOTP", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization") | ||
public String resendOTP(@Param(value = "{\"mobNo\":\"String\"}") @RequestBody String requestOBJ) { | ||
logger.info(requestOBJ.toString()); | ||
Check noticeCode scanning / SonarCloud Logging should not be vulnerable to injection attacks Low
Change this code to not log user-controlled data. See more on SonarQube Cloud
|
||
|
||
OutputResponse response = new OutputResponse(); | ||
|
||
try { | ||
OTPRequestParsor obj = InputMapper.gson().fromJson(requestOBJ, OTPRequestParsor.class); | ||
|
||
String success = otpHandler.resendOTP(obj); | ||
if (success.equalsIgnoreCase("success")) | ||
logger.info(success.toString()); | ||
|
||
if (success.contains("otp")) | ||
response.setResponse(success); | ||
else | ||
response.setError(5000, "failure"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.iemr.common.data.beneficiaryConsent; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class BeneficiaryConsentRequest { | ||
private String mobNo; | ||
private int otp; | ||
private String userName; | ||
private String designation; | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.iemr.common.service.beneficiaryOTPHandler; | ||
|
||
import com.iemr.common.data.beneficiaryConsent.BeneficiaryConsentRequest; | ||
import com.iemr.common.data.otp.OTPRequestParsor; | ||
import org.json.JSONObject; | ||
|
||
public interface BeneficiaryOTPHandler { | ||
public String sendOTP(BeneficiaryConsentRequest obj) throws Exception; | ||
|
||
public JSONObject validateOTP(BeneficiaryConsentRequest obj) throws Exception; | ||
|
||
public String resendOTP(BeneficiaryConsentRequest obj) throws Exception; | ||
|
||
} |
Check notice
Code scanning / SonarCloud
Logging should not be vulnerable to injection attacks Low