Rename "Database" to "Vault"

We decided on calling the state file the "vault" a while back. This patch makes
the naming consistent across the codebase. I left "DatabaseImporter" classes
alone, because I'm not sure what a better name for those would be.
This commit is contained in:
Alexander Bakker 2019-12-25 19:21:34 +01:00
parent d0baeef064
commit 5ab4307963
63 changed files with 480 additions and 494 deletions

View file

@ -12,9 +12,11 @@ import android.content.pm.ShortcutManager;
import android.graphics.drawable.Icon; import android.graphics.drawable.Icon;
import android.os.Build; import android.os.Build;
import com.beemdevelopment.aegis.db.DatabaseManager; import androidx.annotation.RequiresApi;
import com.beemdevelopment.aegis.services.NotificationService; import com.beemdevelopment.aegis.services.NotificationService;
import com.beemdevelopment.aegis.ui.MainActivity; import com.beemdevelopment.aegis.ui.MainActivity;
import com.beemdevelopment.aegis.vault.VaultManager;
import com.mikepenz.iconics.Iconics; import com.mikepenz.iconics.Iconics;
import com.mikepenz.material_design_iconic_typeface_library.MaterialDesignIconic; import com.mikepenz.material_design_iconic_typeface_library.MaterialDesignIconic;
@ -22,20 +24,18 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import androidx.annotation.RequiresApi;
public class AegisApplication extends Application { public class AegisApplication extends Application {
private DatabaseManager _manager; private VaultManager _manager;
private Preferences _prefs; private Preferences _prefs;
private List<LockListener> _lockListeners; private List<LockListener> _lockListeners;
private static final String CODE_LOCK_STATUS_ID = "lock_status_channel"; private static final String CODE_LOCK_STATUS_ID = "lock_status_channel";
private static final String CODE_LOCK_DATABASE_ACTION = "lock_database"; private static final String CODE_LOCK_VAULT_ACTION = "lock_vault";
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
_manager = new DatabaseManager(this); _manager = new VaultManager(this);
_prefs = new Preferences(this); _prefs = new Preferences(this);
_lockListeners = new ArrayList<>(); _lockListeners = new ArrayList<>();
@ -46,7 +46,7 @@ public class AegisApplication extends Application {
ScreenOffReceiver receiver = new ScreenOffReceiver(); ScreenOffReceiver receiver = new ScreenOffReceiver();
IntentFilter intentFilter = new IntentFilter(); IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_SCREEN_OFF); intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
intentFilter.addAction(CODE_LOCK_DATABASE_ACTION); intentFilter.addAction(CODE_LOCK_VAULT_ACTION);
registerReceiver(receiver, intentFilter); registerReceiver(receiver, intentFilter);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
@ -58,7 +58,7 @@ public class AegisApplication extends Application {
} }
} }
public DatabaseManager getDatabaseManager() { public VaultManager getVaultManager() {
return _manager; return _manager;
} }

View file

