From ca23f37726ce09779201f8cae4a9e44ac5336b1d Mon Sep 17 00:00:00 2001 From: Sachin Rana Date: Wed, 5 Feb 2025 16:15:56 +0530 Subject: [PATCH] reverted usage of Map in-place of MultiValueMap (#57) Signed-off-by: Sachin Rana --- .../mosip/captcha/service/CaptchaServiceImpl.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/captcha-validation-service/src/main/java/io/mosip/captcha/service/CaptchaServiceImpl.java b/captcha-validation-service/src/main/java/io/mosip/captcha/service/CaptchaServiceImpl.java index 9a70407..d188195 100644 --- a/captcha-validation-service/src/main/java/io/mosip/captcha/service/CaptchaServiceImpl.java +++ b/captcha-validation-service/src/main/java/io/mosip/captcha/service/CaptchaServiceImpl.java @@ -1,6 +1,5 @@ package io.mosip.captcha.service; -import java.util.HashMap; import java.util.Map; import io.mosip.captcha.util.ErrorConstants; @@ -12,6 +11,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; @@ -52,11 +53,11 @@ public class CaptchaServiceImpl implements CaptchaService { public ResponseWrapper validateCaptcha(CaptchaRequestDTO captchaRequest) throws CaptchaException { String moduleName = captchaRequest.getModuleName(); - Map param = new HashMap<>(); - param.put("secret", secret.get(moduleName == null? defaultModuleName : moduleName)); - param.put("response", captchaRequest.getCaptchaToken().trim()); + MultiValueMap param = new LinkedMultiValueMap<>(); + param.add("secret", secret.get(moduleName == null? defaultModuleName : moduleName)); + param.add("response", captchaRequest.getCaptchaToken().trim()); - if(param.get("secret") == null) { + if(param.get("secret").getFirst() == null) { log.error("Failed to find secret for module {}", moduleName); throw new CaptchaException(ErrorConstants.CAPTCHA_VALIDATION_FAILED); } @@ -65,7 +66,7 @@ public ResponseWrapper validateCaptcha(CaptchaRequestDTO cap try { log.info("validate the token request via {}", captchaVerifyUrl); captchaResponse = this.restTemplate.postForObject(captchaVerifyUrl, param, GoogleReCaptchaV2Response.class); - log.debug(" captchaResponse -> {}", captchaResponse); + log.info(" captchaResponse -> {}", captchaResponse); } catch (RestClientException ex) { log.error("captcha token validation request failed", ex); }