Search in sources :

Example 1 with PasscodeRequest

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;
}
Also used : PasscodeRequest(io.picos.sailfish.mfa.passcode.model.PasscodeRequest) Date(java.util.Date) LocalDate(java.time.LocalDate) CachePut(org.springframework.cache.annotation.CachePut)

Aggregations

PasscodeRequest (io.picos.sailfish.mfa.passcode.model.PasscodeRequest)1 LocalDate (java.time.LocalDate)1 Date (java.util.Date)1 CachePut (org.springframework.cache.annotation.CachePut)1