use of io.picos.sailfish.mfa.passcode.model.PasscodeRequest in project sailfish-mfa by picos-io.
the class PasscodeRequestManagerImpl method requestPasscode.
@CachePut(key = "#requestId")
@Override
public PasscodeRequest requestPasscode(String requestId, int bits, long timeToLive) {
PasscodeRequest passcodeRequest = findById(requestId);
if (passcodeRequest != null) {
return passcodeRequest;
}
passcodeRequest = new PasscodeRequest();
passcodeRequest.setId(requestId);
passcodeRequest.setCode(passcodeGenerator.generate(bits < 4 ? 4 : bits));
passcodeRequest.setCreatedAt(new Date());
passcodeRequest.setExpiredAt(new Date(System.currentTimeMillis() + timeToLive));
return passcodeRequest;
}
Aggregations