Keep groups when importing from Authenticator Plus

This commit is contained in:
orangenbaumblatt 2020-03-18 21:16:43 +01:00
parent a273fdaa1d
commit 6885463b11
2 changed files with 21 additions and 1 deletions

View file

@ -101,7 +101,14 @@ public class AuthenticatorPlusImporter extends DatabaseImporter {
name = parts[1];
}
return new VaultEntry(info, name, entry.getIssuer());
// Authenticator Plus saves all entries to the "All Accounts" category by default
// If an entry is in this category, we can consider it as uncategorized
String group = entry.getGroup();
if (group.equals("All Accounts")) {
return new VaultEntry(info, name, entry.getIssuer());
}
return new VaultEntry(info, name, entry.getIssuer(), entry.getGroup());
} catch (EncodingException | OtpInfoException | DatabaseImporterException e) {
throw new DatabaseImporterEntryException(e, entry.toString());
}
@ -129,6 +136,7 @@ public class AuthenticatorPlusImporter extends DatabaseImporter {
private String _secret;
private String _email;
private String _issuer;
private String _group;
private long _counter;
public Entry(Cursor cursor) {
@ -137,6 +145,7 @@ public class AuthenticatorPlusImporter extends DatabaseImporter {
_secret = SqlImporterHelper.getString(cursor, "secret");
_email = SqlImporterHelper.getString(cursor, "email", "");
_issuer = SqlImporterHelper.getString(cursor, "issuer", "");
_group = SqlImporterHelper.getString(cursor, "category", "");
_counter = SqlImporterHelper.getLong(cursor, "counter");
}
@ -156,6 +165,10 @@ public class AuthenticatorPlusImporter extends DatabaseImporter {
return _issuer;
}
public String getGroup() {
return _group;
}
public long getCounter() {
return _counter;
}

View file

@ -38,6 +38,13 @@ public class VaultEntry extends UUIDMap.Value {
setIssuer(issuer);
}
public VaultEntry(OtpInfo info, String name, String issuer, String group) {
this(info);
setName(name);
setIssuer(issuer);
setGroup(group);
}
public VaultEntry(GoogleAuthInfo info) {
this(info.getOtpInfo(), info.getAccountName(), info.getIssuer());
}