summaryrefslogtreecommitdiff
path: root/src/se/leap
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-05-01 18:41:05 +0200
committerParménides GV <parmegv@sdf.org>2013-05-01 18:41:05 +0200
commitff3d469a9549e3670e097fc0e49c043c84e7b7d4 (patch)
tree9fb747e05841020f11d062a86df86bdcdd85e689 /src/se/leap
parent09493a9dec5fb235d5c4914eb8f8142e3312e246 (diff)
If the app is restarted with a custom provider selected, the client can
request a log in without certificates problems. I've removed the addition of the certificate when downloaded eip-service.json, because I already do that in LeapHttpClient. Solves issue 2367: https://leap.se/code/issues/2367
Diffstat (limited to 'src/se/leap')
-rw-r--r--src/se/leap/leapclient/ConfigHelper.java16
-rw-r--r--src/se/leap/leapclient/Dashboard.java4
-rw-r--r--src/se/leap/leapclient/LeapHttpClient.java7
-rw-r--r--src/se/leap/leapclient/ProviderAPI.java8
-rw-r--r--src/se/leap/leapclient/ProviderListContent.java2
5 files changed, 28 insertions, 9 deletions
diff --git a/src/se/leap/leapclient/ConfigHelper.java b/src/se/leap/leapclient/ConfigHelper.java
index 7c52629b..76845228 100644
--- a/src/se/leap/leapclient/ConfigHelper.java
+++ b/src/se/leap/leapclient/ConfigHelper.java
@@ -48,7 +48,7 @@ public class ConfigHelper {
final public static String api_url_key = "api_uri";
final public static String username_key = "username";
final public static String password_key = "password";
- final public static String eip_service_api_path = "/config/eip-service.json";
+ final public static String eip_service_api_path = "config/eip-service.json";
final public static String NG_1024 =
"eeaf0ab9adb38dd69c33f80afa8fc5e86072618775ff3c0b9ea2314c9c256576d674df7496ea81d3383b4813d692c6e0e0d5d8e250b98be48e495c1d6089dad15dc7d7b46154d6b6ce8ef4ad69b15d4982559b297bcf1885c529f566660e57ec68edbc3c05726cc02fd4cbf4976eaa9afd5138fe8376435b9fc61d2fc0eb06e3";
@@ -159,6 +159,9 @@ public class ConfigHelper {
cf = CertificateFactory.getInstance("X.509");
X509Certificate cert =
(X509Certificate)cf.generateCertificate(openFileInputStream(filename_to_save));
+ if(keystore_trusted == null) {
+ getNewKeystore(null);
+ }
keystore_trusted.setCertificateEntry(provider, cert);
} catch (CertificateException e) {
// TODO Auto-generated catch block
@@ -179,10 +182,15 @@ public class ConfigHelper {
try {
// Initialize the keystore with the provided trusted certificates
// Also provide the password of the keystore
- //keystore_trusted.load(leap_keystore, "uer92jf".toCharArray());
- keystore_trusted.load(null, null);
+ if(leap_keystore != null) {
+ //keystore_trusted.load(leap_keystore, "uer92jf".toCharArray());
+ keystore_trusted.load(null, null);
+ } else {
+ keystore_trusted.load(null, null);
+ }
} finally {
- leap_keystore.close();
+ if(leap_keystore != null)
+ leap_keystore.close();
}
} catch (KeyStoreException e) {
// TODO Auto-generated catch block
diff --git a/src/se/leap/leapclient/Dashboard.java b/src/se/leap/leapclient/Dashboard.java
index 577092bb..a68c048b 100644
--- a/src/se/leap/leapclient/Dashboard.java
+++ b/src/se/leap/leapclient/Dashboard.java
@@ -43,7 +43,9 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
setContentView(R.layout.client_dashboard);
preferences = getSharedPreferences(ConfigHelper.PREFERENCES_KEY,MODE_PRIVATE);
-
+ if(ConfigHelper.shared_preferences == null)
+ ConfigHelper.setSharedPreferences(preferences);
+
// Check if we have preferences, run configuration wizard if not
// TODO We should do a better check for config that this!
if (!preferences.contains("provider") )
diff --git a/src/se/leap/leapclient/LeapHttpClient.java b/src/se/leap/leapclient/LeapHttpClient.java
index d1908c34..f9119823 100644
--- a/src/se/leap/leapclient/LeapHttpClient.java
+++ b/src/se/leap/leapclient/LeapHttpClient.java
@@ -51,8 +51,13 @@ public class LeapHttpClient extends DefaultHttpClient {
}
public static LeapHttpClient getInstance(Context context) {
- if(client == null)
+ if(client == null) {
client = new LeapHttpClient(context);
+ String cert_string = ConfigHelper.getStringFromSharedPref(ConfigHelper.cert_key);
+ if(!cert_string.isEmpty()) {
+ ConfigHelper.addTrustedCertificate("recovered_certificate", cert_string);
+ }
+ }
return client;
}
}
diff --git a/src/se/leap/leapclient/ProviderAPI.java b/src/se/leap/leapclient/ProviderAPI.java
index 66eb3e60..4a288787 100644
--- a/src/se/leap/leapclient/ProviderAPI.java
+++ b/src/se/leap/leapclient/ProviderAPI.java
@@ -93,7 +93,7 @@ public class ProviderAPI extends IntentService {
boolean danger_on = task.getBoolean(ConfigHelper.danger_on);
try {
String cert_string = getStringFromProvider(cert_url, danger_on);
- ConfigHelper.addTrustedCertificate(provider_name, cert_string);
+ //ConfigHelper.addTrustedCertificate(provider_name, cert_string);
JSONObject cert_json = new JSONObject("{ \"certificate\" : \"" + cert_string + "\"}");
ConfigHelper.saveSharedPref(ConfigHelper.cert_key, cert_json);
JSONObject eip_service_json = getJSONFromProvider(eip_service_json_url, danger_on);
@@ -177,9 +177,11 @@ public class ProviderAPI extends IntentService {
if(!json_response.isNull("errors") || json_response.has("errors")) {
return new JSONObject();
}
+
+ String session_id = "";
List<Cookie> cookies = client.getCookieStore().getCookies();
if(!cookies.isEmpty()) {
- String session_id = cookies.get(0).getValue();
+ session_id = cookies.get(0).getValue();
}
return json_response;
}
@@ -190,6 +192,8 @@ public class ProviderAPI extends IntentService {
HttpPut put = new HttpPut(server_url + "/sessions/" + username +".json" + "?" + parameter_chain);
HttpContext localContext = new BasicHttpContext();
localContext.setAttribute(ClientContext.COOKIE_STORE, client.getCookieStore());
+ String session_id = client.getCookieStore().getCookies().get(0).getValue();
+ int number_of_cookies = client.getCookieStore().getCookies().size();
HttpResponse getResponse = client.execute(put, localContext);
HttpEntity responseEntity = getResponse.getEntity();
diff --git a/src/se/leap/leapclient/ProviderListContent.java b/src/se/leap/leapclient/ProviderListContent.java
index 9ed7e9bf..8cc349c2 100644
--- a/src/se/leap/leapclient/ProviderListContent.java
+++ b/src/se/leap/leapclient/ProviderListContent.java
@@ -88,7 +88,7 @@ public class ProviderListContent {
id = name;
this.name = name;
this.provider_json_url = provider_json_url;
- eip_service_json_url = (String) file_contents.get("api_uri") + ConfigHelper.eip_service_api_path;
+ eip_service_json_url = file_contents.getString("api_uri") + "/" + file_contents.getString("api_version") + "/" + ConfigHelper.eip_service_api_path;
cert_json_url = (String) file_contents.get("ca_cert_uri");
this.custom = custom;
this.danger_on = danger_on;