summaryrefslogtreecommitdiff
path: root/src/se/leap/leapclient/ProviderAPI.java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-02-05 20:46:33 +0100
committerParménides GV <parmegv@sdf.org>2013-02-05 20:46:33 +0100
commit1d5f1c320ee67cfadd62aeef056a043bee75096d (patch)
treed92f986b1579e6a2b365e774115f39c658d74fca /src/se/leap/leapclient/ProviderAPI.java
parent45b86cd7c8922cfd03a7f056941852273c2d122a (diff)
Simplified certificates and urls: only 1 certificate, and no :443 port
in eip. Downloads certificate and eip from web, and loads provider from assets. KeyStore not created with latest version of BouncyCastle. Looking forward to file a bug and look for a solution.
Diffstat (limited to 'src/se/leap/leapclient/ProviderAPI.java')
-rw-r--r--src/se/leap/leapclient/ProviderAPI.java21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/se/leap/leapclient/ProviderAPI.java b/src/se/leap/leapclient/ProviderAPI.java
index d487ebe3..33f7fd74 100644
--- a/src/se/leap/leapclient/ProviderAPI.java
+++ b/src/se/leap/leapclient/ProviderAPI.java
@@ -5,6 +5,7 @@ import java.util.Scanner;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
+import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONException;
@@ -28,35 +29,41 @@ public class ProviderAPI extends IntentService {
Bundle task;
System.out.println("onHandleIntent called");
if (!(task = task_for.getBundleExtra(ConfigHelper.downloadJsonFilesBundleExtra)).isEmpty()) {
- String provider_json_url = (String) task.get(ConfigHelper.provider_key);
+ String cert_url = (String) task.get(ConfigHelper.cert_key);
String eip_service_json_url = (String) task.get(ConfigHelper.eip_service_key);
try {
- JSONObject provider_json = getFromProvider(provider_json_url);
- ConfigHelper.saveSharedPref(ConfigHelper.provider_key, provider_json);
- JSONObject eip_service_json = getFromProvider(eip_service_json_url);
+ 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();
}
}
}
- private JSONObject getFromProvider(String json_url) throws IOException, JSONException {
+ private String getStringFromProvider(String string_url) throws IOException {
String json_file_content = "";
DefaultHttpClient client = new LeapHttpClient(getApplicationContext());
- HttpGet get = new HttpGet(json_url);
+ HttpGet get = new HttpGet(string_url);
// Execute the GET call and obtain the response
HttpResponse getResponse = client.execute(get);
HttpEntity responseEntity = getResponse.getEntity();
json_file_content = new Scanner(responseEntity.getContent()).useDelimiter("\\A").next();
-
+ return json_file_content;
+ }
+ private JSONObject getJSONFromProvider(String json_url) throws IOException, JSONException {
+ String json_file_content = getStringFromProvider(json_url);
return new JSONObject(json_file_content);
}