From 1436eb032c852650b58bd065cabb08424492bd43 Mon Sep 17 00:00:00 2001 From: arielpetit Date: Tue, 25 Feb 2025 10:28:47 +0100 Subject: [PATCH 1/2] Chore(): removed redis related logic --- .../src/main/resources/application.properties | 5 ---- .../adorsys/webank/config/RedisConfig.java | 25 ------------------- 2 files changed, 30 deletions(-) delete mode 100644 prs/prs-service-impl/src/main/java/com/adorsys/webank/config/RedisConfig.java diff --git a/prs/prs-rest-server/src/main/resources/application.properties b/prs/prs-rest-server/src/main/resources/application.properties index 06a8e2f..680cc96 100644 --- a/prs/prs-rest-server/src/main/resources/application.properties +++ b/prs/prs-rest-server/src/main/resources/application.properties @@ -18,8 +18,3 @@ jwt.issuer=${JWT_ISSUER} jwt.expiration-time-ms=${JWT_EXPIRATION_TIME_MS} server.forward-headers-strategy=framework - -spring.redis.host=localhost -spring.redis.port=6379 -spring.redis.password=your_password # Optional if you're using password protection -spring.redis.timeout=2000 # Timeout for Redis operations (in milliseconds) diff --git a/prs/prs-service-impl/src/main/java/com/adorsys/webank/config/RedisConfig.java b/prs/prs-service-impl/src/main/java/com/adorsys/webank/config/RedisConfig.java deleted file mode 100644 index b6f29a0..0000000 --- a/prs/prs-service-impl/src/main/java/com/adorsys/webank/config/RedisConfig.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.adorsys.webank.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.serializer.StringRedisSerializer; -import org.springframework.data.redis.serializer.RedisSerializer; - -@Configuration -public class RedisConfig { - - @Bean - public RedisTemplate redisTemplate(RedisConnectionFactory factory) { - RedisTemplate template = new RedisTemplate<>(); - template.setConnectionFactory(factory); - - // Setting the serializer for the keys and values - RedisSerializer stringSerializer = new StringRedisSerializer(); - template.setKeySerializer(stringSerializer); - template.setValueSerializer(stringSerializer); - - return template; - } -} From 04ef37db0a212299d7de1c55926d9613b3a65e99 Mon Sep 17 00:00:00 2001 From: arielpetit Date: Tue, 25 Feb 2025 10:29:10 +0100 Subject: [PATCH 2/2] Chore(): removed redis related logic --- prs/prs-service-impl/pom.xml | 11 +-------- .../webank/serviceimpl/OtpServiceImpl.java | 23 +++++-------------- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/prs/prs-service-impl/pom.xml b/prs/prs-service-impl/pom.xml index b8fecf6..7b8e47a 100644 --- a/prs/prs-service-impl/pom.xml +++ b/prs/prs-service-impl/pom.xml @@ -68,16 +68,7 @@ java-json-canonicalization 1.1 - - org.springframework.boot - spring-boot-starter-data-redis - - - - org.springframework.data - spring-data-redis - 3.4.2 - + diff --git a/prs/prs-service-impl/src/main/java/com/adorsys/webank/serviceimpl/OtpServiceImpl.java b/prs/prs-service-impl/src/main/java/com/adorsys/webank/serviceimpl/OtpServiceImpl.java index ece6cd4..1c417c8 100644 --- a/prs/prs-service-impl/src/main/java/com/adorsys/webank/serviceimpl/OtpServiceImpl.java +++ b/prs/prs-service-impl/src/main/java/com/adorsys/webank/serviceimpl/OtpServiceImpl.java @@ -8,15 +8,12 @@ import com.nimbusds.jose.jwk.ECKey; import com.nimbusds.jose.jwk.JWK; import com.twilio.Twilio; -import com.twilio.rest.api.v2010.account.Message; -import com.twilio.type.PhoneNumber; import jakarta.annotation.PostConstruct; import org.erdtman.jcs.JsonCanonicalizer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import java.nio.charset.StandardCharsets; @@ -51,7 +48,6 @@ public class OtpServiceImpl implements OtpServiceApi { private String SERVER_PUBLIC_KEY_JSON; @Autowired - private RedisTemplate redisTemplate; @PostConstruct public void initTwilio() { @@ -72,9 +68,6 @@ public String sendOtp(JWK devicePub, String phoneNumber) { } try { - // Check if the phone number exists in Redis cache - if (!(redisTemplate.hasKey(phoneNumber))) { - log.info("Phone number {} not found in cache.", phoneNumber); String otp = generateOtp(); log.info("OTP sent to phone number:{}", otp); @@ -91,20 +84,16 @@ public String sendOtp(JWK devicePub, String phoneNumber) { String otpHash = computeHash(input); log.info("OTP hash:{}", otpHash); - // Send OTP via Twilio (if desired, uncomment this part) - // Message message = Message.creator( - // new PhoneNumber(phoneNumber), - // new PhoneNumber(fromPhoneNumber), - // "Your OTP is: " + otp - // ).create(); +// Send OTP via Twilio (if desired, uncomment this part) +// Message message = Message.creator( +// new PhoneNumber(phoneNumber), +// new PhoneNumber(fromPhoneNumber), +// "Your OTP is: " + otp +// ).create(); log.info("Message sent to phone number: {}", phoneNumber); return otpHash; - } else { - log.warn("Phone number {} exists in the cache.", phoneNumber); - return "Phone number {} exists in the cache."; - } } catch (Exception e) { throw new FailedToSendOTPException("Failed to send OTP");