Inform user if signature check fails

This commit is contained in:
Dominik Schürmann 2013-12-30 20:57:49 +01:00
parent a8cafd59e4
commit 19082b62a9
5 changed files with 58 additions and 6 deletions

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<org.sufficientlysecure.htmltextview.HtmlTextView
android:id="@+id/api_app_error_message_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:paddingBottom="0dip"
android:text="Set in-code!"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>

View File

@ -338,6 +338,7 @@
<string name="api_select_pub_keys_missing_text">No public keys were found for these user ids:</string> <string name="api_select_pub_keys_missing_text">No public keys were found for these user ids:</string>
<string name="api_select_pub_keys_dublicates_text">More than one public key exist for these user ids:</string> <string name="api_select_pub_keys_dublicates_text">More than one public key exist for these user ids:</string>
<string name="api_select_pub_keys_text">Please review the list of recipients!</string> <string name="api_select_pub_keys_text">Please review the list of recipients!</string>
<string name="api_error_wrong_signature">Signature check failed! Have you installed this app from a different source? If you are sure that this is not an attack, revoke this app\'s registration in OpenPGP Keychain and then register the app again.</string>
<!-- Share --> <!-- Share -->
<string name="share_qr_code_dialog_start">Go through all QR Codes using \'Next\', and scan them one by one.</string> <string name="share_qr_code_dialog_start">Go through all QR Codes using \'Next\', and scan them one by one.</string>

View File

@ -102,8 +102,7 @@ public class ActionBarHelper {
final View customActionBarView = inflater final View customActionBarView = inflater
.inflate(R.layout.actionbar_custom_view_done, null); .inflate(R.layout.actionbar_custom_view_done, null);
((TextView) customActionBarView.findViewById(R.id.actionbar_done_text)) ((TextView) customActionBarView.findViewById(R.id.actionbar_done_text)).setText(doneText);
.setText(R.string.api_settings_save);
customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener( customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(
doneOnClickListener); doneOnClickListener);

View File

@ -23,6 +23,7 @@ import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.exception.WrongPackageSignatureException; import org.sufficientlysecure.keychain.service.exception.WrongPackageSignatureException;
@ -140,8 +141,12 @@ public abstract class RemoteService extends Service {
} }
} }
} catch (WrongPackageSignatureException e) { } catch (WrongPackageSignatureException e) {
// TODO: Inform user about wrong signature! Log.e(Constants.TAG, e.getMessage());
Log.e(Constants.TAG, "RemoteService", e);
Bundle extras = new Bundle();
extras.putString(RemoteServiceActivity.EXTRA_ERROR_MESSAGE,
getString(R.string.api_error_wrong_signature));
pauseAndStartUserInteraction(RemoteServiceActivity.ACTION_ERROR_MESSAGE, null, extras);
} }
} }
@ -243,8 +248,13 @@ public abstract class RemoteService extends Service {
mThreadPool.shutdownNow(); mThreadPool.shutdownNow();
} }
} catch (WrongPackageSignatureException e) { } catch (WrongPackageSignatureException e) {
// TODO: Inform user about wrong signature! Log.e(Constants.TAG, e.getMessage());
Log.e(Constants.TAG, "RemoteService", e);
Bundle extras = new Bundle();
extras.putString(RemoteServiceActivity.EXTRA_ERROR_MESSAGE,
getString(R.string.api_error_wrong_signature));
pauseAndStartUserInteraction(RemoteServiceActivity.ACTION_ERROR_MESSAGE, null,
extras);
} }
} else { } else {
allowed = false; allowed = false;

View File

@ -48,6 +48,8 @@ public class RemoteServiceActivity extends SherlockFragmentActivity {
+ "API_ACTIVITY_CACHE_PASSPHRASE"; + "API_ACTIVITY_CACHE_PASSPHRASE";
public static final String ACTION_SELECT_PUB_KEYS = Constants.INTENT_PREFIX public static final String ACTION_SELECT_PUB_KEYS = Constants.INTENT_PREFIX
+ "API_ACTIVITY_SELECT_PUB_KEYS"; + "API_ACTIVITY_SELECT_PUB_KEYS";
public static final String ACTION_ERROR_MESSAGE = Constants.INTENT_PREFIX
+ "API_ACTIVITY_ERROR_MESSAGE";
public static final String EXTRA_MESSENGER = "messenger"; public static final String EXTRA_MESSENGER = "messenger";
@ -60,6 +62,8 @@ public class RemoteServiceActivity extends SherlockFragmentActivity {
public static final String EXTRA_SELECTED_MASTER_KEY_IDS = "master_key_ids"; public static final String EXTRA_SELECTED_MASTER_KEY_IDS = "master_key_ids";
public static final String EXTRA_MISSING_USER_IDS = "missing_user_ids"; public static final String EXTRA_MISSING_USER_IDS = "missing_user_ids";
public static final String EXTRA_DUBLICATE_USER_IDS = "dublicate_user_ids"; public static final String EXTRA_DUBLICATE_USER_IDS = "dublicate_user_ids";
// error message
public static final String EXTRA_ERROR_MESSAGE = "error_message";
private Messenger mMessenger; private Messenger mMessenger;
@ -271,6 +275,27 @@ public class RemoteServiceActivity extends SherlockFragmentActivity {
getSupportFragmentManager().beginTransaction() getSupportFragmentManager().beginTransaction()
.add(R.id.api_select_pub_keys_fragment_container, mSelectFragment).commit(); .add(R.id.api_select_pub_keys_fragment_container, mSelectFragment).commit();
} }
} else if (ACTION_ERROR_MESSAGE.equals(action)) {
String errorMessage = intent.getStringExtra(EXTRA_ERROR_MESSAGE);
String text = new String();
text += "<font color=\"red\">" + errorMessage + "</font>";
// Inflate a "Done" custom action bar view
ActionBarHelper.setDoneView(getSupportActionBar(), R.string.btn_okay,
new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
setContentView(R.layout.api_app_error_message);
// set text on view
HtmlTextView textView = (HtmlTextView) findViewById(R.id.api_app_error_message_text);
textView.setHtmlFromString(text);
} else { } else {
Log.e(Constants.TAG, "Wrong action!"); Log.e(Constants.TAG, "Wrong action!");
finish(); finish();