Make sure auth key selection dialog lists only keys with auth subkey available.

Presently the dialog lists all master keys, and keys without auth subkeys are not marked in any way. Sleecting one of those via SSH authentication API will result in cryptic "Could not create description: null" message.
This commit is contained in:
Constantine Verutin 2018-11-30 10:55:33 +00:00
parent 29b014edad
commit 4e4c070228
3 changed files with 11 additions and 1 deletions

View File

@ -164,6 +164,11 @@ public class KeyRepository extends AbstractDao {
return mapAllRows(query, SubKey.UNIFIED_KEY_INFO_MAPPER);
}
public List<UnifiedKeyInfo> getAllUnifiedKeyInfoWithAuthKeySecret() {
SqlDelightQuery query = SubKey.FACTORY.selectAllUnifiedKeyInfoWithAuthKeySecret();
return mapAllRows(query, SubKey.UNIFIED_KEY_INFO_MAPPER);
}
public List<UserId> getUserIds(long... masterKeyIds) {
SqlDelightQuery query = UserPacket.FACTORY.selectUserIdsByMasterKeyId(masterKeyIds);
return mapAllRows(query, UserPacket.USER_ID_MAPPER);

View File

@ -104,7 +104,7 @@ public class RemoteSelectAuthenticationKeyActivity extends FragmentActivity {
if (keyInfoLiveData == null) {
keyInfoLiveData = new GenericLiveData<>(context, () -> {
KeyRepository keyRepository = KeyRepository.create(context);
return keyRepository.getAllUnifiedKeyInfoWithSecret();
return keyRepository.getAllUnifiedKeyInfoWithAuthKeySecret();
});
}
return keyInfoLiveData;

View File

@ -92,6 +92,11 @@ SELECT * FROM unifiedKeyView
WHERE has_any_secret_int = 1
ORDER BY creation DESC;
selectAllUnifiedKeyInfoWithAuthKeySecret:
SELECT * FROM unifiedKeyView
WHERE has_any_secret_int = 1 AND has_auth_key_int IS NOT NULL
ORDER BY creation DESC;
selectMasterKeyIdBySubkey:
SELECT master_key_id
FROM keys