From 5d84bd838744f63d46d5a08110bad13b5192ae6a Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Wed, 10 Jan 2024 17:02:03 +0100 Subject: [PATCH] Update AGP to 7.4.2, update SqlDelight to 1.4.2 The adaptations to SqlDelight 1.4.2 leave the type namings *extremely* messy. But it works and is as semantically equivalent as I could make it. --- .gitignore | 5 +- OpenKeychain/build.gradle | 9 +- .../keychain/KeychainDatabase.java | 414 ++++-------------- .../keychain/daos/AbstractDao.java | 41 +- .../keychain/daos/ApiAppDao.java | 109 ++--- .../keychain/daos/AutocryptPeerDao.java | 108 ++--- .../keychain/daos/CertificationDao.java | 15 +- .../daos/DatabaseBatchInteractor.java | 103 ++--- .../keychain/daos/KeyMetadataDao.java | 38 +- .../keychain/daos/KeyRepository.java | 144 +++--- .../keychain/daos/KeyWritableRepository.java | 65 ++- .../keychain/daos/OverriddenWarningsDao.java | 20 +- .../keychain/daos/UserIdDao.java | 51 ++- .../keychain/livedata/ApiAppsLiveData.java | 12 +- .../keychain/model/ApiAllowedKey.java | 11 - .../keychain/model/ApiApp.java | 33 -- .../keychain/model/AutocryptPeer.java | 57 --- .../keychain/model/Certification.java | 39 -- .../keychain/model/CustomColumnAdapters.java | 6 +- .../keychain/model/GossipOrigin.java | 5 + .../keychain/model/KeyMetadata.java | 24 - .../keychain/model/KeyRingPublic.java | 27 -- .../keychain/model/KeySignature.java | 27 -- .../keychain/model/OverriddenWarning.java | 14 - .../keychain/model/SubKey.java | 116 ----- .../keychain/model/UnifiedKeyInfo.java | 108 +++++ .../keychain/model/UserId.java | 49 +++ .../keychain/model/UserPacket.java | 67 --- .../keychain/operations/BackupOperation.java | 2 +- .../keychain/operations/RevokeOperation.java | 2 +- .../pgp/OpenPgpSignatureResultBuilder.java | 2 +- .../keychain/remote/AutocryptInteractor.java | 70 +-- .../remote/KeychainExternalProvider.java | 97 ++-- .../keychain/remote/OpenPgpService.java | 2 +- .../remote/SshAuthenticationService.java | 2 +- .../remote/ui/AppSettingsActivity.java | 18 +- .../AppSettingsAllowedKeysListFragment.java | 2 +- .../remote/ui/RemoteRegisterPresenter.java | 6 +- .../ui/RequestKeyPermissionPresenter.java | 2 +- .../remote/ui/SelectPublicKeyFragment.java | 2 +- .../ui/SelectSignKeyIdListFragment.java | 16 +- .../ui/dialog/DialogKeyChoiceAdapter.java | 2 +- .../ui/dialog/RemoteDeduplicateActivity.java | 2 +- .../ui/dialog/RemoteDeduplicatePresenter.java | 2 +- ...RemoteSelectAuthenticationKeyActivity.java | 22 +- ...emoteSelectAuthenticationKeyPresenter.java | 2 +- .../ui/dialog/RemoteSelectIdKeyActivity.java | 2 +- .../RemoteSelectIdentityKeyPresenter.java | 12 +- .../keychain/ui/BackupRestoreFragment.java | 18 +- .../ui/CertifyFingerprintFragment.java | 2 +- .../keychain/ui/CertifyKeyFragment.java | 2 +- .../keychain/ui/CreateKeyFinalFragment.java | 16 +- .../keychain/ui/DecryptFragment.java | 2 +- .../keychain/ui/DeleteKeyDialogActivity.java | 2 +- .../ui/EncryptModeAsymmetricFragment.java | 6 +- .../keychain/ui/KeyListFragment.java | 4 +- .../keychain/ui/MultiUserIdsFragment.java | 16 +- .../keychain/ui/PassphraseDialogActivity.java | 2 +- .../keychain/ui/QrCodeViewActivity.java | 2 +- .../keychain/ui/SubKeyItem.java | 32 +- .../keychain/ui/ViewKeyAdvActivity.java | 11 +- .../keychain/ui/ViewKeyAdvShareFragment.java | 2 +- .../ui/ViewKeyAdvSubkeysFragment.java | 46 +- .../ui/ViewKeyAdvUserIdsFragment.java | 16 +- .../ui/adapter/FlexibleKeyDetailsItem.java | 2 +- .../ui/adapter/FlexibleKeyItemFactory.java | 2 +- .../ui/adapter/ImportKeysAdapter.java | 5 +- .../keychain/ui/adapter/KeyChoiceAdapter.java | 2 +- .../keychain/ui/adapter/UserIdsAdapter.java | 2 +- .../ui/chips/EncryptRecipientChipAdapter.java | 4 +- .../ui/chips/EncryptRecipientChipsInput.java | 2 +- .../ui/keyview/KeyFragmentViewModel.java | 12 +- .../ui/keyview/UnifiedKeyInfoViewModel.java | 8 +- .../keychain/ui/keyview/ViewKeyActivity.java | 2 +- .../keychain/ui/keyview/ViewKeyFragment.java | 12 +- .../ui/keyview/loader/IdentityDao.java | 108 +++-- .../ui/keyview/loader/SubkeyStatusDao.java | 30 +- .../keychain/ui/util/KeyInfoFormatter.java | 5 +- .../keychain/ui/widget/CertListWidget.java | 86 ---- .../ui/widget/KeyChoiceSpinnerAdapter.java | 2 +- .../keychain/ui/widget/KeySpinner.java | 2 +- .../keychain/util/ShareKeyHelper.java | 2 +- .../src/main/res/layout/cert_list_widget.xml | 44 -- .../keychain/ApiAllowedKeys.sq | 2 +- .../keychain/AutocryptPeers.sq | 22 +- .../org/sufficientlysecure/keychain/Certs.sq | 4 +- .../keychain/KeyMetadata.sq | 2 +- .../keychain/KeyRingsPublic.sq | 4 +- .../keychain/KeySignatures.sq | 2 +- .../org/sufficientlysecure/keychain/Keys.sq | 18 +- .../keychain/UserPackets.sq | 3 +- .../org/sufficientlysecure/keychain/Util.sq | 2 + .../operations/PromoteKeyOperationTest.java | 2 +- .../keychain/pgp/PgpEncryptDecryptTest.java | 7 +- .../provider/KeyRepositorySaveTest.java | 3 +- .../remote/KeychainExternalProviderTest.java | 12 +- build.gradle | 10 +- extern/bouncycastle | 2 +- extern/openpgp-api-lib | 2 +- gradle.properties | 2 +- gradle/wrapper/gradle-wrapper.jar | Bin 59203 -> 59536 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 269 +++++++----- sshauthentication-api/build.gradle | 18 +- 104 files changed, 1141 insertions(+), 1742 deletions(-) delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/ApiAllowedKey.java delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/ApiApp.java delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/AutocryptPeer.java delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/Certification.java create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/GossipOrigin.java delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/KeyMetadata.java delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/KeyRingPublic.java delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/KeySignature.java delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/OverriddenWarning.java delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/SubKey.java create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/UnifiedKeyInfo.java create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/UserId.java delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/UserPacket.java delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/CertListWidget.java delete mode 100644 OpenKeychain/src/main/res/layout/cert_list_widget.xml create mode 100644 OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/Util.sq diff --git a/.gitignore b/.gitignore index 67e423d92..7892cb1c0 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,7 @@ fastlane/screenshots fastlane/test_output # omit for now: -fastlane/Appfile \ No newline at end of file +fastlane/Appfile + +OpenKeychain/release +OpenKeychain/google diff --git a/OpenKeychain/build.gradle b/OpenKeychain/build.gradle index c1d073ab2..634ac801e 100644 --- a/OpenKeychain/build.gradle +++ b/OpenKeychain/build.gradle @@ -1,5 +1,8 @@ -apply plugin: 'com.android.application' -apply plugin: 'com.squareup.sqldelight' +plugins { + id 'com.android.application' + id 'kotlin-android' + id 'com.squareup.sqldelight' +} dependencies { // from local Android SDK @@ -20,6 +23,7 @@ dependencies { implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.14.9' implementation 'org.apache.james:apache-mime4j-core:0.8.1' implementation 'org.apache.james:apache-mime4j-dom:0.8.1' + implementation "com.squareup.sqldelight:android-driver:1.5.4" // UI implementation 'org.sufficientlysecure:html-textview:3.1' @@ -86,6 +90,7 @@ dependencies { android { compileSdkVersion rootProject.ext.compileSdkVersion + namespace 'org.sufficientlysecure.keychain' defaultConfig { minSdkVersion 15 diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainDatabase.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainDatabase.java index 160005f79..2574ae90d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainDatabase.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/KeychainDatabase.java @@ -23,17 +23,15 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import android.content.Context; + import androidx.sqlite.db.SupportSQLiteDatabase; import androidx.sqlite.db.SupportSQLiteOpenHelper; import androidx.sqlite.db.SupportSQLiteOpenHelper.Callback; import androidx.sqlite.db.SupportSQLiteOpenHelper.Configuration; import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory; -import android.content.Context; -import android.database.Cursor; -import android.database.SQLException; -import android.database.sqlite.SQLiteException; - -import org.sufficientlysecure.keychain.daos.LocalSecretKeyStorage; +import com.squareup.sqldelight.android.AndroidSqliteDriver; +import org.sufficientlysecure.keychain.model.CustomColumnAdapters; import org.sufficientlysecure.keychain.util.Preferences; import timber.log.Timber; @@ -41,15 +39,18 @@ import timber.log.Timber; /** * SQLite Datatypes (from http://www.sqlite.org/datatype3.html) * - NULL. The value is a NULL value. - * - INTEGER. The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value. + * - INTEGER. The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the + * magnitude of the value. * - REAL. The value is a floating point value, stored as an 8-byte IEEE floating point number. - * - TEXT. The value is a text string, stored using the database encoding (UTF-8, UTF-16BE or UTF-16LE). + * - TEXT. The value is a text string, stored using the database encoding (UTF-8, UTF-16BE or + * UTF-16LE). * - BLOB. The value is a blob of data, stored exactly as it was input. */ public class KeychainDatabase { private static final String DATABASE_NAME = "openkeychain.db"; - private static final int DATABASE_VERSION = 34; + private static final int DATABASE_VERSION = 35; private final SupportSQLiteOpenHelper supportSQLiteOpenHelper; + private final Database sqldelightDatabase; private static KeychainDatabase sInstance; @@ -71,12 +72,15 @@ public class KeychainDatabase { } @Override - public void onUpgrade(SupportSQLiteDatabase db, int oldVersion, int newVersion) { - KeychainDatabase.this.onUpgrade(db, context, oldVersion, newVersion); + public void onUpgrade(SupportSQLiteDatabase db, int oldVersion, + int newVersion) { + KeychainDatabase.this.onUpgrade(db, context, oldVersion, + newVersion); } @Override - public void onDowngrade(SupportSQLiteDatabase db, int oldVersion, int newVersion) { + public void onDowngrade(SupportSQLiteDatabase db, + int oldVersion, int newVersion) { KeychainDatabase.this.onDowngrade(); } @@ -86,12 +90,19 @@ public class KeychainDatabase { if (!db.isReadOnly()) { // Enable foreign key constraints db.execSQL("PRAGMA foreign_keys=ON;"); - if (Constants.DEBUG) { - recreateUnifiedKeyView(db); - } } } }).build()); + AndroidSqliteDriver driver = new AndroidSqliteDriver(supportSQLiteOpenHelper); + sqldelightDatabase = Database.Companion.invoke(driver, + new Autocrypt_peers.Adapter(CustomColumnAdapters.DATE_ADAPTER, + CustomColumnAdapters.DATE_ADAPTER, + CustomColumnAdapters.DATE_ADAPTER, + CustomColumnAdapters.GOSSIP_ORIGIN_ADAPTER), + new Certs.Adapter(CustomColumnAdapters.VERIFICATON_STATUS_ADAPTER), + new Key_metadata.Adapter(CustomColumnAdapters.DATE_ADAPTER), + new Keys.Adapter(CustomColumnAdapters.SECRET_KEY_TYPE_ADAPTER) + ); } public SupportSQLiteDatabase getReadableDatabase() { @@ -102,328 +113,85 @@ public class KeychainDatabase { return supportSQLiteOpenHelper.getWritableDatabase(); } + public Database getSqlDelightDatabase() { + return sqldelightDatabase; + } + @SuppressWarnings("deprecation") // using some sqldelight constants private void onCreate(SupportSQLiteDatabase db, Context context) { Timber.w("Creating database..."); - db.execSQL(KeyRingsPublicModel.CREATE_TABLE); - db.execSQL(KeysModel.CREATE_TABLE); - db.execSQL(UserPacketsModel.CREATE_TABLE); - db.execSQL(CertsModel.CREATE_TABLE); - db.execSQL(KeyMetadataModel.CREATE_TABLE); - db.execSQL(KeySignaturesModel.CREATE_TABLE); - db.execSQL(ApiAppsModel.CREATE_TABLE); - db.execSQL(OverriddenWarningsModel.CREATE_TABLE); - db.execSQL(AutocryptPeersModel.CREATE_TABLE); - db.execSQL(ApiAllowedKeysModel.CREATE_TABLE); - db.execSQL(KeysModel.UNIFIEDKEYVIEW); - db.execSQL(KeysModel.VALIDKEYSVIEW); - db.execSQL(KeysModel.VALIDMASTERKEYSVIEW); - db.execSQL(UserPacketsModel.UIDSTATUS); + AndroidSqliteDriver sqlDriver = new AndroidSqliteDriver(db); + Database.Companion.getSchema().create(sqlDriver); + recreateDatabaseViews(db); - db.execSQL("CREATE INDEX keys_by_rank ON keys (" + KeysModel.RANK + ", " + KeysModel.MASTER_KEY_ID + ");"); - db.execSQL("CREATE INDEX uids_by_rank ON user_packets (" + UserPacketsModel.RANK + ", " - + UserPacketsModel.USER_ID + ", " + UserPacketsModel.MASTER_KEY_ID + ");"); - db.execSQL("CREATE INDEX verified_certs ON certs (" - + CertsModel.VERIFIED + ", " + CertsModel.MASTER_KEY_ID + ");"); - db.execSQL("CREATE INDEX uids_by_email ON user_packets (" - + UserPacketsModel.EMAIL + ");"); + db.execSQL("CREATE INDEX keys_by_rank ON keys (rank, master_key_id);"); + db.execSQL("CREATE INDEX uids_by_rank ON user_packets (rank, user_id, master_key_id);"); + db.execSQL("CREATE INDEX verified_certs ON certs (verified, master_key_id);"); + db.execSQL("CREATE INDEX uids_by_email ON user_packets (email);"); Preferences.getPreferences(context).setKeySignaturesTableInitialized(); } - private void onUpgrade(SupportSQLiteDatabase db, Context context, int oldVersion, int newVersion) { + private void onUpgrade(SupportSQLiteDatabase db, Context context, int oldVersion, + int newVersion) { Timber.d("Upgrading db from " + oldVersion + " to " + newVersion); - + if (oldVersion < 34) { + throw new IllegalStateException("upgrades from older versions not supported"); + } switch (oldVersion) { - case 1: - // add has_secret for all who are upgrading from a beta version - try { - db.execSQL("ALTER TABLE keys ADD COLUMN has_secret INTEGER"); - } catch (Exception e) { - // never mind, the column probably already existed - } - // fall through - case 2: - // ECC support - try { - db.execSQL("ALTER TABLE keys ADD COLUMN key_curve_oid TEXT"); - } catch (Exception e) { - // never mind, the column probably already existed - } - // fall through - case 3: - // better s2k detection, we need consolidate - // fall through - case 4: - try { - db.execSQL("ALTER TABLE keys ADD COLUMN can_authenticate INTEGER"); - } catch (Exception e) { - // never mind, the column probably already existed - } - // fall through - case 5: - // do consolidate for 3.0 beta3 - // fall through - case 6: - db.execSQL("ALTER TABLE user_ids ADD COLUMN type INTEGER"); - db.execSQL("ALTER TABLE user_ids ADD COLUMN attribute_data BLOB"); - case 7: - // new table for allowed key ids in API - try { - db.execSQL(ApiAppsModel.CREATE_TABLE); - } catch (Exception e) { - // never mind, the column probably already existed - } - case 8: - // tbale name for user_ids changed to user_packets - db.execSQL("DROP TABLE IF EXISTS certs"); - db.execSQL("DROP TABLE IF EXISTS user_ids"); - db.execSQL("CREATE TABLE IF NOT EXISTS user_packets(" - + "master_key_id INTEGER, " - + "type INT, " - + "user_id TEXT, " - + "attribute_data BLOB, " - - + "is_primary INTEGER, " - + "is_revoked INTEGER, " - + "rank INTEGER, " - - + "PRIMARY KEY(master_key_id, rank), " - + "FOREIGN KEY(master_key_id) REFERENCES " - + "keyrings_public(master_key_id) ON DELETE CASCADE" - + ")"); - db.execSQL("CREATE TABLE IF NOT EXISTS certs(" - + "master_key_id INTEGER," - + "rank INTEGER, " // rank of certified uid - - + "key_id_certifier INTEGER, " // certifying key - + "type INTEGER, " - + "verified INTEGER, " - + "creation INTEGER, " - - + "data BLOB, " - - + "PRIMARY KEY(master_key_id, rank, " - + "key_id_certifier), " - + "FOREIGN KEY(master_key_id) REFERENCES " - + "keyrings_public(master_key_id) ON DELETE CASCADE," - + "FOREIGN KEY(master_key_id, rank) REFERENCES " - + "user_packets(master_key_id, rank) ON DELETE CASCADE" - + ")"); - case 9: - // do nothing here, just consolidate - case 10: - // fix problems in database, see #1402 for details - // https://github.com/open-keychain/open-keychain/issues/1402 - // no longer needed, api_accounts is deprecated - // db.execSQL("DELETE FROM api_accounts WHERE key_id BETWEEN 0 AND 3"); - case 11: - db.execSQL("CREATE TABLE IF NOT EXISTS updated_keys (" - + "master_key_id INTEGER PRIMARY KEY, " - + "last_updated INTEGER, " - + "FOREIGN KEY(master_key_id) REFERENCES " - + "keyrings_public(master_key_id) ON DELETE CASCADE" - + ")"); - case 12: - // do nothing here, just consolidate - case 13: - db.execSQL("CREATE INDEX keys_by_rank ON keys (rank);"); - db.execSQL("CREATE INDEX uids_by_rank ON user_packets (rank, user_id, master_key_id);"); - db.execSQL("CREATE INDEX verified_certs ON certs (verified, master_key_id);"); - case 14: - db.execSQL("ALTER TABLE user_packets ADD COLUMN name TEXT"); - db.execSQL("ALTER TABLE user_packets ADD COLUMN email TEXT"); - db.execSQL("ALTER TABLE user_packets ADD COLUMN comment TEXT"); - case 15: - db.execSQL("CREATE INDEX uids_by_name ON user_packets (name COLLATE NOCASE)"); - db.execSQL("CREATE INDEX uids_by_email ON user_packets (email COLLATE NOCASE)"); - case 16: - // splitUserId changed: Execute consolidate for new parsing of name, email - case 17: - // splitUserId changed: Execute consolidate for new parsing of name, email - case 18: - db.execSQL("ALTER TABLE keys ADD COLUMN is_secure INTEGER"); - case 19: - // emergency fix for crashing consolidate - db.execSQL("UPDATE keys SET is_secure = 1;"); - case 20: - db.execSQL( - "CREATE TABLE IF NOT EXISTS overridden_warnings (" - + "_id INTEGER PRIMARY KEY AUTOINCREMENT, " - + "identifier TEXT NOT NULL UNIQUE " - + ")"); - - case 21: - try { - db.execSQL("ALTER TABLE updated_keys ADD COLUMN seen_on_keyservers INTEGER;"); - } catch (SQLiteException e) { - // don't bother, the column probably already existed - } - - case 22: - db.execSQL("CREATE TABLE IF NOT EXISTS api_autocrypt_peers (" - + "package_name TEXT NOT NULL, " - + "identifier TEXT NOT NULL, " - + "last_updated INTEGER NOT NULL, " - + "last_seen_key INTEGER NOT NULL, " - + "state INTEGER NOT NULL, " - + "master_key_id INTEGER, " - + "PRIMARY KEY(package_name, identifier), " - + "FOREIGN KEY(package_name) REFERENCES api_apps(package_name) ON DELETE CASCADE" - + ")"); - - case 23: - db.execSQL("CREATE TABLE IF NOT EXISTS key_signatures (" - + "master_key_id INTEGER NOT NULL, " - + "signer_key_id INTEGER NOT NULL, " - + "PRIMARY KEY(master_key_id, signer_key_id), " - + "FOREIGN KEY(master_key_id) REFERENCES keyrings_public(master_key_id) ON DELETE CASCADE" - + ")"); - - case 24: { - db.execSQL("ALTER TABLE api_autocrypt_peers RENAME TO tmp"); - db.execSQL("CREATE TABLE api_autocrypt_peers (" - + "package_name TEXT NOT NULL, " - + "identifier TEXT NOT NULL, " - + "last_seen INTEGER, " - + "last_seen_key INTEGER, " - + "is_mutual INTEGER, " - + "master_key_id INTEGER, " - + "gossip_master_key_id INTEGER, " - + "gossip_last_seen_key INTEGER, " - + "gossip_origin INTEGER, " - + "PRIMARY KEY(package_name, identifier), " - + "FOREIGN KEY(package_name) REFERENCES api_apps (package_name) ON DELETE CASCADE" - + ")"); - // Note: Keys from Autocrypt 0.X with state == "reset" (0) are dropped - db.execSQL("INSERT INTO api_autocrypt_peers " + - "(package_name, identifier, last_seen, gossip_last_seen_key, gossip_master_key_id, gossip_origin) " + - "SELECT package_name, identifier, last_updated, last_seen_key, master_key_id, 0 " + - "FROM tmp WHERE state = 1"); // Autocrypt 0.X, "gossip" -> now origin=autocrypt - db.execSQL("INSERT INTO api_autocrypt_peers " + - "(package_name, identifier, last_seen, gossip_last_seen_key, gossip_master_key_id, gossip_origin) " + - "SELECT package_name, identifier, last_updated, last_seen_key, master_key_id, 20 " + - "FROM tmp WHERE state = 2"); // "selected" keys -> now origin=dedup - db.execSQL("INSERT INTO api_autocrypt_peers " + - "(package_name, identifier, last_seen, last_seen_key, master_key_id, is_mutual) " + - "SELECT package_name, identifier, last_updated, last_seen_key, master_key_id, 0 " + - "FROM tmp WHERE state = 3"); // Autocrypt 0.X, state = "available" - db.execSQL("INSERT INTO api_autocrypt_peers " + - "(package_name, identifier, last_seen, last_seen_key, master_key_id, is_mutual) " + - "SELECT package_name, identifier, last_updated, last_seen_key, master_key_id, 1 " + - "FROM tmp WHERE state = 4"); // from Autocrypt 0.X, state = "mutual" - db.execSQL("DROP TABLE tmp"); - - db.execSQL("CREATE INDEX IF NOT EXISTS uids_by_email ON user_packets (email);"); - db.execSQL("DROP INDEX keys_by_rank"); - db.execSQL("CREATE INDEX keys_by_rank ON keys(rank, master_key_id);"); - } - - case 25: { - try { - migrateSecretKeysFromDbToLocalStorage(db, context); - } catch (IOException e) { - throw new IllegalStateException("Error migrating secret keys! This is bad!!"); - } - } - - case 26: - migrateUpdatedKeysToKeyMetadataTable(db); - - case 27: - renameApiAutocryptPeersTable(db); - - case 28: - // drop old table from version 20 - db.execSQL("DROP TABLE IF EXISTS api_accounts"); - - case 29: - recreateUnifiedKeyView(db); - - case 30: - // ignore. this case only came up in an unreleased beta. - - case 31: - addSubkeyValidFromField(db); - - case 32: - recreateUnifiedKeyView(db); - - case 33: - dropKeyMetadataForeignKey(db); + case 34: + // nothing } + // recreate the unified key view on any upgrade + recreateDatabaseViews(db); } - private void addSubkeyValidFromField(SupportSQLiteDatabase db) { - try { - db.execSQL("ALTER TABLE keys ADD COLUMN validFrom INTEGER NOT NULL DEFAULT 0;"); - db.execSQL("UPDATE keys SET validFrom = creation"); - } catch (SQLiteException e) { - // column probably already existed, nvm this - } - } + private static void recreateDatabaseViews(SupportSQLiteDatabase db) { + // for some reason those aren't created as part of the schema. so we do it here. + db.execSQL("DROP VIEW IF EXISTS unifiedKeyView"); + db.execSQL( + """ + CREATE VIEW unifiedKeyView AS + SELECT keys.master_key_id, keys.fingerprint, MIN(user_packets.rank), user_packets.user_id, user_packets.name, user_packets.email, user_packets.comment, keys.creation, keys.expiry, keys.is_revoked, keys.is_secure, keys.can_certify, certs.verified, + (EXISTS (SELECT * FROM user_packets AS dups WHERE dups.master_key_id != keys.master_key_id AND dups.rank = 0 AND dups.name = user_packets.name COLLATE NOCASE AND dups.email = user_packets.email COLLATE NOCASE )) AS has_duplicate, + (EXISTS (SELECT * FROM keys AS k WHERE k.master_key_id = keys.master_key_id AND k.has_secret != 0)) AS has_any_secret, + (EXISTS (SELECT * FROM keys AS k WHERE k.master_key_id = keys.master_key_id AND k.can_encrypt != 0)) AS has_encrypt_key, + (EXISTS (SELECT * FROM keys AS k WHERE k.master_key_id = keys.master_key_id AND k.can_sign != 0)) AS has_sign_key, + (EXISTS (SELECT * FROM keys AS k WHERE k.master_key_id = keys.master_key_id AND k.can_authenticate != 0)) AS has_auth_key, + GROUP_CONCAT(DISTINCT aTI.package_name) AS autocrypt_package_names_csv, + GROUP_CONCAT(user_packets.user_id, '|||') AS user_id_list + FROM keys + INNER JOIN user_packets ON ( keys.master_key_id = user_packets.master_key_id AND user_packets.type IS NULL AND (user_packets.rank = 0 OR user_packets.is_revoked = 0)) + LEFT JOIN certs ON ( keys.master_key_id = certs.master_key_id AND certs.verified = 1 ) + LEFT JOIN autocrypt_peers AS aTI ON ( aTI.master_key_id = keys.master_key_id ) + WHERE keys.rank = 0 + GROUP BY keys.master_key_id;"""); + db.execSQL("DROP VIEW IF EXISTS validKeys"); + db.execSQL(""" + CREATE VIEW validKeys AS + SELECT master_key_id, rank, key_id, key_size, key_curve_oid, algorithm, fingerprint, can_certify, can_sign, can_encrypt, can_authenticate, is_revoked, has_secret, is_secure, creation, expiry + FROM keys + WHERE is_revoked = 0 AND is_secure = 1 AND (expiry IS NULL OR expiry >= strftime('%s', 'now')) AND validFrom <= strftime('%s', 'now'); + """); + db.execSQL("DROP VIEW IF EXISTS uidStatus"); + db.execSQL(""" + CREATE VIEW uidStatus AS + SELECT user_packets.email, MIN(certs.verified) AS key_status_int, user_packets.user_id, user_packets.master_key_id, COUNT(DISTINCT user_packets.master_key_id) AS candidates + FROM user_packets + JOIN validMasterKeys USING (master_key_id) + LEFT JOIN certs ON (certs.master_key_id = user_packets.master_key_id AND certs.rank = user_packets.rank AND certs.verified > 0) + WHERE user_packets.email IS NOT NULL + GROUP BY user_packets.email; + """); + db.execSQL("DROP VIEW IF EXISTS validMasterKeys"); + db.execSQL(""" + CREATE VIEW validMasterKeys AS + SELECT * + FROM validKeys + WHERE rank = 0; + """); - private void recreateUnifiedKeyView(SupportSQLiteDatabase db) { - // noinspection deprecation - db.execSQL("DROP VIEW IF EXISTS " + KeysModel.UNIFIEDKEYVIEW_VIEW_NAME); - db.execSQL(KeysModel.UNIFIEDKEYVIEW); - // noinspection deprecation - db.execSQL("DROP VIEW IF EXISTS " + KeysModel.VALIDKEYS_VIEW_NAME); - db.execSQL(KeysModel.VALIDKEYSVIEW); - // noinspection deprecation - db.execSQL("DROP VIEW IF EXISTS " + KeysModel.VALIDMASTERKEYS_VIEW_NAME); - db.execSQL(KeysModel.VALIDMASTERKEYSVIEW); - // noinspection deprecation - db.execSQL("DROP VIEW IF EXISTS " + UserPacketsModel.UIDSTATUS_VIEW_NAME); - db.execSQL(UserPacketsModel.UIDSTATUS); - } - - private void dropKeyMetadataForeignKey(SupportSQLiteDatabase db) { - // noinspection deprecation - db.execSQL("ALTER TABLE " + KeyMetadataModel.TABLE_NAME + " RENAME TO metadata_tmp"); - db.execSQL(KeyMetadataModel.CREATE_TABLE); - // noinspection deprecation - db.execSQL("INSERT INTO " + KeyMetadataModel.TABLE_NAME + " SELECT * FROM metadata_tmp"); - db.execSQL("DROP TABLE metadata_tmp"); - } - - private void migrateSecretKeysFromDbToLocalStorage(SupportSQLiteDatabase db, Context context) throws IOException { - LocalSecretKeyStorage localSecretKeyStorage = LocalSecretKeyStorage.getInstance(context); - Cursor cursor = db.query("SELECT master_key_id, key_ring_data FROM keyrings_secret"); - while (cursor.moveToNext()) { - long masterKeyId = cursor.getLong(0); - byte[] secretKeyBlob = cursor.getBlob(1); - localSecretKeyStorage.writeSecretKey(masterKeyId, secretKeyBlob); - } - cursor.close(); - - // we'll keep this around for now, but make sure to delete when migration looks ok!! - // db.execSQL("DROP TABLE keyrings_secret"); - } - - private void migrateUpdatedKeysToKeyMetadataTable(SupportSQLiteDatabase db) { - try { - db.execSQL("ALTER TABLE updated_keys RENAME TO key_metadata;"); - } catch (SQLException e) { - if (Constants.DEBUG) { - Timber.e(e, "Ignoring migration exception, this probably happened before"); - return; - } - throw e; - } - } - - private void renameApiAutocryptPeersTable(SupportSQLiteDatabase db) { - try { - db.execSQL("ALTER TABLE api_autocrypt_peers RENAME TO autocrypt_peers;"); - } catch (SQLException e) { - if (Constants.DEBUG) { - Timber.e(e, "Ignoring migration exception, this probably happened before"); - return; - } - throw e; - } } private void onDowngrade() { @@ -468,7 +236,7 @@ public class KeychainDatabase { out.createNewFile(); } if (!in.canRead()) { - throw new IOException("Cannot read " + in.getName()); + throw new IOException("Cannot read " + in.getName()); } if (!out.canWrite()) { throw new IOException("Cannot write " + out.getName()); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/AbstractDao.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/AbstractDao.java index f123c9160..3caa0cb73 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/AbstractDao.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/AbstractDao.java @@ -1,16 +1,9 @@ package org.sufficientlysecure.keychain.daos; -import java.util.ArrayList; -import java.util.List; - import androidx.sqlite.db.SupportSQLiteDatabase; -import androidx.sqlite.db.SupportSQLiteQuery; -import android.database.Cursor; - -import com.squareup.sqldelight.RowMapper; +import org.sufficientlysecure.keychain.Database; import org.sufficientlysecure.keychain.KeychainDatabase; -import org.sufficientlysecure.keychain.daos.KeyRepository.NotFoundException; class AbstractDao { @@ -22,8 +15,8 @@ class AbstractDao { this.databaseNotifyManager = databaseNotifyManager; } - SupportSQLiteDatabase getReadableDb() { - return db.getReadableDatabase(); + Database getDatabase() { + return db.getSqlDelightDatabase(); } SupportSQLiteDatabase getWritableDb() { @@ -33,32 +26,4 @@ class AbstractDao { DatabaseNotifyManager getDatabaseNotifyManager() { return databaseNotifyManager; } - - List mapAllRows(SupportSQLiteQuery query, RowMapper mapper) { - ArrayList result = new ArrayList<>(); - try (Cursor cursor = getReadableDb().query(query)) { - while (cursor.moveToNext()) { - T item = mapper.map(cursor); - result.add(item); - } - } - return result; - } - - T mapSingleRowOrThrow(SupportSQLiteQuery query, RowMapper mapper) throws NotFoundException { - T result = mapSingleRow(query, mapper); - if (result == null) { - throw new NotFoundException(); - } - return result; - } - - T mapSingleRow(SupportSQLiteQuery query, RowMapper mapper) { - try (Cursor cursor = getReadableDb().query(query)) { - if (cursor.moveToNext()) { - return mapper.map(cursor); - } - } - return null; - } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/ApiAppDao.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/ApiAppDao.java index 9346f559e..3c4384d9b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/ApiAppDao.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/ApiAppDao.java @@ -18,26 +18,25 @@ package org.sufficientlysecure.keychain.daos; -import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; import android.content.Context; -import android.database.Cursor; -import com.squareup.sqldelight.SqlDelightQuery; -import org.sufficientlysecure.keychain.ApiAllowedKeysModel.InsertAllowedKey; -import org.sufficientlysecure.keychain.ApiAppsModel; -import org.sufficientlysecure.keychain.ApiAppsModel.DeleteByPackageName; -import org.sufficientlysecure.keychain.ApiAppsModel.InsertApiApp; +import org.sufficientlysecure.keychain.ApiAllowedKeysQueries; +import org.sufficientlysecure.keychain.ApiAppsQueries; +import org.sufficientlysecure.keychain.Api_apps; +import org.sufficientlysecure.keychain.GetCertificate; import org.sufficientlysecure.keychain.KeychainDatabase; -import org.sufficientlysecure.keychain.model.ApiAllowedKey; -import org.sufficientlysecure.keychain.model.ApiApp; public class ApiAppDao extends AbstractDao { + private final ApiAppsQueries apiAppsQueries = getDatabase().getApiAppsQueries(); + private final ApiAllowedKeysQueries apiAllowedKeysQueries = + getDatabase().getApiAllowedKeysQueries(); + public static ApiAppDao getInstance(Context context) { KeychainDatabase keychainDatabase = KeychainDatabase.getInstance(context); DatabaseNotifyManager databaseNotifyManager = DatabaseNotifyManager.create(context); @@ -45,95 +44,75 @@ public class ApiAppDao extends AbstractDao { return new ApiAppDao(keychainDatabase, databaseNotifyManager); } - private ApiAppDao(KeychainDatabase keychainDatabase, DatabaseNotifyManager databaseNotifyManager) { + private ApiAppDao(KeychainDatabase keychainDatabase, + DatabaseNotifyManager databaseNotifyManager) { super(keychainDatabase, databaseNotifyManager); } - public ApiApp getApiApp(String packageName) { - try (Cursor cursor = getReadableDb().query(ApiApp.FACTORY.selectByPackageName(packageName))) { - if (cursor.moveToFirst()) { - return ApiApp.FACTORY.selectByPackageNameMapper().map(cursor); - } - return null; - } + public Api_apps getApiApp(String packageName) { + return apiAppsQueries.selectByPackageName(packageName).executeAsOneOrNull(); } public byte[] getApiAppCertificate(String packageName) { - try (Cursor cursor = getReadableDb().query(ApiApp.FACTORY.getCertificate(packageName))) { - if (cursor.moveToFirst()) { - return ApiApp.FACTORY.getCertificateMapper().map(cursor); - } + GetCertificate getCertificate = + apiAppsQueries.getCertificate(packageName).executeAsOneOrNull(); + if (getCertificate == null) { return null; } + return getCertificate.getPackage_signature(); } - public void insertApiApp(ApiApp apiApp) { - ApiApp existingApiApp = getApiApp(apiApp.package_name()); + public void insertApiApp(String packageName, byte[] signature) { + Api_apps existingApiApp = getApiApp(packageName); if (existingApiApp != null) { - if (!Arrays.equals(existingApiApp.package_signature(), apiApp.package_signature())) { - throw new IllegalStateException("Inserting existing api with different signature?!"); + if (!Arrays.equals(existingApiApp.getPackage_signature(), + signature)) { + throw new IllegalStateException( + "Inserting existing api with different signature?!"); } return; } - InsertApiApp statement = new ApiAppsModel.InsertApiApp(getWritableDb()); - statement.bind(apiApp.package_name(), apiApp.package_signature()); - statement.executeInsert(); + apiAppsQueries.insertApiApp(packageName, signature); + getDatabaseNotifyManager().notifyApiAppChange(packageName); + } - getDatabaseNotifyManager().notifyApiAppChange(apiApp.package_name()); + public void insertApiApp(Api_apps apiApp) { + Api_apps existingApiApp = getApiApp(apiApp.getPackage_name()); + if (existingApiApp != null) { + if (!Arrays.equals(existingApiApp.getPackage_signature(), + apiApp.getPackage_signature())) { + throw new IllegalStateException( + "Inserting existing api with different signature?!"); + } + return; + } + apiAppsQueries.insertApiApp(apiApp.getPackage_name(), apiApp.getPackage_signature()); + getDatabaseNotifyManager().notifyApiAppChange(apiApp.getPackage_name()); } public void deleteApiApp(String packageName) { - DeleteByPackageName deleteByPackageName = new DeleteByPackageName(getWritableDb()); - deleteByPackageName.bind(packageName); - deleteByPackageName.executeUpdateDelete(); - + apiAppsQueries.deleteByPackageName(packageName); getDatabaseNotifyManager().notifyApiAppChange(packageName); } public HashSet getAllowedKeyIdsForApp(String packageName) { - SqlDelightQuery allowedKeys = ApiAllowedKey.FACTORY.getAllowedKeys(packageName); - HashSet keyIds = new HashSet<>(); - try (Cursor cursor = getReadableDb().query(allowedKeys)) { - while (cursor.moveToNext()) { - long allowedKeyId = ApiAllowedKey.FACTORY.getAllowedKeysMapper().map(cursor); - keyIds.add(allowedKeyId); - } - } - return keyIds; + return new HashSet<>(apiAllowedKeysQueries.getAllowedKeys(packageName).executeAsList()); } public void saveAllowedKeyIdsForApp(String packageName, Set allowedKeyIds) { - ApiAllowedKey.DeleteByPackageName deleteByPackageName = new ApiAllowedKey.DeleteByPackageName(getWritableDb()); - deleteByPackageName.bind(packageName); - deleteByPackageName.executeUpdateDelete(); - - InsertAllowedKey statement = new InsertAllowedKey(getWritableDb()); + apiAllowedKeysQueries.deleteByPackageName(packageName); for (Long keyId : allowedKeyIds) { - statement.bind(packageName, keyId); - statement.execute(); + apiAllowedKeysQueries.insertAllowedKey(packageName, keyId); } - getDatabaseNotifyManager().notifyApiAppChange(packageName); } public void addAllowedKeyIdForApp(String packageName, long allowedKeyId) { - InsertAllowedKey statement = new InsertAllowedKey(getWritableDb()); - statement.bind(packageName, allowedKeyId); - statement.executeInsert(); - + apiAllowedKeysQueries.insertAllowedKey(packageName, allowedKeyId); getDatabaseNotifyManager().notifyApiAppChange(packageName); } - public List getAllApiApps() { - SqlDelightQuery query = ApiApp.FACTORY.selectAll(); - - ArrayList result = new ArrayList<>(); - try (Cursor cursor = getReadableDb().query(query)) { - while (cursor.moveToNext()) { - ApiApp apiApp = ApiApp.FACTORY.selectAllMapper().map(cursor); - result.add(apiApp); - } - } - return result; + public List getAllApiApps() { + return apiAppsQueries.selectAll().executeAsList(); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/AutocryptPeerDao.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/AutocryptPeerDao.java index 2d4a05e67..4e6e57391 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/AutocryptPeerDao.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/AutocryptPeerDao.java @@ -18,28 +18,26 @@ package org.sufficientlysecure.keychain.daos; -import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.Date; import java.util.List; import android.content.Context; -import android.database.Cursor; -import androidx.annotation.Nullable; -import com.squareup.sqldelight.SqlDelightQuery; -import org.sufficientlysecure.keychain.AutocryptPeersModel.DeleteByIdentifier; -import org.sufficientlysecure.keychain.AutocryptPeersModel.DeleteByMasterKeyId; -import org.sufficientlysecure.keychain.AutocryptPeersModel.InsertPeer; -import org.sufficientlysecure.keychain.AutocryptPeersModel.UpdateGossipKey; -import org.sufficientlysecure.keychain.AutocryptPeersModel.UpdateKey; -import org.sufficientlysecure.keychain.AutocryptPeersModel.UpdateLastSeen; +import androidx.annotation.Nullable; +import org.sufficientlysecure.keychain.AutocryptPeersQueries; +import org.sufficientlysecure.keychain.Autocrypt_peers; import org.sufficientlysecure.keychain.KeychainDatabase; -import org.sufficientlysecure.keychain.model.AutocryptPeer; -import org.sufficientlysecure.keychain.model.AutocryptPeer.AutocryptKeyStatus; -import org.sufficientlysecure.keychain.model.AutocryptPeer.GossipOrigin; +import org.sufficientlysecure.keychain.SelectAutocryptKeyStatus; +import org.sufficientlysecure.keychain.SelectMasterKeyIdByIdentifier; +import org.sufficientlysecure.keychain.model.GossipOrigin; public class AutocryptPeerDao extends AbstractDao { + private final AutocryptPeersQueries autocryptPeersQueries = + getDatabase().getAutocryptPeersQueries(); + public static AutocryptPeerDao getInstance(Context context) { KeychainDatabase keychainDatabase = KeychainDatabase.getInstance(context); DatabaseNotifyManager databaseNotifyManager = DatabaseNotifyManager.create(context); @@ -47,100 +45,78 @@ public class AutocryptPeerDao extends AbstractDao { return new AutocryptPeerDao(keychainDatabase, databaseNotifyManager); } - private AutocryptPeerDao(KeychainDatabase database, DatabaseNotifyManager databaseNotifyManager) { + private AutocryptPeerDao(KeychainDatabase database, + DatabaseNotifyManager databaseNotifyManager) { super(database, databaseNotifyManager); } public Long getMasterKeyIdForAutocryptPeer(String autocryptId) { - SqlDelightQuery query = AutocryptPeer.FACTORY.selectMasterKeyIdByIdentifier(autocryptId); - try (Cursor cursor = getReadableDb().query(query)) { - if (cursor.moveToFirst()) { - return AutocryptPeer.FACTORY.selectMasterKeyIdByIdentifierMapper().map(cursor); - } + SelectMasterKeyIdByIdentifier masterKeyId = + autocryptPeersQueries.selectMasterKeyIdByIdentifier(autocryptId) + .executeAsOneOrNull(); + if (masterKeyId != null) { + return masterKeyId.getMaster_key_id(); } return null; } @Nullable - public AutocryptPeer getAutocryptPeer(String packageName, String autocryptId) { - List autocryptPeers = getAutocryptPeers(packageName, autocryptId); - if (!autocryptPeers.isEmpty()) { - return autocryptPeers.get(0); - } - return null; + public Autocrypt_peers getAutocryptPeer(String packageName, String autocryptId) { + return autocryptPeersQueries.selectByIdentifiers(packageName, + Collections.singleton(autocryptId)).executeAsOneOrNull(); } - private List getAutocryptPeers(String packageName, String... autocryptId) { - SqlDelightQuery query = AutocryptPeer.FACTORY.selectByIdentifiers(packageName, autocryptId); - return mapAllRows(query, AutocryptPeer.PEER_MAPPER); + private List getAutocryptPeers(String packageName, String... autocryptId) { + return autocryptPeersQueries.selectByIdentifiers(packageName, Arrays.asList(autocryptId)) + .executeAsList(); } - public List getAutocryptKeyStatus(String packageName, String[] autocryptIds) { - SqlDelightQuery query = AutocryptPeer.FACTORY.selectAutocryptKeyStatus(packageName, autocryptIds); - return mapAllRows(query, AutocryptPeer.KEY_STATUS_MAPPER); + public List getAutocryptKeyStatus(String packageName, + String[] autocryptIds) { + return autocryptPeersQueries.selectAutocryptKeyStatus(packageName, + Arrays.asList(autocryptIds)).executeAsList(); } private void ensureAutocryptPeerExists(String packageName, String autocryptId) { - InsertPeer insertStatement = new InsertPeer(getWritableDb()); - insertStatement.bind(packageName, autocryptId); - insertStatement.executeInsert(); + autocryptPeersQueries.insertPeer(packageName, autocryptId); } public void insertOrUpdateLastSeen(String packageName, String autocryptId, Date date) { ensureAutocryptPeerExists(packageName, autocryptId); - - UpdateLastSeen updateStatement = new UpdateLastSeen(getWritableDb(), AutocryptPeer.FACTORY); - updateStatement.bind(packageName, autocryptId, date); - updateStatement.executeUpdateDelete(); + autocryptPeersQueries.updateLastSeen(packageName, autocryptId, date); } - public void updateKey(String packageName, String autocryptId, Date effectiveDate, long masterKeyId, + public void updateKey(String packageName, String autocryptId, Date effectiveDate, + long masterKeyId, boolean isMutual) { ensureAutocryptPeerExists(packageName, autocryptId); - - UpdateKey updateStatement = new UpdateKey(getWritableDb(), AutocryptPeer.FACTORY); - updateStatement.bind(packageName, autocryptId, effectiveDate, masterKeyId, isMutual); - updateStatement.executeUpdateDelete(); - + autocryptPeersQueries.updateKey(packageName, autocryptId, effectiveDate, masterKeyId, + isMutual); getDatabaseNotifyManager().notifyAutocryptUpdate(autocryptId, masterKeyId); } - public void updateKeyGossip(String packageName, String autocryptId, Date effectiveDate, long masterKeyId, + public void updateKeyGossip(String packageName, String autocryptId, Date effectiveDate, + long masterKeyId, GossipOrigin origin) { ensureAutocryptPeerExists(packageName, autocryptId); - - UpdateGossipKey updateStatement = new UpdateGossipKey(getWritableDb(), AutocryptPeer.FACTORY); - updateStatement.bind(packageName, autocryptId, effectiveDate, masterKeyId, origin); - updateStatement.executeUpdateDelete(); - + autocryptPeersQueries.updateGossipKey(packageName, autocryptId, effectiveDate, masterKeyId, + origin); getDatabaseNotifyManager().notifyAutocryptUpdate(autocryptId, masterKeyId); } - public List getAutocryptPeersForKey(long masterKeyId) { - ArrayList result = new ArrayList<>(); - SqlDelightQuery query = AutocryptPeer.FACTORY.selectByMasterKeyId(masterKeyId); - try (Cursor cursor = getReadableDb().query(query)) { - if (cursor.moveToNext()) { - AutocryptPeer autocryptPeer = AutocryptPeer.PEER_MAPPER.map(cursor); - result.add(autocryptPeer); - } - } - return result; + public List getAutocryptPeersForKey(long masterKeyId) { + return autocryptPeersQueries.selectByMasterKeyId(masterKeyId).executeAsList(); } public void deleteByIdentifier(String packageName, String autocryptId) { Long masterKeyId = getMasterKeyIdForAutocryptPeer(autocryptId); - DeleteByIdentifier deleteStatement = new DeleteByIdentifier(getReadableDb()); - deleteStatement.bind(packageName, autocryptId); - deleteStatement.execute(); + autocryptPeersQueries.deleteByIdentifier(packageName, autocryptId); if (masterKeyId != null) { getDatabaseNotifyManager().notifyAutocryptDelete(autocryptId, masterKeyId); } } public void deleteByMasterKeyId(long masterKeyId) { - DeleteByMasterKeyId deleteStatement = new DeleteByMasterKeyId(getReadableDb()); - deleteStatement.bind(masterKeyId); - deleteStatement.execute(); + autocryptPeersQueries.deleteByMasterKeyId(masterKeyId); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/CertificationDao.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/CertificationDao.java index 8343a55f8..e345b6503 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/CertificationDao.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/CertificationDao.java @@ -2,12 +2,9 @@ package org.sufficientlysecure.keychain.daos; import android.content.Context; -import android.database.Cursor; -import com.squareup.sqldelight.SqlDelightQuery; import org.sufficientlysecure.keychain.KeychainDatabase; -import org.sufficientlysecure.keychain.model.Certification; -import org.sufficientlysecure.keychain.model.Certification.CertDetails; +import org.sufficientlysecure.keychain.SelectVerifyingCertDetails; public class CertificationDao extends AbstractDao { @@ -22,14 +19,8 @@ public class CertificationDao extends AbstractDao { super(keychainDatabase, databaseNotifyManager); } - public CertDetails getVerifyingCertDetails(long masterKeyId, int userPacketRank) { - SqlDelightQuery query = Certification.FACTORY.selectVerifyingCertDetails(masterKeyId, userPacketRank); - try (Cursor cursor = getReadableDb().query(query)) { - if (cursor.moveToFirst()) { - return Certification.CERT_DETAILS_MAPPER.map(cursor); - } - } - return null; + public SelectVerifyingCertDetails getVerifyingCertDetails(long masterKeyId, int userPacketRank) { + return getDatabase().getCertsQueries().selectVerifyingCertDetails(masterKeyId, userPacketRank).executeAsOneOrNull(); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/DatabaseBatchInteractor.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/DatabaseBatchInteractor.java index 788f77d14..490146e56 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/DatabaseBatchInteractor.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/DatabaseBatchInteractor.java @@ -3,95 +3,76 @@ package org.sufficientlysecure.keychain.daos; import java.util.List; -import androidx.sqlite.db.SupportSQLiteDatabase; - -import org.sufficientlysecure.keychain.CertsModel.InsertCert; -import org.sufficientlysecure.keychain.KeyRingsPublicModel.InsertKeyRingPublic; -import org.sufficientlysecure.keychain.KeySignaturesModel.InsertKeySignature; -import org.sufficientlysecure.keychain.KeysModel.InsertKey; -import org.sufficientlysecure.keychain.UserPacketsModel.InsertUserPacket; -import org.sufficientlysecure.keychain.model.Certification; -import org.sufficientlysecure.keychain.model.KeyRingPublic; -import org.sufficientlysecure.keychain.model.KeySignature; -import org.sufficientlysecure.keychain.model.SubKey; -import org.sufficientlysecure.keychain.model.UserPacket; +import com.squareup.sqldelight.TransactionWithoutReturn; +import kotlin.Unit; +import kotlin.jvm.functions.Function1; +import org.sufficientlysecure.keychain.Certs; +import org.sufficientlysecure.keychain.Database; +import org.sufficientlysecure.keychain.Key_signatures; +import org.sufficientlysecure.keychain.Keyrings_public; +import org.sufficientlysecure.keychain.Keys; +import org.sufficientlysecure.keychain.User_packets; public class DatabaseBatchInteractor { - private final SupportSQLiteDatabase db; + private final Database db; - private final InsertKeyRingPublic insertKeyRingPublicStatement; - private final InsertKey insertSubKeyStatement; - private final InsertUserPacket insertUserPacketStatement; - private final InsertCert insertCertificationStatement; - private final InsertKeySignature insertKeySignerStatement; - - DatabaseBatchInteractor(SupportSQLiteDatabase db) { + DatabaseBatchInteractor(Database db) { this.db = db; - insertKeyRingPublicStatement = KeyRingPublic.createInsertStatement(db); - insertSubKeyStatement = SubKey.createInsertStatement(db); - insertUserPacketStatement = UserPacket.createInsertStatement(db); - insertCertificationStatement = Certification.createInsertStatement(db); - insertKeySignerStatement = KeySignature.createInsertStatement(db); - } - - public SupportSQLiteDatabase getDb() { - return db; } public void applyBatch(List operations) { - for (BatchOp op : operations) { - if (op.keyRingPublic != null) { - op.keyRingPublic.bindTo(insertKeyRingPublicStatement); - insertKeyRingPublicStatement.executeInsert(); - } else if (op.subKey != null) { - op.subKey.bindTo(insertSubKeyStatement); - insertSubKeyStatement.executeInsert(); - } else if (op.userPacket != null) { - op.userPacket.bindTo(insertUserPacketStatement); - insertUserPacketStatement.executeInsert(); - } else if (op.certification != null) { - op.certification.bindTo(insertCertificationStatement); - insertCertificationStatement.executeInsert(); - } else if (op.keySignature != null) { - op.keySignature.bindTo(insertKeySignerStatement); - insertKeySignerStatement.executeInsert(); - } else { - throw new IllegalStateException(); - } - } + db.transaction(true, + (Function1) transactionWithoutReturn -> { + for (BatchOp op : operations) { + if (op.keyRingPublic != null) { + db.getKeyRingsPublicQueries().insertKeyRingPublic(op.keyRingPublic); + } else if (op.subKey != null) { + db.getKeysQueries().insertKey(op.subKey); + } else if (op.userPacket != null) { + db.getUserPacketsQueries().insertUserPacket(op.userPacket); + } else if (op.certification != null) { + db.getCertsQueries().insertCert(op.certification); + } else if (op.keySignature != null) { + db.getKeySignaturesQueries().insertKeySignature(op.keySignature); + } else { + throw new IllegalStateException(); + } + } + return Unit.INSTANCE; + }); } - public static BatchOp createInsertKeyRingPublic(KeyRingPublic keyRingPublic) { + public static BatchOp createInsertKeyRingPublic(Keyrings_public keyRingPublic) { return new BatchOp(keyRingPublic, null, null, null, null); } - static BatchOp createInsertSubKey(SubKey subKey) { + static BatchOp createInsertSubKey(Keys subKey) { return new BatchOp(null, subKey, null, null, null); } - public static BatchOp createInsertUserPacket(UserPacket userPacket) { + public static BatchOp createInsertUserPacket(User_packets userPacket) { return new BatchOp(null, null, userPacket, null, null); } - public static BatchOp createInsertCertification(Certification certification) { + public static BatchOp createInsertCertification(Certs certification) { return new BatchOp(null, null, null, certification, null); } - static BatchOp createInsertSignerKey(KeySignature keySignature) { + static BatchOp createInsertSignerKey(Key_signatures keySignature) { return new BatchOp(null, null, null, null, keySignature); } static class BatchOp { - final KeyRingPublic keyRingPublic; - final SubKey subKey; - final UserPacket userPacket; - final Certification certification; - final KeySignature keySignature; + final Keyrings_public keyRingPublic; + final Keys subKey; + final User_packets userPacket; + final Certs certification; + final Key_signatures keySignature; - BatchOp(KeyRingPublic keyRingPublic, SubKey subKey, UserPacket userPacket, - Certification certification, KeySignature keySignature) { + BatchOp(Keyrings_public keyRingPublic, Keys subKey, User_packets userPacket, + Certs certification, Key_signatures keySignature) { this.subKey = subKey; this.keyRingPublic = keyRingPublic; this.userPacket = userPacket; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/KeyMetadataDao.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/KeyMetadataDao.java index bd2c37f3d..a6fea676a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/KeyMetadataDao.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/KeyMetadataDao.java @@ -1,21 +1,20 @@ package org.sufficientlysecure.keychain.daos; -import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.concurrent.TimeUnit; import android.content.Context; -import android.database.Cursor; -import com.squareup.sqldelight.SqlDelightQuery; -import org.sufficientlysecure.keychain.KeyMetadataModel.ReplaceKeyMetadata; +import org.sufficientlysecure.keychain.KeyMetadataQueries; +import org.sufficientlysecure.keychain.Key_metadata; import org.sufficientlysecure.keychain.KeychainDatabase; -import org.sufficientlysecure.keychain.model.KeyMetadata; public class KeyMetadataDao extends AbstractDao { + KeyMetadataQueries queries = getDatabase().getKeyMetadataQueries(); + public static KeyMetadataDao create(Context context) { KeychainDatabase database = KeychainDatabase.getInstance(context); DatabaseNotifyManager databaseNotifyManager = DatabaseNotifyManager.create(context); @@ -27,38 +26,21 @@ public class KeyMetadataDao extends AbstractDao { super(database, databaseNotifyManager); } - public KeyMetadata getKeyMetadata(long masterKeyId) { - SqlDelightQuery query = KeyMetadata.FACTORY.selectByMasterKeyId(masterKeyId); - try (Cursor cursor = getReadableDb().query(query)) { - if (cursor.moveToFirst()) { - return KeyMetadata.FACTORY.selectByMasterKeyIdMapper().map(cursor); - } - } - return null; + public Key_metadata getKeyMetadata(long masterKeyId) { + return queries.selectByMasterKeyId(masterKeyId).executeAsOneOrNull(); } public void resetAllLastUpdatedTimes() { - new KeyMetadata.DeleteAllLastUpdatedTimes(getWritableDb()).execute(); + queries.deleteAllLastUpdatedTimes(); } public void renewKeyLastUpdatedTime(long masterKeyId, boolean seenOnKeyservers) { - ReplaceKeyMetadata replaceStatement = new ReplaceKeyMetadata(getWritableDb(), KeyMetadata.FACTORY); - replaceStatement.bind(masterKeyId, new Date(), seenOnKeyservers); - replaceStatement.executeInsert(); - + queries.replaceKeyMetadata(masterKeyId, new Date(), seenOnKeyservers); getDatabaseNotifyManager().notifyKeyMetadataChange(masterKeyId); } public List getFingerprintsForKeysOlderThan(long olderThan, TimeUnit timeUnit) { - SqlDelightQuery query = KeyMetadata.FACTORY.selectFingerprintsForKeysOlderThan(new Date(timeUnit.toMillis(olderThan))); - - List fingerprintList = new ArrayList<>(); - try (Cursor cursor = getReadableDb().query(query)) { - while (cursor.moveToNext()) { - byte[] fingerprint = KeyMetadata.FACTORY.selectFingerprintsForKeysOlderThanMapper().map(cursor); - fingerprintList.add(fingerprint); - } - } - return fingerprintList; + return queries.selectFingerprintsForKeysOlderThan(new Date(timeUnit.toMillis(olderThan))) + .executeAsList(); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/KeyRepository.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/KeyRepository.java index 4cb0b33ea..5e5f7ddba 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/KeyRepository.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/KeyRepository.java @@ -20,22 +20,23 @@ package org.sufficientlysecure.keychain.daos; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.Arrays; import java.util.List; import android.content.Context; -import android.database.Cursor; -import androidx.annotation.WorkerThread; -import com.squareup.sqldelight.SqlDelightQuery; +import androidx.annotation.WorkerThread; +import com.squareup.sqldelight.Query; +import com.squareup.sqldelight.db.SqlCursor; import org.bouncycastle.bcpg.ArmoredOutputStream; +import org.sufficientlysecure.keychain.KeyRingsPublicQueries; +import org.sufficientlysecure.keychain.KeySignaturesQueries; import org.sufficientlysecure.keychain.KeychainDatabase; -import org.sufficientlysecure.keychain.model.Certification; -import org.sufficientlysecure.keychain.model.KeyRingPublic; -import org.sufficientlysecure.keychain.model.KeySignature; -import org.sufficientlysecure.keychain.model.SubKey; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; -import org.sufficientlysecure.keychain.model.UserPacket; -import org.sufficientlysecure.keychain.model.UserPacket.UserId; +import org.sufficientlysecure.keychain.Keyrings_public; +import org.sufficientlysecure.keychain.Keys; +import org.sufficientlysecure.keychain.KeysQueries; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UserId; import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType; import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog; import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus; @@ -49,9 +50,12 @@ import timber.log.Timber; public class KeyRepository extends AbstractDao { final LocalPublicKeyStorage mLocalPublicKeyStorage; final LocalSecretKeyStorage localSecretKeyStorage; + private final KeysQueries keysQueries = getDatabase().getKeysQueries(); OperationLog mLog; int mIndent; + private final KeyRingsPublicQueries keyRingsPublicQueries = getDatabase().getKeyRingsPublicQueries(); + private final KeySignaturesQueries keySignaturesQueries = getDatabase().getKeySignaturesQueries(); public static KeyRepository create(Context context) { LocalPublicKeyStorage localPublicKeyStorage = LocalPublicKeyStorage.getInstance(context); @@ -59,14 +63,16 @@ public class KeyRepository extends AbstractDao { KeychainDatabase database = KeychainDatabase.getInstance(context); DatabaseNotifyManager databaseNotifyManager = DatabaseNotifyManager.create(context); - return new KeyRepository(database, databaseNotifyManager, localPublicKeyStorage, localSecretKeyStorage); + return new KeyRepository(database, databaseNotifyManager, localPublicKeyStorage, + localSecretKeyStorage); } private KeyRepository(KeychainDatabase database, DatabaseNotifyManager databaseNotifyManager, LocalPublicKeyStorage localPublicKeyStorage, LocalSecretKeyStorage localSecretKeyStorage) { - this(database, databaseNotifyManager, localPublicKeyStorage, localSecretKeyStorage, new OperationLog(), 0); + this(database, databaseNotifyManager, localPublicKeyStorage, localSecretKeyStorage, + new OperationLog(), 0); } KeyRepository(KeychainDatabase database, @@ -101,7 +107,8 @@ public class KeyRepository extends AbstractDao { mLog = new OperationLog(); } - public CanonicalizedPublicKeyRing getCanonicalizedPublicKeyRing(long masterKeyId) throws NotFoundException { + public CanonicalizedPublicKeyRing getCanonicalizedPublicKeyRing(long masterKeyId) + throws NotFoundException { UnifiedKeyInfo unifiedKeyInfo = getUnifiedKeyInfo(masterKeyId); if (unifiedKeyInfo == null) { throw new NotFoundException(); @@ -111,7 +118,8 @@ public class KeyRepository extends AbstractDao { return new CanonicalizedPublicKeyRing(publicKeyData, unifiedKeyInfo.verified()); } - public CanonicalizedSecretKeyRing getCanonicalizedSecretKeyRing(long masterKeyId) throws NotFoundException { + public CanonicalizedSecretKeyRing getCanonicalizedSecretKeyRing(long masterKeyId) + throws NotFoundException { UnifiedKeyInfo unifiedKeyInfo = getUnifiedKeyInfo(masterKeyId); if (unifiedKeyInfo == null || !unifiedKeyInfo.has_any_secret()) { throw new NotFoundException(); @@ -124,75 +132,85 @@ public class KeyRepository extends AbstractDao { } public List getAllMasterKeyIds() { - SqlDelightQuery query = KeyRingPublic.FACTORY.selectAllMasterKeyIds(); - return mapAllRows(query, KeySignature.FACTORY.selectMasterKeyIdsBySignerMapper()); + return keyRingsPublicQueries.selectAllMasterKeyIds().executeAsList(); } public List getMasterKeyIdsBySigner(List signerMasterKeyIds) { - long[] signerKeyIds = getLongListAsArray(signerMasterKeyIds); - SqlDelightQuery query = KeySignature.FACTORY.selectMasterKeyIdsBySigner(signerKeyIds); - return mapAllRows(query, KeySignature.FACTORY.selectMasterKeyIdsBySignerMapper()); + return keySignaturesQueries.selectMasterKeyIdsBySigner(signerMasterKeyIds).executeAsList(); } public Long getMasterKeyIdBySubkeyId(long subKeyId) { - SqlDelightQuery query = SubKey.FACTORY.selectMasterKeyIdBySubkey(subKeyId); - return mapSingleRow(query, SubKey.FACTORY.selectMasterKeyIdBySubkeyMapper()); + return keysQueries.selectMasterKeyIdBySubkey(subKeyId).executeAsOneOrNull(); } public UnifiedKeyInfo getUnifiedKeyInfo(long masterKeyId) { - SqlDelightQuery query = SubKey.FACTORY.selectUnifiedKeyInfoByMasterKeyId(masterKeyId); - return mapSingleRow(query, SubKey.UNIFIED_KEY_INFO_MAPPER); + return keysQueries.selectUnifiedKeyInfoByMasterKeyId(masterKeyId, UnifiedKeyInfo::create).executeAsOneOrNull(); } public List getUnifiedKeyInfo(long... masterKeyIds) { - SqlDelightQuery query = SubKey.FACTORY.selectUnifiedKeyInfoByMasterKeyIds(masterKeyIds); - return mapAllRows(query, SubKey.UNIFIED_KEY_INFO_MAPPER); + return keysQueries.selectUnifiedKeyInfoByMasterKeyIds(getLongArrayAsList(masterKeyIds), UnifiedKeyInfo::create) + .executeAsList(); } public List getUnifiedKeyInfosByMailAddress(String mailAddress) { - SqlDelightQuery query = SubKey.FACTORY.selectUnifiedKeyInfoSearchMailAddress('%' + mailAddress + '%'); - return mapAllRows(query, SubKey.UNIFIED_KEY_INFO_MAPPER); + return keysQueries.selectUnifiedKeyInfoSearchMailAddress('%' + mailAddress + '%', UnifiedKeyInfo::create) + .executeAsList(); } public List getAllUnifiedKeyInfo() { - SqlDelightQuery query = SubKey.FACTORY.selectAllUnifiedKeyInfo(); - return mapAllRows(query, SubKey.UNIFIED_KEY_INFO_MAPPER); + return keysQueries.selectAllUnifiedKeyInfo(UnifiedKeyInfo::create).executeAsList(); } public List getAllUnifiedKeyInfoWithSecret() { - SqlDelightQuery query = SubKey.FACTORY.selectAllUnifiedKeyInfoWithSecret(); - return mapAllRows(query, SubKey.UNIFIED_KEY_INFO_MAPPER); + return keysQueries.selectAllUnifiedKeyInfoWithSecret(UnifiedKeyInfo::create).executeAsList(); } public List getAllUnifiedKeyInfoWithAuthKeySecret() { - SqlDelightQuery query = SubKey.FACTORY.selectAllUnifiedKeyInfoWithAuthKeySecret(); - return mapAllRows(query, SubKey.UNIFIED_KEY_INFO_MAPPER); + return keysQueries.selectAllUnifiedKeyInfoWithAuthKeySecret(UnifiedKeyInfo::create).executeAsList(); } public List getUserIds(long... masterKeyIds) { - SqlDelightQuery query = UserPacket.FACTORY.selectUserIdsByMasterKeyId(masterKeyIds); - return mapAllRows(query, UserPacket.USER_ID_MAPPER); + return getDatabase().getUserPacketsQueries() + .selectUserIdsByMasterKeyId(getLongArrayAsList(masterKeyIds), UserId::create).executeAsList(); } + + public List getConfirmedUserIds(long masterKeyId) { - SqlDelightQuery query = UserPacket.FACTORY.selectUserIdsByMasterKeyIdAndVerification( - Certification.FACTORY, masterKeyId, VerificationStatus.VERIFIED_SECRET); - return mapAllRows(query, cursor -> UserPacket.USER_ID_MAPPER.map(cursor).user_id()); + return getDatabase().getUserPacketsQueries() + .selectUserIdsByMasterKeyIdAndVerification(masterKeyId, + VerificationStatus.VERIFIED_SECRET, ( + master_key_id, + rank, + user_id, + name, + email, + comment, + is_primary, + is_revoked, + verified_int + + ) -> user_id).executeAsList(); } - public List getSubKeysByMasterKeyId(long masterKeyId) { - SqlDelightQuery query = SubKey.FACTORY.selectSubkeysByMasterKeyId(masterKeyId); - return mapAllRows(query, SubKey.SUBKEY_MAPPER); + public List getSubKeysByMasterKeyId(long masterKeyId) { + return keysQueries.selectSubkeysByMasterKeyId(masterKeyId).executeAsList(); } public SecretKeyType getSecretKeyType(long keyId) throws NotFoundException { - SqlDelightQuery query = SubKey.FACTORY.selectSecretKeyType(keyId); - return mapSingleRowOrThrow(query, SubKey.SKT_MAPPER); + try { + return keysQueries.selectSecretKeyType(keyId).executeAsOne(); + } catch (NullPointerException npe) { + throw new NotFoundException(); + } } public byte[] getFingerprintByKeyId(long keyId) throws NotFoundException { - SqlDelightQuery query = SubKey.FACTORY.selectFingerprintByKeyId(keyId); - return mapSingleRowOrThrow(query, SubKey.FACTORY.selectFingerprintByKeyIdMapper()); + try { + return keysQueries.selectFingerprintByKeyId(keyId).executeAsOne(); + } catch (NullPointerException npe) { + throw new NotFoundException(); + } } private byte[] getKeyRingAsArmoredData(byte[] data) throws IOException { @@ -205,23 +223,26 @@ public class KeyRepository extends AbstractDao { return bos.toByteArray(); } - public String getPublicKeyRingAsArmoredString(long masterKeyId) throws NotFoundException, IOException { + public String getPublicKeyRingAsArmoredString(long masterKeyId) + throws NotFoundException, IOException { byte[] data = loadPublicKeyRingData(masterKeyId); byte[] armoredData = getKeyRingAsArmoredData(data); return new String(armoredData); } - public byte[] getSecretKeyRingAsArmoredData(long masterKeyId) throws NotFoundException, IOException { + public byte[] getSecretKeyRingAsArmoredData(long masterKeyId) + throws NotFoundException, IOException { byte[] data = loadSecretKeyRingData(masterKeyId); return getKeyRingAsArmoredData(data); } public final byte[] loadPublicKeyRingData(long masterKeyId) throws NotFoundException { - SqlDelightQuery query = KeyRingPublic.FACTORY.selectByMasterKeyId(masterKeyId); - try (Cursor cursor = getReadableDb().query(query)) { - if (cursor.moveToFirst()) { - KeyRingPublic keyRingPublic = KeyRingPublic.MAPPER.map(cursor); - byte[] keyRingData = keyRingPublic.key_ring_data(); + Query keyringsPublicQuery = + keyRingsPublicQueries.selectByMasterKeyId(masterKeyId); + try (SqlCursor cursor = keyringsPublicQuery.execute()) { + if (cursor.next()) { + Keyrings_public keyRingPublic = keyringsPublicQuery.getMapper().invoke(cursor); + byte[] keyRingData = keyRingPublic.getKey_ring_data(); if (keyRingData == null) { keyRingData = mLocalPublicKeyStorage.readPublicKey(masterKeyId); } @@ -243,18 +264,16 @@ public class KeyRepository extends AbstractDao { } public long getSecretSignId(long masterKeyId) throws NotFoundException { - SqlDelightQuery query = SubKey.FACTORY.selectEffectiveSignKeyIdByMasterKeyId(masterKeyId); - return mapSingleRowOrThrow(query, SubKey.FACTORY.selectEffectiveSignKeyIdByMasterKeyIdMapper()); + return keysQueries.selectEffectiveSignKeyIdByMasterKeyId(masterKeyId).executeAsOneOrNull(); } public long getEffectiveAuthenticationKeyId(long masterKeyId) throws NotFoundException { - SqlDelightQuery query = SubKey.FACTORY.selectEffectiveAuthKeyIdByMasterKeyId(masterKeyId); - return mapSingleRowOrThrow(query, SubKey.FACTORY.selectEffectiveAuthKeyIdByMasterKeyIdMapper()); + return keysQueries.selectEffectiveAuthKeyIdByMasterKeyId(masterKeyId).executeAsOneOrNull(); } public List getPublicEncryptionIds(long masterKeyId) { - SqlDelightQuery query = SubKey.FACTORY.selectEffectiveEncryptionKeyIdsByMasterKeyId(masterKeyId); - return mapAllRows(query, SubKey.FACTORY.selectEffectiveEncryptionKeyIdsByMasterKeyIdMapper()); + return keysQueries.selectEffectiveEncryptionKeyIdsByMasterKeyId(masterKeyId) + .executeAsList(); } public static class NotFoundException extends Exception { @@ -274,4 +293,13 @@ public class KeyRepository extends AbstractDao { } return longs; } + + private List getLongArrayAsList(long[] longList) { + Long[] longs = new Long[longList.length]; + int i = 0; + for (Long aLong : longList) { + longs[i++] = aLong; + } + return Arrays.asList(longs); + } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/KeyWritableRepository.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/KeyWritableRepository.java index cf7d3a610..ac210bdd0 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/KeyWritableRepository.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/KeyWritableRepository.java @@ -25,24 +25,23 @@ import java.util.Collections; import java.util.Date; import java.util.List; -import androidx.sqlite.db.SupportSQLiteDatabase; import android.content.Context; + import androidx.annotation.NonNull; import androidx.collection.LongSparseArray; - +import androidx.sqlite.db.SupportSQLiteDatabase; import org.openintents.openpgp.util.OpenPgpUtils; -import org.sufficientlysecure.keychain.KeyRingsPublicModel.DeleteByMasterKeyId; +import org.sufficientlysecure.keychain.Certs; +import org.sufficientlysecure.keychain.Key_signatures; import org.sufficientlysecure.keychain.KeychainDatabase; -import org.sufficientlysecure.keychain.KeysModel.UpdateHasSecretByKeyId; -import org.sufficientlysecure.keychain.KeysModel.UpdateHasSecretByMasterKeyId; +import org.sufficientlysecure.keychain.Keyrings_public; +import org.sufficientlysecure.keychain.Keys; +import org.sufficientlysecure.keychain.KeysQueries; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.User_packets; +import org.sufficientlysecure.keychain.UtilQueries; import org.sufficientlysecure.keychain.daos.DatabaseBatchInteractor.BatchOp; -import org.sufficientlysecure.keychain.model.Certification; -import org.sufficientlysecure.keychain.model.KeyRingPublic; -import org.sufficientlysecure.keychain.model.KeySignature; -import org.sufficientlysecure.keychain.model.SubKey; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; -import org.sufficientlysecure.keychain.model.UserPacket; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType; import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog; import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult; @@ -114,7 +113,7 @@ public class KeyWritableRepository extends KeyRepository { this.context = context; this.databaseNotifyManager = databaseNotifyManager; this.autocryptPeerDao = autocryptPeerDao; - this.databaseBatchInteractor = new DatabaseBatchInteractor(getWritableDb()); + this.databaseBatchInteractor = new DatabaseBatchInteractor(getDatabase()); } private LongSparseArray getTrustedMasterKeys() { @@ -193,7 +192,7 @@ public class KeyWritableRepository extends KeyRepository { log(LogType.MSG_IP_INSERT_KEYRING); byte[] encodedRingIfDbCachable = encodedKeyRing.length < MAX_CACHED_KEY_SIZE ? encodedKeyRing : null; - KeyRingPublic keyRingPublic = KeyRingPublic.create(masterKeyId, encodedRingIfDbCachable); + Keyrings_public keyRingPublic = new Keyrings_public(masterKeyId, encodedRingIfDbCachable); operations.add(DatabaseBatchInteractor.createInsertKeyRingPublic(keyRingPublic)); log(LogType.MSG_IP_INSERT_SUBKEYS); @@ -239,9 +238,12 @@ public class KeyWritableRepository extends KeyRepository { } } - SubKey subKey = SubKey.create(masterKeyId, rank, key.getKeyId(), + long creationUnixTime = creation.getTime() / 1000; + Long expiryUnixTime = expiry != null ? expiry.getTime() / 1000 : null; + long validFromTime = bindingSignatureTime.getTime() / 1000; + Keys subKey = new Keys(masterKeyId, rank, key.getKeyId(), key.getBitStrength(), key.getCurveOid(), key.getAlgorithm(), key.getFingerprint(), - c, s, e, a, key.isRevoked(), SecretKeyType.UNAVAILABLE, key.isSecure(), creation, expiry, bindingSignatureTime); + c, s, e, a, key.isRevoked(), SecretKeyType.UNAVAILABLE, key.isSecure(), creationUnixTime, expiryUnixTime, validFromTime); operations.add(DatabaseBatchInteractor.createInsertSubKey(subKey)); ++rank; @@ -300,7 +302,7 @@ public class KeyWritableRepository extends KeyRepository { // keep a note about the issuer of this key signature if (!signerKeyIds.contains(certId)) { - KeySignature keySignature = KeySignature.create(masterKeyId, certId); + Key_signatures keySignature = new Key_signatures(masterKeyId, certId); operations.add(DatabaseBatchInteractor.createInsertSignerKey(keySignature)); signerKeyIds.add(certId); } @@ -468,7 +470,7 @@ public class KeyWritableRepository extends KeyRepository { for (int userIdRank = 0; userIdRank < uids.size(); userIdRank++) { UserPacketItem item = uids.get(userIdRank); Long type = item.type != null ? item.type.longValue() : null; - UserPacket userPacket = UserPacket.create(masterKeyId, userIdRank, type, item.userId, item.name, item.email, + User_packets userPacket = new User_packets(masterKeyId, userIdRank, type, item.userId, item.name, item.email, item.comment, item.attributeData, item.isPrimary, item.selfRevocation != null); operations.add(DatabaseBatchInteractor.createInsertUserPacket(userPacket)); @@ -508,14 +510,13 @@ public class KeyWritableRepository extends KeyRepository { mIndent -= 1; } - SupportSQLiteDatabase db = databaseBatchInteractor.getDb(); + SupportSQLiteDatabase db = getWritableDb(); try { db.beginTransaction(); // delete old version of this keyRing (from database only!), which also deletes all keys and userIds on cascade - DeleteByMasterKeyId deleteStatement = new DeleteByMasterKeyId(db); - deleteStatement.bind(masterKeyId); - int deletedRows = deleteStatement.executeUpdateDelete(); + getDatabase().getKeyRingsPublicQueries().deleteByMasterKeyId(masterKeyId); + int deletedRows = getDatabase().getUtilQueries().selectChanges().executeAsOne().intValue(); if (deletedRows > 0) { log(LogType.MSG_IP_DELETE_OLD_OK); @@ -559,9 +560,8 @@ public class KeyWritableRepository extends KeyRepository { } autocryptPeerDao.deleteByMasterKeyId(masterKeyId); - DeleteByMasterKeyId deleteStatement = new DeleteByMasterKeyId(getWritableDb()); - deleteStatement.bind(masterKeyId); - int deletedRows = deleteStatement.executeUpdateDelete(); + getDatabase().getKeyRingsPublicQueries().deleteByMasterKeyId(masterKeyId); + int deletedRows = getDatabase().getUtilQueries().selectChanges().executeAsOne().intValue(); databaseNotifyManager.notifyKeyChange(masterKeyId); @@ -631,12 +631,10 @@ public class KeyWritableRepository extends KeyRepository { } { - UpdateHasSecretByMasterKeyId resetStatement = - SubKey.createUpdateHasSecretByMasterKeyIdStatement(getWritableDb()); - resetStatement.bind(masterKeyId, SecretKeyType.GNU_DUMMY); - resetStatement.executeUpdateDelete(); + KeysQueries keysQueries = getDatabase().getKeysQueries(); + UtilQueries utilQueries = getDatabase().getUtilQueries(); - UpdateHasSecretByKeyId updateStatement = SubKey.createUpdateHasSecretByKeyId(getWritableDb()); + keysQueries.updateHasSecretByMasterKeyId(masterKeyId, SecretKeyType.GNU_DUMMY); // then, mark exactly the keys we have available log(LogType.MSG_IS_IMPORTING_SUBKEYS); @@ -644,8 +642,8 @@ public class KeyWritableRepository extends KeyRepository { for (CanonicalizedSecretKey sub : keyRing.secretKeyIterator()) { long id = sub.getKeyId(); SecretKeyType mode = sub.getSecretKeyTypeSuperExpensive(); - updateStatement.bind(id, mode); - int upd = updateStatement.executeUpdateDelete(); + keysQueries.updateHasSecretByKeyId(id, mode); + int upd = utilQueries.selectChanges().executeAsOne().intValue(); if (upd == 1) { switch (mode) { case PASSPHRASE: @@ -1013,8 +1011,9 @@ public class KeyWritableRepository extends KeyRepository { private BatchOp buildCertOperations(long masterKeyId, int rank, WrappedSignature cert, VerificationStatus verificationStatus) { try { - Certification certification = Certification.create(masterKeyId, rank, cert.getKeyId(), - cert.getSignatureType(), verificationStatus, cert.getCreationTime(), cert.getEncoded()); + long creationUnixTime = cert.getCreationTime().getTime() / 1000; + Certs certification = new Certs(masterKeyId, rank, cert.getKeyId(), + cert.getSignatureType(), verificationStatus, creationUnixTime, cert.getEncoded()); return DatabaseBatchInteractor.createInsertCertification(certification); } catch (IOException e) { throw new AssertionError(e); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/OverriddenWarningsDao.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/OverriddenWarningsDao.java index 12554f1a3..51881fa34 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/OverriddenWarningsDao.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/OverriddenWarningsDao.java @@ -20,11 +20,7 @@ package org.sufficientlysecure.keychain.daos; import android.content.Context; -import com.squareup.sqldelight.SqlDelightQuery; import org.sufficientlysecure.keychain.KeychainDatabase; -import org.sufficientlysecure.keychain.OverriddenWarningsModel.DeleteByIdentifier; -import org.sufficientlysecure.keychain.OverriddenWarningsModel.InsertIdentifier; -import org.sufficientlysecure.keychain.model.OverriddenWarning; public class OverriddenWarningsDao extends AbstractDao { @@ -35,25 +31,21 @@ public class OverriddenWarningsDao extends AbstractDao { return new OverriddenWarningsDao(database, databaseNotifyManager); } - private OverriddenWarningsDao(KeychainDatabase db, DatabaseNotifyManager databaseNotifyManager) { + private OverriddenWarningsDao(KeychainDatabase db, + DatabaseNotifyManager databaseNotifyManager) { super(db, databaseNotifyManager); } public boolean isWarningOverridden(String identifier) { - SqlDelightQuery query = OverriddenWarning.FACTORY.selectCountByIdentifier(identifier); - Long result = mapSingleRow(query, OverriddenWarning.FACTORY.selectCountByIdentifierMapper()::map); - return result != null && result > 0; + return getDatabase().getOverriddenWarningsQueries().selectCountByIdentifier(identifier) + .executeAsOne() > 0; } public void putOverride(String identifier) { - InsertIdentifier statement = new InsertIdentifier(getWritableDb()); - statement.bind(identifier); - statement.executeInsert(); + getDatabase().getOverriddenWarningsQueries().insertIdentifier(identifier); } public void deleteOverride(String identifier) { - DeleteByIdentifier statement = new DeleteByIdentifier(getWritableDb()); - statement.bind(identifier); - statement.executeInsert(); + getDatabase().getOverriddenWarningsQueries().deleteByIdentifier(identifier); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/UserIdDao.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/UserIdDao.java index 3a7bb8863..aae3c2492 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/UserIdDao.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/daos/UserIdDao.java @@ -1,16 +1,19 @@ package org.sufficientlysecure.keychain.daos; +import java.io.IOException; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; import android.content.Context; -import android.database.Cursor; -import com.squareup.sqldelight.SqlDelightQuery; +import com.squareup.sqldelight.Query; +import com.squareup.sqldelight.db.SqlCursor; import org.sufficientlysecure.keychain.KeychainDatabase; -import org.sufficientlysecure.keychain.model.UserPacket; -import org.sufficientlysecure.keychain.model.UserPacket.UidStatus; +import org.sufficientlysecure.keychain.UidStatus; +import org.sufficientlysecure.keychain.model.UserId; public class UserIdDao extends AbstractDao { @@ -25,20 +28,38 @@ public class UserIdDao extends AbstractDao { super(db, databaseNotifyManager); } - public UidStatus getUidStatusByEmailLike(String emailLike) { - SqlDelightQuery query = UserPacket.FACTORY.selectUserIdStatusByEmailLike(emailLike); - return mapSingleRow(query, UserPacket.UID_STATUS_MAPPER); + public List getUserIdsByMasterKeyIds(long... masterKeyIds) { + return getDatabase().getUserPacketsQueries() + .selectUserIdsByMasterKeyId(getLongArrayAsList(masterKeyIds), UserId::create) + .executeAsList(); } - public Map getUidStatusByEmail(String... emails) { - SqlDelightQuery query = UserPacket.FACTORY.selectUserIdStatusByEmail(emails); - Map result = new HashMap<>(); - try (Cursor cursor = getReadableDb().query(query)) { - while (cursor.moveToNext()) { - UidStatus item = UserPacket.UID_STATUS_MAPPER.map(cursor); - result.put(item.email(), item); + public UidStatus getUidStatusByEmailLike(String emailLike) { + return getDatabase().getUserPacketsQueries().selectUserIdStatusByEmailLike(emailLike) + .executeAsOne(); + } + + public Map getUidStatusByEmail(String... emails) { + Query q = getDatabase().getUserPacketsQueries() + .selectUserIdStatusByEmail(Arrays.asList(emails)); + Map result = new HashMap<>(); + try (SqlCursor cursor = q.execute()) { + while (cursor.next()) { + UidStatus item = q.getMapper().invoke(cursor); + result.put(item.getEmail(), item); } + } catch (IOException e) { + // oops } return result; } -} + + private List getLongArrayAsList(long[] longList) { + Long[] longs = new Long[longList.length]; + int i = 0; + for (Long aLong : longList) { + longs[i++] = aLong; + } + return Arrays.asList(longs); + } +} \ No newline at end of file diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/livedata/ApiAppsLiveData.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/livedata/ApiAppsLiveData.java index a3c06d34a..7d5fea346 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/livedata/ApiAppsLiveData.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/livedata/ApiAppsLiveData.java @@ -10,11 +10,11 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; +import org.sufficientlysecure.keychain.Api_apps; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.daos.ApiAppDao; import org.sufficientlysecure.keychain.daos.DatabaseNotifyManager; import org.sufficientlysecure.keychain.livedata.ApiAppsLiveData.ListedApp; -import org.sufficientlysecure.keychain.model.ApiApp; import org.sufficientlysecure.keychain.ui.keyview.loader.AsyncTaskLiveData; @@ -41,18 +41,18 @@ public class ApiAppsLiveData extends AsyncTaskLiveData> { } private void loadRegisteredApps(ArrayList result) { - List registeredApiApps = apiAppDao.getAllApiApps(); + List registeredApiApps = apiAppDao.getAllApiApps(); - for (ApiApp apiApp : registeredApiApps) { + for (Api_apps apiApp : registeredApiApps) { ListedApp listedApp; try { - ApplicationInfo ai = packageManager.getApplicationInfo(apiApp.package_name(), 0); + ApplicationInfo ai = packageManager.getApplicationInfo(apiApp.getPackage_name(), 0); CharSequence applicationLabel = packageManager.getApplicationLabel(ai); Drawable applicationIcon = packageManager.getApplicationIcon(ai); - listedApp = new ListedApp(apiApp.package_name(), true, true, applicationLabel, applicationIcon, null); + listedApp = new ListedApp(apiApp.getPackage_name(), true, true, applicationLabel, applicationIcon, null); } catch (PackageManager.NameNotFoundException e) { - listedApp = new ListedApp(apiApp.package_name(), false, true, apiApp.package_name(), null, null); + listedApp = new ListedApp(apiApp.getPackage_name(), false, true, apiApp.getPackage_name(), null, null); } result.add(listedApp); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/ApiAllowedKey.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/ApiAllowedKey.java deleted file mode 100644 index d635d2931..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/ApiAllowedKey.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.sufficientlysecure.keychain.model; - - -import com.google.auto.value.AutoValue; -import org.sufficientlysecure.keychain.ApiAllowedKeysModel; - - -@AutoValue -public abstract class ApiAllowedKey implements ApiAllowedKeysModel { - public static final Factory FACTORY = new Factory(AutoValue_ApiAllowedKey::new); -} \ No newline at end of file diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/ApiApp.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/ApiApp.java deleted file mode 100644 index 2e84094cb..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/ApiApp.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2017 Schürmann & Breitmoser GbR - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.model; - - -import com.google.auto.value.AutoValue; -import org.sufficientlysecure.keychain.ApiAppsModel; - - -@AutoValue -public abstract class ApiApp implements ApiAppsModel { - public static final ApiAppsModel.Factory FACTORY = - new ApiAppsModel.Factory(AutoValue_ApiApp::new); - - public static ApiApp create(String packageName, byte[] packageSignature) { - return new AutoValue_ApiApp(null, packageName, packageSignature); - } -} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/AutocryptPeer.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/AutocryptPeer.java deleted file mode 100644 index f9c5e1783..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/AutocryptPeer.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.sufficientlysecure.keychain.model; - - -import com.google.auto.value.AutoValue; -import com.squareup.sqldelight.RowMapper; -import org.sufficientlysecure.keychain.AutocryptPeersModel; - - -@AutoValue -public abstract class AutocryptPeer implements AutocryptPeersModel { - - public enum GossipOrigin { - GOSSIP_HEADER, SIGNATURE, DEDUP - } - - public static final Factory FACTORY = new Factory(AutoValue_AutocryptPeer::new, - CustomColumnAdapters.DATE_ADAPTER, CustomColumnAdapters.DATE_ADAPTER, CustomColumnAdapters.DATE_ADAPTER, - CustomColumnAdapters.GOSSIP_ORIGIN_ADAPTER); - - public static final RowMapper PEER_MAPPER = FACTORY.selectByIdentifiersMapper(); - public static final RowMapper KEY_STATUS_MAPPER = - FACTORY.selectAutocryptKeyStatusMapper(AutoValue_AutocryptPeer_AutocryptKeyStatus::new); - - @AutoValue - public static abstract class AutocryptKeyStatus implements SelectAutocryptKeyStatusModel { - public boolean hasGossipKey() { - return autocryptPeer().gossip_master_key_id() != null; - } - - public boolean isGossipKeyRevoked() { - Boolean gossip_key_is_revoked = gossip_key_is_revoked_int(); - return gossip_key_is_revoked != null && gossip_key_is_revoked; - } - - public boolean isGossipKeyExpired() { - return gossip_key_is_expired_int() != 0; - } - - public boolean isGossipKeyVerified() { - return gossip_key_is_verified_int() != 0; - } - - public boolean isKeyRevoked() { - Boolean revoked = key_is_revoked_int(); - return revoked != null && revoked; - } - - public boolean isKeyExpired() { - return key_is_expired_int() != 0; - } - - public boolean isKeyVerified() { - return key_is_verified_int() != 0; - } - } - -} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/Certification.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/Certification.java deleted file mode 100644 index 2a06d837f..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/Certification.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.sufficientlysecure.keychain.model; - - -import java.util.Date; - -import androidx.sqlite.db.SupportSQLiteDatabase; - -import com.google.auto.value.AutoValue; -import org.sufficientlysecure.keychain.CertsModel; -import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus; - - -@AutoValue -public abstract class Certification implements CertsModel { - public static final CertsModel.Factory FACTORY = - new CertsModel.Factory<>(AutoValue_Certification::new, CustomColumnAdapters.VERIFICATON_STATUS_ADAPTER); - - public static final SelectVerifyingCertDetailsMapper CERT_DETAILS_MAPPER = - new SelectVerifyingCertDetailsMapper<>(AutoValue_Certification_CertDetails::new); - - public static Certification create(long masterKeyId, long rank, long keyIdCertifier, long type, - VerificationStatus verified, Date creation, byte[] data) { - long creationUnixTime = creation.getTime() / 1000; - return new AutoValue_Certification(masterKeyId, rank, keyIdCertifier, type, verified, creationUnixTime, data); - } - - public static InsertCert createInsertStatement(SupportSQLiteDatabase db) { - return new InsertCert(db, FACTORY); - } - - public void bindTo(InsertCert statement) { - statement.bind(master_key_id(), rank(), key_id_certifier(), type(), verified(), creation(), data()); - } - - @AutoValue - public static abstract class CertDetails implements CertsModel.SelectVerifyingCertDetailsModel { - - } -} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/CustomColumnAdapters.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/CustomColumnAdapters.java index 9ebcceab1..44b266b07 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/CustomColumnAdapters.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/CustomColumnAdapters.java @@ -4,9 +4,7 @@ package org.sufficientlysecure.keychain.model; import java.util.Date; import androidx.annotation.NonNull; - import com.squareup.sqldelight.ColumnAdapter; -import org.sufficientlysecure.keychain.model.AutocryptPeer.GossipOrigin; import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType; @@ -15,7 +13,7 @@ public final class CustomColumnAdapters { private CustomColumnAdapters() { } - static final ColumnAdapter DATE_ADAPTER = new ColumnAdapter() { + public static final ColumnAdapter DATE_ADAPTER = new ColumnAdapter() { @NonNull @Override public Date decode(Long databaseValue) { @@ -29,7 +27,7 @@ public final class CustomColumnAdapters { } }; - static final ColumnAdapter GOSSIP_ORIGIN_ADAPTER = new ColumnAdapter() { + public static final ColumnAdapter GOSSIP_ORIGIN_ADAPTER = new ColumnAdapter() { @NonNull @Override public GossipOrigin decode(Long databaseValue) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/GossipOrigin.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/GossipOrigin.java new file mode 100644 index 000000000..e15d89986 --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/GossipOrigin.java @@ -0,0 +1,5 @@ +package org.sufficientlysecure.keychain.model; + +public enum GossipOrigin { + GOSSIP_HEADER, SIGNATURE, DEDUP +} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/KeyMetadata.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/KeyMetadata.java deleted file mode 100644 index c1df957b8..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/KeyMetadata.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.sufficientlysecure.keychain.model; - - -import com.google.auto.value.AutoValue; -import org.sufficientlysecure.keychain.KeyMetadataModel; - - -@AutoValue -public abstract class KeyMetadata implements KeyMetadataModel { - public static final Factory FACTORY = new Factory<>( - AutoValue_KeyMetadata::new, CustomColumnAdapters.DATE_ADAPTER); - - public boolean hasBeenUpdated() { - return last_updated() != null; - } - - public boolean isPublished() { - if (last_updated() == null) { - throw new IllegalStateException("Cannot get publication state if key has never been updated!"); - } - Boolean seenOnKeyservers = seen_on_keyservers(); - return seenOnKeyservers != null && seenOnKeyservers; - } -} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/KeyRingPublic.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/KeyRingPublic.java deleted file mode 100644 index bb1604a8c..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/KeyRingPublic.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.sufficientlysecure.keychain.model; - - -import androidx.sqlite.db.SupportSQLiteDatabase; - -import com.google.auto.value.AutoValue; -import org.sufficientlysecure.keychain.KeyRingsPublicModel; - - -@AutoValue -public abstract class KeyRingPublic implements KeyRingsPublicModel { - public static final Factory FACTORY = new Factory<>(AutoValue_KeyRingPublic::new); - - public static final Mapper MAPPER = new Mapper<>(FACTORY); - - public static KeyRingPublic create(long masterKeyId, byte[] keyRingData) { - return new AutoValue_KeyRingPublic(masterKeyId, keyRingData); - } - - public static InsertKeyRingPublic createInsertStatement(SupportSQLiteDatabase db) { - return new InsertKeyRingPublic(db); - } - - public void bindTo(InsertKeyRingPublic statement) { - statement.bind(master_key_id(), key_ring_data()); - } -} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/KeySignature.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/KeySignature.java deleted file mode 100644 index fe101cfb8..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/KeySignature.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.sufficientlysecure.keychain.model; - - -import androidx.sqlite.db.SupportSQLiteDatabase; - -import com.google.auto.value.AutoValue; -import org.sufficientlysecure.keychain.KeySignaturesModel; - - -@AutoValue -public abstract class KeySignature implements KeySignaturesModel { - public static final Factory FACTORY = new Factory<>(AutoValue_KeySignature::new); - - public static final Mapper MAPPER = new Mapper<>(FACTORY); - - public static InsertKeySignature createInsertStatement(SupportSQLiteDatabase db) { - return new InsertKeySignature(db); - } - - public void bindTo(InsertKeySignature statement) { - statement.bind(master_key_id(), signer_key_id()); - } - - public static KeySignature create(long masterKeyId, long certId) { - return new AutoValue_KeySignature(masterKeyId, certId); - } -} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/OverriddenWarning.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/OverriddenWarning.java deleted file mode 100644 index 5de6b385b..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/OverriddenWarning.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.sufficientlysecure.keychain.model; - - -import com.google.auto.value.AutoValue; -import org.sufficientlysecure.keychain.KeySignaturesModel; -import org.sufficientlysecure.keychain.OverriddenWarningsModel; - - -@AutoValue -public abstract class OverriddenWarning implements OverriddenWarningsModel { - public static final Factory FACTORY = new Factory<>(AutoValue_OverriddenWarning::new); - - public static final Mapper MAPPER = new Mapper<>(FACTORY); -} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/SubKey.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/SubKey.java deleted file mode 100644 index c963aa330..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/SubKey.java +++ /dev/null @@ -1,116 +0,0 @@ -package org.sufficientlysecure.keychain.model; - - -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import androidx.sqlite.db.SupportSQLiteDatabase; - -import com.google.auto.value.AutoValue; -import com.squareup.sqldelight.RowMapper; -import org.sufficientlysecure.keychain.KeysModel; -import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus; -import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType; - - -@AutoValue -public abstract class SubKey implements KeysModel { - public static final Factory FACTORY = - new Factory<>(AutoValue_SubKey::new, CustomColumnAdapters.SECRET_KEY_TYPE_ADAPTER); - public static final UnifiedKeyViewMapper UNIFIED_KEY_INFO_MAPPER = - FACTORY.selectAllUnifiedKeyInfoMapper( - AutoValue_SubKey_UnifiedKeyInfo::new, Certification.FACTORY); - public static Mapper SUBKEY_MAPPER = new Mapper<>(FACTORY); - public static RowMapper SKT_MAPPER = FACTORY.selectSecretKeyTypeMapper(); - - public boolean expires() { - return expiry() != null; - } - - public static SubKey create(long masterKeyId, long rank, long keyId, Integer keySize, String keyCurveOid, - int algorithm, byte[] fingerprint, boolean canCertify, boolean canSign, boolean canEncrypt, boolean canAuth, - boolean isRevoked, SecretKeyType hasSecret, boolean isSecure, Date creation, Date expiry, - Date validFrom) { - long creationUnixTime = creation.getTime() / 1000; - Long expiryUnixTime = expiry != null ? expiry.getTime() / 1000 : null; - long validFromTime = validFrom.getTime() / 1000; - return new AutoValue_SubKey(masterKeyId, rank, keyId, keySize, keyCurveOid, algorithm, fingerprint, canCertify, - canSign, canEncrypt, canAuth, isRevoked, hasSecret, isSecure, creationUnixTime, expiryUnixTime, validFromTime); - } - - public static InsertKey createInsertStatement(SupportSQLiteDatabase db) { - return new InsertKey(db, FACTORY); - } - - public static UpdateHasSecretByMasterKeyId createUpdateHasSecretByMasterKeyIdStatement(SupportSQLiteDatabase db) { - return new UpdateHasSecretByMasterKeyId(db, FACTORY); - } - - public static UpdateHasSecretByKeyId createUpdateHasSecretByKeyId(SupportSQLiteDatabase db) { - return new UpdateHasSecretByKeyId(db, FACTORY); - } - - public void bindTo(InsertKey statement) { - statement.bind(master_key_id(), rank(), key_id(), key_size(), key_curve_oid(), algorithm(), fingerprint(), - can_certify(), can_sign(), can_encrypt(), can_authenticate(), is_revoked(), has_secret(), is_secure(), - creation(), expiry(), validFrom()); - } - - @AutoValue - public static abstract class UnifiedKeyInfo implements KeysModel.UnifiedKeyViewModel { - private List autocryptPackageNames; - private String cachedUidSearchString; - - public boolean is_expired() { - Long expiry = expiry(); - return expiry != null && expiry * 1000 < System.currentTimeMillis(); - } - - public boolean has_any_secret() { - return has_any_secret_int() != 0; - } - - public boolean is_verified() { - VerificationStatus verified = verified(); - return verified != null && verified == VerificationStatus.VERIFIED_SECRET; - } - - public boolean has_duplicate() { - return has_duplicate_int() != 0; - } - - public List autocrypt_package_names() { - if (autocryptPackageNames == null) { - String csv = autocrypt_package_names_csv(); - autocryptPackageNames = csv == null ? Collections.emptyList() : - Arrays.asList(csv.split(",")); - } - return autocryptPackageNames; - } - - public boolean has_auth_key() { - return has_auth_key_int() != 0; - } - - public boolean has_encrypt_key() { - return has_encrypt_key_int() != 0; - } - - public boolean has_sign_key() { - return has_sign_key_int() != 0; - } - - public String uidSearchString() { - if (cachedUidSearchString == null) { - cachedUidSearchString = user_id_list(); - if (cachedUidSearchString == null) { - cachedUidSearchString = ""; - } - cachedUidSearchString = cachedUidSearchString.toLowerCase(); - } - return cachedUidSearchString; - } - } -} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/UnifiedKeyInfo.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/UnifiedKeyInfo.java new file mode 100644 index 000000000..f721e9056 --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/UnifiedKeyInfo.java @@ -0,0 +1,108 @@ +package org.sufficientlysecure.keychain.model; + + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import androidx.annotation.Nullable; +import com.google.auto.value.AutoValue; +import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing; +import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus; + + +@AutoValue +public abstract class UnifiedKeyInfo { + public static UnifiedKeyInfo create(long master_key_id, byte[] fingerprint, Long min, + String user_id, String name, String email, String comment, long creation, Long expiry, + boolean is_revoked, boolean is_secure, boolean can_certify, + CanonicalizedKeyRing.VerificationStatus verified, boolean has_duplicate, + boolean has_any_secret, boolean has_encrypt_key, boolean has_sign_key, + boolean has_auth_key, String autocrypt_package_names_csv, String user_id_list) { + return new AutoValue_UnifiedKeyInfo(master_key_id, fingerprint, min, user_id, name, email, + comment, creation, expiry, is_revoked, is_secure, can_certify, verified, + has_duplicate, has_any_secret, has_encrypt_key, has_sign_key, has_auth_key, + autocrypt_package_names_csv, user_id_list); + } + + private List autocryptPackageNames; + private String cachedUidSearchString; + + public abstract long master_key_id(); + + public abstract byte[] fingerprint(); + + @Nullable + public abstract Long min(); + + public abstract String user_id(); + + @Nullable + public abstract String name(); + + @Nullable + public abstract String email(); + + @Nullable + public abstract String comment(); + + public abstract long creation(); + + @Nullable + public abstract Long expiry(); + + public abstract boolean is_revoked(); + + public abstract boolean is_secure(); + + public abstract boolean can_certify(); + + @Nullable + public abstract VerificationStatus verified(); + + public abstract boolean has_duplicate(); + + public abstract boolean has_any_secret(); + + public abstract boolean has_encrypt_key(); + + public abstract boolean has_sign_key(); + + public abstract boolean has_auth_key(); + + @Nullable + public abstract String autocrypt_package_names_csv(); + + @Nullable + public abstract String user_id_list(); + + public boolean is_expired() { + Long expiry = expiry(); + return expiry != null && expiry * 1000 < System.currentTimeMillis(); + } + + public boolean is_verified() { + VerificationStatus verified = verified(); + return verified != null && verified == VerificationStatus.VERIFIED_SECRET; + } + + public List autocrypt_package_names() { + if (autocryptPackageNames == null) { + String csv = autocrypt_package_names_csv(); + autocryptPackageNames = + csv == null ? Collections.emptyList() : Arrays.asList(csv.split(",")); + } + return autocryptPackageNames; + } + + public String uidSearchString() { + if (cachedUidSearchString == null) { + cachedUidSearchString = user_id_list(); + if (cachedUidSearchString == null) { + cachedUidSearchString = ""; + } + cachedUidSearchString = cachedUidSearchString.toLowerCase(); + } + return cachedUidSearchString; + } +} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/UserId.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/UserId.java new file mode 100644 index 000000000..500b871c2 --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/UserId.java @@ -0,0 +1,49 @@ +package org.sufficientlysecure.keychain.model; + + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import com.google.auto.value.AutoValue; +import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus; + + +@AutoValue +public abstract class UserId { + public static UserId create(long master_key_id, int rank, String user_id, + String name, String email, String comment, boolean is_primary, boolean is_revoked, Long verified_int) { + return new AutoValue_UserId(master_key_id, rank, user_id, name, email, comment, + is_primary, is_revoked, verified_int + ); + } + + public abstract long master_key_id(); + + public abstract int rank(); + + @Nullable + public abstract String user_id(); + + @Nullable + public abstract String name(); + + @Nullable + public abstract String email(); + + @Nullable + public abstract String comment(); + + public abstract boolean is_primary(); + + public abstract boolean is_revoked(); + + public abstract Long verified_int(); + + public boolean isVerified() { + return verified() == VerificationStatus.VERIFIED_SECRET; + } + + @NonNull + public VerificationStatus verified() { + return CustomColumnAdapters.VERIFICATON_STATUS_ADAPTER.decode(verified_int()); + } +} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/UserPacket.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/UserPacket.java deleted file mode 100644 index 79af3633b..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/model/UserPacket.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.sufficientlysecure.keychain.model; - - -import androidx.sqlite.db.SupportSQLiteDatabase; -import androidx.annotation.NonNull; - -import com.google.auto.value.AutoValue; -import org.sufficientlysecure.keychain.UserPacketsModel; -import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus; - - -@AutoValue -public abstract class UserPacket implements UserPacketsModel { - public static final Factory FACTORY = new Factory<>(AutoValue_UserPacket::new); - public static final SelectUserIdsByMasterKeyIdMapper USER_ID_MAPPER = - FACTORY.selectUserIdsByMasterKeyIdMapper(AutoValue_UserPacket_UserId::new); - public static final SelectUserAttributesByTypeAndMasterKeyIdMapper USER_ATTRIBUTE_MAPPER = - FACTORY.selectUserAttributesByTypeAndMasterKeyIdMapper(AutoValue_UserPacket_UserAttribute::new); - public static final UidStatusMapper UID_STATUS_MAPPER = - FACTORY.selectUserIdStatusByEmailMapper(AutoValue_UserPacket_UidStatus::new); - - public static UserPacket create(long masterKeyId, int rank, Long type, String userId, String name, String email, - String comment, byte[] attribute_data, boolean isPrimary, boolean isRevoked) { - return new AutoValue_UserPacket(masterKeyId, rank, type, - userId, name, email, comment, attribute_data, isPrimary, isRevoked); - } - - public static InsertUserPacket createInsertStatement(SupportSQLiteDatabase db) { - return new InsertUserPacket(db); - } - - public void bindTo(InsertUserPacket statement) { - statement.bind(master_key_id(), rank(), type(), user_id(), name(), email(), comment(), attribute_data(), - is_primary(), is_revoked()); - } - - @AutoValue - public static abstract class UserId implements SelectUserIdsByMasterKeyIdModel { - public boolean isVerified() { - return verified() == VerificationStatus.VERIFIED_SECRET; - } - - @NonNull - public VerificationStatus verified() { - return CustomColumnAdapters.VERIFICATON_STATUS_ADAPTER.decode(verified_int()); - } - } - - @AutoValue - public static abstract class UserAttribute implements SelectUserAttributesByTypeAndMasterKeyIdModel { - public boolean isVerified() { - return verified() == VerificationStatus.VERIFIED_SECRET; - } - - @NonNull - public VerificationStatus verified() { - return CustomColumnAdapters.VERIFICATON_STATUS_ADAPTER.decode(verified_int()); - } - } - - @AutoValue - public static abstract class UidStatus implements UidStatusModel { - public VerificationStatus keyStatus() { - return CustomColumnAdapters.VERIFICATON_STATUS_ADAPTER.decode(key_status_int()); - } - } -} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BackupOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BackupOperation.java index f870c5386..5a9af2ed8 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BackupOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BackupOperation.java @@ -40,7 +40,7 @@ import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.daos.KeyRepository; import org.sufficientlysecure.keychain.daos.KeyRepository.NotFoundException; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.operations.results.ExportResult; import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType; import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/RevokeOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/RevokeOperation.java index 36101cfa0..26705e299 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/RevokeOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/RevokeOperation.java @@ -21,7 +21,7 @@ package org.sufficientlysecure.keychain.operations; import android.content.Context; import androidx.annotation.NonNull; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.operations.results.EditKeyResult; import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.operations.results.RevokeResult; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OpenPgpSignatureResultBuilder.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OpenPgpSignatureResultBuilder.java index 033879f51..b9fdac9d8 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OpenPgpSignatureResultBuilder.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/OpenPgpSignatureResultBuilder.java @@ -26,8 +26,8 @@ import org.openintents.openpgp.OpenPgpSignatureResult; import org.openintents.openpgp.OpenPgpSignatureResult.SenderStatusResult; import org.openintents.openpgp.util.OpenPgpUtils; import org.openintents.openpgp.util.OpenPgpUtils.UserId; -import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus; import org.sufficientlysecure.keychain.daos.KeyRepository; +import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus; import timber.log.Timber; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/AutocryptInteractor.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/AutocryptInteractor.java index 4907f47c7..c5867858e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/AutocryptInteractor.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/AutocryptInteractor.java @@ -8,20 +8,20 @@ import java.util.HashMap; import java.util.Map; import android.content.Context; -import androidx.annotation.Nullable; import android.text.format.DateUtils; +import androidx.annotation.Nullable; import org.openintents.openpgp.AutocryptPeerUpdate; import org.openintents.openpgp.AutocryptPeerUpdate.PreferEncrypt; +import org.sufficientlysecure.keychain.Autocrypt_peers; import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.model.AutocryptPeer; -import org.sufficientlysecure.keychain.model.AutocryptPeer.AutocryptKeyStatus; -import org.sufficientlysecure.keychain.model.AutocryptPeer.GossipOrigin; +import org.sufficientlysecure.keychain.SelectAutocryptKeyStatus; +import org.sufficientlysecure.keychain.daos.AutocryptPeerDao; +import org.sufficientlysecure.keychain.daos.KeyWritableRepository; +import org.sufficientlysecure.keychain.model.GossipOrigin; import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult; import org.sufficientlysecure.keychain.pgp.UncachedKeyRing; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; -import org.sufficientlysecure.keychain.daos.AutocryptPeerDao; -import org.sufficientlysecure.keychain.daos.KeyWritableRepository; import timber.log.Timber; @@ -48,17 +48,17 @@ public class AutocryptInteractor { } void updateAutocryptPeerState(String autocryptPeerId, AutocryptPeerUpdate autocryptPeerUpdate) { - AutocryptPeer currentAutocryptPeer = autocryptPeerDao.getAutocryptPeer(packageName, autocryptPeerId); + Autocrypt_peers currentAutocryptPeer = autocryptPeerDao.getAutocryptPeer(packageName, autocryptPeerId); Date effectiveDate = autocryptPeerUpdate.getEffectiveDate(); // 1. If the message’s effective date is older than the peers[from-addr].autocrypt_timestamp value, then no changes are required, and the update process terminates. - Date lastSeenKey = currentAutocryptPeer != null ? currentAutocryptPeer.last_seen_key() : null; + Date lastSeenKey = currentAutocryptPeer != null ? currentAutocryptPeer.getLast_seen_key() : null; if (lastSeenKey != null && effectiveDate.compareTo(lastSeenKey) <= 0) { return; } // 2. If the message’s effective date is more recent than peers[from-addr].last_seen then set peers[from-addr].last_seen to the message’s effective date. - Date lastSeen = currentAutocryptPeer != null ? currentAutocryptPeer.last_seen() : null; + Date lastSeen = currentAutocryptPeer != null ? currentAutocryptPeer.getLast_seen() : null; if (lastSeen == null || effectiveDate.after(lastSeen)) { autocryptPeerDao.insertOrUpdateLastSeen(packageName, autocryptPeerId, effectiveDate); } @@ -83,14 +83,14 @@ public class AutocryptInteractor { } void updateAutocryptPeerGossipState(String autocryptPeerId, AutocryptPeerUpdate autocryptPeerUpdate) { - AutocryptPeer currentAutocryptPeer = autocryptPeerDao.getAutocryptPeer(packageName, autocryptPeerId); + Autocrypt_peers currentAutocryptPeer = autocryptPeerDao.getAutocryptPeer(packageName, autocryptPeerId); Date effectiveDate = autocryptPeerUpdate.getEffectiveDate(); // 1. If gossip-addr does not match any recipient in the mail’s To or Cc header, the update process terminates (i.e., header is ignored). // -> This should be taken care of in the mail client that sends us this data! // 2. If peers[gossip-addr].gossip_timestamp is more recent than the message’s effective date, then the update process terminates. - Date lastSeenGossip = currentAutocryptPeer != null ? currentAutocryptPeer.gossip_last_seen_key() : null; + Date lastSeenGossip = currentAutocryptPeer != null ? currentAutocryptPeer.getGossip_last_seen_key() : null; if (lastSeenGossip != null && lastSeenGossip.after(effectiveDate)) { return; } @@ -150,7 +150,7 @@ public class AutocryptInteractor { public Map determineAutocryptRecommendations(String... autocryptIds) { Map result = new HashMap<>(autocryptIds.length); - for (AutocryptKeyStatus autocryptKeyStatus : autocryptPeerDao.getAutocryptKeyStatus(packageName, autocryptIds)) { + for (SelectAutocryptKeyStatus autocryptKeyStatus : autocryptPeerDao.getAutocryptKeyStatus(packageName, autocryptIds)) { AutocryptRecommendationResult peerResult = determineAutocryptRecommendation(autocryptKeyStatus); result.put(peerResult.peerId, peerResult); } @@ -161,58 +161,60 @@ public class AutocryptInteractor { /** Determines Autocrypt "ui-recommendation", according to spec. * See https://autocrypt.org/level1.html#recommendations-for-single-recipient-messages */ - private AutocryptRecommendationResult determineAutocryptRecommendation(AutocryptKeyStatus autocryptKeyStatus) { + private AutocryptRecommendationResult determineAutocryptRecommendation( + SelectAutocryptKeyStatus autocryptKeyStatus) { AutocryptRecommendationResult keyRecommendation = determineAutocryptKeyRecommendation(autocryptKeyStatus); if (keyRecommendation != null) return keyRecommendation; AutocryptRecommendationResult gossipRecommendation = determineAutocryptGossipRecommendation(autocryptKeyStatus); if (gossipRecommendation != null) return gossipRecommendation; - return new AutocryptRecommendationResult(autocryptKeyStatus.autocryptPeer().identifier(), AutocryptState.DISABLE, null, false); + return new AutocryptRecommendationResult(autocryptKeyStatus.getIdentifier(), AutocryptState.DISABLE, null, false); } @Nullable - private AutocryptRecommendationResult determineAutocryptKeyRecommendation(AutocryptKeyStatus autocryptKeyStatus) { - AutocryptPeer autocryptPeer = autocryptKeyStatus.autocryptPeer(); - - Long masterKeyId = autocryptPeer.master_key_id(); + private AutocryptRecommendationResult determineAutocryptKeyRecommendation( + SelectAutocryptKeyStatus autocryptKeyStatus) { + Long masterKeyId = autocryptKeyStatus.getMaster_key_id(); boolean hasKey = masterKeyId != null; - boolean isRevoked = autocryptKeyStatus.isKeyRevoked(); - boolean isExpired = autocryptKeyStatus.isKeyExpired(); + boolean isRevoked = Boolean.TRUE.equals(autocryptKeyStatus.getKey_is_revoked()); + boolean isExpired = autocryptKeyStatus.getKey_is_expired_int() != 0; if (!hasKey || isRevoked || isExpired) { return null; } - Date lastSeen = autocryptPeer.last_seen(); - Date lastSeenKey = autocryptPeer.last_seen_key(); - boolean isVerified = autocryptKeyStatus.isKeyVerified(); + Date lastSeen = autocryptKeyStatus.getLast_seen(); + Date lastSeenKey = autocryptKeyStatus.getLast_seen_key(); + boolean isVerified = autocryptKeyStatus.getKey_is_verified(); boolean isLastSeenOlderThanDiscourageTimespan = lastSeen != null && lastSeenKey != null && lastSeenKey.getTime() < (lastSeen.getTime() - AUTOCRYPT_DISCOURAGE_THRESHOLD_MILLIS); if (isLastSeenOlderThanDiscourageTimespan) { - return new AutocryptRecommendationResult(autocryptPeer.identifier(), AutocryptState.DISCOURAGED_OLD, masterKeyId, isVerified); + return new AutocryptRecommendationResult(autocryptKeyStatus.getIdentifier(), AutocryptState.DISCOURAGED_OLD, masterKeyId, isVerified); } - boolean isMutual = autocryptPeer.is_mutual(); + boolean isMutual = autocryptKeyStatus.is_mutual(); if (isMutual) { - return new AutocryptRecommendationResult(autocryptPeer.identifier(), AutocryptState.MUTUAL, masterKeyId, isVerified); + return new AutocryptRecommendationResult(autocryptKeyStatus.getIdentifier(), AutocryptState.MUTUAL, masterKeyId, isVerified); } else { - return new AutocryptRecommendationResult(autocryptPeer.identifier(), AutocryptState.AVAILABLE, masterKeyId, isVerified); + return new AutocryptRecommendationResult(autocryptKeyStatus.getIdentifier(), AutocryptState.AVAILABLE, masterKeyId, isVerified); } } @Nullable - private AutocryptRecommendationResult determineAutocryptGossipRecommendation(AutocryptKeyStatus autocryptKeyStatus) { - boolean gossipHasKey = autocryptKeyStatus.hasGossipKey(); - boolean gossipIsRevoked = autocryptKeyStatus.isGossipKeyRevoked(); - boolean gossipIsExpired = autocryptKeyStatus.isGossipKeyExpired(); - boolean isVerified = autocryptKeyStatus.isGossipKeyVerified(); + private AutocryptRecommendationResult determineAutocryptGossipRecommendation( + SelectAutocryptKeyStatus autocryptKeyStatus) { + boolean gossipHasKey = autocryptKeyStatus.getGossip_master_key_id() != null; + boolean gossipIsRevoked = + Boolean.TRUE.equals(autocryptKeyStatus.getGossip_key_is_revoked()); + boolean gossipIsExpired = autocryptKeyStatus.getGossip_key_is_expired_int() != 0; + boolean isVerified = autocryptKeyStatus.getGossip_key_is_verified(); if (!gossipHasKey || gossipIsRevoked || gossipIsExpired) { return null; } - Long masterKeyId = autocryptKeyStatus.autocryptPeer().gossip_master_key_id(); - return new AutocryptRecommendationResult(autocryptKeyStatus.autocryptPeer().identifier(), AutocryptState.DISCOURAGED_GOSSIP, masterKeyId, isVerified); + Long masterKeyId = autocryptKeyStatus.getGossip_master_key_id(); + return new AutocryptRecommendationResult(autocryptKeyStatus.getIdentifier(), AutocryptState.DISCOURAGED_GOSSIP, masterKeyId, isVerified); } public void updateKeyGossipFromSignature(String autocryptId, Date effectiveDate, long masterKeyId) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/KeychainExternalProvider.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/KeychainExternalProvider.java index 831a01e31..d23f88aac 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/KeychainExternalProvider.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/KeychainExternalProvider.java @@ -31,14 +31,15 @@ import android.content.UriMatcher; import android.database.Cursor; import android.database.MatrixCursor; import android.net.Uri; -import androidx.annotation.NonNull; import android.widget.Toast; +import androidx.annotation.NonNull; import org.sufficientlysecure.keychain.BuildConfig; +import org.sufficientlysecure.keychain.UidStatus; import org.sufficientlysecure.keychain.daos.ApiAppDao; import org.sufficientlysecure.keychain.daos.DatabaseNotifyManager; import org.sufficientlysecure.keychain.daos.UserIdDao; -import org.sufficientlysecure.keychain.model.UserPacket.UidStatus; +import org.sufficientlysecure.keychain.model.CustomColumnAdapters; import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus; import org.sufficientlysecure.keychain.provider.KeychainExternalContract; import org.sufficientlysecure.keychain.provider.KeychainExternalContract.AutocryptStatus; @@ -65,7 +66,8 @@ public class KeychainExternalProvider extends ContentProvider { matcher.addURI(authority, KeychainExternalContract.BASE_EMAIL_STATUS, EMAIL_STATUS); matcher.addURI(authority, KeychainExternalContract.BASE_AUTOCRYPT_STATUS, AUTOCRYPT_STATUS); - matcher.addURI(authority, KeychainExternalContract.BASE_AUTOCRYPT_STATUS + "/*", AUTOCRYPT_STATUS_INTERNAL); + matcher.addURI(authority, KeychainExternalContract.BASE_AUTOCRYPT_STATUS + "/*", + AUTOCRYPT_STATUS_INTERNAL); return matcher; } @@ -84,8 +86,9 @@ public class KeychainExternalProvider extends ContentProvider { } @Override - public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, - String sortOrder) { + public Cursor query(@NonNull Uri uri, String[] projection, String selection, + String[] selectionArgs, + String sortOrder) { Timber.v("query(uri=" + uri + ", proj=" + Arrays.toString(projection) + ")"); Context context = getContext(); if (context == null) { @@ -97,7 +100,8 @@ public class KeychainExternalProvider extends ContentProvider { int match = uriMatcher.match(uri); switch (match) { case EMAIL_STATUS: { - Toast.makeText(context, "This API is no longer supported by OpenKeychain!", Toast.LENGTH_SHORT).show(); + Toast.makeText(context, "This API is no longer supported by OpenKeychain!", + Toast.LENGTH_SHORT).show(); return new MatrixCursor(projection); } @@ -107,12 +111,14 @@ public class KeychainExternalProvider extends ContentProvider { } // override package name to use any external - callingPackageName = uri.getLastPathSegment(); + callingPackageName = uri.getLastPathSegment(); case AUTOCRYPT_STATUS: { - boolean callerIsAllowed = (match == AUTOCRYPT_STATUS_INTERNAL) || apiPermissionHelper.isAllowedIgnoreErrors(); + boolean callerIsAllowed = (match == AUTOCRYPT_STATUS_INTERNAL) || + apiPermissionHelper.isAllowedIgnoreErrors(); if (!callerIsAllowed) { - throw new AccessControlException("An application must register before use of KeychainExternalProvider!"); + throw new AccessControlException( + "An application must register before use of KeychainExternalProvider!"); } if (projection == null) { @@ -120,25 +126,32 @@ public class KeychainExternalProvider extends ContentProvider { } List plist = Arrays.asList(projection); - boolean isWildcardSelector = selectionArgs.length == 1 && selectionArgs[0].contains("%"); + boolean isWildcardSelector = + selectionArgs.length == 1 && selectionArgs[0].contains("%"); boolean queriesUidResult = plist.contains(AutocryptStatus.UID_KEY_STATUS) || plist.contains(AutocryptStatus.UID_ADDRESS) || plist.contains(AutocryptStatus.UID_MASTER_KEY_ID) || plist.contains(AutocryptStatus.UID_CANDIDATES); - boolean queriesAutocryptResult = plist.contains(AutocryptStatus.AUTOCRYPT_PEER_STATE) || - plist.contains(AutocryptStatus.AUTOCRYPT_MASTER_KEY_ID) || - plist.contains(AutocryptStatus.AUTOCRYPT_KEY_STATUS); + boolean queriesAutocryptResult = + plist.contains(AutocryptStatus.AUTOCRYPT_PEER_STATE) || + plist.contains(AutocryptStatus.AUTOCRYPT_MASTER_KEY_ID) || + plist.contains(AutocryptStatus.AUTOCRYPT_KEY_STATUS); if (isWildcardSelector && queriesAutocryptResult) { - throw new UnsupportedOperationException("Cannot wildcard-query autocrypt results!"); + throw new UnsupportedOperationException( + "Cannot wildcard-query autocrypt results!"); } Map uidStatuses = queriesUidResult ? - loadUidStatusMap(selectionArgs, isWildcardSelector) : Collections.emptyMap(); - Map autocryptStates = queriesAutocryptResult ? - loadAutocryptRecommendationMap(selectionArgs, callingPackageName) : Collections.emptyMap(); + loadUidStatusMap(selectionArgs, isWildcardSelector) : + Collections.emptyMap(); + Map autocryptStates = + queriesAutocryptResult ? + loadAutocryptRecommendationMap(selectionArgs, callingPackageName) : + Collections.emptyMap(); MatrixCursor cursor = - mapResultsToProjectedMatrixCursor(projection, selectionArgs, uidStatuses, autocryptStates); + mapResultsToProjectedMatrixCursor(projection, selectionArgs, uidStatuses, + autocryptStates); uri = DatabaseNotifyManager.getNotifyUriAllKeys(); cursor.setNotificationUri(context.getContentResolver(), uri); @@ -153,8 +166,10 @@ public class KeychainExternalProvider extends ContentProvider { } @NonNull - private MatrixCursor mapResultsToProjectedMatrixCursor(String[] projection, String[] selectionArgs, - Map uidStatuses, Map autocryptStates) { + private MatrixCursor mapResultsToProjectedMatrixCursor(String[] projection, + String[] selectionArgs, + Map uidStatuses, + Map autocryptStates) { MatrixCursor cursor = new MatrixCursor(projection); for (String selectionArg : selectionArgs) { AutocryptRecommendationResult autocryptResult = autocryptStates.get(selectionArg); @@ -162,7 +177,8 @@ public class KeychainExternalProvider extends ContentProvider { Object[] row = new Object[projection.length]; for (int i = 0; i < projection.length; i++) { - if (AutocryptStatus.ADDRESS.equals(projection[i]) || AutocryptStatus._ID.equals(projection[i])) { + if (AutocryptStatus.ADDRESS.equals(projection[i]) || + AutocryptStatus._ID.equals(projection[i])) { row[i] = selectionArg; } else { row[i] = columnNameToRowContent(projection[i], autocryptResult, uidStatus); @@ -180,7 +196,8 @@ public class KeychainExternalProvider extends ContentProvider { if (uidStatus == null) { return null; } - return uidStatus.keyStatus() == VerificationStatus.VERIFIED_SECRET ? + return CustomColumnAdapters.VERIFICATON_STATUS_ADAPTER.decode( + uidStatus.getKey_status_int()) == VerificationStatus.VERIFIED_SECRET ? KeychainExternalContract.KEY_STATUS_VERIFIED : KeychainExternalContract.KEY_STATUS_UNVERIFIED; } @@ -188,19 +205,19 @@ public class KeychainExternalProvider extends ContentProvider { if (uidStatus == null) { return null; } - return uidStatus.user_id(); + return uidStatus.getUser_id(); case AutocryptStatus.UID_MASTER_KEY_ID: if (uidStatus == null) { return null; } - return uidStatus.master_key_id(); + return uidStatus.getMaster_key_id(); case AutocryptStatus.UID_CANDIDATES: if (uidStatus == null) { return null; } - return uidStatus.candidates(); + return uidStatus.getCandidates(); case AutocryptStatus.AUTOCRYPT_PEER_STATE: if (autocryptResult == null) { @@ -213,7 +230,8 @@ public class KeychainExternalProvider extends ContentProvider { return null; } return autocryptResult.isVerified ? - KeychainExternalContract.KEY_STATUS_VERIFIED : KeychainExternalContract.KEY_STATUS_UNVERIFIED; + KeychainExternalContract.KEY_STATUS_VERIFIED : + KeychainExternalContract.KEY_STATUS_UNVERIFIED; case AutocryptStatus.AUTOCRYPT_MASTER_KEY_ID: if (autocryptResult == null) { @@ -226,10 +244,12 @@ public class KeychainExternalProvider extends ContentProvider { } } - private Map loadUidStatusMap(String[] selectionArgs, boolean isWildcardSelector) { + private Map loadUidStatusMap( + String[] selectionArgs, boolean isWildcardSelector) { UserIdDao userIdDao = UserIdDao.getInstance(getContext()); if (isWildcardSelector) { - UidStatus uidStatus = userIdDao.getUidStatusByEmailLike(selectionArgs[0]); + org.sufficientlysecure.keychain.UidStatus uidStatus = + userIdDao.getUidStatusByEmailLike(selectionArgs[0]); return Collections.singletonMap(selectionArgs[0], uidStatus); } else { return userIdDao.getUidStatusByEmail(selectionArgs); @@ -238,17 +258,23 @@ public class KeychainExternalProvider extends ContentProvider { private Map loadAutocryptRecommendationMap( String[] selectionArgs, String callingPackageName) { - AutocryptInteractor autocryptInteractor = AutocryptInteractor.getInstance(getContext(), callingPackageName); + AutocryptInteractor autocryptInteractor = + AutocryptInteractor.getInstance(getContext(), callingPackageName); return autocryptInteractor.determineAutocryptRecommendations(selectionArgs); } private int getPeerStateValue(AutocryptState autocryptState) { switch (autocryptState) { - case DISABLE: return AutocryptStatus.AUTOCRYPT_PEER_DISABLED; - case DISCOURAGED_OLD: return AutocryptStatus.AUTOCRYPT_PEER_DISCOURAGED_OLD; - case DISCOURAGED_GOSSIP: return AutocryptStatus.AUTOCRYPT_PEER_GOSSIP; - case AVAILABLE: return AutocryptStatus.AUTOCRYPT_PEER_AVAILABLE; - case MUTUAL: return AutocryptStatus.AUTOCRYPT_PEER_MUTUAL; + case DISABLE: + return AutocryptStatus.AUTOCRYPT_PEER_DISABLED; + case DISCOURAGED_OLD: + return AutocryptStatus.AUTOCRYPT_PEER_DISCOURAGED_OLD; + case DISCOURAGED_GOSSIP: + return AutocryptStatus.AUTOCRYPT_PEER_GOSSIP; + case AVAILABLE: + return AutocryptStatus.AUTOCRYPT_PEER_AVAILABLE; + case MUTUAL: + return AutocryptStatus.AUTOCRYPT_PEER_MUTUAL; } throw new IllegalStateException("Unhandled case!"); } @@ -269,7 +295,8 @@ public class KeychainExternalProvider extends ContentProvider { } @Override - public int update(@NonNull Uri uri, ContentValues values, String selection, String[] selectionArgs) { + public int update(@NonNull Uri uri, ContentValues values, String selection, + String[] selectionArgs) { throw new UnsupportedOperationException(); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java index daf5d4fd1..041098240 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -57,7 +57,7 @@ import org.sufficientlysecure.keychain.daos.AutocryptPeerDao; import org.sufficientlysecure.keychain.daos.KeyRepository; import org.sufficientlysecure.keychain.daos.KeyRepository.NotFoundException; import org.sufficientlysecure.keychain.daos.OverriddenWarningsDao; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.operations.BackupOperation; import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult; import org.sufficientlysecure.keychain.operations.results.ExportResult; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/SshAuthenticationService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/SshAuthenticationService.java index 670bda19e..614070242 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/SshAuthenticationService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/SshAuthenticationService.java @@ -43,7 +43,7 @@ import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.daos.ApiAppDao; import org.sufficientlysecure.keychain.daos.KeyRepository; import org.sufficientlysecure.keychain.daos.KeyRepository.NotFoundException; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.operations.results.OperationResult.LogEntryParcel; import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKey; import org.sufficientlysecure.keychain.pgp.SshPublicKey; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java index fd2ba5fa5..114f12470 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java @@ -27,17 +27,17 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; import android.os.Bundle; -import androidx.fragment.app.FragmentManager; import android.view.Menu; import android.view.MenuItem; import android.widget.ImageView; import android.widget.TextView; +import androidx.fragment.app.FragmentManager; import org.bouncycastle.util.encoders.Hex; +import org.sufficientlysecure.keychain.Api_apps; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.model.ApiApp; -import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.daos.ApiAppDao; +import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.ui.base.BaseActivity; import org.sufficientlysecure.keychain.ui.dialog.AdvancedAppSettingsDialogFragment; import timber.log.Timber; @@ -53,7 +53,7 @@ public class AppSettingsActivity extends BaseActivity { // model - ApiApp mApiApp; + Api_apps mApiApp; private ApiAppDao apiAppDao; @Override @@ -140,7 +140,7 @@ public class AppSettingsActivity extends BaseActivity { // advanced info: package certificate SHA-256 try { MessageDigest md = MessageDigest.getInstance("SHA-256"); - md.update(mApiApp.package_signature()); + md.update(mApiApp.getPackage_signature()); byte[] digest = md.digest(); certificate = new String(Hex.encode(digest)); } catch (NoSuchAlgorithmException e) { @@ -148,7 +148,7 @@ public class AppSettingsActivity extends BaseActivity { } AdvancedAppSettingsDialogFragment dialogFragment = - AdvancedAppSettingsDialogFragment.newInstance(mApiApp.package_name(), certificate); + AdvancedAppSettingsDialogFragment.newInstance(mApiApp.getPackage_name(), certificate); dialogFragment.show(getSupportFragmentManager(), "advancedDialog"); } @@ -157,7 +157,7 @@ public class AppSettingsActivity extends BaseActivity { Intent i; PackageManager manager = getPackageManager(); try { - i = manager.getLaunchIntentForPackage(mApiApp.package_name()); + i = manager.getLaunchIntentForPackage(mApiApp.getPackage_name()); if (i == null) throw new PackageManager.NameNotFoundException(); // start like the Android launcher would do @@ -177,13 +177,13 @@ public class AppSettingsActivity extends BaseActivity { Drawable appIcon = null; PackageManager pm = getApplicationContext().getPackageManager(); try { - ApplicationInfo ai = pm.getApplicationInfo(mApiApp.package_name(), 0); + ApplicationInfo ai = pm.getApplicationInfo(mApiApp.getPackage_name(), 0); appName = (String) pm.getApplicationLabel(ai); appIcon = pm.getApplicationIcon(ai); } catch (PackageManager.NameNotFoundException e) { // fallback - appName = mApiApp.package_name(); + appName = mApiApp.getPackage_name(); } mAppNameView.setText(appName); mAppIconView.setImageDrawable(appIcon); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsAllowedKeysListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsAllowedKeysListFragment.java index 0e8beddcd..1c5e1368b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsAllowedKeysListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsAllowedKeysListFragment.java @@ -27,7 +27,7 @@ import android.os.Bundle; import androidx.recyclerview.widget.LinearLayoutManager; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.daos.ApiAppDao; import org.sufficientlysecure.keychain.daos.KeyRepository; import org.sufficientlysecure.keychain.ui.adapter.KeyChoiceAdapter; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteRegisterPresenter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteRegisterPresenter.java index e87ac4eb1..b6e58b7e4 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteRegisterPresenter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteRegisterPresenter.java @@ -25,8 +25,8 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.graphics.drawable.Drawable; +import org.sufficientlysecure.keychain.Api_apps; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.model.ApiApp; import org.sufficientlysecure.keychain.daos.ApiAppDao; import timber.log.Timber; @@ -39,7 +39,7 @@ class RemoteRegisterPresenter { private RemoteRegisterView view; private Intent resultData; - private ApiApp apiApp; + private Api_apps apiApp; RemoteRegisterPresenter(Context context) { @@ -54,7 +54,7 @@ class RemoteRegisterPresenter { } void setupFromIntentData(Intent resultData, String packageName, byte[] packageSignature) { - this.apiApp = ApiApp.create(packageName, packageSignature); + this.apiApp = new Api_apps(0L, packageName, packageSignature); this.resultData = resultData; try { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RequestKeyPermissionPresenter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RequestKeyPermissionPresenter.java index 29a3c3e53..cf9c30a97 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RequestKeyPermissionPresenter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RequestKeyPermissionPresenter.java @@ -26,7 +26,7 @@ import android.graphics.drawable.Drawable; import androidx.annotation.Nullable; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType; import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; import org.sufficientlysecure.keychain.daos.ApiAppDao; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/SelectPublicKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/SelectPublicKeyFragment.java index 1a8ae735c..50ad8f024 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/SelectPublicKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/SelectPublicKeyFragment.java @@ -31,7 +31,7 @@ import androidx.annotation.NonNull; import androidx.recyclerview.widget.LinearLayoutManager; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.daos.KeyRepository; import org.sufficientlysecure.keychain.ui.adapter.KeyChoiceAdapter; import org.sufficientlysecure.keychain.ui.base.RecyclerFragment; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/SelectSignKeyIdListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/SelectSignKeyIdListFragment.java index 365935bce..6f7990c50 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/SelectSignKeyIdListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/SelectSignKeyIdListFragment.java @@ -21,24 +21,23 @@ package org.sufficientlysecure.keychain.remote.ui; import java.util.List; import android.app.Activity; -import androidx.lifecycle.LiveData; -import androidx.lifecycle.ViewModelProviders; import android.content.Intent; import android.os.Bundle; -import androidx.recyclerview.widget.LinearLayoutManager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; +import androidx.lifecycle.LiveData; +import androidx.lifecycle.ViewModelProviders; +import androidx.recyclerview.widget.LinearLayoutManager; import org.openintents.openpgp.util.OpenPgpApi; import org.openintents.openpgp.util.OpenPgpUtils; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.model.ApiApp; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; -import org.sufficientlysecure.keychain.pgp.KeyRing; import org.sufficientlysecure.keychain.daos.ApiAppDao; import org.sufficientlysecure.keychain.daos.KeyRepository; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.pgp.KeyRing; import org.sufficientlysecure.keychain.ui.CreateKeyActivity; import org.sufficientlysecure.keychain.ui.adapter.KeyChoiceAdapter; import org.sufficientlysecure.keychain.ui.base.RecyclerFragment; @@ -117,7 +116,7 @@ public class SelectSignKeyIdListFragment extends RecyclerFragment> liveData = viewModel.getGenericLiveData( requireContext(), keyRepository::getAllUnifiedKeyInfoWithSecret); - liveData.observe(this, this::onLoadUnifiedKeyData); + liveData.observe(getViewLifecycleOwner(), this::onLoadUnifiedKeyData); } public void onLoadUnifiedKeyData(List data) { @@ -155,8 +154,7 @@ public class SelectSignKeyIdListFragment extends RecyclerFragment subKeys = keyRepository.getSubKeysByMasterKeyId(saveKeyResult.mMasterKeyId); - for (SubKey subKey : subKeys) { - builder.addOrReplaceSubkeyChange(SubkeyChange.createMoveToSecurityTokenChange(subKey.key_id())); + List subKeys = keyRepository.getSubKeysByMasterKeyId(saveKeyResult.mMasterKeyId); + for (Keys subKey : subKeys) { + builder.addOrReplaceSubkeyChange(SubkeyChange.createMoveToSecurityTokenChange(subKey.getKey_id())); } // define new PIN and Admin PIN for the card diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java index 5982a145e..0f1b42057 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java @@ -40,7 +40,7 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.keyimport.HkpKeyserverAddress; import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing; import org.sufficientlysecure.keychain.livedata.GenericLiveData; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult; import org.sufficientlysecure.keychain.operations.results.ImportKeyResult; import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DeleteKeyDialogActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DeleteKeyDialogActivity.java index 2b0d4fedf..e85b34634 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DeleteKeyDialogActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DeleteKeyDialogActivity.java @@ -37,7 +37,7 @@ import android.widget.Spinner; import android.widget.TextView; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.operations.results.DeleteResult; import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.operations.results.RevokeResult; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptModeAsymmetricFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptModeAsymmetricFragment.java index ee1a690f1..e1a1150da 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptModeAsymmetricFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptModeAsymmetricFragment.java @@ -39,7 +39,7 @@ import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.daos.KeyRepository; import org.sufficientlysecure.keychain.livedata.GenericLiveData; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.ui.chips.EncryptRecipientChipsInput; import org.sufficientlysecure.keychain.ui.chips.EncryptRecipientChipsInput.EncryptRecipientChip; import org.sufficientlysecure.keychain.ui.widget.KeySpinner; @@ -121,8 +121,8 @@ public class EncryptModeAsymmetricFragment extends EncryptModeFragment { super.onActivityCreated(savedInstanceState); EncryptModeViewModel viewModel = ViewModelProviders.of(this).get(EncryptModeViewModel.class); - viewModel.getSignKeyLiveData(requireContext()).observe(this, mSignKeySpinner::setData); - viewModel.getEncryptRecipientLiveData(requireContext()).observe(this, mEncryptKeyView::setData); + viewModel.getSignKeyLiveData(requireContext()).observe(getViewLifecycleOwner(), mSignKeySpinner::setData); + viewModel.getEncryptRecipientLiveData(requireContext()).observe(getViewLifecycleOwner(), mEncryptKeyView::setData); // preselect keys given, from state or arguments if (savedInstanceState == null) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index 4b26c337d..d2767665f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -58,7 +58,7 @@ import org.sufficientlysecure.keychain.compatibility.ClipboardReflection; import org.sufficientlysecure.keychain.daos.DatabaseNotifyManager; import org.sufficientlysecure.keychain.daos.KeyRepository; import org.sufficientlysecure.keychain.keysync.KeyserverSyncManager; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.operations.KeySyncParcel; import org.sufficientlysecure.keychain.operations.results.BenchmarkResult; import org.sufficientlysecure.keychain.operations.results.ImportKeyResult; @@ -252,7 +252,7 @@ public class KeyListFragment extends RecyclerFragment> liveData = viewModel.getGenericLiveData(requireContext(), this::loadFlexibleKeyItems); - liveData.observe(this, this::onLoadKeyItems); + liveData.observe(getViewLifecycleOwner(), this::onLoadKeyItems); } @WorkerThread diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MultiUserIdsFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MultiUserIdsFragment.java index d18320ace..5b6ec92cd 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MultiUserIdsFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MultiUserIdsFragment.java @@ -21,23 +21,23 @@ package org.sufficientlysecure.keychain.ui; import java.util.ArrayList; import java.util.List; -import androidx.lifecycle.LiveData; import android.database.MatrixCursor; import android.os.Bundle; import android.os.Parcel; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentActivity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; +import androidx.lifecycle.LiveData; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.livedata.GenericLiveData; -import org.sufficientlysecure.keychain.model.UserPacket.UserId; import org.sufficientlysecure.keychain.daos.KeyRepository; +import org.sufficientlysecure.keychain.livedata.GenericLiveData; +import org.sufficientlysecure.keychain.model.UserId; import org.sufficientlysecure.keychain.service.CertifyActionsParcel; import org.sufficientlysecure.keychain.ui.adapter.MultiUserIdsAdapter; import timber.log.Timber; @@ -85,7 +85,7 @@ public class MultiUserIdsFragment extends Fragment { KeyRepository keyRepository = KeyRepository.create(activity); LiveData> userIdLiveData = new GenericLiveData<>(getContext(), () -> keyRepository.getUserIds(pubMasterKeyIds)); - userIdLiveData.observe(this, this::onUserIdsLoaded); + userIdLiveData.observe(getViewLifecycleOwner(), this::onUserIdsLoaded); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java index 24c431436..9c3f01212 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java @@ -52,7 +52,7 @@ import android.widget.ViewAnimator; import org.openintents.openpgp.util.OpenPgpUtils; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeViewActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeViewActivity.java index 0a2d2126e..dbfdc629c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeViewActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeViewActivity.java @@ -28,7 +28,7 @@ import android.widget.ImageView; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.ui.base.BaseActivity; import org.sufficientlysecure.keychain.ui.keyview.UnifiedKeyInfoViewModel; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SubKeyItem.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SubKeyItem.java index 178abf307..b03dc6bae 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SubKeyItem.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SubKeyItem.java @@ -9,19 +9,19 @@ import java.util.TimeZone; import android.content.Context; import android.graphics.PorterDuff; import android.graphics.Typeface; -import androidx.annotation.StringRes; import android.text.format.DateFormat; import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageView; import android.widget.TextView; +import androidx.annotation.StringRes; import eu.davidea.flexibleadapter.FlexibleAdapter; import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; import eu.davidea.flexibleadapter.items.IFlexible; import eu.davidea.viewholders.FlexibleViewHolder; +import org.sufficientlysecure.keychain.Keys; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.model.SubKey; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType; import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm; import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Builder; @@ -32,22 +32,22 @@ import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; public class SubKeyItem extends AbstractFlexibleItem { - final SubKey subkeyInfo; + final Keys subkeyInfo; private final SubkeyEditViewModel viewModel; - SubKeyItem(SubKey subkeyInfo, SubkeyEditViewModel viewModel) { + SubKeyItem(Keys subkeyInfo, SubkeyEditViewModel viewModel) { this.subkeyInfo = subkeyInfo; this.viewModel = viewModel; } @Override public boolean equals(Object o) { - return o instanceof SubKeyItem && ((SubKeyItem) o).subkeyInfo.key_id() == subkeyInfo.key_id(); + return o instanceof SubKeyItem && ((SubKeyItem) o).subkeyInfo.getKey_id() == subkeyInfo.getKey_id(); } @Override public int hashCode() { - long key_id = subkeyInfo.key_id(); + long key_id = subkeyInfo.getKey_id(); return (int) (key_id ^ (key_id >>> 32)); } @@ -100,13 +100,13 @@ public class SubKeyItem extends AbstractFlexibleItem { - saveKeyringParcelBuilder.removeModificationsForSubkey(subkeyInfo.key_id()); + saveKeyringParcelBuilder.removeModificationsForSubkey(subkeyInfo.getKey_id()); mAdapter.notifyItemChanged(getAdapterPosition()); }; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java index 27e259855..81f136eef 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java @@ -42,16 +42,15 @@ import androidx.lifecycle.ViewModelProviders; import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager.OnPageChangeListener; import com.astuetz.PagerSlidingTabStrip; +import org.sufficientlysecure.keychain.Keys; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.daos.KeyRepository; import org.sufficientlysecure.keychain.livedata.GenericLiveData; -import org.sufficientlysecure.keychain.model.SubKey; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; -import org.sufficientlysecure.keychain.model.UserPacket.UserId; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UserId; import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter; import org.sufficientlysecure.keychain.ui.base.BaseActivity; -import org.sufficientlysecure.keychain.ui.keyview.ViewKeyActivity; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; @@ -112,7 +111,7 @@ public class ViewKeyAdvActivity extends BaseActivity implements OnPageChangeList public static class ViewKeyAdvViewModel extends ViewModel { private Long masterKeyId; private LiveData unifiedKeyInfoLiveData; - private LiveData> subKeyLiveData; + private LiveData> subKeyLiveData; private LiveData> userIdsLiveData; void setMasterKeyId(long masterKeyId) { @@ -134,7 +133,7 @@ public class ViewKeyAdvActivity extends BaseActivity implements OnPageChangeList return unifiedKeyInfoLiveData; } - LiveData> getSubkeyLiveData(Context context) { + LiveData> getSubkeyLiveData(Context context) { if (subKeyLiveData == null) { KeyRepository keyRepository = KeyRepository.create(context); subKeyLiveData = Transformations.switchMap(getUnifiedKeyInfoLiveData(context), diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvShareFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvShareFragment.java index bba11d1de..10d2ca098 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvShareFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvShareFragment.java @@ -45,7 +45,7 @@ import android.widget.TextView; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.livedata.GenericLiveData; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.ui.ViewKeyAdvActivity.ViewKeyAdvViewModel; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.ui.util.Notify; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvSubkeysFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvSubkeysFragment.java index 9a7928821..5b5be5dfe 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvSubkeysFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvSubkeysFragment.java @@ -21,18 +21,11 @@ package org.sufficientlysecure.keychain.ui; import java.util.ArrayList; import java.util.List; -import androidx.lifecycle.ViewModel; -import androidx.lifecycle.ViewModelProviders; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.os.Messenger; -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentActivity; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; import android.view.ActionMode; import android.view.LayoutInflater; import android.view.Menu; @@ -41,13 +34,20 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ViewAnimator; +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; +import androidx.lifecycle.ViewModel; +import androidx.lifecycle.ViewModelProviders; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import eu.davidea.flexibleadapter.FlexibleAdapter; import eu.davidea.flexibleadapter.FlexibleAdapter.OnItemClickListener; import eu.davidea.flexibleadapter.items.IFlexible; +import org.sufficientlysecure.keychain.Keys; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; -import org.sufficientlysecure.keychain.model.SubKey; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.operations.results.EditKeyResult; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType; import org.sufficientlysecure.keychain.service.SaveKeyringParcel; @@ -99,8 +99,8 @@ public class ViewKeyAdvSubkeysFragment extends Fragment { subkeysList.setAdapter(subkeysAdapter); ViewKeyAdvViewModel viewModel = ViewModelProviders.of(requireActivity()).get(ViewKeyAdvViewModel.class); - viewModel.getUnifiedKeyInfoLiveData(requireContext()).observe(this, this::onLoadUnifiedKeyId); - viewModel.getSubkeyLiveData(requireContext()).observe(this, this::onLoadSubKeys); + viewModel.getUnifiedKeyInfoLiveData(requireContext()).observe(getViewLifecycleOwner(), this::onLoadUnifiedKeyId); + viewModel.getSubkeyLiveData(requireContext()).observe(getViewLifecycleOwner(), this::onLoadSubKeys); subkeyEditViewModel = ViewModelProviders.of(this).get(SubkeyEditViewModel.class); } @@ -114,9 +114,9 @@ public class ViewKeyAdvSubkeysFragment extends Fragment { subkeyEditViewModel.unifiedKeyInfo = unifiedKeyInfo; } - private void onLoadSubKeys(List subKeys) { + private void onLoadSubKeys(List subKeys) { ArrayList subKeyItems = new ArrayList<>(subKeys.size()); - for (SubKey subKey : subKeys) { + for (Keys subKey : subKeys) { subKeyItems.add(new SubKeyItem(subKey, subkeyEditViewModel)); } subkeysAdapter.updateDataSet(subKeyItems); @@ -207,7 +207,7 @@ public class ViewKeyAdvSubkeysFragment extends Fragment { } private void editSubkey(int position, SubKeyItem item) { - if (subkeyEditViewModel.skpBuilder.hasModificationsForSubkey(item.subkeyInfo.key_id())) { + if (subkeyEditViewModel.skpBuilder.hasModificationsForSubkey(item.subkeyInfo.getKey_id())) { return; } @@ -219,8 +219,8 @@ public class ViewKeyAdvSubkeysFragment extends Fragment { editSubkeyExpiry(item); break; case EditSubkeyDialogFragment.MESSAGE_REVOKE: - SubKey subKey = item.subkeyInfo; - subkeyEditViewModel.skpBuilder.addRevokeSubkey(subKey.key_id()); + Keys subKey = item.subkeyInfo; + subkeyEditViewModel.skpBuilder.addRevokeSubkey(subKey.getKey_id()); break; case EditSubkeyDialogFragment.MESSAGE_STRIP: { editSubkeyToggleStrip(item); @@ -241,21 +241,21 @@ public class ViewKeyAdvSubkeysFragment extends Fragment { } private void editSubkeyToggleStrip(SubKeyItem item) { - SubKey subKey = item.subkeyInfo; - if (subKey.has_secret() == SecretKeyType.GNU_DUMMY) { + Keys subKey = item.subkeyInfo; + if (subKey.getHas_secret() == SecretKeyType.GNU_DUMMY) { // Key is already stripped; this is a no-op. return; } - subkeyEditViewModel.skpBuilder.addOrReplaceSubkeyChange(SubkeyChange.createStripChange(subKey.key_id())); + subkeyEditViewModel.skpBuilder.addOrReplaceSubkeyChange(SubkeyChange.createStripChange(subKey.getKey_id())); } private void editSubkeyExpiry(SubKeyItem item) { - SubKey subKey = item.subkeyInfo; + Keys subKey = item.subkeyInfo; - final long keyId = subKey.key_id(); - final Long creationDate = subKey.creation(); - final Long expiryDate = subKey.expiry(); + final long keyId = subKey.getKey_id(); + final Long creationDate = subKey.getCreation(); + final Long expiryDate = subKey.getExpiry(); Handler returnHandler = new Handler() { @Override diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvUserIdsFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvUserIdsFragment.java index 0a9a67c4e..c2e3bbacd 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvUserIdsFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvUserIdsFragment.java @@ -20,15 +20,11 @@ package org.sufficientlysecure.keychain.ui; import java.util.List; -import androidx.lifecycle.ViewModelProviders; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.os.Messenger; -import androidx.annotation.NonNull; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentActivity; import android.view.ActionMode; import android.view.LayoutInflater; import android.view.Menu; @@ -38,10 +34,14 @@ import android.view.ViewGroup; import android.widget.ListView; import android.widget.ViewAnimator; +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; +import androidx.lifecycle.ViewModelProviders; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; -import org.sufficientlysecure.keychain.model.UserPacket.UserId; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UserId; import org.sufficientlysecure.keychain.operations.results.EditKeyResult; import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus; import org.sufficientlysecure.keychain.service.SaveKeyringParcel; @@ -196,8 +196,8 @@ public class ViewKeyAdvUserIdsFragment extends Fragment { mUserIds.setAdapter(mUserIdsAdapter); ViewKeyAdvViewModel viewModel = ViewModelProviders.of(requireActivity()).get(ViewKeyAdvViewModel.class); - viewModel.getUnifiedKeyInfoLiveData(requireContext()).observe(this, this::onLoadUnifiedKeyInfo); - viewModel.getUserIdLiveData(requireContext()).observe(this, this::onLoadUserIds); + viewModel.getUnifiedKeyInfoLiveData(requireContext()).observe(getViewLifecycleOwner(), this::onLoadUnifiedKeyInfo); + viewModel.getUserIdLiveData(requireContext()).observe(getViewLifecycleOwner(), this::onLoadUserIds); } public void onLoadUnifiedKeyInfo(UnifiedKeyInfo unifiedKeyInfo) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/FlexibleKeyDetailsItem.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/FlexibleKeyDetailsItem.java index 372bd0830..b791ba798 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/FlexibleKeyDetailsItem.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/FlexibleKeyDetailsItem.java @@ -14,7 +14,7 @@ import eu.davidea.flexibleadapter.items.IFlexible; import eu.davidea.viewholders.FlexibleViewHolder; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.ui.adapter.FlexibleKeyDetailsItem.FlexibleKeyItemViewHolder; import org.sufficientlysecure.keychain.ui.adapter.FlexibleKeyItem.FlexibleSectionableKeyItem; import org.sufficientlysecure.keychain.ui.util.KeyInfoFormatter; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/FlexibleKeyItemFactory.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/FlexibleKeyItemFactory.java index fa8b14835..905f6bd2a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/FlexibleKeyItemFactory.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/FlexibleKeyItemFactory.java @@ -10,7 +10,7 @@ import android.content.res.Resources; import androidx.annotation.NonNull; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; public class FlexibleKeyItemFactory { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java index 543454b04..cf1a9ca4b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java @@ -32,9 +32,6 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; -import androidx.databinding.DataBindingUtil; -import androidx.fragment.app.FragmentActivity; -import androidx.recyclerview.widget.RecyclerView; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.daos.KeyRepository; import org.sufficientlysecure.keychain.databinding.ImportKeysListItemBinding; @@ -44,7 +41,7 @@ import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing; import org.sufficientlysecure.keychain.keyimport.processing.ImportKeysListener; import org.sufficientlysecure.keychain.keyimport.processing.ImportKeysOperationCallback; import org.sufficientlysecure.keychain.keyimport.processing.ImportKeysResultListener; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.operations.ImportOperation; import org.sufficientlysecure.keychain.operations.results.ImportKeyResult; import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyChoiceAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyChoiceAdapter.java index 7322dbaed..2fb7c02ff 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyChoiceAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyChoiceAdapter.java @@ -22,7 +22,7 @@ import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; import eu.davidea.flexibleadapter.items.IFlexible; import eu.davidea.viewholders.FlexibleViewHolder; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.ui.adapter.KeyChoiceAdapter.KeyChoiceItem; import org.sufficientlysecure.keychain.ui.util.KeyInfoFormatter; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java index d19c61617..901910ae6 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java @@ -33,7 +33,7 @@ import android.widget.TextView; import android.widget.ViewAnimator; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.model.UserPacket.UserId; +import org.sufficientlysecure.keychain.model.UserId; import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing.VerificationStatus; import org.sufficientlysecure.keychain.service.SaveKeyringParcel; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/chips/EncryptRecipientChipAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/chips/EncryptRecipientChipAdapter.java index d22c0da88..65c245c4e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/chips/EncryptRecipientChipAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/chips/EncryptRecipientChipAdapter.java @@ -7,6 +7,7 @@ import androidx.recyclerview.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.materialchips.ChipView; import org.sufficientlysecure.materialchips.ChipsInput; import org.sufficientlysecure.materialchips.adapter.ChipsAdapter; @@ -15,7 +16,6 @@ import org.sufficientlysecure.materialchips.util.ViewUtil; import org.sufficientlysecure.materialchips.views.DetailedChipView; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.model.SubKey; import org.sufficientlysecure.keychain.ui.chips.EncryptRecipientChipAdapter.ItemViewHolder; import org.sufficientlysecure.keychain.ui.chips.EncryptRecipientChipsInput.EncryptRecipientChip; @@ -63,7 +63,7 @@ public class EncryptRecipientChipAdapter extends ChipsAdapter> identityInfo; private LiveData subkeyStatus; - private LiveData keyserverStatus; + private LiveData keyserverStatus; LiveData> getIdentityInfo(Context context, LiveData unifiedKeyInfoLiveData) { if (identityInfo == null) { @@ -43,7 +43,7 @@ public class KeyFragmentViewModel extends ViewModel { return subkeyStatus; } - LiveData getKeyserverStatus(Context context, LiveData unifiedKeyInfoLiveData) { + LiveData getKeyserverStatus(Context context, LiveData unifiedKeyInfoLiveData) { if (keyserverStatus == null) { KeyMetadataDao keyMetadataDao = KeyMetadataDao.create(context); keyserverStatus = Transformations.switchMap(unifiedKeyInfoLiveData, diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/UnifiedKeyInfoViewModel.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/UnifiedKeyInfoViewModel.java index b7d0ad065..86a2dbf41 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/UnifiedKeyInfoViewModel.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/UnifiedKeyInfoViewModel.java @@ -1,15 +1,15 @@ package org.sufficientlysecure.keychain.ui.keyview; -import androidx.lifecycle.LiveData; -import androidx.lifecycle.ViewModel; import android.content.Context; import android.net.Uri; -import org.sufficientlysecure.keychain.livedata.GenericLiveData; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import androidx.lifecycle.LiveData; +import androidx.lifecycle.ViewModel; import org.sufficientlysecure.keychain.daos.DatabaseNotifyManager; import org.sufficientlysecure.keychain.daos.KeyRepository; +import org.sufficientlysecure.keychain.livedata.GenericLiveData; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; public class UnifiedKeyInfoViewModel extends ViewModel { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/ViewKeyActivity.java index 4951f6441..d15aa66d1 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/ViewKeyActivity.java @@ -70,7 +70,7 @@ import org.sufficientlysecure.keychain.daos.KeyRepository; import org.sufficientlysecure.keychain.daos.KeyRepository.NotFoundException; import org.sufficientlysecure.keychain.keyimport.HkpKeyserverAddress; import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.operations.results.EditKeyResult; import org.sufficientlysecure.keychain.operations.results.ImportKeyResult; import org.sufficientlysecure.keychain.operations.results.OperationResult; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/ViewKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/ViewKeyFragment.java index b8d7d1d79..d40d746d5 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/ViewKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/ViewKeyFragment.java @@ -35,11 +35,11 @@ import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; import androidx.lifecycle.LiveData; import androidx.lifecycle.ViewModelProvider; +import org.sufficientlysecure.keychain.Key_metadata; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; import org.sufficientlysecure.keychain.daos.AutocryptPeerDao; -import org.sufficientlysecure.keychain.model.KeyMetadata; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType; import org.sufficientlysecure.keychain.ui.adapter.IdentityAdapter; @@ -265,16 +265,16 @@ public class ViewKeyFragment extends Fragment implements OnMenuItemClickListener identitiesAdapter.setData(identityInfos); } - private void onLoadKeyMetadata(KeyMetadata keyMetadata) { + private void onLoadKeyMetadata(Key_metadata keyMetadata) { if (keyMetadata == null) { keyserverStatusView.setDisplayStatusUnknown(); - } else if (keyMetadata.hasBeenUpdated()) { - if (keyMetadata.isPublished()) { + } else if (keyMetadata.getLast_updated() != null) { + if (keyMetadata.getSeen_on_keyservers() != null && keyMetadata.getSeen_on_keyservers()) { keyserverStatusView.setDisplayStatusPublished(); } else { keyserverStatusView.setDisplayStatusNotPublished(); } - keyserverStatusView.setLastUpdated(keyMetadata.last_updated()); + keyserverStatusView.setLastUpdated(keyMetadata.getLast_updated()); } else { keyserverStatusView.setDisplayStatusUnknown(); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/IdentityDao.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/IdentityDao.java index b64a84f91..dc711b77e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/IdentityDao.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/IdentityDao.java @@ -22,47 +22,43 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import androidx.sqlite.db.SupportSQLiteDatabase; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; -import android.database.Cursor; import android.graphics.drawable.Drawable; -import androidx.annotation.Nullable; +import androidx.annotation.Nullable; import com.google.auto.value.AutoValue; -import com.squareup.sqldelight.SqlDelightQuery; import org.openintents.openpgp.util.OpenPgpApi; -import org.sufficientlysecure.keychain.KeychainDatabase; +import org.sufficientlysecure.keychain.Autocrypt_peers; import org.sufficientlysecure.keychain.daos.AutocryptPeerDao; -import org.sufficientlysecure.keychain.model.AutocryptPeer; -import org.sufficientlysecure.keychain.model.UserPacket; -import org.sufficientlysecure.keychain.model.UserPacket.UserId; +import org.sufficientlysecure.keychain.daos.UserIdDao; +import org.sufficientlysecure.keychain.model.UserId; import org.sufficientlysecure.keychain.ui.util.PackageIconGetter; public class IdentityDao { - private final SupportSQLiteDatabase db; private final PackageIconGetter packageIconGetter; private final PackageManager packageManager; private final AutocryptPeerDao autocryptPeerDao; + private final UserIdDao userIdDao; public static IdentityDao getInstance(Context context) { - SupportSQLiteDatabase db = KeychainDatabase.getInstance(context).getWritableDatabase(); PackageManager packageManager = context.getPackageManager(); PackageIconGetter iconGetter = PackageIconGetter.getInstance(context); AutocryptPeerDao autocryptPeerDao = AutocryptPeerDao.getInstance(context); - return new IdentityDao(db, packageManager, iconGetter, autocryptPeerDao); + UserIdDao userIdDao = UserIdDao.getInstance(context); + return new IdentityDao(packageManager, iconGetter, autocryptPeerDao, userIdDao); } - private IdentityDao(SupportSQLiteDatabase db, - PackageManager packageManager, PackageIconGetter iconGetter, - AutocryptPeerDao autocryptPeerDao) { - this.db = db; + private IdentityDao(PackageManager packageManager, + PackageIconGetter iconGetter, AutocryptPeerDao autocryptPeerDao, + UserIdDao userIdDao) { this.packageManager = packageManager; this.packageIconGetter = iconGetter; this.autocryptPeerDao = autocryptPeerDao; + this.userIdDao = userIdDao; } public List getIdentityInfos(long masterKeyId) { @@ -74,29 +70,36 @@ public class IdentityDao { return Collections.unmodifiableList(identities); } - private void correlateOrAddAutocryptPeers(ArrayList identities, long masterKeyId) { - for (AutocryptPeer autocryptPeer : autocryptPeerDao.getAutocryptPeersForKey(masterKeyId)) { - String packageName = autocryptPeer.package_name(); - String autocryptId = autocryptPeer.identifier(); + private void correlateOrAddAutocryptPeers(ArrayList identities, + long masterKeyId) { + for (Autocrypt_peers autocryptPeer : autocryptPeerDao.getAutocryptPeersForKey( + masterKeyId)) { + String packageName = autocryptPeer.getPackage_name(); + String autocryptId = autocryptPeer.getIdentifier(); Drawable drawable = packageIconGetter.getDrawableForPackageName(packageName); - Intent autocryptPeerIntent = getAutocryptPeerActivityIntentIfResolvable(packageName, autocryptId); + Intent autocryptPeerIntent = + getAutocryptPeerActivityIntentIfResolvable(packageName, autocryptId); - UserIdInfo associatedUserIdInfo = findUserIdMatchingAutocryptPeer(identities, autocryptId); + UserIdInfo associatedUserIdInfo = + findUserIdMatchingAutocryptPeer(identities, autocryptId); if (associatedUserIdInfo != null) { int position = identities.indexOf(associatedUserIdInfo); AutocryptPeerInfo autocryptPeerInfo = AutocryptPeerInfo - .create(masterKeyId, associatedUserIdInfo, autocryptId, packageName, drawable, autocryptPeerIntent); + .create(masterKeyId, associatedUserIdInfo, autocryptId, packageName, + drawable, autocryptPeerIntent); identities.set(position, autocryptPeerInfo); } else { AutocryptPeerInfo autocryptPeerInfo = AutocryptPeerInfo - .create(masterKeyId, autocryptId, packageName, drawable, autocryptPeerIntent); + .create(masterKeyId, autocryptId, packageName, drawable, + autocryptPeerIntent); identities.add(autocryptPeerInfo); } } } - private Intent getAutocryptPeerActivityIntentIfResolvable(String packageName, String autocryptPeer) { + private Intent getAutocryptPeerActivityIntentIfResolvable(String packageName, + String autocryptPeer) { Intent intent = new Intent(); intent.setAction("org.autocrypt.PEER_ACTION"); intent.setPackage(packageName); @@ -111,7 +114,8 @@ public class IdentityDao { } } - private static UserIdInfo findUserIdMatchingAutocryptPeer(List identities, String autocryptPeer) { + private static UserIdInfo findUserIdMatchingAutocryptPeer(List identities, + String autocryptPeer) { for (IdentityInfo identityInfo : identities) { if (identityInfo instanceof UserIdInfo) { UserIdInfo userIdInfo = (UserIdInfo) identityInfo; @@ -123,72 +127,90 @@ public class IdentityDao { return null; } - private void loadUserIds(ArrayList identities, long... masterKeyId) { - SqlDelightQuery query = UserPacket.FACTORY.selectUserIdsByMasterKeyId(masterKeyId); - try (Cursor cursor = db.query(query)) { - while (cursor.moveToNext()) { - UserId userId = UserPacket.USER_ID_MAPPER.map(cursor); - - if (userId.name() != null || userId.email() != null) { - IdentityInfo identityInfo = UserIdInfo.create( - userId.master_key_id(), userId.rank(), userId.isVerified(), userId.is_primary(), userId.name(), userId.email(), userId.comment()); - identities.add(identityInfo); - } + private void loadUserIds(ArrayList identities, long... masterKeyIds) { + for (UserId userId : userIdDao.getUserIdsByMasterKeyIds(masterKeyIds)) { + if (userId.name() != null || userId.email() != null) { + IdentityInfo identityInfo = UserIdInfo.create( + userId.master_key_id(), userId.rank(), userId.isVerified(), + userId.is_primary(), userId.name(), userId.email(), userId.email()); + identities.add(identityInfo); } } } public interface IdentityInfo { long getMasterKeyId(); + int getRank(); + boolean isVerified(); + boolean isPrimary(); } @AutoValue public abstract static class UserIdInfo implements IdentityInfo { public abstract long getMasterKeyId(); + public abstract int getRank(); + public abstract boolean isVerified(); + public abstract boolean isPrimary(); @Nullable public abstract String getName(); + @Nullable public abstract String getEmail(); + @Nullable public abstract String getComment(); - static UserIdInfo create(long masterKeyId, int rank, boolean isVerified, boolean isPrimary, String name, String email, + static UserIdInfo create(long masterKeyId, int rank, boolean isVerified, boolean isPrimary, + String name, String email, String comment) { - return new AutoValue_IdentityDao_UserIdInfo(masterKeyId, rank, isVerified, isPrimary, name, email, comment); + return new AutoValue_IdentityDao_UserIdInfo(masterKeyId, rank, isVerified, isPrimary, + name, email, comment); } } @AutoValue public abstract static class AutocryptPeerInfo implements IdentityInfo { public abstract long getMasterKeyId(); + public abstract int getRank(); + public abstract boolean isVerified(); + public abstract boolean isPrimary(); public abstract String getIdentity(); + public abstract String getPackageName(); + @Nullable public abstract Drawable getAppIcon(); + @Nullable public abstract UserIdInfo getUserIdInfo(); + @Nullable public abstract Intent getAutocryptPeerIntent(); - static AutocryptPeerInfo create(long masterKeyId, UserIdInfo userIdInfo, String autocryptPeer, String packageName, + static AutocryptPeerInfo create(long masterKeyId, UserIdInfo userIdInfo, + String autocryptPeer, String packageName, Drawable appIcon, Intent autocryptPeerIntent) { - return new AutoValue_IdentityDao_AutocryptPeerInfo(masterKeyId, userIdInfo.getRank(), userIdInfo.isVerified(), - userIdInfo.isPrimary(), autocryptPeer, packageName, appIcon, userIdInfo, autocryptPeerIntent); + return new AutoValue_IdentityDao_AutocryptPeerInfo(masterKeyId, userIdInfo.getRank(), + userIdInfo.isVerified(), + userIdInfo.isPrimary(), autocryptPeer, packageName, appIcon, userIdInfo, + autocryptPeerIntent); } - static AutocryptPeerInfo create(long masterKeyId, String autocryptPeer, String packageName, Drawable appIcon, Intent autocryptPeerIntent) { - return new AutoValue_IdentityDao_AutocryptPeerInfo(masterKeyId,0, false, false, autocryptPeer, packageName, appIcon, null, autocryptPeerIntent); + static AutocryptPeerInfo create(long masterKeyId, String autocryptPeer, String packageName, + Drawable appIcon, Intent autocryptPeerIntent) { + return new AutoValue_IdentityDao_AutocryptPeerInfo(masterKeyId, 0, false, false, + autocryptPeer, packageName, appIcon, null, autocryptPeerIntent); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/SubkeyStatusDao.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/SubkeyStatusDao.java index c1ad2ed11..fa4cc2382 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/SubkeyStatusDao.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/keyview/loader/SubkeyStatusDao.java @@ -25,13 +25,13 @@ import java.util.Date; import java.util.List; import android.content.Context; -import androidx.annotation.NonNull; -import org.sufficientlysecure.keychain.model.SubKey; +import androidx.annotation.NonNull; +import org.sufficientlysecure.keychain.Keys; +import org.sufficientlysecure.keychain.daos.KeyRepository; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType; import org.sufficientlysecure.keychain.pgp.PgpSecurityConstants; import org.sufficientlysecure.keychain.pgp.SecurityProblem.KeySecurityProblem; -import org.sufficientlysecure.keychain.daos.KeyRepository; public class SubkeyStatusDao { @@ -51,7 +51,7 @@ public class SubkeyStatusDao { SubKeyItem keyCertify = null; ArrayList keysSign = new ArrayList<>(); ArrayList keysEncrypt = new ArrayList<>(); - for (SubKey subKey : keyRepository.getSubKeysByMasterKeyId(masterKeyId)) { + for (Keys subKey : keyRepository.getSubKeysByMasterKeyId(masterKeyId)) { SubKeyItem ski = new SubKeyItem(masterKeyId, subKey); if (ski.mKeyId == masterKeyId) { @@ -183,23 +183,23 @@ public class SubkeyStatusDao { final boolean mCanCertify, mCanSign, mCanEncrypt; public final KeySecurityProblem mSecurityProblem; - SubKeyItem(long masterKeyId, SubKey subKey) { - mKeyId = subKey.key_id(); - mCreation = new Date(subKey.creation() * 1000); + SubKeyItem(long masterKeyId, Keys subKey) { + mKeyId = subKey.getKey_id(); + mCreation = new Date(subKey.getCreation() * 1000); - mSecretKeyType = subKey.has_secret(); + mSecretKeyType = subKey.getHas_secret(); mIsRevoked = subKey.is_revoked(); - mExpiry = subKey.expiry() == null ? null : new Date(subKey.expiry() * 1000); + mExpiry = subKey.getExpiry() == null ? null : new Date(subKey.getExpiry() * 1000); mIsExpired = mExpiry != null && mExpiry.before(new Date()); - mCanCertify = subKey.can_certify(); - mCanSign = subKey.can_sign(); - mCanEncrypt = subKey.can_encrypt(); + mCanCertify = subKey.getCan_certify(); + mCanSign = subKey.getCan_sign(); + mCanEncrypt = subKey.getCan_encrypt(); - int algorithm = subKey.algorithm(); - Integer bitStrength = subKey.key_size(); - String curveOid = subKey.key_curve_oid(); + int algorithm = subKey.getAlgorithm(); + Integer bitStrength = subKey.getKey_size(); + String curveOid = subKey.getKey_curve_oid(); mSecurityProblem = PgpSecurityConstants.getKeySecurityProblem( masterKeyId, mKeyId, algorithm, bitStrength, curveOid); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyInfoFormatter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyInfoFormatter.java index 1aa2c9aae..27a4c336a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyInfoFormatter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyInfoFormatter.java @@ -10,8 +10,7 @@ import android.widget.ImageView; import android.widget.TextView; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.model.SubKey; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import java.util.List; @@ -150,7 +149,7 @@ public class KeyInfoFormatter { } @NonNull - private String getSecretKeyReadableTime(Context context, SubKey.UnifiedKeyInfo keyInfo) { + private String getSecretKeyReadableTime(Context context, UnifiedKeyInfo keyInfo) { long creationMillis = keyInfo.creation() * 1000; boolean allowRelativeTimestamp = keyInfo.has_duplicate(); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/CertListWidget.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/CertListWidget.java deleted file mode 100644 index 7d31d92e3..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/CertListWidget.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2017 Schürmann & Breitmoser GbR - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.ui.widget; - - -import android.content.Context; -import android.text.format.DateUtils; -import android.util.AttributeSet; -import android.view.View; -import android.widget.ListView; -import android.widget.TextView; -import android.widget.ViewAnimator; - -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.model.Certification.CertDetails; - -public class CertListWidget extends ViewAnimator { - private TextView vCollapsed; - private ListView vExpanded; - private View vExpandButton; - - public CertListWidget(Context context, AttributeSet attrs) { - super(context, attrs); - } - - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - - View root = getRootView(); - vCollapsed = root.findViewById(R.id.cert_collapsed_list); - vExpanded = root.findViewById(R.id.cert_expanded_list); - vExpandButton = root.findViewById(R.id.cert_expand_button); - - // for now - vExpandButton.setVisibility(View.GONE); - vExpandButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - toggleExpanded(); - } - }); - - // vExpanded.setAdapter(null); - - } - - void toggleExpanded() { - setDisplayedChild(getDisplayedChild() == 1 ? 0 : 1); - } - - void setExpanded(boolean expanded) { - setDisplayedChild(expanded ? 1 : 0); - } - - public void setData(CertDetails certDetails, boolean isSecret) { - if (certDetails != null) { - CharSequence relativeTimeStr = DateUtils - .getRelativeTimeSpanString(certDetails.creation(), System.currentTimeMillis(), 0, DateUtils.FORMAT_ABBREV_ALL); - if (isSecret) { - vCollapsed.setText("You created this identity " + relativeTimeStr + "."); - } else { - vCollapsed.setText("You verified and confirmed this identity " + relativeTimeStr + "."); - } - } else { - vCollapsed.setText("This identity is not yet verified or confirmed."); - } - - } - -} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyChoiceSpinnerAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyChoiceSpinnerAdapter.java index 4cf64ffa3..5b776a3da 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyChoiceSpinnerAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyChoiceSpinnerAdapter.java @@ -11,7 +11,7 @@ import android.widget.ImageView; import android.widget.TextView; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.ui.util.KeyInfoFormatter; import java.util.Arrays; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeySpinner.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeySpinner.java index 794443542..19e18dd30 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeySpinner.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeySpinner.java @@ -31,7 +31,7 @@ import android.view.View; import android.widget.AdapterView; import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; public class KeySpinner extends AppCompatSpinner { public static final String ARG_SUPER_STATE = "super_state"; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ShareKeyHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ShareKeyHelper.java index 12d7b8351..ad5e2056b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ShareKeyHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ShareKeyHelper.java @@ -37,7 +37,7 @@ import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.daos.KeyRepository; import org.sufficientlysecure.keychain.daos.KeyRepository.NotFoundException; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKey; import org.sufficientlysecure.keychain.pgp.SshPublicKey; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; diff --git a/OpenKeychain/src/main/res/layout/cert_list_widget.xml b/OpenKeychain/src/main/res/layout/cert_list_widget.xml deleted file mode 100644 index 7e3dbcdf4..000000000 --- a/OpenKeychain/src/main/res/layout/cert_list_widget.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/ApiAllowedKeys.sq b/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/ApiAllowedKeys.sq index ea9b0b1fe..8f765f28d 100644 --- a/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/ApiAllowedKeys.sq +++ b/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/ApiAllowedKeys.sq @@ -1,6 +1,6 @@ CREATE TABLE IF NOT EXISTS api_allowed_keys ( _id INTEGER PRIMARY KEY AUTOINCREMENT, - key_id INTEGER, + key_id INTEGER NOT NULL, package_name TEXT NOT NULL, UNIQUE (key_id, package_name), FOREIGN KEY (package_name) REFERENCES api_apps (package_name) ON DELETE CASCADE diff --git a/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/AutocryptPeers.sq b/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/AutocryptPeers.sq index 1e98dd8c4..a4fd7ebd9 100644 --- a/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/AutocryptPeers.sq +++ b/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/AutocryptPeers.sq @@ -1,16 +1,16 @@ import java.util.Date; -import org.sufficientlysecure.keychain.model.AutocryptPeer.GossipOrigin; +import org.sufficientlysecure.keychain.model.GossipOrigin; CREATE TABLE IF NOT EXISTS autocrypt_peers ( package_name TEXT NOT NULL, identifier TEXT NOT NULL, - last_seen INTEGER AS Date NULL, - last_seen_key INTEGER AS Date NULL, + last_seen INTEGER AS Date, + last_seen_key INTEGER AS Date, is_mutual INTEGER AS Boolean NOT NULL DEFAULT 0, - master_key_id INTEGER NULL, - gossip_master_key_id INTEGER NULL, - gossip_last_seen_key INTEGER AS Date NULL, - gossip_origin INTEGER AS GossipOrigin NULL, + master_key_id INTEGER, + gossip_master_key_id INTEGER, + gossip_last_seen_key INTEGER AS Date, + gossip_origin INTEGER AS GossipOrigin, PRIMARY KEY(package_name, identifier), FOREIGN KEY(package_name) REFERENCES api_apps (package_name) ON DELETE CASCADE ); @@ -54,10 +54,10 @@ selectAutocryptKeyStatus: SELECT autocryptPeer.*, (CASE WHEN ac_key.expiry IS NULL THEN 0 WHEN ac_key.expiry > strftime('%s', 'now') THEN 0 ELSE 1 END) AS key_is_expired_int, (CASE WHEN gossip_key.expiry IS NULL THEN 0 WHEN gossip_key.expiry > strftime('%s', 'now') THEN 0 ELSE 1 END) AS gossip_key_is_expired_int, - ac_key.is_revoked AS key_is_revoked_int, - gossip_key.is_revoked AS gossip_key_is_revoked_int, - EXISTS (SELECT * FROM certs WHERE certs.master_key_id = autocryptPeer.master_key_id AND verified = 1 ) AS key_is_verified_int, - EXISTS (SELECT * FROM certs WHERE certs.master_key_id = autocryptPeer.gossip_master_key_id AND verified = 1 ) AS gossip_key_is_verified_int + ac_key.is_revoked AS key_is_revoked, + gossip_key.is_revoked AS gossip_key_is_revoked, + EXISTS (SELECT * FROM certs WHERE certs.master_key_id = autocryptPeer.master_key_id AND verified = 1) AS key_is_verified, + EXISTS (SELECT * FROM certs WHERE certs.master_key_id = autocryptPeer.gossip_master_key_id AND verified = 1) AS gossip_key_is_verified FROM autocrypt_peers AS autocryptPeer LEFT JOIN keys AS ac_key ON (ac_key.master_key_id = autocryptPeer.master_key_id AND ac_key.rank = 0) LEFT JOIN keys AS gossip_key ON (gossip_key.master_key_id = gossip_master_key_id AND gossip_key.rank = 0) diff --git a/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/Certs.sq b/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/Certs.sq index 5678e546e..3d44ee4cb 100644 --- a/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/Certs.sq +++ b/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/Certs.sq @@ -15,11 +15,11 @@ CREATE TABLE IF NOT EXISTS certs( ); insertCert: -INSERT INTO certs (master_key_id, rank, key_id_certifier, type, verified, creation, data) VALUES (?, ?, ?, ?, ?, ?, ?); +INSERT INTO certs VALUES ?; selectVerifyingCertDetails: SELECT master_key_id AS masterKeyId, key_id_certifier AS signerMasterKeyId, creation * 1000 AS creation FROM certs WHERE verified = 1 AND master_key_id = ? AND rank = ? - ORDER BY creation DESC + ORDER BY certs.creation DESC LIMIT 1; \ No newline at end of file diff --git a/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/KeyMetadata.sq b/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/KeyMetadata.sq index 309dcd7ac..547d72eef 100644 --- a/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/KeyMetadata.sq +++ b/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/KeyMetadata.sq @@ -16,7 +16,7 @@ SELECT * deleteAllLastUpdatedTimes: UPDATE key_metadata - SET last_updated = null, seen_on_keyservers = null; + SET last_updated = NULL, seen_on_keyservers = NULL; replaceKeyMetadata: REPLACE INTO key_metadata (master_key_id, last_updated, seen_on_keyservers) VALUES (?, ?, ?); diff --git a/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/KeyRingsPublic.sq b/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/KeyRingsPublic.sq index 306aa6dac..94dcf1eb8 100644 --- a/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/KeyRingsPublic.sq +++ b/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/KeyRingsPublic.sq @@ -1,10 +1,10 @@ CREATE TABLE IF NOT EXISTS keyrings_public ( master_key_id INTEGER NOT NULL PRIMARY KEY, - key_ring_data BLOB NULL + key_ring_data BLOB ); insertKeyRingPublic: -INSERT INTO keyrings_public (master_key_id, key_ring_data) VALUES (?, ?); +INSERT INTO keyrings_public (master_key_id, key_ring_data) VALUES ?; selectAllMasterKeyIds: SELECT master_key_id diff --git a/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/KeySignatures.sq b/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/KeySignatures.sq index ce1c5d89d..b59fdb494 100644 --- a/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/KeySignatures.sq +++ b/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/KeySignatures.sq @@ -6,7 +6,7 @@ CREATE TABLE IF NOT EXISTS key_signatures ( ); insertKeySignature: -INSERT INTO key_signatures (master_key_id, signer_key_id) VALUES (?, ?); +INSERT INTO key_signatures (master_key_id, signer_key_id) VALUES ?; selectMasterKeyIdsBySigner: SELECT master_key_id diff --git a/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/Keys.sq b/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/Keys.sq index db208a4bf..0d50d6029 100644 --- a/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/Keys.sq +++ b/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/Keys.sq @@ -29,7 +29,7 @@ INSERT INTO keys ( master_key_id, rank, key_id, key_size, key_curve_oid, algorithm, fingerprint, can_certify, can_sign, can_encrypt, can_authenticate, is_revoked, has_secret, is_secure, creation, expiry, validFrom - ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); + ) VALUES ?; updateHasSecretByMasterKeyId: UPDATE keys @@ -56,11 +56,11 @@ SELECT master_key_id, rank, key_id, key_size, key_curve_oid, algorithm, fingerpr unifiedKeyView: CREATE VIEW unifiedKeyView AS SELECT keys.master_key_id, keys.fingerprint, MIN(user_packets.rank), user_packets.user_id, user_packets.name, user_packets.email, user_packets.comment, keys.creation, keys.expiry, keys.is_revoked, keys.is_secure, keys.can_certify, certs.verified, - (EXISTS (SELECT * FROM user_packets AS dups WHERE dups.master_key_id != keys.master_key_id AND dups.rank = 0 AND dups.name = user_packets.name COLLATE NOCASE AND dups.email = user_packets.email COLLATE NOCASE )) AS has_duplicate_int, - (EXISTS (SELECT * FROM keys AS k WHERE k.master_key_id = keys.master_key_id AND k.has_secret != 0 )) AS has_any_secret_int, - (SELECT key_id FROM keys AS k WHERE k.master_key_id = keys.master_key_id AND k.can_encrypt != 0 LIMIT 1) AS has_encrypt_key_int, - (SELECT key_id FROM keys AS k WHERE k.master_key_id = keys.master_key_id AND k.can_sign != 0 LIMIT 1) AS has_sign_key_int, - (SELECT key_id FROM keys AS k WHERE k.master_key_id = keys.master_key_id AND k.can_authenticate != 0 LIMIT 1) AS has_auth_key_int, + (EXISTS (SELECT * FROM user_packets AS dups WHERE dups.master_key_id != keys.master_key_id AND dups.rank = 0 AND dups.name = user_packets.name COLLATE NOCASE AND dups.email = user_packets.email COLLATE NOCASE )) AS has_duplicate, + (EXISTS (SELECT * FROM keys AS k WHERE k.master_key_id = keys.master_key_id AND k.has_secret != 0)) AS has_any_secret, + (EXISTS (SELECT * FROM keys AS k WHERE k.master_key_id = keys.master_key_id AND k.can_encrypt != 0)) AS has_encrypt_key, + (EXISTS (SELECT * FROM keys AS k WHERE k.master_key_id = keys.master_key_id AND k.can_sign != 0)) AS has_sign_key, + (EXISTS (SELECT * FROM keys AS k WHERE k.master_key_id = keys.master_key_id AND k.can_authenticate != 0)) AS has_auth_key, GROUP_CONCAT(DISTINCT aTI.package_name) AS autocrypt_package_names_csv, GROUP_CONCAT(user_packets.user_id, '|||') AS user_id_list FROM keys @@ -72,7 +72,7 @@ CREATE VIEW unifiedKeyView AS selectAllUnifiedKeyInfo: SELECT * FROM unifiedKeyView - ORDER BY has_any_secret_int DESC, IFNULL(name, email) COLLATE NOCASE ASC, creation DESC; + ORDER BY has_any_secret DESC, IFNULL(name, email) COLLATE NOCASE ASC, creation DESC; selectUnifiedKeyInfoByMasterKeyId: SELECT * FROM unifiedKeyView @@ -89,12 +89,12 @@ SELECT * FROM unifiedKeyView selectAllUnifiedKeyInfoWithSecret: SELECT * FROM unifiedKeyView - WHERE has_any_secret_int = 1 + WHERE has_any_secret = 1 ORDER BY creation DESC; selectAllUnifiedKeyInfoWithAuthKeySecret: SELECT * FROM unifiedKeyView - WHERE has_any_secret_int = 1 AND has_auth_key_int IS NOT NULL + WHERE has_any_secret = 1 AND has_auth_key IS NOT NULL ORDER BY creation DESC; selectMasterKeyIdBySubkey: diff --git a/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/UserPackets.sq b/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/UserPackets.sq index 701408c31..ceec18ca5 100644 --- a/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/UserPackets.sq +++ b/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/UserPackets.sq @@ -16,8 +16,7 @@ CREATE TABLE IF NOT EXISTS user_packets( ); insertUserPacket: -INSERT INTO user_packets (master_key_id, rank, type, user_id, name, email, comment, attribute_data, is_primary, is_revoked) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?); +INSERT INTO user_packets VALUES ?; selectUserIdsByMasterKeyId: SELECT user_packets.master_key_id, user_packets.rank, user_id, name, email, comment, is_primary, is_revoked, MIN(certs.verified) AS verified_int diff --git a/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/Util.sq b/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/Util.sq new file mode 100644 index 000000000..08f464972 --- /dev/null +++ b/OpenKeychain/src/main/sqldelight/org/sufficientlysecure/keychain/Util.sq @@ -0,0 +1,2 @@ +selectChanges: +SELECT changes(); \ No newline at end of file diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/PromoteKeyOperationTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/PromoteKeyOperationTest.java index 269a3dd51..8e1f97b66 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/PromoteKeyOperationTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/operations/PromoteKeyOperationTest.java @@ -34,7 +34,7 @@ import org.junit.runner.RunWith; import org.robolectric.RuntimeEnvironment; import org.robolectric.shadows.ShadowLog; import org.sufficientlysecure.keychain.KeychainTestRunner; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.operations.results.PgpEditKeyResult; import org.sufficientlysecure.keychain.operations.results.PromoteKeyResult; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey; diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/PgpEncryptDecryptTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/PgpEncryptDecryptTest.java index 3555339ba..b802165d1 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/PgpEncryptDecryptTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/pgp/PgpEncryptDecryptTest.java @@ -27,7 +27,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.Iterator; -import org.apache.tools.ant.util.StringUtils; import org.bouncycastle.bcpg.BCPGInputStream; import org.bouncycastle.bcpg.Packet; import org.bouncycastle.bcpg.PacketTags; @@ -388,9 +387,9 @@ public class PgpEncryptDecryptTest { Assert.assertTrue("verification must succeed", result.success()); - Assert.assertTrue("verification text should equal plaintext (ignoring newlines)", - new String(out.toByteArray()).replace(StringUtils.LINE_SEP, "") - .equals(plaintext.replace("\r", "").replace("\n", ""))); + Assert.assertEquals("verification text should equal plaintext (ignoring newlines)", + out.toString().replace("\r", "").replace("\n", ""), + plaintext.replace("\r", "").replace("\n", "")); Assert.assertEquals("decryptionResult should be RESULT_NOT_ENCRYPTED", OpenPgpDecryptionResult.RESULT_NOT_ENCRYPTED, result.getDecryptionResult().getResult()); Assert.assertEquals("signatureResult should be RESULT_VALID_CONFIRMED", diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/KeyRepositorySaveTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/KeyRepositorySaveTest.java index 4461fda68..8e18d4357 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/KeyRepositorySaveTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/provider/KeyRepositorySaveTest.java @@ -29,7 +29,7 @@ import org.robolectric.RuntimeEnvironment; import org.robolectric.shadows.ShadowLog; import org.sufficientlysecure.keychain.KeychainTestRunner; import org.sufficientlysecure.keychain.daos.KeyWritableRepository; -import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo; +import org.sufficientlysecure.keychain.model.UnifiedKeyInfo; import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog; import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult; import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing; @@ -128,7 +128,6 @@ public class KeyRepositorySaveTest { CanonicalizedPublicKeyRing pubRing = mDatabaseInteractor.getCanonicalizedPublicKeyRing(keyId); Assert.assertEquals("master key should be encryption key", keyId, pubRing.getEncryptId()); - Assert.assertEquals("master key should be encryption key (cached)", keyId, unifiedKeyInfo.has_encrypt_key_int()); Assert.assertEquals("canonicalized key flags should be zero", 0, (long) pubRing.getPublicKey().getKeyUsage()); diff --git a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/remote/KeychainExternalProviderTest.java b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/remote/KeychainExternalProviderTest.java index 55344de57..9a21e4fbc 100644 --- a/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/remote/KeychainExternalProviderTest.java +++ b/OpenKeychain/src/test/java/org/sufficientlysecure/keychain/remote/KeychainExternalProviderTest.java @@ -17,15 +17,13 @@ import org.junit.runner.RunWith; import org.robolectric.Robolectric; import org.robolectric.RuntimeEnvironment; import org.robolectric.shadows.ShadowBinder; -import org.robolectric.shadows.ShadowContentResolver; import org.robolectric.shadows.ShadowLog; import org.robolectric.shadows.ShadowPackageManager; import org.sufficientlysecure.keychain.KeychainTestRunner; import org.sufficientlysecure.keychain.daos.ApiAppDao; import org.sufficientlysecure.keychain.daos.AutocryptPeerDao; import org.sufficientlysecure.keychain.daos.KeyWritableRepository; -import org.sufficientlysecure.keychain.model.ApiApp; -import org.sufficientlysecure.keychain.model.AutocryptPeer.GossipOrigin; +import org.sufficientlysecure.keychain.model.GossipOrigin; import org.sufficientlysecure.keychain.operations.CertifyOperation; import org.sufficientlysecure.keychain.operations.results.CertifyResult; import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult; @@ -59,8 +57,8 @@ public class KeychainExternalProviderTest { KeyWritableRepository databaseInteractor = - KeyWritableRepository.create(RuntimeEnvironment.application); - ContentResolver contentResolver = RuntimeEnvironment.application.getContentResolver(); + KeyWritableRepository.create(RuntimeEnvironment.getApplication()); + ContentResolver contentResolver = RuntimeEnvironment.getApplication().getContentResolver(); ApiPermissionHelper apiPermissionHelper; ApiAppDao apiAppDao; AutocryptPeerDao autocryptPeerDao; @@ -87,7 +85,7 @@ public class KeychainExternalProviderTest { apiPermissionHelper = new ApiPermissionHelper(RuntimeEnvironment.application, apiAppDao); autocryptPeerDao = AutocryptPeerDao.getInstance(RuntimeEnvironment.application); - apiAppDao.insertApiApp(ApiApp.create(PACKAGE_NAME, PACKAGE_SIGNATURE)); + apiAppDao.insertApiApp(PACKAGE_NAME, PACKAGE_SIGNATURE); } @Test(expected = AccessControlException.class) @@ -104,7 +102,7 @@ public class KeychainExternalProviderTest { @Test(expected = AccessControlException.class) public void testPermission__withWrongPackageCert() throws Exception { apiAppDao.deleteApiApp(PACKAGE_NAME); - apiAppDao.insertApiApp(ApiApp.create(PACKAGE_NAME, new byte[] { 1, 2, 4 })); + apiAppDao.insertApiApp(PACKAGE_NAME, new byte[] { 1, 2, 4 }); contentResolver.query( AutocryptStatus.CONTENT_URI, diff --git a/build.gradle b/build.gradle index 8d75412ab..b7a8d4c7a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,8 @@ buildscript { + ext { + kotlin_version = '1.8.20' + } + repositories { google() mavenCentral() @@ -6,8 +10,10 @@ buildscript { dependencies { // NOTE: Always use fixed version codes not dynamic ones, e.g. 0.7.3 instead of 0.7.+, see README for more information - classpath 'com.android.tools.build:gradle:4.2.2' - classpath 'com.squareup.sqldelight:gradle-plugin:0.8.0' + classpath 'com.android.tools.build:gradle:7.4.2' + // classpath 'com.squareup.sqldelight:gradle-plugin:0.8.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'com.squareup.sqldelight:gradle-plugin:1.5.4' } } diff --git a/extern/bouncycastle b/extern/bouncycastle index d920f5959..187ca21dd 160000 --- a/extern/bouncycastle +++ b/extern/bouncycastle @@ -1 +1 @@ -Subproject commit d920f59594858d2835c330ec95b9dad0c4b7d00c +Subproject commit 187ca21dd44766942e6c85e3a85430ecbca77f22 diff --git a/extern/openpgp-api-lib b/extern/openpgp-api-lib index 8bc98b412..f91db6be3 160000 --- a/extern/openpgp-api-lib +++ b/extern/openpgp-api-lib @@ -1 +1 @@ -Subproject commit 8bc98b412bd7cd546b33eac1ced1c1cb302906ca +Subproject commit f91db6be300e8a777c49bbcb8ad0b3a9a583ef08 diff --git a/gradle.properties b/gradle.properties index 2f49a28e9..dbb049958 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ android.enableJetifier=true android.useAndroidX=true -android.jetifier.blacklist=bcprov-jdk15on +android.jetifier.ignorelist=bcprov-jdk15on org.gradle.jvmargs=-Xms128m -Xmx4096m -XX:+CMSClassUnloadingEnabled \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e708b1c023ec8b20f512888fe07c5bd3ff77bb8f..7454180f2ae8848c63b8b4dea2cb829da983f2fa 100644 GIT binary patch delta 18435 zcmY&<19zBR)MXm8v2EM7ZQHi-#I|kQZfv7Tn#Q)%81v4zX3d)U4d4 zYYc!v@NU%|U;_sM`2z(4BAilWijmR>4U^KdN)D8%@2KLcqkTDW%^3U(Wg>{qkAF z&RcYr;D1I5aD(N-PnqoEeBN~JyXiT(+@b`4Pv`;KmkBXYN48@0;iXuq6!ytn`vGp$ z6X4DQHMx^WlOek^bde&~cvEO@K$oJ}i`T`N;M|lX0mhmEH zuRpo!rS~#&rg}ajBdma$$}+vEhz?JAFUW|iZEcL%amAg_pzqul-B7Itq6Y_BGmOCC zX*Bw3rFz3R)DXpCVBkI!SoOHtYstv*e-May|+?b80ZRh$MZ$FerlC`)ZKt} zTd0Arf9N2dimjs>mg5&@sfTPsRXKXI;0L~&t+GH zkB<>wxI9D+k5VHHcB7Rku{Z>i3$&hgd9Mt_hS_GaGg0#2EHzyV=j=u5xSyV~F0*qs zW{k9}lFZ?H%@4hII_!bzao!S(J^^ZZVmG_;^qXkpJb7OyR*sPL>))Jx{K4xtO2xTr@St!@CJ=y3q2wY5F`77Tqwz8!&Q{f7Dp zifvzVV1!Dj*dxG%BsQyRP6${X+Tc$+XOG zzvq5xcC#&-iXlp$)L=9t{oD~bT~v^ZxQG;FRz|HcZj|^L#_(VNG)k{=_6|6Bs-tRNCn-XuaZ^*^hpZ@qwi`m|BxcF6IWc?_bhtK_cDZRTw#*bZ2`1@1HcB`mLUmo_>@2R&nj7&CiH zF&laHkG~7#U>c}rn#H)q^|sk+lc!?6wg0x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ln~Bt^A4)(%?l-&(Dm!iL#$K_xOyhwAf=K2<+Bom zw7|hl6E5}B$d%n0sfZvfQRy9Fyz2~ z83#=#LaHnf1th^k*p|ux8!!8pfHE!)x*%=_hAddl)P%4h4%&8!5-W#xqqb}c=H(i|wqcIS&oDQ{ zhI7N-$f$ra3=RjPmMh?-IEkJYQ<}R9Z!}wmp$#~Uc%u1oh#TP}wF*kJJmQX2#27kL z_dz(yKufo<=m71bZfLp^Ll#t3(IHkrgMcvx@~om%Ib(h(<$Da7urTI`x|%`wD--sN zJEEa>4DGSEG?0ulkosfj8IMNN4)B=ZtvGG{|4Fp=Xhg!wPNgYzS>{Bp%%Qa+624X@ X49Luk)baa85H9$5YCsTPT`SVRWMtMW diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 442d9132e..8049c684f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 4f906e0c8..1b6c78733 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,101 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -106,80 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/sshauthentication-api/build.gradle b/sshauthentication-api/build.gradle index 6e2b78b6b..499cadc2f 100644 --- a/sshauthentication-api/build.gradle +++ b/sshauthentication-api/build.gradle @@ -2,18 +2,16 @@ apply plugin: 'com.android.library' apply plugin: 'maven-publish' android { - if (project.hasProperty('compileSdkVersion')) { - compileSdkVersion rootProject.ext.compileSdkVersion - } else { - compileSdkVersion 28 - } - - defaultConfig { minSdkVersion 14 - targetSdkVersion 28 - versionCode 2 - versionName "2.0" + versionCode 3 + versionName "3.0" + namespace 'org.openintents.ssh.authentication' + if (project.hasProperty('compileSdkVersion')) { + compileSdk rootProject.ext.compileSdkVersion + } else { + compileSdk 28 + } } // Do not abort build if lint finds errors