Class OtpService
java.lang.Object
es.kukenan.smartfi.microservice.onboarding.service.OtpService
Otp Service for check otps and otp management access.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) AddressRepositoryAddress repository.private static final StringAdvance constant.private AmqpControllerAmqpController controller.private BackofficeServiceBackoffice service.private StringIp for internal services.private InternalProductsApiClientCore api client.private KafkaControllerKafka Controller.private final es.kukenan.smartfi.logger.WalletLoggerInstance logger.private StringMicroservice JWT token, used to perform internal inter-microservice calls.(package private) OnboardingUpdateEventMapperUser updated Event mapper.private OtpCacheOperationOtpCacheOperation otp cache operations.private intOTP failure limit.private intOTP resend limit.private intTime to live.private OtpUtilitiesutilities for otp.private es.kukenan.smartfi.common.context.RequestContextManagerRequestContextManager context manager.private static final intNumber of resend to ignore primary channel.(package private) UserBackofficeRepositoryUser Backoffice repository.(package private) UserDocumentRepositoryUserDocument repository.(package private) UserRepositoryUsers repository. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprivate booleancheckOtpTimeToLiveExpired(Timestamp ttlOtp) Check otp time to live is expired then return exception.getOtpSessionCache(String userId, String endpointVerb, String endpointPath, byte[] endpointBody, String generatedOtpValue, String deviceId, OtpConfiguration otpConfiguration, Map<String, String> headers) Get Otp session cache.private booleanisOtpValid(OtpCache otpCache, String otpValue) private voidmanageInvalidOtp(String processId, OtpCache otpCache, String otpValue, es.kukenan.smartfi.dto.ResponseDTO<Object> responseDto, es.kukenan.smartfi.dto.BasicApiResponse result) es.kukenan.smartfi.microservice.security.gateway.events.otp.OtpGeneratedEventmapOtpGeneratedEvent(String userId, String otpValue, String deviceId, String operationType, Boolean ignorePrimaryChannel) Process response messages otp generated.voidpublishEvent(es.kukenan.smartfi.microservice.security.gateway.events.AbstractSecurityGatewayEvent event) Process response messages.private voidregenerateOtpValueForProcessId(String processId, OtpCache otpCache, es.kukenan.smartfi.dto.ResponseDTO<Object> responseDto, es.kukenan.smartfi.dto.BasicApiResponse result) Regenerate otp value in resend cases.setActiveUser(User user) Update State and Type to Active and Client for User.private voidupdateCounterOtpCacheForProcessId(String processId, OtpCache otpCache, es.kukenan.smartfi.dto.ResponseDTO<Object> responseDto, es.kukenan.smartfi.dto.BasicApiResponse result) Update otp counter for specific processId.org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<Object>>validateOnboardingOtpProcess(String userId, String processId, es.kukenan.smartfi.dto.onboarding.OtpRequestDto otpRequestDto, String userAgent, String userIp, String product) Define if otp required is for SCA or OTP Generic Process depends otp cache content.protected org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<Object>>validateOtpGenericProcess(String processId, OtpCache otpCache, es.kukenan.smartfi.dto.onboarding.OtpRequestDto otpRequestDto, boolean resumeTask, String userId, String userAgent, String userIp, String product) Generic OTP management process validate.
-
Field Details
-
ADVANCE_PRODUCT
Advance constant.- See Also:
-
RESEND_TO_CHANGE_OTP
private static final int RESEND_TO_CHANGE_OTPNumber of resend to ignore primary channel.- See Also:
-
log
private final es.kukenan.smartfi.logger.WalletLogger logInstance logger. -
internalIpUsers
Ip for internal services. -
otpTimeToLive
@Value("${otp.expired.timetolive}") private int otpTimeToLiveTime to live. -
otpResendLimit
@Value("${otp.resend.limit}") private int otpResendLimitOTP resend limit. -
otpFailureLimit
@Value("${otp.failure.limit}") private int otpFailureLimitOTP failure limit. -
microserviceJwt
Microservice JWT token, used to perform internal inter-microservice calls. -
otpUtilities
utilities for otp. -
requestContextManager
@Autowired private es.kukenan.smartfi.common.context.RequestContextManager requestContextManagerRequestContextManager context manager. -
amqpController
AmqpController controller. -
kafkaController
Kafka Controller. -
otpCacheOperation
OtpCacheOperation otp cache operations. -
userRepository
Users repository. -
userBackofficeRepository
User Backoffice repository. -
addressRepository
Address repository. -
userDocumentRepository
UserDocument repository. -
onboardingUpdateEventMapper
User updated Event mapper. -
internalProductsApiClient
Core api client. -
backofficeService
Backoffice service.
-
-
Constructor Details
-
OtpService
public OtpService()
-
-
Method Details
-
validateOnboardingOtpProcess
public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<Object>> validateOnboardingOtpProcess(String userId, String processId, es.kukenan.smartfi.dto.onboarding.OtpRequestDto otpRequestDto, String userAgent, String userIp, String product) throws NoSuchAlgorithmException Define if otp required is for SCA or OTP Generic Process depends otp cache content.- Parameters:
userId- unique user identifier.processId- otp cache unique identifier.otpRequestDto- data with otp.userAgent- user Agent.userIp- user Ip.product- Application product type.- Returns:
- String With response of OTP process.
- Throws:
NoSuchAlgorithmException- if algorithm not found..
-
validateOtpGenericProcess
protected org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<Object>> validateOtpGenericProcess(String processId, OtpCache otpCache, es.kukenan.smartfi.dto.onboarding.OtpRequestDto otpRequestDto, boolean resumeTask, String userId, String userAgent, String userIp, String product) throws NoSuchAlgorithmException Generic OTP management process validate.- Parameters:
processId- unique identifier of otp process.otpCache- cache with otp data.otpRequestDto- otp data for check.resumeTask- flag to fire stored task execution.userId- user Id.userAgent- user Agent.userIp- user Ip.product- Application product type.- Returns:
- Error if otp value checked is incorrect.
- Throws:
NoSuchAlgorithmException- exception
-
setActiveUser
Update State and Type to Active and Client for User.- Parameters:
user- User entity to change State and Type.- Returns:
- updated User.
-
getOtpSessionCache
public OtpCache getOtpSessionCache(String userId, String endpointVerb, String endpointPath, byte[] endpointBody, String generatedOtpValue, String deviceId, OtpConfiguration otpConfiguration, Map<String, String> headers) Get Otp session cache.- Parameters:
userId- unique user identifier.endpointVerb- verb of endpoint otp required.endpointPath- path of endpoint.endpointBody- body of endpoint otp required.generatedOtpValue- otp value for check.deviceId- device unique identifier.otpConfiguration- requested OTP additional configuration.headers- otp request headers.- Returns:
- OtpCache for new otp
-
mapOtpGeneratedEvent
public es.kukenan.smartfi.microservice.security.gateway.events.otp.OtpGeneratedEvent mapOtpGeneratedEvent(String userId, String otpValue, String deviceId, String operationType, Boolean ignorePrimaryChannel) Process response messages otp generated.- Parameters:
userId- user identification.otpValue- otp generated.deviceId- device unique identifier.operationType- Event operation type Otp generated.ignorePrimaryChannel- indicates if the primary channel should be ignored.- Returns:
- OtpGeneratedEvent otp notification event info.
-
publishEvent
public void publishEvent(es.kukenan.smartfi.microservice.security.gateway.events.AbstractSecurityGatewayEvent event) Process response messages.- Parameters:
event-AbstractSecurityGatewayEvent
-
blockUser
-
isOtpValid
-
manageInvalidOtp
private void manageInvalidOtp(String processId, OtpCache otpCache, String otpValue, es.kukenan.smartfi.dto.ResponseDTO<Object> responseDto, es.kukenan.smartfi.dto.BasicApiResponse result) throws NoSuchAlgorithmException - Throws:
NoSuchAlgorithmException
-
updateCounterOtpCacheForProcessId
private void updateCounterOtpCacheForProcessId(String processId, OtpCache otpCache, es.kukenan.smartfi.dto.ResponseDTO<Object> responseDto, es.kukenan.smartfi.dto.BasicApiResponse result) Update otp counter for specific processId.- Parameters:
processId- unique otp process identifier.otpCache- otp cache information.responseDto- response object.result- basic response object.
-
checkOtpTimeToLiveExpired
Check otp time to live is expired then return exception.- Parameters:
ttlOtp- time to live otp- Returns:
- boolean false if time to live is not expired and exception if time to live is expired
-
regenerateOtpValueForProcessId
private void regenerateOtpValueForProcessId(String processId, OtpCache otpCache, es.kukenan.smartfi.dto.ResponseDTO<Object> responseDto, es.kukenan.smartfi.dto.BasicApiResponse result) throws NoSuchAlgorithmException Regenerate otp value in resend cases.- Parameters:
processId- unique process identifier for otp.otpCache- otp cache data.responseDto- response object.result- basic response object.- Throws:
NoSuchAlgorithmException- exception.
-