mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 09:12:16 -05:00
API: User interaction when account keys are deleted
This commit is contained in:
parent
38da2af0e8
commit
db12f782f2
@ -3,7 +3,7 @@
|
||||
* Key edit: awesome new design, key revocation
|
||||
* Key import: awesome new design, secure keyserver connections via hkps, keyserver resolving via DNS SRV records
|
||||
* New first time screen
|
||||
* New create key screen: autocompletion of name and email based on your personal Android accounts
|
||||
* New key creation screen: autocompletion of name and email based on your personal Android accounts
|
||||
* File encryption: awesome new design, support for encrypting multiple files
|
||||
* New icons to show status of key (by Brennan Novak)
|
||||
* Important bug fix: Importing of large key collections from a file is now possible
|
||||
@ -31,7 +31,7 @@ This release wouldn't be possible without the work of Vincent Breitmoser (GSoC 2
|
||||
|
||||
2.5
|
||||
* Fix decryption of symmetric pgp messages/files
|
||||
* Refactored edit key screen (thanks to Ash Hughes)
|
||||
* Refactored key edit screen (thanks to Ash Hughes)
|
||||
* New modern design for encrypt/decrypt screens
|
||||
* OpenPGP API version 3 (multiple api accounts, internal fixes, key lookup)
|
||||
|
||||
|
@ -925,7 +925,7 @@ public class ProviderHelper {
|
||||
mContentResolver.insert(uri, contentValueForApiAccounts(accSettings));
|
||||
}
|
||||
|
||||
public void updateApiAccount(AccountSettings accSettings, Uri uri) {
|
||||
public void updateApiAccount(Uri uri, AccountSettings accSettings) {
|
||||
if (mContentResolver.update(uri, contentValueForApiAccounts(accSettings), null,
|
||||
null) <= 0) {
|
||||
throw new RuntimeException();
|
||||
|
@ -164,7 +164,13 @@ public class OpenPgpService extends RemoteService {
|
||||
if (data.hasExtra(OpenPgpApi.EXTRA_PASSPHRASE)) {
|
||||
passphrase = data.getStringExtra(OpenPgpApi.EXTRA_PASSPHRASE);
|
||||
} else {
|
||||
passphrase = PassphraseCacheService.getCachedPassphrase(getContext(), accSettings.getKeyId());
|
||||
try {
|
||||
passphrase = PassphraseCacheService.getCachedPassphrase(getContext(), accSettings.getKeyId());
|
||||
} catch (PassphraseCacheService.KeyNotFoundException e) {
|
||||
// secret key that is set for this account is deleted?
|
||||
// show account config again!
|
||||
return getCreateAccountIntent(data, data.getStringExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME));
|
||||
}
|
||||
}
|
||||
if (passphrase == null) {
|
||||
// get PendingIntent for passphrase input, add it to given params and return to client
|
||||
|
@ -102,7 +102,7 @@ public class AccountSettingsActivity extends ActionBarActivity {
|
||||
}
|
||||
|
||||
private void save() {
|
||||
new ProviderHelper(this).updateApiAccount(mAccountSettingsFragment.getAccSettings(), mAccountUri);
|
||||
new ProviderHelper(this).updateApiAccount(mAccountUri, mAccountSettingsFragment.getAccSettings());
|
||||
finish();
|
||||
}
|
||||
|
||||
|
@ -18,11 +18,13 @@
|
||||
package org.sufficientlysecure.keychain.remote.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.openintents.openpgp.util.OpenPgpApi;
|
||||
import org.sufficientlysecure.htmltextview.HtmlTextView;
|
||||
@ -37,6 +39,7 @@ import org.sufficientlysecure.keychain.ui.SelectPublicKeyFragment;
|
||||
import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import java.security.Provider;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RemoteServiceActivity extends ActionBarActivity {
|
||||
@ -76,10 +79,17 @@ public class RemoteServiceActivity extends ActionBarActivity {
|
||||
// select pub keys view
|
||||
private SelectPublicKeyFragment mSelectFragment;
|
||||
|
||||
private ProviderHelper mProviderHelper;
|
||||
|
||||
// for ACTION_CREATE_ACCOUNT
|
||||
boolean mUpdateExistingAccount;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mProviderHelper = new ProviderHelper(this);
|
||||
|
||||
handleActions(getIntent(), savedInstanceState);
|
||||
}
|
||||
|
||||
@ -94,6 +104,14 @@ public class RemoteServiceActivity extends ActionBarActivity {
|
||||
final byte[] packageSignature = extras.getByteArray(EXTRA_PACKAGE_SIGNATURE);
|
||||
Log.d(Constants.TAG, "ACTION_REGISTER packageName: " + packageName);
|
||||
|
||||
setContentView(R.layout.api_remote_register_app);
|
||||
|
||||
mAppSettingsFragment = (AppSettingsFragment) getSupportFragmentManager().findFragmentById(
|
||||
R.id.api_app_settings_fragment);
|
||||
|
||||
AppSettings settings = new AppSettings(packageName, packageSignature);
|
||||
mAppSettingsFragment.setAppSettings(settings);
|
||||
|
||||
// Inflate a "Done"/"Cancel" custom action bar view
|
||||
ActionBarHelper.setTwoButtonView(getSupportActionBar(),
|
||||
R.string.api_register_allow, R.drawable.ic_action_done,
|
||||
@ -102,8 +120,7 @@ public class RemoteServiceActivity extends ActionBarActivity {
|
||||
public void onClick(View v) {
|
||||
// Allow
|
||||
|
||||
new ProviderHelper(RemoteServiceActivity.this).insertApiApp(
|
||||
mAppSettingsFragment.getAppSettings());
|
||||
mProviderHelper.insertApiApp(mAppSettingsFragment.getAppSettings());
|
||||
|
||||
// give data through for new service call
|
||||
Intent resultData = extras.getParcelable(EXTRA_DATA);
|
||||
@ -120,18 +137,34 @@ public class RemoteServiceActivity extends ActionBarActivity {
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
setContentView(R.layout.api_remote_register_app);
|
||||
|
||||
mAppSettingsFragment = (AppSettingsFragment) getSupportFragmentManager().findFragmentById(
|
||||
R.id.api_app_settings_fragment);
|
||||
|
||||
AppSettings settings = new AppSettings(packageName, packageSignature);
|
||||
mAppSettingsFragment.setAppSettings(settings);
|
||||
} else if (ACTION_CREATE_ACCOUNT.equals(action)) {
|
||||
final String packageName = extras.getString(EXTRA_PACKAGE_NAME);
|
||||
final String accName = extras.getString(EXTRA_ACC_NAME);
|
||||
|
||||
setContentView(R.layout.api_remote_create_account);
|
||||
|
||||
mAccSettingsFragment = (AccountSettingsFragment) getSupportFragmentManager().findFragmentById(
|
||||
R.id.api_account_settings_fragment);
|
||||
|
||||
TextView text = (TextView) findViewById(R.id.api_remote_create_account_text);
|
||||
|
||||
// update existing?
|
||||
Uri uri = KeychainContract.ApiAccounts.buildByPackageAndAccountUri(packageName, accName);
|
||||
AccountSettings settings = mProviderHelper.getApiAccountSettings(uri);
|
||||
if (settings == null) {
|
||||
// create new account
|
||||
settings = new AccountSettings(accName);
|
||||
mUpdateExistingAccount = false;
|
||||
|
||||
text.setText(R.string.api_create_account_text);
|
||||
} else {
|
||||
// update existing account
|
||||
mUpdateExistingAccount = true;
|
||||
|
||||
text.setText(R.string.api_update_account_text);
|
||||
}
|
||||
mAccSettingsFragment.setAccSettings(settings);
|
||||
|
||||
// Inflate a "Done"/"Cancel" custom action bar view
|
||||
ActionBarHelper.setTwoButtonView(getSupportActionBar(),
|
||||
R.string.api_settings_save, R.drawable.ic_action_done,
|
||||
@ -145,9 +178,17 @@ public class RemoteServiceActivity extends ActionBarActivity {
|
||||
mAccSettingsFragment.setErrorOnSelectKeyFragment(
|
||||
getString(R.string.api_register_error_select_key));
|
||||
} else {
|
||||
new ProviderHelper(RemoteServiceActivity.this).insertApiAccount(
|
||||
KeychainContract.ApiAccounts.buildBaseUri(packageName),
|
||||
mAccSettingsFragment.getAccSettings());
|
||||
if (mUpdateExistingAccount) {
|
||||
Uri baseUri = KeychainContract.ApiAccounts.buildBaseUri(packageName);
|
||||
Uri accountUri = baseUri.buildUpon().appendEncodedPath(accName).build();
|
||||
mProviderHelper.updateApiAccount(
|
||||
accountUri,
|
||||
mAccSettingsFragment.getAccSettings());
|
||||
} else {
|
||||
mProviderHelper.insertApiAccount(
|
||||
KeychainContract.ApiAccounts.buildBaseUri(packageName),
|
||||
mAccSettingsFragment.getAccSettings());
|
||||
}
|
||||
|
||||
// give data through for new service call
|
||||
Intent resultData = extras.getParcelable(EXTRA_DATA);
|
||||
@ -166,13 +207,6 @@ public class RemoteServiceActivity extends ActionBarActivity {
|
||||
}
|
||||
);
|
||||
|
||||
setContentView(R.layout.api_remote_create_account);
|
||||
|
||||
mAccSettingsFragment = (AccountSettingsFragment) getSupportFragmentManager().findFragmentById(
|
||||
R.id.api_account_settings_fragment);
|
||||
|
||||
AccountSettings settings = new AccountSettings(accName);
|
||||
mAccSettingsFragment.setAccSettings(settings);
|
||||
} else if (ACTION_CACHE_PASSPHRASE.equals(action)) {
|
||||
long secretKeyId = extras.getLong(EXTRA_SECRET_KEY_ID);
|
||||
final Intent resultData = extras.getParcelable(EXTRA_DATA);
|
||||
@ -190,7 +224,8 @@ public class RemoteServiceActivity extends ActionBarActivity {
|
||||
|
||||
RemoteServiceActivity.this.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
} else if (ACTION_SELECT_PUB_KEYS.equals(action)) {
|
||||
long[] selectedMasterKeyIds = intent.getLongArrayExtra(EXTRA_SELECTED_MASTER_KEY_IDS);
|
||||
@ -286,7 +321,8 @@ public class RemoteServiceActivity extends ActionBarActivity {
|
||||
RemoteServiceActivity.this.setResult(RESULT_CANCELED);
|
||||
RemoteServiceActivity.this.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
setContentView(R.layout.api_remote_error_message);
|
||||
|
||||
|
@ -11,7 +11,7 @@ And don't add newlines before or after p tags because of transifex -->
|
||||
<li>Key edit: awesome new design, key revocation</li>
|
||||
<li>Key import: awesome new design, secure keyserver connections via hkps, keyserver resolving via DNS SRV records</li>
|
||||
<li>New first time screen</li>
|
||||
<li>New create key screen: autocompletion of name and email based on your personal Android accounts</li>
|
||||
<li>New key creation screen: autocompletion of name and email based on your personal Android accounts</li>
|
||||
<li>File encryption: awesome new design, support for encrypting multiple files</li>
|
||||
<li>New icons to show status of key (by Brennan Novak)</li>
|
||||
<li>Important bug fix: Importing of large key collections from a file is now possible</li>
|
||||
@ -45,7 +45,7 @@ And don't add newlines before or after p tags because of transifex -->
|
||||
<h2>2.5</h2>
|
||||
<ul>
|
||||
<li>Fix decryption of symmetric pgp messages/files</li>
|
||||
<li>Refactored edit key screen (thanks to Ash Hughes)</li>
|
||||
<li>Refactored key edit screen (thanks to Ash Hughes)</li>
|
||||
<li>New modern design for encrypt/decrypt screens</li>
|
||||
<li>OpenPGP API version 3 (multiple api accounts, internal fixes, key lookup)</li>
|
||||
</ul>
|
||||
|
@ -391,6 +391,7 @@
|
||||
<string name="api_settings_accounts">Accounts</string>
|
||||
<string name="api_settings_accounts_empty">No accounts attached to this app.</string>
|
||||
<string name="api_create_account_text">The app requests the creation of a new account. Please select one of your existing keys or create a new one.\nApps are restricted to the usage of keys you select here!</string>
|
||||
<string name="api_update_account_text">The key saved for this account has been deleted. Please select a different one!\nApps are restricted to the usage of keys you select here!</string>
|
||||
<string name="api_register_text">The displayed app wants to encrypt/decrypt messages and sign them in your name.\nAllow access?\n\nWARNING: If you do not know why this screen appeared, disallow access! You can revoke access later using the \'Apps\' screen.</string>
|
||||
<string name="api_register_allow">Allow access</string>
|
||||
<string name="api_register_disallow">Disallow access</string>
|
||||
|
Loading…
Reference in New Issue
Block a user