@ -1,6 +1,6 @@
package com.beemdevelopment.aegis; package com.beemdevelopment.aegis;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.helpers.comparators.AccountNameComparator; import com.beemdevelopment.aegis.helpers.comparators.AccountNameComparator;
import com.beemdevelopment.aegis.helpers.comparators.IssuerNameComparator; import com.beemdevelopment.aegis.helpers.comparators.IssuerNameComparator;
@ -24,8 +24,8 @@ public enum SortCategory {
return _values[x]; return _values[x];
} }
public Comparator<DatabaseEntry> getComparator() { public Comparator<VaultEntry> getComparator() {
Comparator<DatabaseEntry> comparator = null; Comparator<VaultEntry> comparator = null;
switch (this) { switch (this) {
case ACCOUNT: case ACCOUNT:

View file

@ -1,11 +0,0 @@
package com.beemdevelopment.aegis.db;
public class DatabaseException extends Exception {
public DatabaseException(Throwable cause) {
super(cause);
}
public DatabaseException(String message) {
super(message);
}
}

View file

@ -1,11 +0,0 @@
package com.beemdevelopment.aegis.db;
public class DatabaseFileException extends Exception {
public DatabaseFileException(Throwable cause) {
super(cause);
}
public DatabaseFileException(String message) {
super(message);
}
}

View file

@ -1,7 +0,0 @@
package com.beemdevelopment.aegis.db;
public class DatabaseManagerException extends Exception {
public DatabaseManagerException(Throwable cause) {
super(cause);
}
}

View file

@ -7,9 +7,9 @@ import androidx.fragment.app.FragmentActivity;
import com.beemdevelopment.aegis.crypto.KeyStoreHandle; import com.beemdevelopment.aegis.crypto.KeyStoreHandle;
import com.beemdevelopment.aegis.crypto.KeyStoreHandleException; import com.beemdevelopment.aegis.crypto.KeyStoreHandleException;
import com.beemdevelopment.aegis.db.slots.BiometricSlot; import com.beemdevelopment.aegis.vault.slots.BiometricSlot;
import com.beemdevelopment.aegis.db.slots.Slot; import com.beemdevelopment.aegis.vault.slots.Slot;
import com.beemdevelopment.aegis.db.slots.SlotException; import com.beemdevelopment.aegis.vault.slots.SlotException;
import java.util.Objects; import java.util.Objects;

View file

@ -3,14 +3,12 @@ package com.beemdevelopment.aegis.helpers;
import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.ui.views.EntryAdapter; import com.beemdevelopment.aegis.ui.views.EntryAdapter;
import java.util.Map;
public class SimpleItemTouchHelperCallback extends ItemTouchHelper.Callback { public class SimpleItemTouchHelperCallback extends ItemTouchHelper.Callback {
private DatabaseEntry _selectedEntry; private VaultEntry _selectedEntry;
private final ItemTouchHelperAdapter _adapter; private final ItemTouchHelperAdapter _adapter;
private boolean _positionChanged = false; private boolean _positionChanged = false;
@ -29,7 +27,7 @@ public class SimpleItemTouchHelperCallback extends ItemTouchHelper.Callback {
_isLongPressDragEnabled = enabled; _isLongPressDragEnabled = enabled;
} }
public void setSelectedEntry(DatabaseEntry entry) { public void setSelectedEntry(VaultEntry entry) {
_selectedEntry = entry; _selectedEntry = entry;
} }

View file

@ -1,12 +1,12 @@
package com.beemdevelopment.aegis.helpers.comparators; package com.beemdevelopment.aegis.helpers.comparators;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import java.util.Comparator; import java.util.Comparator;
public class AccountNameComparator implements Comparator<DatabaseEntry> { public class AccountNameComparator implements Comparator<VaultEntry> {
@Override @Override
public int compare(DatabaseEntry a, DatabaseEntry b) { public int compare(VaultEntry a, VaultEntry b) {
return a.getName().compareToIgnoreCase(b.getName()); return a.getName().compareToIgnoreCase(b.getName());
} }
} }

View file

@ -1,12 +1,12 @@
package com.beemdevelopment.aegis.helpers.comparators; package com.beemdevelopment.aegis.helpers.comparators;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import java.util.Comparator; import java.util.Comparator;
public class IssuerNameComparator implements Comparator<DatabaseEntry> { public class IssuerNameComparator implements Comparator<VaultEntry> {
@Override @Override
public int compare(DatabaseEntry a, DatabaseEntry b) { public int compare(VaultEntry a, VaultEntry b) {
return a.getIssuer().compareToIgnoreCase(b.getIssuer()); return a.getIssuer().compareToIgnoreCase(b.getIssuer());
} }
} }

View file

@ -2,11 +2,11 @@ package com.beemdevelopment.aegis.importers;
import android.content.Context; import android.content.Context;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.db.DatabaseFile; import com.beemdevelopment.aegis.vault.VaultFile;
import com.beemdevelopment.aegis.db.DatabaseFileCredentials; import com.beemdevelopment.aegis.vault.VaultFileCredentials;
import com.beemdevelopment.aegis.db.DatabaseFileException; import com.beemdevelopment.aegis.vault.VaultFileException;
import com.beemdevelopment.aegis.db.slots.SlotList; import com.beemdevelopment.aegis.vault.slots.SlotList;
import com.beemdevelopment.aegis.encoding.Base64Exception; import com.beemdevelopment.aegis.encoding.Base64Exception;
import com.beemdevelopment.aegis.otp.OtpInfoException; import com.beemdevelopment.aegis.otp.OtpInfoException;
@ -36,20 +36,20 @@ public class AegisImporter extends DatabaseImporter {
public State read(FileReader reader) throws DatabaseImporterException { public State read(FileReader reader) throws DatabaseImporterException {
try { try {
byte[] bytes = reader.readAll(); byte[] bytes = reader.readAll();
DatabaseFile file = DatabaseFile.fromBytes(bytes); VaultFile file = VaultFile.fromBytes(bytes);
if (file.isEncrypted()) { if (file.isEncrypted()) {
return new EncryptedState(file); return new EncryptedState(file);
} }
return new DecryptedState(file.getContent()); return new DecryptedState(file.getContent());
} catch (DatabaseFileException | IOException e) { } catch (VaultFileException | IOException e) {
throw new DatabaseImporterException(e); throw new DatabaseImporterException(e);
} }
} }
public static class EncryptedState extends State { public static class EncryptedState extends State {
private DatabaseFile _file; private VaultFile _file;
private EncryptedState(DatabaseFile file) { private EncryptedState(VaultFile file) {
super(true); super(true);
_file = file; _file = file;
} }
@ -58,7 +58,7 @@ public class AegisImporter extends DatabaseImporter {
return _file.getHeader().getSlots(); return _file.getHeader().getSlots();
} }
public State decrypt(DatabaseFileCredentials creds) throws DatabaseFileException { public State decrypt(VaultFileCredentials creds) throws VaultFileException {
JSONObject obj = _file.getContent(creds); JSONObject obj = _file.getContent(creds);
return new DecryptedState(obj); return new DecryptedState(obj);
} }
@ -86,7 +86,7 @@ public class AegisImporter extends DatabaseImporter {
for (int i = 0; i < array.length(); i++) { for (int i = 0; i < array.length(); i++) {
JSONObject entryObj = array.getJSONObject(i); JSONObject entryObj = array.getJSONObject(i);
try { try {
DatabaseEntry entry = convertEntry(entryObj); VaultEntry entry = convertEntry(entryObj);
result.addEntry(entry); result.addEntry(entry);
} catch (DatabaseImporterEntryException e) { } catch (DatabaseImporterEntryException e) {
result.addError(e); result.addError(e);
@ -99,9 +99,9 @@ public class AegisImporter extends DatabaseImporter {
return result; return result;
} }
private static DatabaseEntry convertEntry(JSONObject obj) throws DatabaseImporterEntryException { private static VaultEntry convertEntry(JSONObject obj) throws DatabaseImporterEntryException {
try { try {
return DatabaseEntry.fromJson(obj); return VaultEntry.fromJson(obj);
} catch (JSONException | OtpInfoException | Base64Exception e) { } catch (JSONException | OtpInfoException | Base64Exception e) {
throw new DatabaseImporterEntryException(e, obj.toString()); throw new DatabaseImporterEntryException(e, obj.toString());
} }

View file

@ -8,7 +8,7 @@ import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.crypto.CryptParameters; import com.beemdevelopment.aegis.crypto.CryptParameters;
import com.beemdevelopment.aegis.crypto.CryptResult; import com.beemdevelopment.aegis.crypto.CryptResult;
import com.beemdevelopment.aegis.crypto.CryptoUtils; import com.beemdevelopment.aegis.crypto.CryptoUtils;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.encoding.Base32; import com.beemdevelopment.aegis.encoding.Base32;
import com.beemdevelopment.aegis.encoding.Base32Exception; import com.beemdevelopment.aegis.encoding.Base32Exception;
import com.beemdevelopment.aegis.otp.HotpInfo; import com.beemdevelopment.aegis.otp.HotpInfo;
@ -184,7 +184,7 @@ public class AndOtpImporter extends DatabaseImporter {
for (int i = 0; i < _obj.length(); i++) { for (int i = 0; i < _obj.length(); i++) {
try { try {
JSONObject obj = _obj.getJSONObject(i); JSONObject obj = _obj.getJSONObject(i);
DatabaseEntry entry = convertEntry(obj); VaultEntry entry = convertEntry(obj);
result.addEntry(entry); result.addEntry(entry);
} catch (JSONException e) { } catch (JSONException e) {
throw new DatabaseImporterException(e); throw new DatabaseImporterException(e);
@ -196,7 +196,7 @@ public class AndOtpImporter extends DatabaseImporter {
return result; return result;
} }
private static DatabaseEntry convertEntry(JSONObject obj) throws DatabaseImporterEntryException { private static VaultEntry convertEntry(JSONObject obj) throws DatabaseImporterEntryException {
try { try {
String type = obj.getString("type").toLowerCase(); String type = obj.getString("type").toLowerCase();
String algo = obj.getString("algorithm"); String algo = obj.getString("algorithm");
@ -229,7 +229,7 @@ public class AndOtpImporter extends DatabaseImporter {
name = parts[0]; name = parts[0];
} }
return new DatabaseEntry(info, name, issuer); return new VaultEntry(info, name, issuer);
} catch (DatabaseImporterException | Base32Exception | OtpInfoException | JSONException e) { } catch (DatabaseImporterException | Base32Exception | OtpInfoException | JSONException e) {
throw new DatabaseImporterEntryException(e, obj.toString()); throw new DatabaseImporterEntryException(e, obj.toString());
} }

View file

@ -3,7 +3,7 @@ package com.beemdevelopment.aegis.importers;
import android.content.Context; import android.content.Context;
import android.util.Xml; import android.util.Xml;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.encoding.Base32; import com.beemdevelopment.aegis.encoding.Base32;
import com.beemdevelopment.aegis.encoding.Base32Exception; import com.beemdevelopment.aegis.encoding.Base32Exception;
import com.beemdevelopment.aegis.otp.OtpInfo; import com.beemdevelopment.aegis.otp.OtpInfo;
@ -74,7 +74,7 @@ public class AuthyImporter extends DatabaseImporter {
for (int i = 0; i < _obj.length(); i++) { for (int i = 0; i < _obj.length(); i++) {
JSONObject entryObj = _obj.getJSONObject(i); JSONObject entryObj = _obj.getJSONObject(i);
try { try {
DatabaseEntry entry = convertEntry(entryObj); VaultEntry entry = convertEntry(entryObj);
result.addEntry(entry); result.addEntry(entry);
} catch (DatabaseImporterEntryException e) { } catch (DatabaseImporterEntryException e) {
result.addError(e); result.addError(e);
@ -87,7 +87,7 @@ public class AuthyImporter extends DatabaseImporter {
return result; return result;
} }
private static DatabaseEntry convertEntry(JSONObject entry) throws DatabaseImporterEntryException { private static VaultEntry convertEntry(JSONObject entry) throws DatabaseImporterEntryException {
try { try {
AuthyEntryInfo authyEntryInfo = new AuthyEntryInfo(); AuthyEntryInfo authyEntryInfo = new AuthyEntryInfo();
authyEntryInfo.OriginalName = entry.getString("originalName"); authyEntryInfo.OriginalName = entry.getString("originalName");
@ -101,7 +101,7 @@ public class AuthyImporter extends DatabaseImporter {
OtpInfo info = new TotpInfo(secret, "SHA1", digits, 30); OtpInfo info = new TotpInfo(secret, "SHA1", digits, 30);
return new DatabaseEntry(info, authyEntryInfo.Name, authyEntryInfo.Issuer); return new VaultEntry(info, authyEntryInfo.Name, authyEntryInfo.Issuer);
} catch (OtpInfoException | JSONException | Base32Exception e) { } catch (OtpInfoException | JSONException | Base32Exception e) {
throw new DatabaseImporterEntryException(e, entry.toString()); throw new DatabaseImporterEntryException(e, entry.toString());
} }

View file

@ -2,17 +2,12 @@ package com.beemdevelopment.aegis.importers;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.Uri;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.util.ByteInputStream; import com.beemdevelopment.aegis.util.ByteInputStream;
import com.beemdevelopment.aegis.util.UUIDMap; import com.beemdevelopment.aegis.util.UUIDMap;
import com.topjohnwu.superuser.io.SuFile; import com.topjohnwu.superuser.io.SuFile;
import com.topjohnwu.superuser.io.SuFileInputStream;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@ -117,10 +112,10 @@ public abstract class DatabaseImporter {
} }
public static class Result { public static class Result {
private UUIDMap<DatabaseEntry> _entries = new UUIDMap<>(); private UUIDMap<VaultEntry> _entries = new UUIDMap<>();
private List<DatabaseImporterEntryException> _errors = new ArrayList<>(); private List<DatabaseImporterEntryException> _errors = new ArrayList<>();
public void addEntry(DatabaseEntry entry) { public void addEntry(VaultEntry entry) {
_entries.add(entry); _entries.add(entry);
} }
@ -128,7 +123,7 @@ public abstract class DatabaseImporter {
_errors.add(error); _errors.add(error);
} }
public UUIDMap<DatabaseEntry> getEntries() { public UUIDMap<VaultEntry> getEntries() {
return _entries; return _entries;
} }

View file

@ -3,7 +3,7 @@ package com.beemdevelopment.aegis.importers;
import android.content.Context; import android.content.Context;
import android.util.Xml; import android.util.Xml;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.otp.HotpInfo; import com.beemdevelopment.aegis.otp.HotpInfo;
import com.beemdevelopment.aegis.otp.OtpInfo; import com.beemdevelopment.aegis.otp.OtpInfo;
import com.beemdevelopment.aegis.otp.OtpInfoException; import com.beemdevelopment.aegis.otp.OtpInfoException;
@ -73,7 +73,7 @@ public class FreeOtpImporter extends DatabaseImporter {
for (JSONObject obj : _entries) { for (JSONObject obj : _entries) {
try { try {
DatabaseEntry entry = convertEntry(obj); VaultEntry entry = convertEntry(obj);
result.addEntry(entry); result.addEntry(entry);
} catch (DatabaseImporterEntryException e) { } catch (DatabaseImporterEntryException e) {
result.addError(e); result.addError(e);
@ -83,7 +83,7 @@ public class FreeOtpImporter extends DatabaseImporter {
return result; return result;
} }
private static DatabaseEntry convertEntry(JSONObject obj) throws DatabaseImporterEntryException { private static VaultEntry convertEntry(JSONObject obj) throws DatabaseImporterEntryException {
try { try {
String type = obj.getString("type").toLowerCase(); String type = obj.getString("type").toLowerCase();
String algo = obj.getString("algo"); String algo = obj.getString("algo");
@ -110,7 +110,7 @@ public class FreeOtpImporter extends DatabaseImporter {
throw new DatabaseImporterException("unsupported otp type: " + type); throw new DatabaseImporterException("unsupported otp type: " + type);
} }
return new DatabaseEntry(info, name, issuer); return new VaultEntry(info, name, issuer);
} catch (DatabaseImporterException | OtpInfoException | JSONException e) { } catch (DatabaseImporterException | OtpInfoException | JSONException e) {
throw new DatabaseImporterEntryException(e, obj.toString()); throw new DatabaseImporterEntryException(e, obj.toString());
} }

View file

@ -5,7 +5,7 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteException;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.encoding.Base32; import com.beemdevelopment.aegis.encoding.Base32;
import com.beemdevelopment.aegis.encoding.Base32Exception; import com.beemdevelopment.aegis.encoding.Base32Exception;
import com.beemdevelopment.aegis.otp.HotpInfo; import com.beemdevelopment.aegis.otp.HotpInfo;
@ -92,7 +92,7 @@ public class GoogleAuthImporter extends DatabaseImporter {
for (Entry sqlEntry : _entries) { for (Entry sqlEntry : _entries) {
try { try {
DatabaseEntry entry = convertEntry(sqlEntry); VaultEntry entry = convertEntry(sqlEntry);
result.addEntry(entry); result.addEntry(entry);
} catch (DatabaseImporterEntryException e) { } catch (DatabaseImporterEntryException e) {
result.addError(e); result.addError(e);
@ -102,7 +102,7 @@ public class GoogleAuthImporter extends DatabaseImporter {
return result; return result;
} }
private static DatabaseEntry convertEntry(Entry entry) throws DatabaseImporterEntryException { private static VaultEntry convertEntry(Entry entry) throws DatabaseImporterEntryException {
try { try {
byte[] secret = Base32.decode(entry.getSecret().toCharArray()); byte[] secret = Base32.decode(entry.getSecret().toCharArray());
@ -124,7 +124,7 @@ public class GoogleAuthImporter extends DatabaseImporter {
name = parts[1]; name = parts[1];
} }
return new DatabaseEntry(info, name, entry.getIssuer()); return new VaultEntry(info, name, entry.getIssuer());
} catch (Base32Exception | OtpInfoException | DatabaseImporterException e) { } catch (Base32Exception | OtpInfoException | DatabaseImporterException e) {
throw new DatabaseImporterEntryException(e, entry.toString()); throw new DatabaseImporterEntryException(e, entry.toString());
} }

View file

@ -3,7 +3,7 @@ package com.beemdevelopment.aegis.importers;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.encoding.Base64; import com.beemdevelopment.aegis.encoding.Base64;
import com.beemdevelopment.aegis.encoding.Base64Exception; import com.beemdevelopment.aegis.encoding.Base64Exception;
import com.beemdevelopment.aegis.otp.OtpInfoException; import com.beemdevelopment.aegis.otp.OtpInfoException;
@ -66,7 +66,7 @@ public class SteamImporter extends DatabaseImporter {
Result result = new Result(); Result result = new Result();
try { try {
DatabaseEntry entry = convertEntry(_obj); VaultEntry entry = convertEntry(_obj);
result.addEntry(entry); result.addEntry(entry);
} catch (DatabaseImporterEntryException e) { } catch (DatabaseImporterEntryException e) {
result.addError(e); result.addError(e);
@ -75,13 +75,13 @@ public class SteamImporter extends DatabaseImporter {
return result; return result;
} }
private static DatabaseEntry convertEntry(JSONObject obj) throws DatabaseImporterEntryException { private static VaultEntry convertEntry(JSONObject obj) throws DatabaseImporterEntryException {
try { try {
byte[] secret = Base64.decode(obj.getString("shared_secret")); byte[] secret = Base64.decode(obj.getString("shared_secret"));
SteamInfo info = new SteamInfo(secret); SteamInfo info = new SteamInfo(secret);
String account = obj.getString("account_name"); String account = obj.getString("account_name");
return new DatabaseEntry(info, account, "Steam"); return new VaultEntry(info, account, "Steam");
} catch (JSONException | Base64Exception | OtpInfoException e) { } catch (JSONException | Base64Exception | OtpInfoException e) {
throw new DatabaseImporterEntryException(e, obj.toString()); throw new DatabaseImporterEntryException(e, obj.toString());
} }

View file

@ -1,7 +1,7 @@
package com.beemdevelopment.aegis.importers; package com.beemdevelopment.aegis.importers;
import android.content.Context; import android.content.Context;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.otp.GoogleAuthInfo; import com.beemdevelopment.aegis.otp.GoogleAuthInfo;
import com.beemdevelopment.aegis.otp.GoogleAuthInfoException; import com.beemdevelopment.aegis.otp.GoogleAuthInfoException;
@ -57,7 +57,7 @@ public class WinAuthImporter extends DatabaseImporter {
for (String line : _lines) { for (String line : _lines) {
try { try {
DatabaseEntry entry = convertEntry(line); VaultEntry entry = convertEntry(line);
result.addEntry(entry); result.addEntry(entry);
} catch (DatabaseImporterEntryException e) { } catch (DatabaseImporterEntryException e) {
result.addError(e); result.addError(e);
@ -67,14 +67,14 @@ public class WinAuthImporter extends DatabaseImporter {
return result; return result;
} }
private static DatabaseEntry convertEntry(String line) throws DatabaseImporterEntryException { private static VaultEntry convertEntry(String line) throws DatabaseImporterEntryException {
try { try {
GoogleAuthInfo info = GoogleAuthInfo.parseUri(line); GoogleAuthInfo info = GoogleAuthInfo.parseUri(line);
DatabaseEntry databaseEntry = new DatabaseEntry(info); VaultEntry vaultEntry = new VaultEntry(info);
databaseEntry.setIssuer(databaseEntry.getName()); vaultEntry.setIssuer(vaultEntry.getName());
databaseEntry.setName("WinAuth"); vaultEntry.setName("WinAuth");
return databaseEntry; return vaultEntry;
} catch (GoogleAuthInfoException e) { } catch (GoogleAuthInfoException e) {
throw new DatabaseImporterEntryException(e, line); throw new DatabaseImporterEntryException(e, line);
} }

View file

@ -9,14 +9,13 @@ import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat; import androidx.core.app.NotificationManagerCompat;
import com.beemdevelopment.aegis.AegisApplication;
import com.beemdevelopment.aegis.R; import com.beemdevelopment.aegis.R;
public class NotificationService extends Service { public class NotificationService extends Service {
public static final int DATABASE_UNLOCKED_ID = 1; public static final int VAULT_UNLOCKED_ID = 1;
private static final String CODE_LOCK_STATUS_ID = "lock_status_channel"; private static final String CODE_LOCK_STATUS_ID = "lock_status_channel";
private static final String CODE_LOCK_DATABASE_ACTION = "lock_database"; private static final String CODE_LOCK_VAULT_ACTION = "lock_vault";
public NotificationService() { public NotificationService() {
@ -31,7 +30,7 @@ public class NotificationService extends Service {
} }
public void serviceMethod() { public void serviceMethod() {
Intent intentAction = new Intent(CODE_LOCK_DATABASE_ACTION); Intent intentAction = new Intent(CODE_LOCK_VAULT_ACTION);
PendingIntent lockDatabaseIntent = PendingIntent.getBroadcast(this,1,intentAction, 0); PendingIntent lockDatabaseIntent = PendingIntent.getBroadcast(this,1,intentAction, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CODE_LOCK_STATUS_ID) NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CODE_LOCK_STATUS_ID)
.setSmallIcon(R.drawable.ic_fingerprint_black_24dp) .setSmallIcon(R.drawable.ic_fingerprint_black_24dp)
@ -42,7 +41,7 @@ public class NotificationService extends Service {
.setContentIntent(lockDatabaseIntent); .setContentIntent(lockDatabaseIntent);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
notificationManager.notify(DATABASE_UNLOCKED_ID, builder.build()); notificationManager.notify(VAULT_UNLOCKED_ID, builder.build());
} }
@Override @Override
@ -50,7 +49,7 @@ public class NotificationService extends Service {
super.onDestroy(); super.onDestroy();
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
notificationManager.cancel(DATABASE_UNLOCKED_ID); notificationManager.cancel(VAULT_UNLOCKED_ID);
} }
@Nullable @Nullable

View file

@ -3,7 +3,6 @@ package com.beemdevelopment.aegis.ui;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings; import android.provider.Settings;
import android.view.WindowManager; import android.view.WindowManager;
@ -126,7 +125,7 @@ public abstract class AegisActivity extends AppCompatActivity implements AegisAp
* the vault was locked by an external trigger while the Activity was still open. * the vault was locked by an external trigger while the Activity was still open.
*/ */
private boolean isOrphan() { private boolean isOrphan() {
return !(this instanceof MainActivity) && _app.getDatabaseManager().isLocked(); return !(this instanceof MainActivity) && _app.getVaultManager().isLocked();
} }
private void setGlobalAnimationDurationScale() { private void setGlobalAnimationDurationScale() {

View file

@ -21,12 +21,12 @@ import com.beemdevelopment.aegis.CancelAction;
import com.beemdevelopment.aegis.R; import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.crypto.KeyStoreHandle; import com.beemdevelopment.aegis.crypto.KeyStoreHandle;
import com.beemdevelopment.aegis.crypto.KeyStoreHandleException; import com.beemdevelopment.aegis.crypto.KeyStoreHandleException;
import com.beemdevelopment.aegis.db.DatabaseFileCredentials; import com.beemdevelopment.aegis.vault.VaultFileCredentials;
import com.beemdevelopment.aegis.db.slots.BiometricSlot; import com.beemdevelopment.aegis.vault.slots.BiometricSlot;
import com.beemdevelopment.aegis.db.slots.PasswordSlot; import com.beemdevelopment.aegis.vault.slots.PasswordSlot;
import com.beemdevelopment.aegis.db.slots.Slot; import com.beemdevelopment.aegis.vault.slots.Slot;
import com.beemdevelopment.aegis.db.slots.SlotException; import com.beemdevelopment.aegis.vault.slots.SlotException;
import com.beemdevelopment.aegis.db.slots.SlotList; import com.beemdevelopment.aegis.vault.slots.SlotList;
import com.beemdevelopment.aegis.helpers.BiometricsHelper; import com.beemdevelopment.aegis.helpers.BiometricsHelper;
import com.beemdevelopment.aegis.helpers.EditTextHelper; import com.beemdevelopment.aegis.helpers.EditTextHelper;
import com.beemdevelopment.aegis.helpers.UiThreadExecutor; import com.beemdevelopment.aegis.helpers.UiThreadExecutor;
@ -189,7 +189,7 @@ public class AuthActivity extends AegisActivity implements SlotListTask.Callback
// send the master key back to the main activity // send the master key back to the main activity
Intent intent = new Intent(); Intent intent = new Intent();
intent.putExtra("creds", new DatabaseFileCredentials(result.getKey(), _slots)); intent.putExtra("creds", new VaultFileCredentials(result.getKey(), _slots));
intent.putExtra("repairedSlot", result.isSlotRepaired()); intent.putExtra("repairedSlot", result.isSlotRepaired());
setResult(RESULT_OK, intent); setResult(RESULT_OK, intent);
finish(); finish();

View file

@ -22,9 +22,9 @@ import androidx.appcompat.app.AlertDialog;
import com.beemdevelopment.aegis.Preferences; import com.beemdevelopment.aegis.Preferences;
import com.beemdevelopment.aegis.R; import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.db.slots.PasswordSlot; import com.beemdevelopment.aegis.vault.slots.PasswordSlot;
import com.beemdevelopment.aegis.db.slots.Slot; import com.beemdevelopment.aegis.vault.slots.Slot;
import com.beemdevelopment.aegis.db.slots.SlotException; import com.beemdevelopment.aegis.vault.slots.SlotException;
import com.beemdevelopment.aegis.helpers.EditTextHelper; import com.beemdevelopment.aegis.helpers.EditTextHelper;
import com.beemdevelopment.aegis.ui.tasks.DerivationTask; import com.beemdevelopment.aegis.ui.tasks.DerivationTask;

View file

@ -25,7 +25,7 @@ import android.widget.TableRow;
import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.TextDrawable;
import com.avito.android.krop.KropView; import com.avito.android.krop.KropView;
import com.beemdevelopment.aegis.R; import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.encoding.Base32; import com.beemdevelopment.aegis.encoding.Base32;
import com.beemdevelopment.aegis.encoding.Base32Exception; import com.beemdevelopment.aegis.encoding.Base32Exception;
import com.beemdevelopment.aegis.helpers.EditTextHelper; import com.beemdevelopment.aegis.helpers.EditTextHelper;
@ -60,7 +60,7 @@ public class EditEntryActivity extends AegisActivity {
private static final int PICK_IMAGE_REQUEST = 0; private static final int PICK_IMAGE_REQUEST = 0;
private boolean _isNew = false; private boolean _isNew = false;
private DatabaseEntry _origEntry; private VaultEntry _origEntry;
private TreeSet<String> _groups; private TreeSet<String> _groups;
private boolean _hasCustomIcon = false; private boolean _hasCustomIcon = false;
// keep track of icon changes separately as the generated jpeg's are not deterministic // keep track of icon changes separately as the generated jpeg's are not deterministic
@ -99,7 +99,7 @@ public class EditEntryActivity extends AegisActivity {
// retrieve info from the calling activity // retrieve info from the calling activity
Intent intent = getIntent(); Intent intent = getIntent();
_origEntry = (DatabaseEntry) intent.getSerializableExtra("entry"); _origEntry = (VaultEntry) intent.getSerializableExtra("entry");
_isNew = intent.getBooleanExtra("isNew", false); _isNew = intent.getBooleanExtra("isNew", false);
_groups = new TreeSet<>(Collator.getInstance()); _groups = new TreeSet<>(Collator.getInstance());
_groups.addAll(intent.getStringArrayListExtra("groups")); _groups.addAll(intent.getStringArrayListExtra("groups"));
@ -320,7 +320,7 @@ public class EditEntryActivity extends AegisActivity {
@Override @Override
public void onBackPressed() { public void onBackPressed() {
AtomicReference<String> msg = new AtomicReference<>(); AtomicReference<String> msg = new AtomicReference<>();
AtomicReference<DatabaseEntry> entry = new AtomicReference<>(); AtomicReference<VaultEntry> entry = new AtomicReference<>();
try { try {
entry.set(parseEntry()); entry.set(parseEntry());
@ -388,7 +388,7 @@ public class EditEntryActivity extends AegisActivity {
return true; return true;
} }
private void finish(DatabaseEntry entry, boolean delete) { private void finish(VaultEntry entry, boolean delete) {
Intent intent = new Intent(); Intent intent = new Intent();
intent.putExtra("entry", entry); intent.putExtra("entry", entry);
intent.putExtra("delete", delete); intent.putExtra("delete", delete);
@ -441,7 +441,7 @@ public class EditEntryActivity extends AegisActivity {
} }
} }
private DatabaseEntry parseEntry() throws ParseException { private VaultEntry parseEntry() throws ParseException {
if (_textSecret.length() == 0) { if (_textSecret.length() == 0) {
throw new ParseException("Secret is a required field."); throw new ParseException("Secret is a required field.");
} }
@ -491,7 +491,7 @@ public class EditEntryActivity extends AegisActivity {
throw new ParseException("The entered info is incorrect: " + e.getMessage()); throw new ParseException("The entered info is incorrect: " + e.getMessage());
} }
DatabaseEntry entry = Cloner.clone(_origEntry); VaultEntry entry = Cloner.clone(_origEntry);
entry.setInfo(info); entry.setInfo(info);
entry.setIssuer(_textIssuer.getText().toString()); entry.setIssuer(_textIssuer.getText().toString());
entry.setName(_textName.getText().toString()); entry.setName(_textName.getText().toString());
@ -528,7 +528,7 @@ public class EditEntryActivity extends AegisActivity {
} }
private boolean onSave() { private boolean onSave() {
DatabaseEntry entry; VaultEntry entry;
try { try {
entry = parseEntry(); entry = parseEntry();
} catch (ParseException e) { } catch (ParseException e) {

View file

@ -8,16 +8,16 @@ import androidx.fragment.app.Fragment;
import com.beemdevelopment.aegis.Preferences; import com.beemdevelopment.aegis.Preferences;
import com.beemdevelopment.aegis.R; import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.db.Database; import com.beemdevelopment.aegis.vault.Vault;
import com.beemdevelopment.aegis.db.DatabaseFile; import com.beemdevelopment.aegis.vault.VaultFile;
import com.beemdevelopment.aegis.db.DatabaseFileCredentials; import com.beemdevelopment.aegis.vault.VaultFileCredentials;
import com.beemdevelopment.aegis.db.DatabaseFileException; import com.beemdevelopment.aegis.vault.VaultFileException;
import com.beemdevelopment.aegis.db.DatabaseManager; import com.beemdevelopment.aegis.vault.VaultManager;
import com.beemdevelopment.aegis.db.DatabaseManagerException; import com.beemdevelopment.aegis.vault.VaultManagerException;
import com.beemdevelopment.aegis.db.slots.BiometricSlot; import com.beemdevelopment.aegis.vault.slots.BiometricSlot;
import com.beemdevelopment.aegis.db.slots.PasswordSlot; import com.beemdevelopment.aegis.vault.slots.PasswordSlot;
import com.beemdevelopment.aegis.db.slots.Slot; import com.beemdevelopment.aegis.vault.slots.Slot;
import com.beemdevelopment.aegis.db.slots.SlotException; import com.beemdevelopment.aegis.vault.slots.SlotException;
import com.beemdevelopment.aegis.ui.slides.CustomAuthenticatedSlide; import com.beemdevelopment.aegis.ui.slides.CustomAuthenticatedSlide;
import com.beemdevelopment.aegis.ui.slides.CustomAuthenticationSlide; import com.beemdevelopment.aegis.ui.slides.CustomAuthenticationSlide;
import com.beemdevelopment.aegis.ui.tasks.DerivationTask; import com.beemdevelopment.aegis.ui.tasks.DerivationTask;
@ -38,8 +38,8 @@ public class IntroActivity extends AppIntro2 implements DerivationTask.Callback
private CustomAuthenticationSlide _authenticationSlide; private CustomAuthenticationSlide _authenticationSlide;
private Fragment _endSlide; private Fragment _endSlide;
private Database _database; private Vault _vault;
private DatabaseFile _databaseFile; private VaultFile _vaultFile;
private PasswordSlot _passwordSlot; private PasswordSlot _passwordSlot;
private Cipher _passwordCipher; private Cipher _passwordCipher;
@ -87,9 +87,8 @@ public class IntroActivity extends AppIntro2 implements DerivationTask.Callback
_endSlide = AppIntroFragment.newInstance(endSliderPage); _endSlide = AppIntroFragment.newInstance(endSliderPage);
addSlide(_endSlide); addSlide(_endSlide);
// create the database and database file _vault = new Vault();
_database = new Database(); _vaultFile = new VaultFile();
_databaseFile = new DatabaseFile();
} }
private void setException(Exception e) { private void setException(Exception e) {
@ -129,9 +128,9 @@ public class IntroActivity extends AppIntro2 implements DerivationTask.Callback
} }
// generate the master key // generate the master key
DatabaseFileCredentials creds = null; VaultFileCredentials creds = null;
if (cryptType != CustomAuthenticationSlide.CRYPT_TYPE_NONE) { if (cryptType != CustomAuthenticationSlide.CRYPT_TYPE_NONE) {
creds = new DatabaseFileCredentials(); creds = new VaultFileCredentials();
} }
if (cryptType != CustomAuthenticationSlide.CRYPT_TYPE_NONE) { if (cryptType != CustomAuthenticationSlide.CRYPT_TYPE_NONE) {
@ -158,16 +157,16 @@ public class IntroActivity extends AppIntro2 implements DerivationTask.Callback
creds.getSlots().add(slot); creds.getSlots().add(slot);
} }
// finally, save the database // finally, save the vault
try { try {
JSONObject obj = _database.toJson(); JSONObject obj = _vault.toJson();
if (cryptType == CustomAuthenticationSlide.CRYPT_TYPE_NONE) { if (cryptType == CustomAuthenticationSlide.CRYPT_TYPE_NONE) {
_databaseFile.setContent(obj); _vaultFile.setContent(obj);
} else { } else {
_databaseFile.setContent(obj, creds); _vaultFile.setContent(obj, creds);
} }
DatabaseManager.save(getApplicationContext(), _databaseFile); VaultManager.save(getApplicationContext(), _vaultFile);
} catch (DatabaseManagerException | DatabaseFileException e) { } catch (VaultManagerException | VaultFileException e) {
setException(e); setException(e);
return; return;
} }

View file

@ -21,19 +21,19 @@ import androidx.appcompat.view.ActionMode;
import androidx.appcompat.widget.SearchView; import androidx.appcompat.widget.SearchView;
import com.beemdevelopment.aegis.AegisApplication; import com.beemdevelopment.aegis.AegisApplication;
import com.beemdevelopment.aegis.CancelAction;
import com.beemdevelopment.aegis.R; import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.SortCategory; import com.beemdevelopment.aegis.SortCategory;
import com.beemdevelopment.aegis.CancelAction;
import com.beemdevelopment.aegis.ViewMode; import com.beemdevelopment.aegis.ViewMode;
import com.beemdevelopment.aegis.db.DatabaseEntry;
import com.beemdevelopment.aegis.db.DatabaseFileCredentials;
import com.beemdevelopment.aegis.db.DatabaseManager;
import com.beemdevelopment.aegis.db.DatabaseManagerException;
import com.beemdevelopment.aegis.helpers.FabScrollHelper; import com.beemdevelopment.aegis.helpers.FabScrollHelper;
import com.beemdevelopment.aegis.helpers.PermissionHelper; import com.beemdevelopment.aegis.helpers.PermissionHelper;
import com.beemdevelopment.aegis.otp.GoogleAuthInfo; import com.beemdevelopment.aegis.otp.GoogleAuthInfo;
import com.beemdevelopment.aegis.otp.GoogleAuthInfoException; import com.beemdevelopment.aegis.otp.GoogleAuthInfoException;
import com.beemdevelopment.aegis.ui.views.EntryListView; import com.beemdevelopment.aegis.ui.views.EntryListView;
import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.vault.VaultFileCredentials;
import com.beemdevelopment.aegis.vault.VaultManager;
import com.beemdevelopment.aegis.vault.VaultManagerException;
import com.getbase.floatingactionbutton.FloatingActionsMenu; import com.getbase.floatingactionbutton.FloatingActionsMenu;
import com.google.zxing.BinaryBitmap; import com.google.zxing.BinaryBitmap;
import com.google.zxing.ChecksumException; import com.google.zxing.ChecksumException;
@ -45,7 +45,6 @@ import com.google.zxing.RGBLuminanceSource;
import com.google.zxing.Reader; import com.google.zxing.Reader;
import com.google.zxing.Result; import com.google.zxing.Result;
import com.google.zxing.common.HybridBinarizer; import com.google.zxing.common.HybridBinarizer;
import com.mikepenz.iconics.context.IconicsContextWrapper;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -69,12 +68,12 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
private static final int CODE_PERM_READ_STORAGE = 1; private static final int CODE_PERM_READ_STORAGE = 1;
private AegisApplication _app; private AegisApplication _app;
private DatabaseManager _db; private VaultManager _vault;
private boolean _loaded; private boolean _loaded;
private String _selectedGroup; private String _selectedGroup;
private boolean _searchSubmitted; private boolean _searchSubmitted;
private DatabaseEntry _selectedEntry; private VaultEntry _selectedEntry;
private ActionMode _actionMode; private ActionMode _actionMode;
private Menu _menu; private Menu _menu;
@ -91,7 +90,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
_app = (AegisApplication) getApplication(); _app = (AegisApplication) getApplication();
_db = _app.getDatabaseManager(); _vault = _app.getVaultManager();
_loaded = false; _loaded = false;
// set up the main view // set up the main view
@ -164,7 +163,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
} }
// don't process any activity results if the vault is locked // don't process any activity results if the vault is locked
if (requestCode != CODE_DECRYPT && requestCode != CODE_DO_INTRO && _db.isLocked()) { if (requestCode != CODE_DECRYPT && requestCode != CODE_DO_INTRO && _vault.isLocked()) {
return; return;
} }
@ -235,50 +234,50 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
} }
} }
private void startEditProfileActivity(int requestCode, DatabaseEntry entry, boolean isNew) { private void startEditProfileActivity(int requestCode, VaultEntry entry, boolean isNew) {
Intent intent = new Intent(this, EditEntryActivity.class); Intent intent = new Intent(this, EditEntryActivity.class);
intent.putExtra("entry", entry != null ? entry : DatabaseEntry.getDefault()); intent.putExtra("entry", entry != null ? entry : VaultEntry.getDefault());
intent.putExtra("isNew", isNew); intent.putExtra("isNew", isNew);
intent.putExtra("selectedGroup", _selectedGroup); intent.putExtra("selectedGroup", _selectedGroup);
intent.putExtra("groups", new ArrayList<>(_db.getGroups())); intent.putExtra("groups", new ArrayList<>(_vault.getGroups()));
startActivityForResult(intent, requestCode); startActivityForResult(intent, requestCode);
} }
private void onScanResult(int resultCode, Intent data) { private void onScanResult(int resultCode, Intent data) {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
DatabaseEntry entry = (DatabaseEntry) data.getSerializableExtra("entry"); VaultEntry entry = (VaultEntry) data.getSerializableExtra("entry");
startEditProfileActivity(CODE_ADD_ENTRY, entry, true); startEditProfileActivity(CODE_ADD_ENTRY, entry, true);
} }
} }
private void onAddEntryResult(int resultCode, Intent data) { private void onAddEntryResult(int resultCode, Intent data) {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
DatabaseEntry entry = (DatabaseEntry) data.getSerializableExtra("entry"); VaultEntry entry = (VaultEntry) data.getSerializableExtra("entry");
addEntry(entry); addEntry(entry);
saveDatabase(); saveVault();
} }
} }
private void onEditEntryResult(int resultCode, Intent data) { private void onEditEntryResult(int resultCode, Intent data) {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
DatabaseEntry entry = (DatabaseEntry) data.getSerializableExtra("entry"); VaultEntry entry = (VaultEntry) data.getSerializableExtra("entry");
if (data.getBooleanExtra("delete", false)) { if (data.getBooleanExtra("delete", false)) {
deleteEntry(entry); deleteEntry(entry);
} else { } else {
// this profile has been serialized/deserialized and is no longer the same instance it once was // this profile has been serialized/deserialized and is no longer the same instance it once was
// to deal with this, the replaceEntry functions are used // to deal with this, the replaceEntry functions are used
DatabaseEntry oldEntry = _db.replaceEntry(entry); VaultEntry oldEntry = _vault.replaceEntry(entry);
_entryListView.replaceEntry(oldEntry, entry); _entryListView.replaceEntry(oldEntry, entry);
saveDatabase(); saveVault();
} }
} }
} }
private void onEnterEntryResult(int resultCode, Intent data) { private void onEnterEntryResult(int resultCode, Intent data) {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
DatabaseEntry entry = (DatabaseEntry) data.getSerializableExtra("entry"); VaultEntry entry = (VaultEntry) data.getSerializableExtra("entry");
addEntry(entry); addEntry(entry);
saveDatabase(); saveVault();
} }
} }
@ -304,7 +303,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
Result result = reader.decode(binaryBitmap); Result result = reader.decode(binaryBitmap);
GoogleAuthInfo info = GoogleAuthInfo.parseUri(result.getText()); GoogleAuthInfo info = GoogleAuthInfo.parseUri(result.getText());
DatabaseEntry entry = new DatabaseEntry(info); VaultEntry entry = new VaultEntry(info);
startEditProfileActivity(CODE_ADD_ENTRY, entry, true); startEditProfileActivity(CODE_ADD_ENTRY, entry, true);
} catch (NotFoundException | IOException | ChecksumException | FormatException | GoogleAuthInfoException e) { } catch (NotFoundException | IOException | ChecksumException | FormatException | GoogleAuthInfoException e) {
@ -325,7 +324,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
} }
// if the group no longer exists, switch back to 'All' // if the group no longer exists, switch back to 'All'
TreeSet<String> groups = _db.getGroups(); TreeSet<String> groups = _vault.getGroups();
if (_selectedGroup != null && !groups.contains(_selectedGroup)) { if (_selectedGroup != null && !groups.contains(_selectedGroup)) {
menu.findItem(R.id.menu_filter_all).setChecked(true); menu.findItem(R.id.menu_filter_all).setChecked(true);
setGroupFilter(null); setGroupFilter(null);
@ -356,8 +355,8 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
_entryListView.setGroupFilter(group, true); _entryListView.setGroupFilter(group, true);
} }
private void addEntry(DatabaseEntry entry) { private void addEntry(VaultEntry entry) {
_db.addEntry(entry); _vault.addEntry(entry);
_entryListView.addEntry(entry); _entryListView.addEntry(entry);
} }
@ -368,18 +367,18 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
throw new RuntimeException(e); throw new RuntimeException(e);
} }
DatabaseFileCredentials creds = (DatabaseFileCredentials) data.getSerializableExtra("creds"); VaultFileCredentials creds = (VaultFileCredentials) data.getSerializableExtra("creds");
unlockDatabase(creds); unlockVault(creds);
} }
private void onDecryptResult(int resultCode, Intent intent) { private void onDecryptResult(int resultCode, Intent intent) {
DatabaseFileCredentials creds = (DatabaseFileCredentials) intent.getSerializableExtra("creds"); VaultFileCredentials creds = (VaultFileCredentials) intent.getSerializableExtra("creds");
boolean unlocked = unlockDatabase(creds); boolean unlocked = unlockVault(creds);
// save the database in case a slot was repaired // save the vault in case a slot was repaired
if (unlocked && intent.getBooleanExtra("repairedSlot", false)) { if (unlocked && intent.getBooleanExtra("repairedSlot", false)) {
_db.setCredentials(creds); _vault.setCredentials(creds);
saveDatabase(); saveVault();
} }
doShortcutActions(); doShortcutActions();
@ -409,7 +408,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
private void doShortcutActions() { private void doShortcutActions() {
Intent intent = getIntent(); Intent intent = getIntent();
String action = intent.getStringExtra("action"); String action = intent.getStringExtra("action");
if (action == null || _db.isLocked()) { if (action == null || _vault.isLocked()) {
return; return;
} }
@ -423,7 +422,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
} }
private void handleDeeplink() { private void handleDeeplink() {
if (_db.isLocked()) { if (_vault.isLocked()) {
return; return;
} }
@ -442,7 +441,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
} }
if (info != null) { if (info != null) {
DatabaseEntry entry = new DatabaseEntry(info); VaultEntry entry = new VaultEntry(info);
startEditProfileActivity(CODE_ADD_ENTRY, entry, true); startEditProfileActivity(CODE_ADD_ENTRY, entry, true);
} }
} }
@ -453,10 +452,10 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
if (_db.isLocked()) { if (_vault.isLocked()) {
// start the intro if the database file doesn't exist // start the intro if the vault file doesn't exist
if (!_db.isLoaded() && !_db.fileExists()) { if (!_vault.isLoaded() && !_vault.fileExists()) {
// the db doesn't exist, start the intro // the vault doesn't exist, start the intro
if (getPreferences().isIntroDone()) { if (getPreferences().isIntroDone()) {
Toast.makeText(this, getString(R.string.vault_not_found), Toast.LENGTH_SHORT).show(); Toast.makeText(this, getString(R.string.vault_not_found), Toast.LENGTH_SHORT).show();
} }
@ -464,7 +463,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
startActivityForResult(intro, CODE_DO_INTRO); startActivityForResult(intro, CODE_DO_INTRO);
return; return;
} else { } else {
unlockDatabase(null); unlockVault(null);
} }
} else if (_loaded) { } else if (_loaded) {
// update the list of groups in the filter menu // update the list of groups in the filter menu
@ -503,9 +502,9 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
super.onBackPressed(); super.onBackPressed();
} }
private void deleteEntry(DatabaseEntry entry) { private void deleteEntry(VaultEntry entry) {
DatabaseEntry oldEntry = _db.removeEntry(entry); VaultEntry oldEntry = _vault.removeEntry(entry);
saveDatabase(); saveVault();
_entryListView.removeEntry(oldEntry); _entryListView.removeEntry(oldEntry);
} }
@ -615,20 +614,20 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
_searchView.setIconified(true); _searchView.setIconified(true);
} }
private boolean unlockDatabase(DatabaseFileCredentials creds) { private boolean unlockVault(VaultFileCredentials creds) {
try { try {
if (!_db.isLoaded()) { if (!_vault.isLoaded()) {
_db.load(); _vault.load();
} }
if (_db.isLocked()) { if (_vault.isLocked()) {
if (creds == null) { if (creds == null) {
startAuthActivity(); startAuthActivity();
return false; return false;
} else { } else {
_db.unlock(creds); _vault.unlock(creds);
} }
} }
} catch (DatabaseManagerException e) { } catch (VaultManagerException e) {
Toast.makeText(this, getString(R.string.decryption_error), Toast.LENGTH_LONG).show(); Toast.makeText(this, getString(R.string.decryption_error), Toast.LENGTH_LONG).show();
startAuthActivity(); startAuthActivity();
return false; return false;
@ -640,7 +639,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
private void loadEntries() { private void loadEntries() {
// load all entries // load all entries
List<DatabaseEntry> entries = new ArrayList<DatabaseEntry>(_db.getEntries()); List<VaultEntry> entries = new ArrayList<VaultEntry>(_vault.getEntries());
_entryListView.addEntries(entries); _entryListView.addEntries(entries);
_entryListView.runEntriesAnimation(); _entryListView.runEntriesAnimation();
_loaded = true; _loaded = true;
@ -648,30 +647,30 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
private void startAuthActivity() { private void startAuthActivity() {
Intent intent = new Intent(this, AuthActivity.class); Intent intent = new Intent(this, AuthActivity.class);
intent.putExtra("slots", _db.getFileHeader().getSlots()); intent.putExtra("slots", _vault.getFileHeader().getSlots());
intent.putExtra("requiresUnlock", false); intent.putExtra("requiresUnlock", false);
intent.putExtra("cancelAction", CancelAction.KILL); intent.putExtra("cancelAction", CancelAction.KILL);
startActivityForResult(intent, CODE_DECRYPT); startActivityForResult(intent, CODE_DECRYPT);
} }
private void saveDatabase() { private void saveVault() {
try { try {
_db.save(); _vault.save();
} catch (DatabaseManagerException e) { } catch (VaultManagerException e) {
Toast.makeText(this, getString(R.string.saving_error), Toast.LENGTH_LONG).show(); Toast.makeText(this, getString(R.string.saving_error), Toast.LENGTH_LONG).show();
} }
} }
private void updateLockIcon() { private void updateLockIcon() {
// hide the lock icon if the database is not unlocked // hide the lock icon if the vault is not unlocked
if (_menu != null && !_db.isLocked()) { if (_menu != null && !_vault.isLocked()) {
MenuItem item = _menu.findItem(R.id.action_lock); MenuItem item = _menu.findItem(R.id.action_lock);
item.setVisible(_db.isEncryptionEnabled()); item.setVisible(_vault.isEncryptionEnabled());
} }
} }
@Override @Override
public void onEntryClick(DatabaseEntry entry) { public void onEntryClick(VaultEntry entry) {
if (_selectedEntry != null) { if (_selectedEntry != null) {
if (_selectedEntry == entry) { if (_selectedEntry == entry) {
_actionMode.finish(); _actionMode.finish();
@ -687,7 +686,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
} }
@Override @Override
public void onLongEntryClick(DatabaseEntry entry) { public void onLongEntryClick(VaultEntry entry) {
if (_selectedEntry != null) { if (_selectedEntry != null) {
return; return;
} }
@ -698,18 +697,18 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
} }
@Override @Override
public void onEntryMove(DatabaseEntry entry1, DatabaseEntry entry2) { public void onEntryMove(VaultEntry entry1, VaultEntry entry2) {
_db.swapEntries(entry1, entry2); _vault.swapEntries(entry1, entry2);
} }
@Override @Override
public void onEntryDrop(DatabaseEntry entry) { public void onEntryDrop(VaultEntry entry) {
saveDatabase(); saveVault();
} }
@Override @Override
public void onEntryChange(DatabaseEntry entry) { public void onEntryChange(VaultEntry entry) {
saveDatabase(); saveVault();
} }
@Override @Override
@ -759,7 +758,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
deleteEntry(_selectedEntry); deleteEntry(_selectedEntry);
if (_selectedEntry.getGroup() != null) { if (_selectedEntry.getGroup() != null) {
if (!_db.getGroups().contains(_selectedEntry.getGroup())) { if (!_vault.getGroups().contains(_selectedEntry.getGroup())) {
updateGroupFilterMenu(); updateGroupFilterMenu();
} }
} }

View file

@ -26,16 +26,16 @@ import com.beemdevelopment.aegis.Theme;
import com.beemdevelopment.aegis.ViewMode; import com.beemdevelopment.aegis.ViewMode;
import com.beemdevelopment.aegis.crypto.KeyStoreHandle; import com.beemdevelopment.aegis.crypto.KeyStoreHandle;
import com.beemdevelopment.aegis.crypto.KeyStoreHandleException; import com.beemdevelopment.aegis.crypto.KeyStoreHandleException;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.db.DatabaseFileCredentials; import com.beemdevelopment.aegis.vault.VaultFileCredentials;
import com.beemdevelopment.aegis.db.DatabaseFileException; import com.beemdevelopment.aegis.vault.VaultFileException;
import com.beemdevelopment.aegis.db.DatabaseManager; import com.beemdevelopment.aegis.vault.VaultManager;
import com.beemdevelopment.aegis.db.DatabaseManagerException; import com.beemdevelopment.aegis.vault.VaultManagerException;
import com.beemdevelopment.aegis.db.slots.BiometricSlot; import com.beemdevelopment.aegis.vault.slots.BiometricSlot;
import com.beemdevelopment.aegis.db.slots.PasswordSlot; import com.beemdevelopment.aegis.vault.slots.PasswordSlot;
import com.beemdevelopment.aegis.db.slots.Slot; import com.beemdevelopment.aegis.vault.slots.Slot;
import com.beemdevelopment.aegis.db.slots.SlotException; import com.beemdevelopment.aegis.vault.slots.SlotException;
import com.beemdevelopment.aegis.db.slots.SlotList; import com.beemdevelopment.aegis.vault.slots.SlotList;
import com.beemdevelopment.aegis.helpers.BiometricSlotInitializer; import com.beemdevelopment.aegis.helpers.BiometricSlotInitializer;
import com.beemdevelopment.aegis.helpers.BiometricsHelper; import com.beemdevelopment.aegis.helpers.BiometricsHelper;
import com.beemdevelopment.aegis.helpers.PermissionHelper; import com.beemdevelopment.aegis.helpers.PermissionHelper;
@ -76,12 +76,12 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
private static final int CODE_PERM_EXPORT = 1; private static final int CODE_PERM_EXPORT = 1;
private Intent _result; private Intent _result;
private DatabaseManager _db; private VaultManager _vault;
// keep a reference to the type of database converter the user selected // keep a reference to the type of database converter the user selected
private Class<? extends DatabaseImporter> _importerType; private Class<? extends DatabaseImporter> _importerType;
private AegisImporter.State _importerState; private AegisImporter.State _importerState;
private UUIDMap<DatabaseEntry> _importerEntries; private UUIDMap<VaultEntry> _importerEntries;
private SwitchPreference _encryptionPreference; private SwitchPreference _encryptionPreference;
private SwitchPreference _biometricsPreference; private SwitchPreference _biometricsPreference;
@ -95,7 +95,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
addPreferencesFromResource(R.xml.preferences); addPreferencesFromResource(R.xml.preferences);
AegisApplication app = (AegisApplication) getActivity().getApplication(); AegisApplication app = (AegisApplication) getActivity().getApplication();
_db = app.getDatabaseManager(); _vault = app.getVaultManager();
// set the result intent in advance // set the result intent in advance
setResult(new Intent()); setResult(new Intent());
@ -258,7 +258,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
_encryptionPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { _encryptionPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
if (!_db.isEncryptionEnabled()) { if (!_vault.isEncryptionEnabled()) {
Dialogs.showSetPasswordDialog(getActivity(), new EnableEncryptionListener()); Dialogs.showSetPasswordDialog(getActivity(), new EnableEncryptionListener());
} else { } else {
Dialogs.showSecureDialog(new AlertDialog.Builder(getActivity()) Dialogs.showSecureDialog(new AlertDialog.Builder(getActivity())
@ -267,8 +267,8 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
try { try {
_db.disableEncryption(); _vault.disableEncryption();
} catch (DatabaseManagerException e) { } catch (VaultManagerException e) {
Toast.makeText(getActivity(), R.string.disable_encryption_error, Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(), R.string.disable_encryption_error, Toast.LENGTH_SHORT).show();
return; return;
} }
@ -296,7 +296,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
_biometricsPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { _biometricsPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
DatabaseFileCredentials creds = _db.getCredentials(); VaultFileCredentials creds = _vault.getCredentials();
SlotList slots = creds.getSlots(); SlotList slots = creds.getSlots();
if (!slots.has(BiometricSlot.class)) { if (!slots.has(BiometricSlot.class)) {
@ -312,7 +312,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
// remove the biometric slot // remove the biometric slot
BiometricSlot slot = slots.find(BiometricSlot.class); BiometricSlot slot = slots.find(BiometricSlot.class);
slots.remove(slot); slots.remove(slot);
_db.setCredentials(creds); _vault.setCredentials(creds);
// remove the KeyStore key // remove the KeyStore key
try { try {
@ -322,7 +322,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
e.printStackTrace(); e.printStackTrace();
} }
saveDatabase(); saveVault();
updateEncryptionPreferences(); updateEncryptionPreferences();
} }
@ -341,7 +341,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(getActivity(), SlotManagerActivity.class); Intent intent = new Intent(getActivity(), SlotManagerActivity.class);
intent.putExtra("creds", _db.getCredentials()); intent.putExtra("creds", _vault.getCredentials());
startActivityForResult(intent, CODE_SLOTS); startActivityForResult(intent, CODE_SLOTS);
return true; return true;
} }
@ -352,7 +352,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(getActivity(), GroupManagerActivity.class); Intent intent = new Intent(getActivity(), GroupManagerActivity.class);
intent.putExtra("groups", new ArrayList<>(_db.getGroups())); intent.putExtra("groups", new ArrayList<>(_vault.getGroups()));
startActivityForResult(intent, CODE_GROUPS); startActivityForResult(intent, CODE_GROUPS);
return true; return true;
} }
@ -485,7 +485,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
try { try {
DatabaseImporter.State state = importer.read(reader); DatabaseImporter.State state = importer.read(reader);
if (state.isEncrypted()) { if (state.isEncrypted()) {
// temporary special case for encrypted Aegis databases // temporary special case for encrypted Aegis vaults
if (state instanceof AegisImporter.EncryptedState) { if (state instanceof AegisImporter.EncryptedState) {
_importerState = state; _importerState = state;
@ -522,11 +522,11 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
return; return;
} }
DatabaseFileCredentials creds = (DatabaseFileCredentials) data.getSerializableExtra("creds"); VaultFileCredentials creds = (VaultFileCredentials) data.getSerializableExtra("creds");
DatabaseImporter.State state; DatabaseImporter.State state;
try { try {
state = ((AegisImporter.EncryptedState) _importerState).decrypt(creds); state = ((AegisImporter.EncryptedState) _importerState).decrypt(creds);
} catch (DatabaseFileException e) { } catch (VaultFileException e) {
e.printStackTrace(); e.printStackTrace();
Toast.makeText(getActivity(), R.string.decryption_error, Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(), R.string.decryption_error, Toast.LENGTH_SHORT).show();
return; return;
@ -567,7 +567,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
_importerEntries = result.getEntries(); _importerEntries = result.getEntries();
List<ImportEntry> entries = new ArrayList<>(); List<ImportEntry> entries = new ArrayList<>();
for (DatabaseEntry entry : _importerEntries) { for (VaultEntry entry : _importerEntries) {
entries.add(new ImportEntry(entry)); entries.add(new ImportEntry(entry));
} }
@ -585,24 +585,24 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
// TODO: create a custom layout to show a message AND a checkbox // TODO: create a custom layout to show a message AND a checkbox
final AtomicReference<Boolean> checked = new AtomicReference<>(true); final AtomicReference<Boolean> checked = new AtomicReference<>(true);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()) AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
.setTitle("Export the database") .setTitle(R.string.pref_export_summary)
.setPositiveButton(android.R.string.ok, (dialog, which) -> { .setPositiveButton(android.R.string.ok, (dialog, which) -> {
String filename; String filename;
try { try {
filename = _db.export(checked.get()); filename = _vault.export(checked.get());
} catch (DatabaseManagerException e) { } catch (VaultManagerException e) {
Toast.makeText(getActivity(), R.string.exporting_database_error, Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(), R.string.exporting_vault_error, Toast.LENGTH_SHORT).show();
return; return;
} }
// make sure the new file is visible // make sure the new file is visible
MediaScannerConnection.scanFile(getActivity(), new String[]{filename}, null, null); MediaScannerConnection.scanFile(getActivity(), new String[]{filename}, null, null);
Toast.makeText(getActivity(), getString(R.string.export_database_location) + filename, Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(), getString(R.string.export_vault_location) + filename, Toast.LENGTH_SHORT).show();
}) })
.setNegativeButton(android.R.string.cancel, null); .setNegativeButton(android.R.string.cancel, null);
if (_db.isEncryptionEnabled()) { if (_vault.isEncryptionEnabled()) {
final String[] items = {"Keep the database encrypted"}; final String[] items = {"Keep the vault encrypted"};
final boolean[] checkedItems = {true}; final boolean[] checkedItems = {true};
builder.setMultiChoiceItems(items, checkedItems, new DialogInterface.OnMultiChoiceClickListener() { builder.setMultiChoiceItems(items, checkedItems, new DialogInterface.OnMultiChoiceClickListener() {
@Override @Override
@ -621,9 +621,9 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
return; return;
} }
DatabaseFileCredentials creds = (DatabaseFileCredentials) data.getSerializableExtra("creds"); VaultFileCredentials creds = (VaultFileCredentials) data.getSerializableExtra("creds");
_db.setCredentials(creds); _vault.setCredentials(creds);
saveDatabase(); saveVault();
updateEncryptionPreferences(); updateEncryptionPreferences();
} }
@ -634,7 +634,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
HashSet<String> groups = new HashSet<>(data.getStringArrayListExtra("groups")); HashSet<String> groups = new HashSet<>(data.getStringArrayListExtra("groups"));
for (DatabaseEntry entry : _db.getEntries()) { for (VaultEntry entry : _vault.getEntries()) {
if (!groups.contains(entry.getGroup())) { if (!groups.contains(entry.getGroup())) {
entry.setGroup(null); entry.setGroup(null);
} }
@ -648,18 +648,18 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
List<ImportEntry> selectedEntries = (ArrayList<ImportEntry>) data.getSerializableExtra("entries"); List<ImportEntry> selectedEntries = (ArrayList<ImportEntry>) data.getSerializableExtra("entries");
for (ImportEntry selectedEntry : selectedEntries) { for (ImportEntry selectedEntry : selectedEntries) {
DatabaseEntry savedEntry = _importerEntries.getByUUID(selectedEntry.getUUID()); VaultEntry savedEntry = _importerEntries.getByUUID(selectedEntry.getUUID());
// temporary: randomize the UUID of duplicate entries and add them anyway // temporary: randomize the UUID of duplicate entries and add them anyway
if (_db.isEntryDuplicate(savedEntry)) { if (_vault.isEntryDuplicate(savedEntry)) {
savedEntry.resetUUID(); savedEntry.resetUUID();
} }
_db.addEntry(savedEntry); _vault.addEntry(savedEntry);
} }
_importerEntries = null; _importerEntries = null;
if (!saveDatabase()) { if (!saveVault()) {
return; return;
} }
@ -669,10 +669,10 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
_result.putExtra("needsRecreate", true); _result.putExtra("needsRecreate", true);
} }
private boolean saveDatabase() { private boolean saveVault() {
try { try {
_db.save(); _vault.save();
} catch (DatabaseManagerException e) { } catch (VaultManagerException e) {
Toast.makeText(getActivity(), R.string.saving_error, Toast.LENGTH_LONG).show(); Toast.makeText(getActivity(), R.string.saving_error, Toast.LENGTH_LONG).show();
return false; return false;
} }
@ -681,7 +681,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
} }
private void updateEncryptionPreferences() { private void updateEncryptionPreferences() {
boolean encrypted = _db.isEncryptionEnabled(); boolean encrypted = _vault.isEncryptionEnabled();
_encryptionPreference.setChecked(encrypted, true); _encryptionPreference.setChecked(encrypted, true);
_setPasswordPreference.setVisible(encrypted); _setPasswordPreference.setVisible(encrypted);
_biometricsPreference.setVisible(encrypted); _biometricsPreference.setVisible(encrypted);
@ -689,7 +689,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
_autoLockPreference.setVisible(encrypted); _autoLockPreference.setVisible(encrypted);
if (encrypted) { if (encrypted) {
SlotList slots = _db.getCredentials().getSlots(); SlotList slots = _vault.getCredentials().getSlots();
boolean multiPassword = slots.findAll(PasswordSlot.class).size() > 1; boolean multiPassword = slots.findAll(PasswordSlot.class).size() > 1;
boolean multiBio = slots.findAll(BiometricSlot.class).size() > 1; boolean multiBio = slots.findAll(BiometricSlot.class).size() > 1;
boolean showSlots = BuildConfig.DEBUG || multiPassword || multiBio; boolean showSlots = BuildConfig.DEBUG || multiPassword || multiBio;
@ -709,7 +709,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
private class SetPasswordListener implements Dialogs.SlotListener { private class SetPasswordListener implements Dialogs.SlotListener {
@Override @Override
public void onSlotResult(Slot slot, Cipher cipher) { public void onSlotResult(Slot slot, Cipher cipher) {
DatabaseFileCredentials creds = _db.getCredentials(); VaultFileCredentials creds = _vault.getCredentials();
SlotList slots = creds.getSlots(); SlotList slots = creds.getSlots();
try { try {
@ -727,8 +727,8 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
return; return;
} }
_db.setCredentials(creds); _vault.setCredentials(creds);
saveDatabase(); saveVault();
} }
@Override @Override
@ -741,7 +741,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
private class RegisterBiometricsListener implements BiometricSlotInitializer.Listener { private class RegisterBiometricsListener implements BiometricSlotInitializer.Listener {
@Override @Override
public void onInitializeSlot(BiometricSlot slot, Cipher cipher) { public void onInitializeSlot(BiometricSlot slot, Cipher cipher) {
DatabaseFileCredentials creds = _db.getCredentials(); VaultFileCredentials creds = _vault.getCredentials();
try { try {
slot.setKey(creds.getKey(), cipher); slot.setKey(creds.getKey(), cipher);
} catch (SlotException e) { } catch (SlotException e) {
@ -749,9 +749,9 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
return; return;
} }
creds.getSlots().add(slot); creds.getSlots().add(slot);
_db.setCredentials(creds); _vault.setCredentials(creds);
saveDatabase(); saveVault();
updateEncryptionPreferences(); updateEncryptionPreferences();
} }
@ -766,13 +766,13 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
private class EnableEncryptionListener implements Dialogs.SlotListener { private class EnableEncryptionListener implements Dialogs.SlotListener {
@Override @Override
public void onSlotResult(Slot slot, Cipher cipher) { public void onSlotResult(Slot slot, Cipher cipher) {
DatabaseFileCredentials creds = new DatabaseFileCredentials(); VaultFileCredentials creds = new VaultFileCredentials();
try { try {
slot.setKey(creds.getKey(), cipher); slot.setKey(creds.getKey(), cipher);
creds.getSlots().add(slot); creds.getSlots().add(slot);
_db.enableEncryption(creds); _vault.enableEncryption(creds);
} catch (DatabaseManagerException | SlotException e) { } catch (VaultManagerException | SlotException e) {
onException(e); onException(e);
return; return;
} }

View file

@ -10,7 +10,7 @@ import android.widget.Toast;
import com.beemdevelopment.aegis.R; import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.Theme; import com.beemdevelopment.aegis.Theme;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.helpers.SquareFinderView; import com.beemdevelopment.aegis.helpers.SquareFinderView;
import com.beemdevelopment.aegis.otp.GoogleAuthInfo; import com.beemdevelopment.aegis.otp.GoogleAuthInfo;
import com.beemdevelopment.aegis.otp.GoogleAuthInfoException; import com.beemdevelopment.aegis.otp.GoogleAuthInfoException;
@ -109,7 +109,7 @@ public class ScannerActivity extends AegisActivity implements ZXingScannerView.R
try { try {
// parse google auth uri // parse google auth uri
GoogleAuthInfo info = GoogleAuthInfo.parseUri(rawResult.getText()); GoogleAuthInfo info = GoogleAuthInfo.parseUri(rawResult.getText());
DatabaseEntry entry = new DatabaseEntry(info); VaultEntry entry = new VaultEntry(info);
Intent intent = new Intent(); Intent intent = new Intent();
intent.putExtra("entry", entry); intent.putExtra("entry", entry);

View file

@ -17,12 +17,12 @@ import androidx.recyclerview.widget.RecyclerView;
import com.beemdevelopment.aegis.R; import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.crypto.KeyStoreHandle; import com.beemdevelopment.aegis.crypto.KeyStoreHandle;
import com.beemdevelopment.aegis.crypto.KeyStoreHandleException; import com.beemdevelopment.aegis.crypto.KeyStoreHandleException;
import com.beemdevelopment.aegis.db.DatabaseFileCredentials; import com.beemdevelopment.aegis.vault.VaultFileCredentials;
import com.beemdevelopment.aegis.db.slots.BiometricSlot; import com.beemdevelopment.aegis.vault.slots.BiometricSlot;
import com.beemdevelopment.aegis.db.slots.PasswordSlot; import com.beemdevelopment.aegis.vault.slots.PasswordSlot;
import com.beemdevelopment.aegis.db.slots.Slot; import com.beemdevelopment.aegis.vault.slots.Slot;
import com.beemdevelopment.aegis.db.slots.SlotException; import com.beemdevelopment.aegis.vault.slots.SlotException;
import com.beemdevelopment.aegis.db.slots.SlotList; import com.beemdevelopment.aegis.vault.slots.SlotList;
import com.beemdevelopment.aegis.helpers.BiometricSlotInitializer; import com.beemdevelopment.aegis.helpers.BiometricSlotInitializer;
import com.beemdevelopment.aegis.helpers.BiometricsHelper; import com.beemdevelopment.aegis.helpers.BiometricsHelper;
import com.beemdevelopment.aegis.ui.views.SlotAdapter; import com.beemdevelopment.aegis.ui.views.SlotAdapter;
@ -30,7 +30,7 @@ import com.beemdevelopment.aegis.ui.views.SlotAdapter;
import javax.crypto.Cipher; import javax.crypto.Cipher;
public class SlotManagerActivity extends AegisActivity implements SlotAdapter.Listener { public class SlotManagerActivity extends AegisActivity implements SlotAdapter.Listener {
private DatabaseFileCredentials _creds; private VaultFileCredentials _creds;
private SlotAdapter _adapter; private SlotAdapter _adapter;
private boolean _edited; private boolean _edited;
@ -69,7 +69,7 @@ public class SlotManagerActivity extends AegisActivity implements SlotAdapter.Li
slotsView.setNestedScrollingEnabled(false); slotsView.setNestedScrollingEnabled(false);
// load the slots and masterKey // load the slots and masterKey
_creds = (DatabaseFileCredentials) getIntent().getSerializableExtra("creds"); _creds = (VaultFileCredentials) getIntent().getSerializableExtra("creds");
for (Slot slot : _creds.getSlots()) { for (Slot slot : _creds.getSlots()) {
_adapter.addSlot(slot); _adapter.addSlot(slot);
} }

View file

@ -4,7 +4,7 @@ import android.content.Context;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.Registry; import com.bumptech.glide.Registry;
import com.bumptech.glide.annotation.GlideModule; import com.bumptech.glide.annotation.GlideModule;
@ -16,6 +16,6 @@ import java.nio.ByteBuffer;
public class AegisGlideModule extends AppGlideModule { public class AegisGlideModule extends AppGlideModule {
@Override @Override
public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) { public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {
registry.prepend(DatabaseEntry.class, ByteBuffer.class, new IconLoader.Factory()); registry.prepend(VaultEntry.class, ByteBuffer.class, new IconLoader.Factory());
} }
} }

View file

@ -2,7 +2,7 @@ package com.beemdevelopment.aegis.ui.glide;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import com.bumptech.glide.Priority; import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource; import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.Options; import com.bumptech.glide.load.Options;
@ -13,21 +13,21 @@ import com.bumptech.glide.load.model.MultiModelLoaderFactory;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
public class IconLoader implements ModelLoader<DatabaseEntry, ByteBuffer> { public class IconLoader implements ModelLoader<VaultEntry, ByteBuffer> {
@Override @Override
public LoadData<ByteBuffer> buildLoadData(@NonNull DatabaseEntry model, int width, int height, @NonNull Options options) { public LoadData<ByteBuffer> buildLoadData(@NonNull VaultEntry model, int width, int height, @NonNull Options options) {
return new LoadData<>(new UUIDKey(model.getUUID()), new Fetcher(model)); return new LoadData<>(new UUIDKey(model.getUUID()), new Fetcher(model));
} }
@Override @Override
public boolean handles(@NonNull DatabaseEntry model) { public boolean handles(@NonNull VaultEntry model) {
return true; return true;
} }
public static class Fetcher implements DataFetcher<ByteBuffer> { public static class Fetcher implements DataFetcher<ByteBuffer> {
private DatabaseEntry _model; private VaultEntry _model;
private Fetcher(DatabaseEntry model) { private Fetcher(VaultEntry model) {
_model = model; _model = model;
} }
@ -61,10 +61,10 @@ public class IconLoader implements ModelLoader<DatabaseEntry, ByteBuffer> {
} }
} }
public static class Factory implements ModelLoaderFactory<DatabaseEntry, ByteBuffer> { public static class Factory implements ModelLoaderFactory<VaultEntry, ByteBuffer> {
@NonNull @NonNull
@Override @Override
public ModelLoader<DatabaseEntry, ByteBuffer> build(@NonNull MultiModelLoaderFactory unused) { public ModelLoader<VaultEntry, ByteBuffer> build(@NonNull MultiModelLoaderFactory unused) {
return new IconLoader(); return new IconLoader();
} }

View file

@ -1,6 +1,6 @@
package com.beemdevelopment.aegis.ui.models; package com.beemdevelopment.aegis.ui.models;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import java.io.Serializable; import java.io.Serializable;
import java.util.UUID; import java.util.UUID;
@ -13,7 +13,7 @@ public class ImportEntry implements Serializable {
private transient Listener _listener; private transient Listener _listener;
private boolean _isChecked = true; private boolean _isChecked = true;
public ImportEntry(DatabaseEntry entry) { public ImportEntry(VaultEntry entry) {
_uuid = entry.getUUID(); _uuid = entry.getUUID();
_name = entry.getName(); _name = entry.getName();
_issuer = entry.getIssuer(); _issuer = entry.getIssuer();

View file

@ -15,7 +15,7 @@ import androidx.biometric.BiometricPrompt;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import com.beemdevelopment.aegis.R; import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.db.slots.BiometricSlot; import com.beemdevelopment.aegis.vault.slots.BiometricSlot;
import com.beemdevelopment.aegis.helpers.BiometricSlotInitializer; import com.beemdevelopment.aegis.helpers.BiometricSlotInitializer;
import com.beemdevelopment.aegis.helpers.BiometricsHelper; import com.beemdevelopment.aegis.helpers.BiometricsHelper;
import com.beemdevelopment.aegis.helpers.EditTextHelper; import com.beemdevelopment.aegis.helpers.EditTextHelper;

View file

@ -5,7 +5,7 @@ import android.content.Context;
import com.beemdevelopment.aegis.R; import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.crypto.CryptoUtils; import com.beemdevelopment.aegis.crypto.CryptoUtils;
import com.beemdevelopment.aegis.crypto.SCryptParameters; import com.beemdevelopment.aegis.crypto.SCryptParameters;
import com.beemdevelopment.aegis.db.slots.PasswordSlot; import com.beemdevelopment.aegis.vault.slots.PasswordSlot;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;

View file

@ -5,12 +5,12 @@ import android.content.Context;
import com.beemdevelopment.aegis.R; import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.crypto.CryptoUtils; import com.beemdevelopment.aegis.crypto.CryptoUtils;
import com.beemdevelopment.aegis.crypto.MasterKey; import com.beemdevelopment.aegis.crypto.MasterKey;
import com.beemdevelopment.aegis.db.slots.BiometricSlot; import com.beemdevelopment.aegis.vault.slots.BiometricSlot;
import com.beemdevelopment.aegis.db.slots.PasswordSlot; import com.beemdevelopment.aegis.vault.slots.PasswordSlot;
import com.beemdevelopment.aegis.db.slots.Slot; import com.beemdevelopment.aegis.vault.slots.Slot;
import com.beemdevelopment.aegis.db.slots.SlotException; import com.beemdevelopment.aegis.vault.slots.SlotException;
import com.beemdevelopment.aegis.db.slots.SlotIntegrityException; import com.beemdevelopment.aegis.vault.slots.SlotIntegrityException;
import com.beemdevelopment.aegis.db.slots.SlotList; import com.beemdevelopment.aegis.vault.slots.SlotList;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;

View file

@ -10,7 +10,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.beemdevelopment.aegis.R; import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.SortCategory; import com.beemdevelopment.aegis.SortCategory;
import com.beemdevelopment.aegis.ViewMode; import com.beemdevelopment.aegis.ViewMode;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.helpers.ItemTouchHelperAdapter; import com.beemdevelopment.aegis.helpers.ItemTouchHelperAdapter;
import com.beemdevelopment.aegis.otp.HotpInfo; import com.beemdevelopment.aegis.otp.HotpInfo;
import com.beemdevelopment.aegis.otp.OtpInfo; import com.beemdevelopment.aegis.otp.OtpInfo;
@ -24,10 +24,10 @@ import java.util.List;
public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements ItemTouchHelperAdapter { public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements ItemTouchHelperAdapter {
private EntryListView _view; private EntryListView _view;
private List<DatabaseEntry> _entries; private List<VaultEntry> _entries;
private List<DatabaseEntry> _shownEntries; private List<VaultEntry> _shownEntries;
private DatabaseEntry _selectedEntry; private VaultEntry _selectedEntry;
private DatabaseEntry _focusedEntry; private VaultEntry _focusedEntry;
private boolean _showAccountName; private boolean _showAccountName;
private boolean _searchAccountName; private boolean _searchAccountName;
private boolean _highlightEntry; private boolean _highlightEntry;
@ -78,18 +78,18 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
_highlightEntry = highlightEntry; _highlightEntry = highlightEntry;
} }
public DatabaseEntry getEntryAt(int position) { public VaultEntry getEntryAt(int position) {
return _shownEntries.get(position); return _shownEntries.get(position);
} }
public void addEntry(DatabaseEntry entry) { public void addEntry(VaultEntry entry) {
_entries.add(entry); _entries.add(entry);
if (isEntryFiltered(entry)) { if (isEntryFiltered(entry)) {
return; return;
} }
boolean added = false; boolean added = false;
Comparator<DatabaseEntry> comparator = _sortCategory.getComparator(); Comparator<VaultEntry> comparator = _sortCategory.getComparator();
if (comparator != null) { if (comparator != null) {
// insert the entry in the correct order // insert the entry in the correct order
// note: this assumes that _shownEntries has already been sorted // note: this assumes that _shownEntries has already been sorted
@ -117,13 +117,13 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
checkPeriodUniformity(); checkPeriodUniformity();
} }
public void addEntries(List<DatabaseEntry> entries) { public void addEntries(List<VaultEntry> entries) {
_entries.addAll(entries); _entries.addAll(entries);
updateShownEntries(); updateShownEntries();
checkPeriodUniformity(true); checkPeriodUniformity(true);
} }
public void removeEntry(DatabaseEntry entry) { public void removeEntry(VaultEntry entry) {
_entries.remove(entry); _entries.remove(entry);
if (_shownEntries.contains(entry)) { if (_shownEntries.contains(entry)) {
@ -142,7 +142,7 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
checkPeriodUniformity(); checkPeriodUniformity();
} }
public void replaceEntry(DatabaseEntry oldEntry, DatabaseEntry newEntry) { public void replaceEntry(VaultEntry oldEntry, VaultEntry newEntry) {
_entries.set(_entries.indexOf(oldEntry), newEntry); _entries.set(_entries.indexOf(oldEntry), newEntry);
if (_shownEntries.contains(oldEntry)) { if (_shownEntries.contains(oldEntry)) {
@ -165,7 +165,7 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
checkPeriodUniformity(); checkPeriodUniformity();
} }
private boolean isEntryFiltered(DatabaseEntry entry) { private boolean isEntryFiltered(VaultEntry entry) {
String group = entry.getGroup(); String group = entry.getGroup();
String issuer = entry.getIssuer().toLowerCase(); String issuer = entry.getIssuer().toLowerCase();
String name = entry.getName().toLowerCase(); String name = entry.getName().toLowerCase();
@ -229,14 +229,14 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
_shownEntries.clear(); _shownEntries.clear();
// add entries back that are not filtered out // add entries back that are not filtered out
for (DatabaseEntry entry : _entries) { for (VaultEntry entry : _entries) {
if (!isEntryFiltered(entry)) { if (!isEntryFiltered(entry)) {
_shownEntries.add(entry); _shownEntries.add(entry);
} }
} }
// sort the remaining list of entries // sort the remaining list of entries
Comparator<DatabaseEntry> comparator = _sortCategory.getComparator(); Comparator<VaultEntry> comparator = _sortCategory.getComparator();
if (comparator != null) { if (comparator != null) {
Collections.sort(_shownEntries, comparator); Collections.sort(_shownEntries, comparator);
} }
@ -270,7 +270,7 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
return; return;
} }
// notify the database first // notify the vault first
_view.onEntryMove(_entries.get(firstPosition), _entries.get(secondPosition)); _view.onEntryMove(_entries.get(firstPosition), _entries.get(secondPosition));
// update our side of things // update our side of things
@ -301,7 +301,7 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
@Override @Override
public void onBindViewHolder(final EntryHolder holder, int position) { public void onBindViewHolder(final EntryHolder holder, int position) {
DatabaseEntry entry = _shownEntries.get(position); VaultEntry entry = _shownEntries.get(position);
holder.setFocused(entry == _selectedEntry); holder.setFocused(entry == _selectedEntry);
boolean hidden = _tapToReveal && entry != _focusedEntry; boolean hidden = _tapToReveal && entry != _focusedEntry;
@ -354,7 +354,7 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
} }
// notify the listener that the counter has been incremented // notify the listener that the counter has been incremented
// this gives it a chance to save the database // this gives it a chance to save the vault
_view.onEntryChange(entry); _view.onEntryChange(entry);
// finally, refresh the code in the UI // finally, refresh the code in the UI
@ -385,7 +385,7 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
public int getUniformPeriod() { public int getUniformPeriod() {
List<TotpInfo> infos = new ArrayList<>(); List<TotpInfo> infos = new ArrayList<>();
for (DatabaseEntry entry : _shownEntries) { for (VaultEntry entry : _shownEntries) {
OtpInfo info = entry.getInfo(); OtpInfo info = entry.getInfo();
if (info instanceof TotpInfo) { if (info instanceof TotpInfo) {
infos.add((TotpInfo) info); infos.add((TotpInfo) info);
@ -406,7 +406,7 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
return period; return period;
} }
private void focusEntry(DatabaseEntry entry) { private void focusEntry(VaultEntry entry) {
_focusedEntry = entry; _focusedEntry = entry;
_dimHandler.removeCallbacksAndMessages(null); _dimHandler.removeCallbacksAndMessages(null);
@ -444,7 +444,7 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
_focusedEntry = null; _focusedEntry = null;
} }
public void setSelectedEntry(DatabaseEntry entry) { public void setSelectedEntry(VaultEntry entry) {
if (entry == null) { if (entry == null) {
notifyItemChanged(_shownEntries.indexOf(_selectedEntry)); notifyItemChanged(_shownEntries.indexOf(_selectedEntry));
} else if (_highlightEntry) { } else if (_highlightEntry) {
@ -468,11 +468,11 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
} }
public interface Listener { public interface Listener {
void onEntryClick(DatabaseEntry entry); void onEntryClick(VaultEntry entry);
boolean onLongEntryClick(DatabaseEntry entry); boolean onLongEntryClick(VaultEntry entry);
void onEntryMove(DatabaseEntry entry1, DatabaseEntry entry2); void onEntryMove(VaultEntry entry1, VaultEntry entry2);
void onEntryDrop(DatabaseEntry entry); void onEntryDrop(VaultEntry entry);
void onEntryChange(DatabaseEntry entry); void onEntryChange(VaultEntry entry);
void onPeriodUniformityChanged(boolean uniform); void onPeriodUniformityChanged(boolean uniform);
} }
} }

View file

@ -10,7 +10,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.TextDrawable;
import com.beemdevelopment.aegis.R; import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.helpers.TextDrawableHelper; import com.beemdevelopment.aegis.helpers.TextDrawableHelper;
import com.beemdevelopment.aegis.helpers.ThemeHelper; import com.beemdevelopment.aegis.helpers.ThemeHelper;
import com.beemdevelopment.aegis.helpers.UiRefresher; import com.beemdevelopment.aegis.helpers.UiRefresher;
@ -29,7 +29,7 @@ public class EntryHolder extends RecyclerView.ViewHolder {
private TextView _profileCode; private TextView _profileCode;
private TextView _profileIssuer; private TextView _profileIssuer;
private ImageView _profileDrawable; private ImageView _profileDrawable;
private DatabaseEntry _entry; private VaultEntry _entry;
private ImageView _buttonRefresh; private ImageView _buttonRefresh;
private boolean _hidden; private boolean _hidden;
@ -72,7 +72,7 @@ public class EntryHolder extends RecyclerView.ViewHolder {
}); });
} }
public void setData(DatabaseEntry entry, boolean showAccountName, boolean showProgress, boolean hidden, boolean dimmed) { public void setData(VaultEntry entry, boolean showAccountName, boolean showProgress, boolean hidden, boolean dimmed) {
_entry = entry; _entry = entry;
_hidden = hidden; _hidden = hidden;
@ -97,7 +97,7 @@ public class EntryHolder extends RecyclerView.ViewHolder {
itemView.setAlpha(dimmed ? DIMMED_ALPHA : DEFAULT_ALPHA); itemView.setAlpha(dimmed ? DIMMED_ALPHA : DEFAULT_ALPHA);
} }
public DatabaseEntry getEntry() { public VaultEntry getEntry() {
return _entry; return _entry;
} }

View file

@ -22,7 +22,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.beemdevelopment.aegis.R; import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.SortCategory; import com.beemdevelopment.aegis.SortCategory;
import com.beemdevelopment.aegis.ViewMode; import com.beemdevelopment.aegis.ViewMode;
import com.beemdevelopment.aegis.db.DatabaseEntry; import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.helpers.SimpleItemTouchHelperCallback; import com.beemdevelopment.aegis.helpers.SimpleItemTouchHelperCallback;
import com.beemdevelopment.aegis.helpers.UiRefresher; import com.beemdevelopment.aegis.helpers.UiRefresher;
import com.beemdevelopment.aegis.otp.TotpInfo; import com.beemdevelopment.aegis.otp.TotpInfo;
@ -43,7 +43,7 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
private RecyclerView _recyclerView; private RecyclerView _recyclerView;
private RecyclerView.ItemDecoration _dividerDecoration; private RecyclerView.ItemDecoration _dividerDecoration;
private ViewPreloadSizeProvider<DatabaseEntry> _preloadSizeProvider; private ViewPreloadSizeProvider<VaultEntry> _preloadSizeProvider;
private PeriodProgressBar _progressBar; private PeriodProgressBar _progressBar;
private boolean _showProgress; private boolean _showProgress;
private ViewMode _viewMode; private ViewMode _viewMode;
@ -82,7 +82,7 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
// set up icon preloading // set up icon preloading
_preloadSizeProvider = new ViewPreloadSizeProvider<>(); _preloadSizeProvider = new ViewPreloadSizeProvider<>();
IconPreloadProvider modelProvider = new IconPreloadProvider(); IconPreloadProvider modelProvider = new IconPreloadProvider();
RecyclerViewPreloader<DatabaseEntry> preloader = new RecyclerViewPreloader<>(Glide.with(this), modelProvider, _preloadSizeProvider, 10); RecyclerViewPreloader<VaultEntry> preloader = new RecyclerViewPreloader<>(Glide.with(this), modelProvider, _preloadSizeProvider, 10);
_recyclerView.addOnScrollListener(preloader); _recyclerView.addOnScrollListener(preloader);
LinearLayoutManager layoutManager = new LinearLayoutManager(view.getContext()); LinearLayoutManager layoutManager = new LinearLayoutManager(view.getContext());
@ -132,7 +132,7 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
} }
} }
public void setActionModeState(boolean enabled, DatabaseEntry entry) { public void setActionModeState(boolean enabled, VaultEntry entry) {
_touchCallback.setSelectedEntry(entry); _touchCallback.setSelectedEntry(entry);
_touchCallback.setIsLongPressDragEnabled(enabled && _adapter.isDragAndDropAllowed()); _touchCallback.setIsLongPressDragEnabled(enabled && _adapter.isDragAndDropAllowed());
_adapter.setSelectedEntry(entry); _adapter.setSelectedEntry(entry);
@ -170,27 +170,27 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
} }
@Override @Override
public void onEntryClick(DatabaseEntry entry) { public void onEntryClick(VaultEntry entry) {
_listener.onEntryClick(entry); _listener.onEntryClick(entry);
} }
public boolean onLongEntryClick(DatabaseEntry entry) { public boolean onLongEntryClick(VaultEntry entry) {
_listener.onLongEntryClick(entry); _listener.onLongEntryClick(entry);
return true; return true;
} }
@Override @Override
public void onEntryMove(DatabaseEntry entry1, DatabaseEntry entry2) { public void onEntryMove(VaultEntry entry1, VaultEntry entry2) {
_listener.onEntryMove(entry1, entry2); _listener.onEntryMove(entry1, entry2);
} }
@Override @Override
public void onEntryDrop(DatabaseEntry entry) { public void onEntryDrop(VaultEntry entry) {
_listener.onEntryDrop(entry); _listener.onEntryDrop(entry);
} }
@Override @Override
public void onEntryChange(DatabaseEntry entry) { public void onEntryChange(VaultEntry entry) {
_listener.onEntryChange(entry); _listener.onEntryChange(entry);
} }
@ -227,17 +227,17 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
_adapter.setTapToRevealTime(number); _adapter.setTapToRevealTime(number);
} }
public void addEntry(DatabaseEntry entry) { public void addEntry(VaultEntry entry) {
_adapter.addEntry(entry); _adapter.addEntry(entry);
updateEmptyState(); updateEmptyState();
} }
public void addEntries(List<DatabaseEntry> entries) { public void addEntries(List<VaultEntry> entries) {
_adapter.addEntries(entries); _adapter.addEntries(entries);
updateEmptyState(); updateEmptyState();
} }
public void removeEntry(DatabaseEntry entry) { public void removeEntry(VaultEntry entry) {
_adapter.removeEntry(entry); _adapter.removeEntry(entry);
updateEmptyState(); updateEmptyState();
} }
@ -246,7 +246,7 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
_adapter.clearEntries(); _adapter.clearEntries();
} }
public void replaceEntry(DatabaseEntry oldEntry, DatabaseEntry newEntry) { public void replaceEntry(VaultEntry oldEntry, VaultEntry newEntry) {
_adapter.replaceEntry(oldEntry, newEntry); _adapter.replaceEntry(oldEntry, newEntry);
} }
@ -292,11 +292,11 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
} }
public interface Listener { public interface Listener {
void onEntryClick(DatabaseEntry entry); void onEntryClick(VaultEntry entry);
void onEntryMove(DatabaseEntry entry1, DatabaseEntry entry2); void onEntryMove(VaultEntry entry1, VaultEntry entry2);
void onEntryDrop(DatabaseEntry entry); void onEntryDrop(VaultEntry entry);
void onEntryChange(DatabaseEntry entry); void onEntryChange(VaultEntry entry);
void onLongEntryClick(DatabaseEntry entry); void onLongEntryClick(VaultEntry entry);
void onScroll(int dx, int dy); void onScroll(int dx, int dy);
} }
@ -318,11 +318,11 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
} }
} }
private class IconPreloadProvider implements ListPreloader.PreloadModelProvider<DatabaseEntry> { private class IconPreloadProvider implements ListPreloader.PreloadModelProvider<VaultEntry> {
@NonNull @NonNull
@Override @Override
public List<DatabaseEntry> getPreloadItems(int position) { public List<VaultEntry> getPreloadItems(int position) {
DatabaseEntry entry = _adapter.getEntryAt(position); VaultEntry entry = _adapter.getEntryAt(position);
if (!entry.hasIcon()) { if (!entry.hasIcon()) {
return Collections.emptyList(); return Collections.emptyList();
} }
@ -331,7 +331,7 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
@Nullable @Nullable
@Override @Override
public RequestBuilder getPreloadRequestBuilder(@NonNull DatabaseEntry entry) { public RequestBuilder getPreloadRequestBuilder(@NonNull VaultEntry entry) {
return Glide.with(EntryListView.this) return Glide.with(EntryListView.this)
.asDrawable() .asDrawable()
.load(entry) .load(entry)

View file

@ -5,7 +5,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.beemdevelopment.aegis.R; import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.db.DatabaseEntry;
import com.beemdevelopment.aegis.ui.models.ImportEntry; import com.beemdevelopment.aegis.ui.models.ImportEntry;
import java.util.ArrayList; import java.util.ArrayList;

View file

@ -6,7 +6,6 @@ import android.widget.CheckBox;
import android.widget.TextView; import android.widget.TextView;
import com.beemdevelopment.aegis.R; import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.db.DatabaseEntry;
import com.beemdevelopment.aegis.ui.models.ImportEntry; import com.beemdevelopment.aegis.ui.models.ImportEntry;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;

View file

@ -5,7 +5,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.beemdevelopment.aegis.R; import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.db.slots.Slot; import com.beemdevelopment.aegis.vault.slots.Slot;
import java.util.ArrayList; import java.util.ArrayList;

View file

@ -10,10 +10,10 @@ import androidx.recyclerview.widget.RecyclerView;
import com.beemdevelopment.aegis.R; import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.crypto.KeyStoreHandle; import com.beemdevelopment.aegis.crypto.KeyStoreHandle;
import com.beemdevelopment.aegis.crypto.KeyStoreHandleException; import com.beemdevelopment.aegis.crypto.KeyStoreHandleException;
import com.beemdevelopment.aegis.db.slots.BiometricSlot; import com.beemdevelopment.aegis.vault.slots.BiometricSlot;
import com.beemdevelopment.aegis.db.slots.PasswordSlot; import com.beemdevelopment.aegis.vault.slots.PasswordSlot;
import com.beemdevelopment.aegis.db.slots.RawSlot; import com.beemdevelopment.aegis.vault.slots.RawSlot;
import com.beemdevelopment.aegis.db.slots.Slot; import com.beemdevelopment.aegis.vault.slots.Slot;
import com.beemdevelopment.aegis.helpers.BiometricsHelper; import com.beemdevelopment.aegis.helpers.BiometricsHelper;
public class SlotHolder extends RecyclerView.ViewHolder { public class SlotHolder extends RecyclerView.ViewHolder {

View file

@ -1,4 +1,4 @@
package com.beemdevelopment.aegis.db; package com.beemdevelopment.aegis.vault;
import com.beemdevelopment.aegis.encoding.Base64Exception; import com.beemdevelopment.aegis.encoding.Base64Exception;
import com.beemdevelopment.aegis.otp.OtpInfoException; import com.beemdevelopment.aegis.otp.OtpInfoException;
@ -8,14 +8,14 @@ import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
public class Database { public class Vault {
private static final int VERSION = 1; private static final int VERSION = 1;
private UUIDMap<DatabaseEntry> _entries = new UUIDMap<>(); private UUIDMap<VaultEntry> _entries = new UUIDMap<>();
public JSONObject toJson() { public JSONObject toJson() {
try { try {
JSONArray array = new JSONArray(); JSONArray array = new JSONArray();
for (DatabaseEntry e : _entries) { for (VaultEntry e : _entries) {
array.put(e.toJson()); array.put(e.toJson());
} }
@ -28,29 +28,29 @@ public class Database {
} }
} }
public static Database fromJson(JSONObject obj) throws DatabaseException { public static Vault fromJson(JSONObject obj) throws VaultException {
Database db = new Database(); Vault vault = new Vault();
UUIDMap<DatabaseEntry> entries = db.getEntries(); UUIDMap<VaultEntry> entries = vault.getEntries();
try { try {
int ver = obj.getInt("version"); int ver = obj.getInt("version");
if (ver != VERSION) { if (ver != VERSION) {
throw new DatabaseException("Unsupported version"); throw new VaultException("Unsupported version");
} }
JSONArray array = obj.getJSONArray("entries"); JSONArray array = obj.getJSONArray("entries");
for (int i = 0; i < array.length(); i++) { for (int i = 0; i < array.length(); i++) {
DatabaseEntry entry = DatabaseEntry.fromJson(array.getJSONObject(i)); VaultEntry entry = VaultEntry.fromJson(array.getJSONObject(i));
entries.add(entry); entries.add(entry);
} }
} catch (Base64Exception | OtpInfoException | JSONException e) { } catch (Base64Exception | OtpInfoException | JSONException e) {
throw new DatabaseException(e); throw new VaultException(e);
} }
return db; return vault;
} }
public UUIDMap<DatabaseEntry> getEntries() { public UUIDMap<VaultEntry> getEntries() {
return _entries; return _entries;
} }
} }

View file

@ -1,4 +1,4 @@
package com.beemdevelopment.aegis.db; package com.beemdevelopment.aegis.vault;
import com.beemdevelopment.aegis.encoding.Base64; import com.beemdevelopment.aegis.encoding.Base64;
import com.beemdevelopment.aegis.encoding.Base64Exception; import com.beemdevelopment.aegis.encoding.Base64Exception;
@ -15,30 +15,30 @@ import java.util.Arrays;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
public class DatabaseEntry extends UUIDMap.Value { public class VaultEntry extends UUIDMap.Value {
private String _name = ""; private String _name = "";
private String _issuer = ""; private String _issuer = "";
private String _group; private String _group;
private OtpInfo _info; private OtpInfo _info;
private byte[] _icon; private byte[] _icon;
private DatabaseEntry(UUID uuid, OtpInfo info) { private VaultEntry(UUID uuid, OtpInfo info) {
super(uuid); super(uuid);
_info = info; _info = info;
} }
public DatabaseEntry(OtpInfo info) { public VaultEntry(OtpInfo info) {
super(); super();
_info = info; _info = info;
} }
public DatabaseEntry(OtpInfo info, String name, String issuer) { public VaultEntry(OtpInfo info, String name, String issuer) {
this(info); this(info);
setName(name); setName(name);
setIssuer(issuer); setIssuer(issuer);
} }
public DatabaseEntry(GoogleAuthInfo info) { public VaultEntry(GoogleAuthInfo info) {
this(info.getOtpInfo(), info.getAccountName(), info.getIssuer()); this(info.getOtpInfo(), info.getAccountName(), info.getIssuer());
} }
@ -60,7 +60,7 @@ public class DatabaseEntry extends UUIDMap.Value {
return obj; return obj;
} }
public static DatabaseEntry fromJson(JSONObject obj) throws JSONException, OtpInfoException, Base64Exception { public static VaultEntry fromJson(JSONObject obj) throws JSONException, OtpInfoException, Base64Exception {
// if there is no uuid, generate a new one // if there is no uuid, generate a new one
UUID uuid; UUID uuid;
if (!obj.has("uuid")) { if (!obj.has("uuid")) {
@ -70,7 +70,7 @@ public class DatabaseEntry extends UUIDMap.Value {
} }
OtpInfo info = OtpInfo.fromJson(obj.getString("type"), obj.getJSONObject("info")); OtpInfo info = OtpInfo.fromJson(obj.getString("type"), obj.getJSONObject("info"));
DatabaseEntry entry = new DatabaseEntry(uuid, info); VaultEntry entry = new VaultEntry(uuid, info);
entry.setName(obj.getString("name")); entry.setName(obj.getString("name"));
entry.setIssuer(obj.getString("issuer")); entry.setIssuer(obj.getString("issuer"));
entry.setGroup(obj.optString("group", null)); entry.setGroup(obj.optString("group", null));
@ -129,11 +129,11 @@ public class DatabaseEntry extends UUIDMap.Value {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (!(o instanceof DatabaseEntry)) { if (!(o instanceof VaultEntry)) {
return false; return false;
} }
DatabaseEntry entry = (DatabaseEntry) o; VaultEntry entry = (VaultEntry) o;
return super.equals(entry) && equivalates(entry); return super.equals(entry) && equivalates(entry);
} }
@ -142,7 +142,7 @@ public class DatabaseEntry extends UUIDMap.Value {
* entries are ignored during the comparison, so they are not necessarily the same * entries are ignored during the comparison, so they are not necessarily the same
* instance. * instance.
*/ */
public boolean equivalates(DatabaseEntry entry) { public boolean equivalates(VaultEntry entry) {
return getName().equals(entry.getName()) return getName().equals(entry.getName())
&& getIssuer().equals(entry.getIssuer()) && getIssuer().equals(entry.getIssuer())
&& Objects.equals(getGroup(), entry.getGroup()) && Objects.equals(getGroup(), entry.getGroup())
@ -157,9 +157,9 @@ public class DatabaseEntry extends UUIDMap.Value {
return equivalates(getDefault()); return equivalates(getDefault());
} }
public static DatabaseEntry getDefault() { public static VaultEntry getDefault() {
try { try {
return new DatabaseEntry(new TotpInfo(null)); return new VaultEntry(new TotpInfo(null));
} catch (OtpInfoException e) { } catch (OtpInfoException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View file

@ -0,0 +1,11 @@
package com.beemdevelopment.aegis.vault;
public class VaultException extends Exception {
public VaultException(Throwable cause) {
super(cause);
}
public VaultException(String message) {
super(message);
}
}

View file

@ -1,10 +1,10 @@
package com.beemdevelopment.aegis.db; package com.beemdevelopment.aegis.vault;
import com.beemdevelopment.aegis.crypto.CryptParameters; import com.beemdevelopment.aegis.crypto.CryptParameters;
import com.beemdevelopment.aegis.crypto.CryptResult; import com.beemdevelopment.aegis.crypto.CryptResult;
import com.beemdevelopment.aegis.crypto.MasterKeyException; import com.beemdevelopment.aegis.crypto.MasterKeyException;
import com.beemdevelopment.aegis.db.slots.SlotList; import com.beemdevelopment.aegis.vault.slots.SlotList;
import com.beemdevelopment.aegis.db.slots.SlotListException; import com.beemdevelopment.aegis.vault.slots.SlotListException;
import com.beemdevelopment.aegis.encoding.Base64; import com.beemdevelopment.aegis.encoding.Base64;
import com.beemdevelopment.aegis.encoding.Base64Exception; import com.beemdevelopment.aegis.encoding.Base64Exception;
import com.beemdevelopment.aegis.encoding.HexException; import com.beemdevelopment.aegis.encoding.HexException;
@ -14,17 +14,17 @@ import org.json.JSONObject;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
public class DatabaseFile { public class VaultFile {
public static final byte VERSION = 1; public static final byte VERSION = 1;
private Object _content; private Object _content;
private Header _header; private Header _header;
public DatabaseFile() { public VaultFile() {
} }
private DatabaseFile(Object content, Header header) { private VaultFile(Object content, Header header) {
_content = content; _content = content;
_header = header; _header = header;
} }
@ -60,29 +60,29 @@ public class DatabaseFile {
} }
} }
public static DatabaseFile fromJson(JSONObject obj) throws DatabaseFileException { public static VaultFile fromJson(JSONObject obj) throws VaultFileException {
try { try {
if (obj.getInt("version") > VERSION) { if (obj.getInt("version") > VERSION) {
throw new DatabaseFileException("unsupported version"); throw new VaultFileException("unsupported version");
} }
Header header = Header.fromJson(obj.getJSONObject("header")); Header header = Header.fromJson(obj.getJSONObject("header"));
if (!header.isEmpty()) { if (!header.isEmpty()) {
return new DatabaseFile(obj.getString("db"), header); return new VaultFile(obj.getString("db"), header);
} }
return new DatabaseFile(obj.getJSONObject("db"), header); return new VaultFile(obj.getJSONObject("db"), header);
} catch (JSONException e) { } catch (JSONException e) {
throw new DatabaseFileException(e); throw new VaultFileException(e);
} }
} }
public static DatabaseFile fromBytes(byte[] data) throws DatabaseFileException { public static VaultFile fromBytes(byte[] data) throws VaultFileException {
try { try {
JSONObject obj = new JSONObject(new String(data, StandardCharsets.UTF_8)); JSONObject obj = new JSONObject(new String(data, StandardCharsets.UTF_8));
return DatabaseFile.fromJson(obj); return VaultFile.fromJson(obj);
} catch (JSONException e) { } catch (JSONException e) {
throw new DatabaseFileException(e); throw new VaultFileException(e);
} }
} }
@ -90,13 +90,13 @@ public class DatabaseFile {
return (JSONObject) _content; return (JSONObject) _content;
} }
public JSONObject getContent(DatabaseFileCredentials creds) throws DatabaseFileException { public JSONObject getContent(VaultFileCredentials creds) throws VaultFileException {
try { try {
byte[] bytes = Base64.decode((String) _content); byte[] bytes = Base64.decode((String) _content);
CryptResult result = creds.decrypt(bytes, _header.getParams()); CryptResult result = creds.decrypt(bytes, _header.getParams());
return new JSONObject(new String(result.getData(), StandardCharsets.UTF_8)); return new JSONObject(new String(result.getData(), StandardCharsets.UTF_8));
} catch (MasterKeyException | JSONException | Base64Exception e) { } catch (MasterKeyException | JSONException | Base64Exception e) {
throw new DatabaseFileException(e); throw new VaultFileException(e);
} }
} }
@ -105,16 +105,16 @@ public class DatabaseFile {
_header = new Header(null, null); _header = new Header(null, null);
} }
public void setContent(JSONObject obj, DatabaseFileCredentials creds) throws DatabaseFileException { public void setContent(JSONObject obj, VaultFileCredentials creds) throws VaultFileException {
try { try {
String string = obj.toString(4); String string = obj.toString(4);
byte[] dbBytes = string.getBytes(StandardCharsets.UTF_8); byte[] vaultBytes = string.getBytes(StandardCharsets.UTF_8);
CryptResult result = creds.encrypt(dbBytes); CryptResult result = creds.encrypt(vaultBytes);
_content = Base64.encode(result.getData()); _content = Base64.encode(result.getData());
_header = new Header(creds.getSlots(), result.getParams()); _header = new Header(creds.getSlots(), result.getParams());
} catch (MasterKeyException | JSONException e) { } catch (MasterKeyException | JSONException e) {
throw new DatabaseFileException(e); throw new VaultFileException(e);
} }
} }
@ -127,7 +127,7 @@ public class DatabaseFile {
_params = params; _params = params;
} }
public static Header fromJson(JSONObject obj) throws DatabaseFileException { public static Header fromJson(JSONObject obj) throws VaultFileException {
if (obj.isNull("slots") && obj.isNull("params")) { if (obj.isNull("slots") && obj.isNull("params")) {
return new Header(null, null); return new Header(null, null);
} }
@ -137,7 +137,7 @@ public class DatabaseFile {
CryptParameters params = CryptParameters.fromJson(obj.getJSONObject("params")); CryptParameters params = CryptParameters.fromJson(obj.getJSONObject("params"));
return new Header(slots, params); return new Header(slots, params);
} catch (SlotListException | JSONException | HexException e) { } catch (SlotListException | JSONException | HexException e) {
throw new DatabaseFileException(e); throw new VaultFileException(e);
} }
} }

View file

@ -1,23 +1,23 @@
package com.beemdevelopment.aegis.db; package com.beemdevelopment.aegis.vault;
import com.beemdevelopment.aegis.crypto.CryptParameters; import com.beemdevelopment.aegis.crypto.CryptParameters;
import com.beemdevelopment.aegis.crypto.CryptResult; import com.beemdevelopment.aegis.crypto.CryptResult;
import com.beemdevelopment.aegis.crypto.MasterKey; import com.beemdevelopment.aegis.crypto.MasterKey;
import com.beemdevelopment.aegis.crypto.MasterKeyException; import com.beemdevelopment.aegis.crypto.MasterKeyException;
import com.beemdevelopment.aegis.db.slots.SlotList; import com.beemdevelopment.aegis.vault.slots.SlotList;
import java.io.Serializable; import java.io.Serializable;
public class DatabaseFileCredentials implements Serializable { public class VaultFileCredentials implements Serializable {
private MasterKey _key; private MasterKey _key;
private SlotList _slots; private SlotList _slots;
public DatabaseFileCredentials() { public VaultFileCredentials() {
_key = MasterKey.generate(); _key = MasterKey.generate();
_slots = new SlotList(); _slots = new SlotList();
} }
public DatabaseFileCredentials(MasterKey key, SlotList slots) { public VaultFileCredentials(MasterKey key, SlotList slots) {
_key = key; _key = key;
_slots = slots; _slots = slots;
} }

View file

@ -0,0 +1,11 @@
package com.beemdevelopment.aegis.vault;
public class VaultFileException extends Exception {
public VaultFileException(Throwable cause) {
super(cause);
}
public VaultFileException(String message) {
super(message);
}
}

View file

@ -1,4 +1,4 @@
package com.beemdevelopment.aegis.db; package com.beemdevelopment.aegis.vault;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -18,21 +18,20 @@ import java.io.IOException;
import java.text.Collator; import java.text.Collator;
import java.util.Collection; import java.util.Collection;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.UUID;
public class DatabaseManager { public class VaultManager {
private static final String FILENAME = "aegis.json"; private static final String FILENAME = "aegis.json";
private static final String FILENAME_EXPORT = "aegis_export.json"; private static final String FILENAME_EXPORT = "aegis_export.json";
private static final String FILENAME_EXPORT_PLAIN = "aegis_export_plain.json"; private static final String FILENAME_EXPORT_PLAIN = "aegis_export_plain.json";
private Database _db; private Vault _vault;
private DatabaseFile _file; private VaultFile _file;
private DatabaseFileCredentials _creds; private VaultFileCredentials _creds;
private boolean _encrypt; private boolean _encrypt;
private Context _context; private Context _context;
public DatabaseManager(Context context) { public VaultManager(Context context) {
_context = context; _context = context;
} }
@ -41,7 +40,7 @@ public class DatabaseManager {
return file.exists() && file.isFile(); return file.exists() && file.isFile();
} }
public void load() throws DatabaseManagerException { public void load() throws VaultManagerException {
assertState(true, false); assertState(true, false);
try (FileInputStream file = _context.openFileInput(FILENAME)) { try (FileInputStream file = _context.openFileInput(FILENAME)) {
@ -50,70 +49,70 @@ public class DatabaseManager {
stream.readFully(fileBytes); stream.readFully(fileBytes);
stream.close(); stream.close();
_file = DatabaseFile.fromBytes(fileBytes); _file = VaultFile.fromBytes(fileBytes);
_encrypt = _file.isEncrypted(); _encrypt = _file.isEncrypted();
if (!isEncryptionEnabled()) { if (!isEncryptionEnabled()) {
JSONObject obj = _file.getContent(); JSONObject obj = _file.getContent();
_db = Database.fromJson(obj); _vault = Vault.fromJson(obj);
} }
} catch (IOException | DatabaseFileException | DatabaseException e) { } catch (IOException | VaultFileException | VaultException e) {
throw new DatabaseManagerException(e); throw new VaultManagerException(e);
} }
} }
public void lock() { public void lock() {
assertState(false, true); assertState(false, true);
_creds = null; _creds = null;
_db = null; _vault = null;
} }
public void unlock(DatabaseFileCredentials creds) throws DatabaseManagerException { public void unlock(VaultFileCredentials creds) throws VaultManagerException {
assertState(true, true); assertState(true, true);
try { try {
JSONObject obj = _file.getContent(creds); JSONObject obj = _file.getContent(creds);
_db = Database.fromJson(obj); _vault = Vault.fromJson(obj);
_creds = creds; _creds = creds;
_context.startService(new Intent(_context, NotificationService.class)); _context.startService(new Intent(_context, NotificationService.class));
} catch (DatabaseFileException | DatabaseException e) { } catch (VaultFileException | VaultException e) {
throw new DatabaseManagerException(e); throw new VaultManagerException(e);
} }
} }
public static void save(Context context, DatabaseFile file) throws DatabaseManagerException { public static void save(Context context, VaultFile file) throws VaultManagerException {
byte[] bytes = file.toBytes(); byte[] bytes = file.toBytes();
try (FileOutputStream stream = context.openFileOutput(FILENAME, Context.MODE_PRIVATE)) { try (FileOutputStream stream = context.openFileOutput(FILENAME, Context.MODE_PRIVATE)) {
stream.write(bytes); stream.write(bytes);
} catch (IOException e) { } catch (IOException e) {
throw new DatabaseManagerException(e); throw new VaultManagerException(e);
} }
} }
public void save() throws DatabaseManagerException { public void save() throws VaultManagerException {
assertState(false, true); assertState(false, true);
try { try {
JSONObject obj = _db.toJson(); JSONObject obj = _vault.toJson();
if (isEncryptionEnabled()) { if (isEncryptionEnabled()) {
_file.setContent(obj, _creds); _file.setContent(obj, _creds);
} else { } else {
_file.setContent(obj); _file.setContent(obj);
} }
save(_context, _file); save(_context, _file);
} catch (DatabaseFileException e) { } catch (VaultFileException e) {
throw new DatabaseManagerException(e); throw new VaultManagerException(e);
} }
} }
public String export(boolean encrypt) throws DatabaseManagerException { public String export(boolean encrypt) throws VaultManagerException {
assertState(false, true); assertState(false, true);
try { try {
DatabaseFile dbFile = new DatabaseFile(); VaultFile vaultFile = new VaultFile();
if (encrypt && isEncryptionEnabled()) { if (encrypt && isEncryptionEnabled()) {
dbFile.setContent(_db.toJson(), _creds); vaultFile.setContent(_vault.toJson(), _creds);
} else { } else {
dbFile.setContent(_db.toJson()); vaultFile.setContent(_vault.toJson());
} }
String dirName = !BuildConfig.DEBUG ? _context.getString(R.string.app_name) : _context.getString(R.string.app_name_dev); String dirName = !BuildConfig.DEBUG ? _context.getString(R.string.app_name) : _context.getString(R.string.app_name_dev);
@ -122,53 +121,53 @@ public class DatabaseManager {
throw new IOException("error creating external storage directory"); throw new IOException("error creating external storage directory");
} }
byte[] bytes = dbFile.toBytes(); byte[] bytes = vaultFile.toBytes();
File file = new File(dir.getAbsolutePath(), encrypt ? FILENAME_EXPORT : FILENAME_EXPORT_PLAIN); File file = new File(dir.getAbsolutePath(), encrypt ? FILENAME_EXPORT : FILENAME_EXPORT_PLAIN);
try (FileOutputStream stream = new FileOutputStream(file)) { try (FileOutputStream stream = new FileOutputStream(file)) {
stream.write(bytes); stream.write(bytes);
} }
return file.getAbsolutePath(); return file.getAbsolutePath();
} catch (IOException | DatabaseFileException e) { } catch (IOException | VaultFileException e) {
throw new DatabaseManagerException(e); throw new VaultManagerException(e);
} }
} }
public void addEntry(DatabaseEntry entry) { public void addEntry(VaultEntry entry) {
assertState(false, true); assertState(false, true);
_db.getEntries().add(entry); _vault.getEntries().add(entry);
} }
public DatabaseEntry removeEntry(DatabaseEntry entry) { public VaultEntry removeEntry(VaultEntry entry) {
assertState(false, true); assertState(false, true);
return _db.getEntries().remove(entry); return _vault.getEntries().remove(entry);
} }
public DatabaseEntry replaceEntry(DatabaseEntry entry) { public VaultEntry replaceEntry(VaultEntry entry) {
assertState(false, true); assertState(false, true);
return _db.getEntries().replace(entry); return _vault.getEntries().replace(entry);
} }
public void swapEntries(DatabaseEntry entry1, DatabaseEntry entry2) { public void swapEntries(VaultEntry entry1, VaultEntry entry2) {
assertState(false, true); assertState(false, true);
_db.getEntries().swap(entry1, entry2); _vault.getEntries().swap(entry1, entry2);
} }
public boolean isEntryDuplicate(DatabaseEntry entry) { public boolean isEntryDuplicate(VaultEntry entry) {
assertState(false, true); assertState(false, true);
return _db.getEntries().has(entry); return _vault.getEntries().has(entry);
} }
public Collection<DatabaseEntry> getEntries() { public Collection<VaultEntry> getEntries() {
assertState(false, true); assertState(false, true);
return _db.getEntries().getValues(); return _vault.getEntries().getValues();
} }
public TreeSet<String> getGroups() { public TreeSet<String> getGroups() {
assertState(false, true); assertState(false, true);
TreeSet<String> groups = new TreeSet<>(Collator.getInstance()); TreeSet<String> groups = new TreeSet<>(Collator.getInstance());
for (DatabaseEntry entry : getEntries()) { for (VaultEntry entry : getEntries()) {
String group = entry.getGroup(); String group = entry.getGroup();
if (group != null) { if (group != null) {
groups.add(group); groups.add(group);
@ -177,17 +176,17 @@ public class DatabaseManager {
return groups; return groups;
} }
public DatabaseFileCredentials getCredentials() { public VaultFileCredentials getCredentials() {
assertState(false, true); assertState(false, true);
return _creds; return _creds;
} }
public void setCredentials(DatabaseFileCredentials creds) { public void setCredentials(VaultFileCredentials creds) {
assertState(false, true); assertState(false, true);
_creds = creds; _creds = creds;
} }
public DatabaseFile.Header getFileHeader() { public VaultFile.Header getFileHeader() {
assertLoaded(true); assertLoaded(true);
return _file.getHeader(); return _file.getHeader();
} }
@ -197,14 +196,14 @@ public class DatabaseManager {
return _encrypt; return _encrypt;
} }
public void enableEncryption(DatabaseFileCredentials creds) throws DatabaseManagerException { public void enableEncryption(VaultFileCredentials creds) throws VaultManagerException {
assertState(false, true); assertState(false, true);
_creds = creds; _creds = creds;
_encrypt = true; _encrypt = true;
save(); save();
} }
public void disableEncryption() throws DatabaseManagerException { public void disableEncryption() throws VaultManagerException {
assertState(false, true); assertState(false, true);
_creds = null; _creds = null;
_encrypt = false; _encrypt = false;
@ -216,24 +215,24 @@ public class DatabaseManager {
} }
public boolean isLocked() { public boolean isLocked() {
return _db == null; return _vault == null;
} }
private void assertState(boolean locked, boolean loaded) { private void assertState(boolean locked, boolean loaded) {
assertLoaded(loaded); assertLoaded(loaded);
if (isLocked() && !locked) { if (isLocked() && !locked) {
throw new AssertionError("database file has not been unlocked yet"); throw new AssertionError("vault file has not been unlocked yet");
} else if (!isLocked() && locked) { } else if (!isLocked() && locked) {
throw new AssertionError("database file has already been unlocked"); throw new AssertionError("vault file has already been unlocked");
} }
} }
private void assertLoaded(boolean loaded) { private void assertLoaded(boolean loaded) {
if (isLoaded() && !loaded) { if (isLoaded() && !loaded) {
throw new AssertionError("database file has already been loaded"); throw new AssertionError("vault file has already been loaded");
} else if (!isLoaded() && loaded) { } else if (!isLoaded() && loaded) {
throw new AssertionError("database file has not been loaded yet"); throw new AssertionError("vault file has not been loaded yet");
} }
} }
} }

View file

@ -0,0 +1,7 @@
package com.beemdevelopment.aegis.vault;
public class VaultManagerException extends Exception {
public VaultManagerException(Throwable cause) {
super(cause);
}
}

View file

@ -1,4 +1,4 @@
package com.beemdevelopment.aegis.db.slots; package com.beemdevelopment.aegis.vault.slots;
import com.beemdevelopment.aegis.crypto.CryptParameters; import com.beemdevelopment.aegis.crypto.CryptParameters;

View file

@ -1,4 +1,4 @@
package com.beemdevelopment.aegis.db.slots; package com.beemdevelopment.aegis.vault.slots;
import com.beemdevelopment.aegis.crypto.CryptParameters; import com.beemdevelopment.aegis.crypto.CryptParameters;
import com.beemdevelopment.aegis.crypto.CryptoUtils; import com.beemdevelopment.aegis.crypto.CryptoUtils;

View file

@ -1,4 +1,4 @@
package com.beemdevelopment.aegis.db.slots; package com.beemdevelopment.aegis.vault.slots;
import com.beemdevelopment.aegis.crypto.CryptParameters; import com.beemdevelopment.aegis.crypto.CryptParameters;

View file

@ -1,4 +1,4 @@
package com.beemdevelopment.aegis.db.slots; package com.beemdevelopment.aegis.vault.slots;
import com.beemdevelopment.aegis.crypto.CryptParameters; import com.beemdevelopment.aegis.crypto.CryptParameters;
import com.beemdevelopment.aegis.crypto.CryptResult; import com.beemdevelopment.aegis.crypto.CryptResult;

View file

@ -1,4 +1,4 @@
package com.beemdevelopment.aegis.db.slots; package com.beemdevelopment.aegis.vault.slots;
public class SlotException extends Exception { public class SlotException extends Exception {
public SlotException(Throwable cause) { public SlotException(Throwable cause) {

View file

@ -1,4 +1,4 @@
package com.beemdevelopment.aegis.db.slots; package com.beemdevelopment.aegis.vault.slots;
public class SlotIntegrityException extends Exception { public class SlotIntegrityException extends Exception {
public SlotIntegrityException() { public SlotIntegrityException() {

View file

@ -1,4 +1,4 @@
package com.beemdevelopment.aegis.db.slots; package com.beemdevelopment.aegis.vault.slots;
import com.beemdevelopment.aegis.util.UUIDMap; import com.beemdevelopment.aegis.util.UUIDMap;

View file

@ -1,4 +1,4 @@
package com.beemdevelopment.aegis.db.slots; package com.beemdevelopment.aegis.vault.slots;
public class SlotListException extends Exception { public class SlotListException extends Exception {
public SlotListException(Throwable cause) { public SlotListException(Throwable cause) {

View file

@ -109,8 +109,8 @@
<string name="imported_entries_count">Importierte %d Einträge</string> <string name="imported_entries_count">Importierte %d Einträge</string>
<string name="read_entries_count">%d Einträge gelesen. %d Fehler.</string> <string name="read_entries_count">%d Einträge gelesen. %d Fehler.</string>
<string name="import_error_title">Beim Import sind ein oder mehrere Fehler aufgetreten.</string> <string name="import_error_title">Beim Import sind ein oder mehrere Fehler aufgetreten.</string>
<string name="exporting_database_error">Beim Versuch, die Datenbank zu exportieren, ist ein Fehler aufgetreten.</string> <string name="exporting_vault_error">Beim Versuch, die Datenbank zu exportieren, ist ein Fehler aufgetreten.</string>
<string name="export_database_location">Die Datenbank wurde exportiert nach:</string> <string name="export_vault_location">Die Datenbank wurde exportiert nach:</string>
<string name="export_warning">Diese Aktion exportiert die Datenbank aus dem privaten Speicher von Aegis.</string> <string name="export_warning">Diese Aktion exportiert die Datenbank aus dem privaten Speicher von Aegis.</string>
<string name="encryption_set_password_error">Beim Versuch, das Passwort festzulegen, ist ein Fehler aufgetreten: </string> <string name="encryption_set_password_error">Beim Versuch, das Passwort festzulegen, ist ein Fehler aufgetreten: </string>
<string name="no_cameras_available">Keine Kameras verfügbar</string> <string name="no_cameras_available">Keine Kameras verfügbar</string>

View file

@ -112,8 +112,8 @@
<string name="imported_entries_count">%d entrées importées</string> <string name="imported_entries_count">%d entrées importées</string>
<string name="read_entries_count">%d entrées lues. %d erreurs.</string> <string name="read_entries_count">%d entrées lues. %d erreurs.</string>
<string name="import_error_title">Une ou plusieurs erreurs sont survenues lors de l\'importation</string> <string name="import_error_title">Une ou plusieurs erreurs sont survenues lors de l\'importation</string>
<string name="exporting_database_error">Une erreur est survenue en essayant d\'exporter la base de données</string> <string name="exporting_vault_error">Une erreur est survenue en essayant d\'exporter la base de données</string>
<string name="export_database_location">La base de données a été exportée vers :</string> <string name="export_vault_location">La base de données a été exportée vers :</string>
<string name="export_warning">Cette action va exporter la base de données en dehors du stockage privé d\'Aegis.</string> <string name="export_warning">Cette action va exporter la base de données en dehors du stockage privé d\'Aegis.</string>
<string name="encryption_set_password_error">Une erreur est survenue en essayant de définir le mot de passe : </string> <string name="encryption_set_password_error">Une erreur est survenue en essayant de définir le mot de passe : </string>
<string name="no_cameras_available">Aucun appareil photo disponible</string> <string name="no_cameras_available">Aucun appareil photo disponible</string>

View file

@ -102,8 +102,8 @@
<string name="root_error">Fout: Er kon geen root-access verkregen worden</string> <string name="root_error">Fout: Er kon geen root-access verkregen worden</string>
<string name="imported_entries_count">%d items geïmporteerd</string> <string name="imported_entries_count">%d items geïmporteerd</string>
<string name="import_error_title">Er zijn fouten opgetreden tijdens het importeren</string> <string name="import_error_title">Er zijn fouten opgetreden tijdens het importeren</string>
<string name="exporting_database_error">Er is een fout opgetreden tijdens het exporteren van de database</string> <string name="exporting_vault_error">Er is een fout opgetreden tijdens het exporteren van de database</string>
<string name="export_database_location">De database is geëxporteerd naar:</string> <string name="export_vault_location">De database is geëxporteerd naar:</string>
<string name="export_warning">Deze actie zal de database uit de privé-opslag van Aegis exporteren.</string> <string name="export_warning">Deze actie zal de database uit de privé-opslag van Aegis exporteren.</string>
<string name="encryption_set_password_error">Er is een fout opgetreden tijdens het instellen van het wachtwoord: </string> <string name="encryption_set_password_error">Er is een fout opgetreden tijdens het instellen van het wachtwoord: </string>
<string name="no_cameras_available">Geen camera\'s beschikbaar</string> <string name="no_cameras_available">Geen camera\'s beschikbaar</string>

View file

@ -107,8 +107,8 @@
<string name="imported_entries_count">Импортировано %d записей</string> <string name="imported_entries_count">Импортировано %d записей</string>
<string name="read_entries_count">Прочитано %d записей. %d ошибок.</string> <string name="read_entries_count">Прочитано %d записей. %d ошибок.</string>
<string name="import_error_title">При импорте произошла одна или несколько ошибок</string> <string name="import_error_title">При импорте произошла одна или несколько ошибок</string>
<string name="exporting_database_error">Произошла ошибка при попытке экспорта базы данных</string> <string name="exporting_vault_error">Произошла ошибка при попытке экспорта базы данных</string>
<string name="export_database_location">База данных была экспортирована в:</string> <string name="export_vault_location">База данных была экспортирована в:</string>
<string name="export_warning">Это действие экспортирует базу данных из приватного хранилища Aegis.</string> <string name="export_warning">Это действие экспортирует базу данных из приватного хранилища Aegis.</string>
<string name="encryption_set_password_error">Произошла ошибка при попытке установить пароль:</string> <string name="encryption_set_password_error">Произошла ошибка при попытке установить пароль:</string>
<string name="no_cameras_available">Нет доступных камер</string> <string name="no_cameras_available">Нет доступных камер</string>

View file

@ -109,8 +109,8 @@
<string name="imported_entries_count">导入 %d 项条目</string> <string name="imported_entries_count">导入 %d 项条目</string>
<string name="read_entries_count">读取 %!d 项条目。 %!d 项错误。</string> <string name="read_entries_count">读取 %!d 项条目。 %!d 项错误。</string>
<string name="import_error_title">导入时发生一个或多个错误</string> <string name="import_error_title">导入时发生一个或多个错误</string>
<string name="exporting_database_error">试图导出数据库时出错</string> <string name="exporting_vault_error">试图导出数据库时出错</string>
<string name="export_database_location">数据库已经导出至:</string> <string name="export_vault_location">数据库已经导出至:</string>
<string name="export_warning">此操作将导出 Aegis 专用存储的数据库。</string> <string name="export_warning">此操作将导出 Aegis 专用存储的数据库。</string>
<string name="encryption_set_password_error">试图设置密码时出错:</string> <string name="encryption_set_password_error">试图设置密码时出错:</string>
<string name="no_cameras_available">未找到可用的相机</string> <string name="no_cameras_available">未找到可用的相机</string>

View file

@ -23,15 +23,15 @@
<string name="pref_account_name_title">Show the account name</string> <string name="pref_account_name_title">Show the account name</string>
<string name="pref_account_name_summary">Enable this to show the account name next to the issuer</string> <string name="pref_account_name_summary">Enable this to show the account name next to the issuer</string>
<string name="pref_timeout_title">Timeout</string> <string name="pref_timeout_title">Timeout</string>
<string name="pref_timeout_summary">Automatically lock the database after %1$s seconds of inactivity</string> <string name="pref_timeout_summary">Automatically lock the vault after %1$s seconds of inactivity</string>
<string name="pref_slots_title">Key slots</string> <string name="pref_slots_title">Key slots</string>
<string name="pref_slots_summary">Manage the list of keys that can decrypt the database</string> <string name="pref_slots_summary">Manage the list of keys that can decrypt the vault</string>
<string name="pref_import_file_title">Import from file</string> <string name="pref_import_file_title">Import from file</string>
<string name="pref_import_file_summary">Import a database from a file</string> <string name="pref_import_file_summary">Import tokens from a file</string>
<string name="pref_import_app_title">Import from app</string> <string name="pref_import_app_title">Import from app</string>
<string name="pref_import_app_summary">Import a database from an app (requires root access)</string> <string name="pref_import_app_summary">Import tokens from an app (requires root access)</string>
<string name="pref_export_title">Export</string> <string name="pref_export_title">Export</string>
<string name="pref_export_summary">Export the database</string> <string name="pref_export_summary">Export the vault</string>
<string name="pref_secure_screen_title">Screen security</string> <string name="pref_secure_screen_title">Screen security</string>
<string name="pref_secure_screen_summary">Block screenshots and other attempts to capture the screen within the app</string> <string name="pref_secure_screen_summary">Block screenshots and other attempts to capture the screen within the app</string>
<string name="pref_tap_to_reveal_title">Tap to reveal</string> <string name="pref_tap_to_reveal_title">Tap to reveal</string>
@ -40,7 +40,7 @@
<string name="pref_auto_lock_title">Auto lock</string> <string name="pref_auto_lock_title">Auto lock</string>
<string name="pref_auto_lock_summary">Automatically lock when you close the app or lock your device.</string> <string name="pref_auto_lock_summary">Automatically lock when you close the app or lock your device.</string>
<string name="pref_encryption_title">Encryption</string> <string name="pref_encryption_title">Encryption</string>
<string name="pref_encryption_summary">Encrypt the database and unlock it with a password or biometrics</string> <string name="pref_encryption_summary">Encrypt the vault and unlock it with a password or biometrics</string>
<string name="pref_biometrics_title">Biometric unlock</string> <string name="pref_biometrics_title">Biometric unlock</string>
<string name="pref_biometrics_summary">Allow biometric authentication to unlock the vault</string> <string name="pref_biometrics_summary">Allow biometric authentication to unlock the vault</string>
<string name="pref_set_password_title">Change password</string> <string name="pref_set_password_title">Change password</string>
@ -115,7 +115,7 @@
<string name="andotp_new_format">New format (v0.6.3 or newer) </string> <string name="andotp_new_format">New format (v0.6.3 or newer) </string>
<string name="andotp_old_format">Old format (v0.6.2 or older) </string> <string name="andotp_old_format">Old format (v0.6.2 or older) </string>
<string name="choose_andotp_importer">Which format does the andOTP backup file have?</string> <string name="choose_andotp_importer">Which format does the andOTP backup file have?</string>
<string name="choose_application">Select the application you\'d like to import a database from</string> <string name="choose_application">Select the application you\'d like to import from</string>
<string name="choose_theme">Select your desired theme</string> <string name="choose_theme">Select your desired theme</string>
<string name="choose_view_mode">Select your desired view mode</string> <string name="choose_view_mode">Select your desired view mode</string>
<string name="parsing_file_error">An error occurred while trying to parse the file</string> <string name="parsing_file_error">An error occurred while trying to parse the file</string>
@ -126,9 +126,9 @@
<string name="imported_entries_count">Imported %d entries</string> <string name="imported_entries_count">Imported %d entries</string>
<string name="read_entries_count">Read %d entries. %d errors.</string> <string name="read_entries_count">Read %d entries. %d errors.</string>
<string name="import_error_title">One or more errors occurred during the import</string> <string name="import_error_title">One or more errors occurred during the import</string>
<string name="exporting_database_error">An error occurred while trying to export the database</string> <string name="exporting_vault_error">An error occurred while trying to export the vault</string>
<string name="export_database_location">The database has been exported to:</string> <string name="export_vault_location">The vault has been exported to:</string>
<string name="export_warning">This action will export the database out of Aegis\' private storage.</string> <string name="export_warning">This action will export the vault out of Aegis\' private storage.</string>
<string name="encryption_set_password_error">An error occurred while trying to set the password: </string> <string name="encryption_set_password_error">An error occurred while trying to set the password: </string>
<string name="encryption_enable_biometrics_error">An error occurred while trying to enable biometric unlock</string> <string name="encryption_enable_biometrics_error">An error occurred while trying to enable biometric unlock</string>
<string name="no_cameras_available">No cameras available</string> <string name="no_cameras_available">No cameras available</string>

View file

@ -86,7 +86,7 @@
android:summary="@string/pref_timeout_summary" android:summary="@string/pref_timeout_summary"
android:inputType="number" android:inputType="number"
android:defaultValue="30" android:defaultValue="30"
android:dialogTitle="Set number of seconds of inactivity before Aegis locks the database" android:dialogTitle="Set number of seconds of inactivity before Aegis locks the vault"
app:iconSpaceReserved="false"/>--> app:iconSpaceReserved="false"/>-->
<com.beemdevelopment.aegis.ui.preferences.SwitchPreference <com.beemdevelopment.aegis.ui.preferences.SwitchPreference
android:key="pref_encryption" android:key="pref_encryption"