mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-06-28 19:59:54 +00:00
Fall back to default values in the FreeOTP importer
This commit is contained in:
parent
a5dc861336
commit
c81e08bf1f
3 changed files with 12 additions and 3 deletions
|
@ -298,8 +298,8 @@ public class FreeOtpImporter extends DatabaseImporter {
|
|||
private static VaultEntry convertEntry(JSONObject obj) throws DatabaseImporterEntryException {
|
||||
try {
|
||||
String type = obj.getString("type").toLowerCase(Locale.ROOT);
|
||||
String algo = obj.getString("algo");
|
||||
int digits = obj.getInt("digits");
|
||||
String algo = obj.optString("algo", OtpInfo.DEFAULT_ALGORITHM);
|
||||
int digits = obj.optInt("digits", OtpInfo.DEFAULT_DIGITS);
|
||||
byte[] secret = toBytes(obj.getJSONArray("secret"));
|
||||
|
||||
String issuer = obj.getString("issuerExt");
|
||||
|
@ -308,7 +308,7 @@ public class FreeOtpImporter extends DatabaseImporter {
|
|||
OtpInfo info;
|
||||
switch (type) {
|
||||
case "totp":
|
||||
int period = obj.getInt("period");
|
||||
int period = obj.optInt("period", TotpInfo.DEFAULT_PERIOD);
|
||||
if (issuer.equals("Steam")) {
|
||||
info = new SteamInfo(secret, algo, digits, period);
|
||||
} else {
|
||||
|
|
|
@ -257,6 +257,15 @@ public class DatabaseImporterTest {
|
|||
checkImportedEntries(entries);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImportFreeOtpV2NullAlgo() throws IOException, DatabaseImporterException, OtpInfoException {
|
||||
List<VaultEntry> entries = importEncrypted(FreeOtpImporter.class, "freeotp_v2_null_algo.xml", encryptedState -> {
|
||||
final char[] password = "test".toCharArray();
|
||||
return ((FreeOtpImporter.EncryptedState) encryptedState).decrypt(password);
|
||||
});
|
||||
checkImportedEntries(entries);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImportFreeOtpPlus() throws IOException, DatabaseImporterException, OtpInfoException {
|
||||
List<VaultEntry> entries = importPlain(FreeOtpPlusImporter.class, "freeotp_plus.json");
|
||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue