summaryrefslogtreecommitdiff
path: root/src/se/leap
diff options
context:
space:
mode:
Diffstat (limited to 'src/se/leap')
-rw-r--r--src/se/leap/leapclient/ConfigHelper.java4
-rw-r--r--src/se/leap/leapclient/ConfigurationWizard.java9
-rw-r--r--src/se/leap/leapclient/ProviderAPI.java44
3 files changed, 39 insertions, 18 deletions
diff --git a/src/se/leap/leapclient/ConfigHelper.java b/src/se/leap/leapclient/ConfigHelper.java
index 7649fcae..c9810519 100644
--- a/src/se/leap/leapclient/ConfigHelper.java
+++ b/src/se/leap/leapclient/ConfigHelper.java
@@ -37,7 +37,9 @@ public class ConfigHelper {
"EEAF0AB9ADB38DD69C33F80AFA8FC5E86072618775FF3C0B9EA2314C9C256576D674DF7496EA81D3383B4813D692C6E0E0D5D8E250B98BE48E495C1D6089DAD15DC7D7B46154D6B6CE8EF4AD69B15D4982559B297BCF1885C529F566660E57EC68EDBC3C05726CC02FD4CBF4976EAA9AFD5138FE8376435B9FC61D2FC0EB06E3";
final public static BigInteger g = BigInteger.valueOf(2);
- final public static int CUSTOM_PROVIDER_ADDED = 0;
+ final public static int CUSTOM_PROVIDER_ADDED = 0;
+ final public static int CORRECTLY_DOWNLOADED_JSON_FILES = 0;
+ final public static int INCORRECTLY_DOWNLOADED_JSON_FILES = 0;
static void saveSharedPref(String shared_preferences_key, JSONObject content) {
diff --git a/src/se/leap/leapclient/ConfigurationWizard.java b/src/se/leap/leapclient/ConfigurationWizard.java
index e252fa6b..e41eb5cf 100644
--- a/src/se/leap/leapclient/ConfigurationWizard.java
+++ b/src/se/leap/leapclient/ConfigurationWizard.java
@@ -159,6 +159,7 @@ public class ConfigurationWizard extends Activity
method_and_parameters.putString(ConfigHelper.eip_service_key, current_provider_item.eip_service_json_url);
provider_API_command.putExtra(ConfigHelper.downloadJsonFilesBundleExtra, method_and_parameters);
+ provider_API_command.putExtra("receiver", providerAPI_result_receiver);
startService(provider_API_command);
@@ -188,12 +189,12 @@ public class ConfigurationWizard extends Activity
provider_API_command.putExtra(ConfigHelper.downloadNewProviderDotJSON, method_and_parameters);
provider_API_command.putExtra("receiver", providerAPI_result_receiver);
+
startService(provider_API_command);
}
@Override
public void onReceiveResult(int resultCode, Bundle resultData) {
- // TODO Auto-generated method stub
if(resultCode == ConfigHelper.CUSTOM_PROVIDER_ADDED){
ProviderListFragment providerList = new ProviderListFragment();
@@ -202,5 +203,11 @@ public class ConfigurationWizard extends Activity
.replace(R.id.configuration_wizard_layout, providerList, "providerlist")
.commit();
}
+ else if(resultCode == ConfigHelper.INCORRECTLY_DOWNLOADED_JSON_FILES) {
+ // TODO Show error
+ }
+ else if(resultCode == ConfigHelper.CORRECTLY_DOWNLOADED_JSON_FILES) {
+ // TODO Show nothing? Show success?
+ }
}
}
diff --git a/src/se/leap/leapclient/ProviderAPI.java b/src/se/leap/leapclient/ProviderAPI.java
index 96544159..19404c2b 100644
--- a/src/se/leap/leapclient/ProviderAPI.java
+++ b/src/se/leap/leapclient/ProviderAPI.java
@@ -44,25 +44,14 @@ public class ProviderAPI extends IntentService {
@Override
protected void onHandleIntent(Intent task_for) {
final ResultReceiver receiver = task_for.getParcelableExtra("receiver");
+
Bundle task;
System.out.println("onHandleIntent called");
if((task = task_for.getBundleExtra(ConfigHelper.downloadJsonFilesBundleExtra)) != null) {
- String cert_url = (String) task.get(ConfigHelper.cert_key);
- String eip_service_json_url = (String) task.get(ConfigHelper.eip_service_key);
- try {
- String cert_string = getStringFromProvider(cert_url);
- JSONObject cert_json = new JSONObject("{ \"certificate\" : \"" + cert_string + "\"}");
- ConfigHelper.saveSharedPref(ConfigHelper.cert_key, cert_json);
- JSONObject eip_service_json = getJSONFromProvider(eip_service_json_url);
- ConfigHelper.saveSharedPref(ConfigHelper.eip_service_key, eip_service_json);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (JSONException e) {
- ConfigHelper.rescueJSONException(e);
- } catch(Exception e) {
- e.printStackTrace();
- }
+ if(!downloadJsonFiles(task))
+ receiver.send(ConfigHelper.INCORRECTLY_DOWNLOADED_JSON_FILES, Bundle.EMPTY);
+ else
+ receiver.send(ConfigHelper.CORRECTLY_DOWNLOADED_JSON_FILES, Bundle.EMPTY);
}
else if ((task = task_for.getBundleExtra(ConfigHelper.downloadNewProviderDotJSON)) != null) {
boolean custom = true;
@@ -128,6 +117,29 @@ public class ProviderAPI extends IntentService {
}
}
+ private boolean downloadJsonFiles(Bundle task) {
+ String cert_url = (String) task.get(ConfigHelper.cert_key);
+ String eip_service_json_url = (String) task.get(ConfigHelper.eip_service_key);
+ try {
+ String cert_string = getStringFromProvider(cert_url);
+ JSONObject cert_json = new JSONObject("{ \"certificate\" : \"" + cert_string + "\"}");
+ ConfigHelper.saveSharedPref(ConfigHelper.cert_key, cert_json);
+ JSONObject eip_service_json = getJSONFromProvider(eip_service_json_url);
+ ConfigHelper.saveSharedPref(ConfigHelper.eip_service_key, eip_service_json);
+ return true;
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return false;
+ } catch (JSONException e) {
+ ConfigHelper.rescueJSONException(e);
+ return false;
+ } catch(Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
private void sendM1(BigInteger m2, BigInteger k, BigInteger clientA,
BigInteger serverB, int salt, String username) throws NoSuchAlgorithmException {
BigInteger M1 = generateM1(k, clientA, serverB, salt, username);