diff options
Diffstat (limited to 'app/src')
5 files changed, 42 insertions, 35 deletions
diff --git a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java index 886d70a0..ce13d322 100644 --- a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java +++ b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java @@ -554,15 +554,18 @@ public class ProviderAPI extends IntentService { if(!ConfigHelper.checkErroneousDownload(cert_string)) { X509Certificate certificate = ConfigHelper.parseX509CertificateFromString(cert_string); try { - JSONObject provider_json = new JSONObject(preferences.getString(Provider.KEY, "")); - String fingerprint = provider_json.getString(Provider.CA_CERT_FINGERPRINT); - String encoding = fingerprint.split(":")[0]; - String expected_fingerprint = fingerprint.split(":")[1]; - String real_fingerprint = base64toHex(Base64.encodeToString( - MessageDigest.getInstance(encoding).digest(certificate.getEncoded()), - Base64.DEFAULT)); - - result = real_fingerprint.trim().equalsIgnoreCase(expected_fingerprint.trim()); + if(certificate != null) { + JSONObject provider_json = new JSONObject(preferences.getString(Provider.KEY, "")); + String fingerprint = provider_json.getString(Provider.CA_CERT_FINGERPRINT); + String encoding = fingerprint.split(":")[0]; + String expected_fingerprint = fingerprint.split(":")[1]; + String real_fingerprint = base64toHex(Base64.encodeToString( + MessageDigest.getInstance(encoding).digest(certificate.getEncoded()), + Base64.DEFAULT)); + + result = real_fingerprint.trim().equalsIgnoreCase(expected_fingerprint.trim()); + } else + result = false; } catch (JSONException e) { result = false; } catch (NoSuchAlgorithmException e) { diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index e32dbdee..52b22695 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -329,7 +329,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn FragmentTransaction transaction = fragment_manager.removePreviousFragment(SessionDialog.TAG); DialogFragment newFragment = SessionDialog.newInstance(); - if(resultData != null && !resultData.isEmpty()) + if(resultData != null && !resultData.isEmpty() && fragment_manager.findFragmentByTag(SessionDialog.TAG) == null) newFragment.setArguments(resultData); newFragment.show(transaction, SessionDialog.TAG); } @@ -378,7 +378,7 @@ public class Dashboard extends Activity implements SessionDialog.SessionDialogIn FragmentTransaction transaction = fragment_manager.removePreviousFragment(SessionDialog.TAG); DialogFragment newFragment = SessionDialog.newInstance(); - if(resultData != null && !resultData.isEmpty()) { + if(resultData != null && !resultData.isEmpty() && fragment_manager.findFragmentByTag(SessionDialog.TAG) == null) { newFragment.setArguments(resultData); } newFragment.show(transaction, SessionDialog.TAG); diff --git a/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java b/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java index 22e0f128..fd9ca851 100644 --- a/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java +++ b/app/src/main/java/se/leap/bitmaskclient/SessionDialog.java @@ -129,15 +129,15 @@ public class SessionDialog extends DialogFragment{ SessionDialogInterface interface_with_Dashboard; - /** - * @return a new instance of this DialogFragment. - */ - public static DialogFragment newInstance() { + /** + * @return a new instance of this DialogFragment. + */ + public static DialogFragment newInstance() { if(dialog == null) dialog = new SessionDialog(); return dialog; - } + } @Override public void onAttach(Activity activity) { diff --git a/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java index 73de29bc..3d9bb7b1 100644 --- a/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java +++ b/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java @@ -82,14 +82,6 @@ implements NewProviderDialogInterface, ProviderDetailFragmentInterface, Download private String progressbar_text = ""; private String provider_name = ""; private int progress = -1; - - private void initProviderList() { - List<Renderer<Provider>> prototypes = new ArrayList<Renderer<Provider>>(); - prototypes.add(new ProviderRenderer(this)); - ProviderRendererBuilder providerRendererBuilder = new ProviderRendererBuilder(prototypes); - adapter = new ProviderListAdapter(getLayoutInflater(), providerRendererBuilder, provider_manager); - provider_list_view.setAdapter(adapter); - } @Override protected void onSaveInstanceState(Bundle outState) { @@ -109,13 +101,13 @@ implements NewProviderDialogInterface, ProviderDetailFragmentInterface, Download preferences = getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE); fragment_manager = new FragmentManagerEnhanced(getFragmentManager()); provider_manager = ProviderManager.getInstance(getAssets(), getExternalFilesDir(null)); + + setUpProviderList(); setUpInitialUI(); setUpProviderAPIResultReceiver(); - setUpProviderList(); - if ( savedInstanceState != null ) { restoreState(savedInstanceState); } @@ -147,6 +139,7 @@ implements NewProviderDialogInterface, ProviderDetailFragmentInterface, Download private void setUpInitialUI() { setContentView(R.layout.configuration_wizard_activity); ButterKnife.inject(this); + provider_list_view.setAdapter(adapter); hideProgressBar(); } @@ -176,6 +169,13 @@ implements NewProviderDialogInterface, ProviderDetailFragmentInterface, Download update_intent_filter.addCategory(Intent.CATEGORY_DEFAULT); registerReceiver(providerAPI_broadcast_receiver_update, update_intent_filter); } + + private void initProviderList() { + List<Renderer<Provider>> prototypes = new ArrayList<Renderer<Provider>>(); + prototypes.add(new ProviderRenderer(this)); + ProviderRendererBuilder providerRendererBuilder = new ProviderRendererBuilder(prototypes); + adapter = new ProviderListAdapter(getLayoutInflater(), providerRendererBuilder, provider_manager); + } @Override public void onReceiveResult(int resultCode, Bundle resultData) { diff --git a/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java index 9d0b4db6..8b8cabdf 100644 --- a/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java +++ b/app/src/release/java/se/leap/bitmaskclient/ProviderAPI.java @@ -547,15 +547,19 @@ public class ProviderAPI extends IntentService { if(!ConfigHelper.checkErroneousDownload(cert_string)) { X509Certificate certificate = ConfigHelper.parseX509CertificateFromString(cert_string); try { - JSONObject provider_json = new JSONObject(preferences.getString(Provider.KEY, "")); - String fingerprint = provider_json.getString(Provider.CA_CERT_FINGERPRINT); - String encoding = fingerprint.split(":")[0]; - String expected_fingerprint = fingerprint.split(":")[1]; - String real_fingerprint = base64toHex(Base64.encodeToString( - MessageDigest.getInstance(encoding).digest(certificate.getEncoded()), - Base64.DEFAULT)); - - result = real_fingerprint.trim().equalsIgnoreCase(expected_fingerprint.trim()); + if(certificate != null) { + JSONObject provider_json = new JSONObject(preferences.getString(Provider.KEY, "")); + String fingerprint = provider_json.getString(Provider.CA_CERT_FINGERPRINT); + String encoding = fingerprint.split(":")[0]; + String expected_fingerprint = fingerprint.split(":")[1]; + String real_fingerprint = base64toHex(Base64.encodeToString( + MessageDigest.getInstance(encoding).digest(certificate.getEncoded()), + Base64.DEFAULT)); + + result = real_fingerprint.trim().equalsIgnoreCase(expected_fingerprint.trim()); + } + else + result = false; } catch (JSONException e) { result = false; } catch (NoSuchAlgorithmException e) { |