Class OtpUtilities
java.lang.Object
es.kukenan.smartfi.microservice.security.gateway.utils.OtpUtilities
Service utilities class for OTP operations.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnun to define otp state.static enumEnun to define sca required. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intlength for otp.private OtpCacheOperationOtpCacheOperation otp cache operations.private org.springframework.web.client.RestTemplateRest template instance for internal request.private es.kukenan.smartfi.common.utils.otp.TotpGeneratorTOTP generator, if one is configured. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate org.springframework.http.HttpHeadersAdd headers needed to do internal request.org.springframework.http.ResponseEntity<byte[]>doRequestToInternalServices(String method, String path, byte[] body, String otpHeaderValue, String jwtToken, Map<String, String> headers) Generate rest template for correct checked otp.Generates a random OTP.voidmanageOtpCacheForProcessId(String processId, SessionCacheOperationEnum sessionCacheOperationEnum, OtpCache otpCache) Manage specific operation otp cache process.
-
Field Details
-
codeLength
@Value("${opt.generated.code.length}") private int codeLengthlength for otp. -
restTemplate
@Autowired @Qualifier("internalRestTemplate") private org.springframework.web.client.RestTemplate restTemplateRest template instance for internal request. -
otpCacheOperation
OtpCacheOperation otp cache operations. -
totpGenerator
@Autowired(required=false) private es.kukenan.smartfi.common.utils.otp.TotpGenerator totpGeneratorTOTP generator, if one is configured.
-
-
Constructor Details
-
OtpUtilities
public OtpUtilities()
-
-
Method Details
-
generateOtp
Generates a random OTP. NativePRNG is used as algorithm for generating a secure random. Read all about the algorithms here: http://www.moi.vonos .net/java/securerandom/ and http- Returns:
- the generated OTP
- Throws:
NoSuchAlgorithmException- exception.
-
manageOtpCacheForProcessId
public void manageOtpCacheForProcessId(String processId, SessionCacheOperationEnum sessionCacheOperationEnum, OtpCache otpCache) Manage specific operation otp cache process.- Parameters:
processId- unique otp process identifier.sessionCacheOperationEnum- Type of operation in cache.otpCache- Otp cache object for operation.
-
doRequestToInternalServices
public org.springframework.http.ResponseEntity<byte[]> doRequestToInternalServices(String method, String path, byte[] body, String otpHeaderValue, String jwtToken, Map<String, String> headers) Generate rest template for correct checked otp.- Parameters:
method- method of correct otp request.path- path of correct otp request.body- body of correct otp request.otpHeaderValue- otp header value of otp.jwtToken- Jwt token in session cache.headers- http headers for internal request.- Returns:
- ResponseEntity with response data.
-
addHeadersForInternalRequest
private org.springframework.http.HttpHeaders addHeadersForInternalRequest(String otpHeaderValue, String jwtToken, Map<String, String> headersMap) Add headers needed to do internal request.- Parameters:
otpHeaderValue- value for OtpFilter.jwtToken- Token for private type internal services.headersMap- Map with request header for endpoint saves in otp.- Returns:
- headers needed for internal request.
-