From 3105e526c2e07848e60b930d6ec4f72a0da30dc2 Mon Sep 17 00:00:00 2001 From: Vishwa Date: Mon, 8 Jan 2024 13:08:48 +0530 Subject: [PATCH] [ES-503] GoogleRecaptchaValidatorService remove this create a duplicate bean in eSignet Signed-off-by: Vishwa --- .../GoogleRecaptchaValidatorService.java | 50 ------------------- 1 file changed, 50 deletions(-) delete mode 100644 sunbird-rc-esignet-integration-impl/src/main/java/io/mosip/esignet/sunbirdrc/integration/service/GoogleRecaptchaValidatorService.java diff --git a/sunbird-rc-esignet-integration-impl/src/main/java/io/mosip/esignet/sunbirdrc/integration/service/GoogleRecaptchaValidatorService.java b/sunbird-rc-esignet-integration-impl/src/main/java/io/mosip/esignet/sunbirdrc/integration/service/GoogleRecaptchaValidatorService.java deleted file mode 100644 index e811d5c..0000000 --- a/sunbird-rc-esignet-integration-impl/src/main/java/io/mosip/esignet/sunbirdrc/integration/service/GoogleRecaptchaValidatorService.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ -package io.mosip.esignet.sunbirdrc.integration.service; - -import io.mosip.esignet.api.spi.CaptchaValidator; -import io.mosip.esignet.sunbirdrc.integration.dto.ReCaptchaResponse; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.stereotype.Component; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -@ConditionalOnProperty(value = "mosip.esignet.integration.captcha-validator", havingValue = "GoogleRecaptchaValidatorService") -@Component -@Slf4j -public class GoogleRecaptchaValidatorService implements CaptchaValidator { - - @Value("${mosip.esignet.captcha-validator.url}") - private String captchaVerifyUrl; - - @Value("${mosip.esignet.captcha-validator.secret}") - private String verifierSecret; - - @Autowired - private RestTemplate restTemplate; - - @Override - public boolean validateCaptcha(String captchaToken) { - MultiValueMap param = new LinkedMultiValueMap<>(); - param.add("secret", verifierSecret); - param.add("response", captchaToken.trim()); - - ReCaptchaResponse reCaptchaResponse = restTemplate.postForObject(captchaVerifyUrl, param, - ReCaptchaResponse.class); - - if(reCaptchaResponse != null && reCaptchaResponse.isSuccess()) { - return true; - } - - log.error("Recaptcha validation failed with errors : {}", reCaptchaResponse != null ? - reCaptchaResponse.getErrorCodes() : "Response is null"); - return false; - } -}