service: return pending intent for details dialog if security problems occur
This commit is contained in:
@@ -859,6 +859,11 @@
|
|||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:theme="@style/Theme.Keychain.Transparent"
|
android:theme="@style/Theme.Keychain.Transparent"
|
||||||
android:label="@string/app_name" />
|
android:label="@string/app_name" />
|
||||||
|
<activity
|
||||||
|
android:name=".remote.ui.RemoteSecurityProblemDialogActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.Keychain.Transparent"
|
||||||
|
android:label="@string/app_name" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".remote.ui.RemoteSelectPubKeyActivity"
|
android:name=".remote.ui.RemoteSelectPubKeyActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
|
|||||||
@@ -25,12 +25,14 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.pgp.SecurityProblem;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.remote.ui.RemoteBackupActivity;
|
import org.sufficientlysecure.keychain.remote.ui.RemoteBackupActivity;
|
||||||
import org.sufficientlysecure.keychain.remote.ui.RemoteErrorActivity;
|
import org.sufficientlysecure.keychain.remote.ui.RemoteErrorActivity;
|
||||||
import org.sufficientlysecure.keychain.remote.ui.RemoteImportKeysActivity;
|
import org.sufficientlysecure.keychain.remote.ui.RemoteImportKeysActivity;
|
||||||
import org.sufficientlysecure.keychain.remote.ui.RemotePassphraseDialogActivity;
|
import org.sufficientlysecure.keychain.remote.ui.RemotePassphraseDialogActivity;
|
||||||
import org.sufficientlysecure.keychain.remote.ui.RemoteRegisterActivity;
|
import org.sufficientlysecure.keychain.remote.ui.RemoteRegisterActivity;
|
||||||
|
import org.sufficientlysecure.keychain.remote.ui.RemoteSecurityProblemDialogActivity;
|
||||||
import org.sufficientlysecure.keychain.remote.ui.RemoteSecurityTokenOperationActivity;
|
import org.sufficientlysecure.keychain.remote.ui.RemoteSecurityTokenOperationActivity;
|
||||||
import org.sufficientlysecure.keychain.remote.ui.RemoteSelectPubKeyActivity;
|
import org.sufficientlysecure.keychain.remote.ui.RemoteSelectPubKeyActivity;
|
||||||
import org.sufficientlysecure.keychain.remote.ui.RequestKeyPermissionActivity;
|
import org.sufficientlysecure.keychain.remote.ui.RequestKeyPermissionActivity;
|
||||||
@@ -141,6 +143,20 @@ public class ApiPendingIntentFactory {
|
|||||||
return createInternal(data, intent);
|
return createInternal(data, intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PendingIntent createSecurityProblemIntent(String packageName, SecurityProblem keySecurityProblem) {
|
||||||
|
Intent intent = new Intent(mContext, RemoteSecurityProblemDialogActivity.class);
|
||||||
|
intent.putExtra(RemoteSecurityProblemDialogActivity.EXTRA_PACKAGE_NAME, packageName);
|
||||||
|
intent.putExtra(RemoteSecurityProblemDialogActivity.EXTRA_SECURITY_PROBLEM, keySecurityProblem);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
//noinspection ResourceType, looks like lint is missing FLAG_IMMUTABLE
|
||||||
|
return PendingIntent.getActivity(mContext, 0, intent,
|
||||||
|
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
|
||||||
|
} else {
|
||||||
|
return PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private PendingIntent createInternal(Intent data, Intent intent) {
|
private PendingIntent createInternal(Intent data, Intent intent) {
|
||||||
// re-attach "data" for pass through. It will be used later to repeat pgp operation
|
// re-attach "data" for pass through. It will be used later to repeat pgp operation
|
||||||
intent.putExtra(RemoteSecurityTokenOperationActivity.EXTRA_DATA, data);
|
intent.putExtra(RemoteSecurityTokenOperationActivity.EXTRA_DATA, data);
|
||||||
@@ -175,5 +191,4 @@ public class ApiPendingIntentFactory {
|
|||||||
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT);
|
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ import org.sufficientlysecure.keychain.pgp.PgpSignEncryptData;
|
|||||||
import org.sufficientlysecure.keychain.pgp.PgpSignEncryptInputParcel;
|
import org.sufficientlysecure.keychain.pgp.PgpSignEncryptInputParcel;
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpSignEncryptOperation;
|
import org.sufficientlysecure.keychain.pgp.PgpSignEncryptOperation;
|
||||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||||
|
import org.sufficientlysecure.keychain.pgp.SecurityProblem;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||||
import org.sufficientlysecure.keychain.provider.ApiDataAccessObject;
|
import org.sufficientlysecure.keychain.provider.ApiDataAccessObject;
|
||||||
import org.sufficientlysecure.keychain.provider.KeyRepository;
|
import org.sufficientlysecure.keychain.provider.KeyRepository;
|
||||||
@@ -400,6 +401,7 @@ public class OpenPgpService extends Service {
|
|||||||
processDecryptionResultForResultIntent(targetApiVersion, result, pgpResult.getDecryptionResult());
|
processDecryptionResultForResultIntent(targetApiVersion, result, pgpResult.getDecryptionResult());
|
||||||
processMetadataForResultIntent(result, pgpResult.getDecryptionMetadata());
|
processMetadataForResultIntent(result, pgpResult.getDecryptionMetadata());
|
||||||
processSignatureResultForResultIntent(targetApiVersion, data, result, pgpResult);
|
processSignatureResultForResultIntent(targetApiVersion, data, result, pgpResult);
|
||||||
|
processSecurityProblemsPendingIntent(result, pgpResult);
|
||||||
|
|
||||||
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
||||||
return result;
|
return result;
|
||||||
@@ -427,6 +429,20 @@ public class OpenPgpService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void processSecurityProblemsPendingIntent(Intent result, DecryptVerifyResult decryptVerifyResult) {
|
||||||
|
List<SecurityProblem> securityProblems = decryptVerifyResult.getSecurityProblems();
|
||||||
|
if (securityProblems.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO what if there is multiple?
|
||||||
|
SecurityProblem keySecurityProblem = securityProblems.get(0);
|
||||||
|
|
||||||
|
String packageName = mApiPermissionHelper.getCurrentCallingPackage();
|
||||||
|
result.putExtra(OpenPgpApi.RESULT_INSECURE_DETAIL_INTENT,
|
||||||
|
mApiPendingIntentFactory.createSecurityProblemIntent(packageName, keySecurityProblem));
|
||||||
|
}
|
||||||
|
|
||||||
private void processDecryptionResultForResultIntent(int targetApiVersion, Intent result,
|
private void processDecryptionResultForResultIntent(int targetApiVersion, Intent result,
|
||||||
OpenPgpDecryptionResult decryptionResult) {
|
OpenPgpDecryptionResult decryptionResult) {
|
||||||
if (targetApiVersion < API_VERSION_WITH_DECRYPTION_RESULT) {
|
if (targetApiVersion < API_VERSION_WITH_DECRYPTION_RESULT) {
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.sufficientlysecure.keychain.remote.ui;
|
||||||
|
|
||||||
|
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
|
||||||
|
|
||||||
|
public class RemoteSecurityProblemDialogActivity extends FragmentActivity {
|
||||||
|
public static final String EXTRA_PACKAGE_NAME = "package_name";
|
||||||
|
public static final String EXTRA_SECURITY_PROBLEM = "security_problem";
|
||||||
|
}
|
||||||
2
extern/openpgp-api-lib
vendored
2
extern/openpgp-api-lib
vendored
Submodule extern/openpgp-api-lib updated: f28cb92944...d19cfacdee
Reference in New Issue
Block a user