Class OtpService
java.lang.Object
es.kukenan.smartfi.microservice.security.gateway.service.OtpService
Otp Service for check otps and otp management access.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringIp for internal services.private JwtTokenUtilitiesUtilities for access and update session jwt token.private KafkaControllerKafka Controller.private final es.kukenan.smartfi.logger.WalletLoggerInstance logger.private StringMicroservice JWT token, used to perform internal inter-microservice calls.private com.fasterxml.jackson.databind.ObjectMapperCustom object 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.private SessionCacheUtilitiesSession cache utilities for management. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprivate booleancheckOtpTimeToLiveExpired(Timestamp ttlOtp) Check otp time to live is expired then return exception.Get All Otp.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, String userIp, String userAgent) es.kukenan.smartfi.microservice.security.gateway.events.otp.OtpGeneratedEventmapOtpGeneratedEvent(String userId, String otpValue, String deviceId, String operationType, Boolean ignorePrimaryChannel, String userIp, String userAgent) Process response messages otp generated.protected es.kukenan.smartfi.microservice.security.gateway.events.sca.UserDeviceScaUpdatedEventmapUserDeviceScaUpdatedEvent(String userId, String deviceId) Process response messages sca updated event..voidpublishEvent(es.kukenan.smartfi.microservice.security.gateway.events.AbstractSecurityGatewayEvent event) Process response messages.private voidregenerateOtpValueForProcessId(String processId, OtpCache otpCache, String userIp, String userAgent) Regenerate otp value in resend cases.private voidupdateCounterOtpCacheForProcessId(String processId, OtpCache otpCache) Update otp counter for specific processId.private voidupdateToScaSecurityLevel(es.kukenan.smartfi.microservice.security.gateway.cache.model.SessionCache sessionCache) Update security level to SCA for session jwt token.protected org.springframework.http.ResponseEntity<byte[]>validateOtpGenericProcess(String processId, OtpCache otpCache, es.kukenan.smartfi.microservice.security.gateway.cache.model.SessionCache sessionCache, String otpValue, boolean resumeTask, String sessionId, String userAgent, String userIp) Generic OTP management process validate.org.springframework.http.ResponseEntity<byte[]>Define if otp required is for SCA or OTP Generic Process depends otp cache content.
-
Field Details
-
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. -
sessionCacheUtilities
Session cache utilities for management. -
jwtTokenUtilities
Utilities for access and update session jwt token. -
requestContextManager
@Autowired private es.kukenan.smartfi.common.context.RequestContextManager requestContextManagerRequestContextManager context manager. -
kafkaController
Kafka Controller. -
otpCacheOperation
OtpCacheOperation otp cache operations. -
objectMapper
@Autowired private com.fasterxml.jackson.databind.ObjectMapper objectMapperCustom object mapper.
-
-
Constructor Details
-
OtpService
public OtpService()
-
-
Method Details
-
validateOtpProcess
public org.springframework.http.ResponseEntity<byte[]> validateOtpProcess(String uuid, String processId, String otpValue, String userAgent, String userIp) throws NoSuchAlgorithmException Define if otp required is for SCA or OTP Generic Process depends otp cache content.- Parameters:
uuid- unique session cache identifier.processId- otp cache unique identifier.otpValue- value of otp.userAgent- user Agent.userIp- user Ip.- Returns:
- String With response of OTP process.
- Throws:
NoSuchAlgorithmException- if algorithm not found..
-
gellAllOtp
Get All Otp.- Returns:
- List all otp.
-
validateOtpGenericProcess
protected org.springframework.http.ResponseEntity<byte[]> validateOtpGenericProcess(String processId, OtpCache otpCache, es.kukenan.smartfi.microservice.security.gateway.cache.model.SessionCache sessionCache, String otpValue, boolean resumeTask, String sessionId, String userAgent, String userIp) throws NoSuchAlgorithmException Generic OTP management process validate.- Parameters:
processId- unique identifier of otp process.otpCache- cache with otp data.sessionCache- cache qith user session data.otpValue- random otp value for check.resumeTask- flag to fire stored task execution.sessionId- session Id.userAgent- user Agent.userIp- user Ip.- Returns:
- Error if otp value checked is incorrect.
- Throws:
NoSuchAlgorithmException- exception
-
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, String userIp, String userAgent) 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.userIp- user IP Address.userAgent- user-agent header.- Returns:
- OtpGeneratedEvent otp notification event info.
-
mapUserDeviceScaUpdatedEvent
protected es.kukenan.smartfi.microservice.security.gateway.events.sca.UserDeviceScaUpdatedEvent mapUserDeviceScaUpdatedEvent(String userId, String deviceId) Process response messages sca updated event..- Parameters:
userId- user identification.deviceId- device unique identifier.- Returns:
- UserDeviceScaUpdatedEvent UserDevice 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, String userIp, String userAgent) throws NoSuchAlgorithmException - Throws:
NoSuchAlgorithmException
-
updateCounterOtpCacheForProcessId
Update otp counter for specific processId.- Parameters:
processId- unique otp process identifier.otpCache- otp cache information.
-
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, String userIp, String userAgent) throws NoSuchAlgorithmException Regenerate otp value in resend cases.- Parameters:
processId- unique process identifier for otp.otpCache- otp cache data.userIp- user Ip.userAgent- user Agent.- Throws:
NoSuchAlgorithmException- exception.
-
updateToScaSecurityLevel
private void updateToScaSecurityLevel(es.kukenan.smartfi.microservice.security.gateway.cache.model.SessionCache sessionCache) Update security level to SCA for session jwt token.- Parameters:
sessionCache- session cache data.
-