Skip to content

Commit

Permalink
MOSIP-35176 Changed code as per review comment
Browse files Browse the repository at this point in the history
Signed-off-by: kameshsr <[email protected]>
  • Loading branch information
kameshsr committed Oct 15, 2024
1 parent 620db23 commit 0aaa274
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ public void registerTopic(String eventTopic) {
* @return the subscription change response
*/
public SubscriptionChangeResponse subscribe(SubscriptionChangeRequest subscriptionRequest) {
logger.info("Subscription request- "+ subscriptionRequest.toString());
subscriptionRequest.setHubURL(hubURL);
return subscriptionClient.subscribe(subscriptionRequest);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
public class OTPManager {

/** The Constant QUERIED_STATUS_CODES. */
public static final List<String> QUERIED_STATUS_CODES = List.of(IdAuthCommonConstants.ACTIVE_STATUS, IdAuthCommonConstants.FROZEN);
private static final List<String> QUERIED_STATUS_CODES = List.of(IdAuthCommonConstants.ACTIVE_STATUS, IdAuthCommonConstants.FROZEN);

/** The Constant OTP_EXPIRED. */
static final String OTP_EXPIRED = "OTP_EXPIRED";
private static final String OTP_EXPIRED = "OTP_EXPIRED";

/** The Constant USER_BLOCKED. */
private static final String USER_BLOCKED = "USER_BLOCKED";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

import java.util.List;
import java.util.Optional;

/**
Expand Down Expand Up @@ -43,6 +44,13 @@ public class ValidateOtpHelper {
@Value("${mosip.ida.otp.frozen.duration.minutes:30}")
private int otpFrozenTimeMinutes;

/** The Constant OTP_EXPIRED. */
private static final String OTP_EXPIRED = "OTP_EXPIRED";

/** The Constant QUERIED_STATUS_CODES. */
private static final List<String> QUERIED_STATUS_CODES = List.of(IdAuthCommonConstants.ACTIVE_STATUS, IdAuthCommonConstants.FROZEN);


/**
* Creates the OTP frozen exception.
*
Expand All @@ -66,7 +74,7 @@ public IdAuthenticationBusinessException createOTPFrozenException() {
*/
public boolean validateOtp(String pinValue, String otpKey, String individualId) throws IdAuthenticationBusinessException {
String refIdHash = securityManager.hash(individualId);
Optional<OtpTransaction> otpEntityOpt = otpRepo.findFirstByRefIdAndStatusCodeInAndGeneratedDtimesNotNullOrderByGeneratedDtimesDesc(refIdHash, OTPManager.QUERIED_STATUS_CODES);
Optional<OtpTransaction> otpEntityOpt = otpRepo.findFirstByRefIdAndStatusCodeInAndGeneratedDtimesNotNullOrderByGeneratedDtimesDesc(refIdHash, QUERIED_STATUS_CODES);

if (otpEntityOpt.isEmpty()) {
throw new IdAuthenticationBusinessException(IdAuthenticationErrorConstants.OTP_REQUEST_REQUIRED);
Expand All @@ -90,7 +98,7 @@ public boolean validateOtp(String pinValue, String otpKey, String individualId)
otpRepo.save(otpEntity);
if (!otpEntity.getExpiryDtimes().isAfter(DateUtils.getUTCCurrentDateTime())) {
logger.error(IdAuthCommonConstants.SESSION_ID, this.getClass().getSimpleName(),
IdAuthenticationErrorConstants.EXPIRED_OTP.getErrorCode(), OTPManager.OTP_EXPIRED);
IdAuthenticationErrorConstants.EXPIRED_OTP.getErrorCode(), OTP_EXPIRED);
throw new IdAuthenticationBusinessException(IdAuthenticationErrorConstants.EXPIRED_OTP);
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ openapi.service.servers[0].description=Id Authentication Service
openapi.group.name=${openapi.info.title}
openapi.group.paths[0]=/**
springdoc.swagger-ui.disable-swagger-default-url=true
#Test

0 comments on commit 0aaa274

Please sign in to comment.