Abstract away otp refreshing

This commit is contained in:
Alexander Bakker 2017-11-26 19:50:05 +01:00
parent f09d227378
commit 754a42b2c0
4 changed files with 13 additions and 32 deletions

View file

@ -1,7 +1,9 @@
package me.impy.aegis;
import java.io.Serializable;
import java.lang.reflect.UndeclaredThrowableException;
import me.impy.aegis.crypto.otp.OTP;
import me.impy.aegis.db.DatabaseEntry;
public class KeyProfile implements Serializable {
@ -19,7 +21,12 @@ public class KeyProfile implements Serializable {
return _code;
}
public void setCode(String code) {
_code = code;
public String refreshCode() {
try {
_code = OTP.generateOTP(_entry.getInfo());
} catch (Exception e) {
throw new UndeclaredThrowableException(e);
}
return _code;
}
}