summaryrefslogtreecommitdiff
path: root/src/se/leap/leapclient/LeapHttpClient.java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-05-08 18:23:10 +0200
committerParménides GV <parmegv@sdf.org>2013-05-08 18:23:10 +0200
commitfb5e26c2ff4f95dd826a3ce3545865ac4388b711 (patch)
tree51dc8cc61e1024ae4c6d060077b6a6f60dfc35fd /src/se/leap/leapclient/LeapHttpClient.java
parent0cb5d9470127e280d2d955effd32b82e533d9de3 (diff)
After loggin in successfully, the new client certificate is downloaded.
It is stored in SharedPrefs, with ConfigHelper.cert_key (="cert") key.
Diffstat (limited to 'src/se/leap/leapclient/LeapHttpClient.java')
-rw-r--r--src/se/leap/leapclient/LeapHttpClient.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/se/leap/leapclient/LeapHttpClient.java b/src/se/leap/leapclient/LeapHttpClient.java
index f9119823..4de7ae08 100644
--- a/src/se/leap/leapclient/LeapHttpClient.java
+++ b/src/se/leap/leapclient/LeapHttpClient.java
@@ -9,6 +9,8 @@ import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.SingleClientConnManager;
+import org.json.JSONException;
+import org.json.JSONObject;
import android.content.Context;
@@ -49,13 +51,20 @@ public class LeapHttpClient extends DefaultHttpClient {
throw new AssertionError(e);
}
}
-
+
public static LeapHttpClient getInstance(Context context) {
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);
+ String cert_json_string = ConfigHelper.getStringFromSharedPref(ConfigHelper.main_cert_key);
+ String cert_string;
+ try {
+ cert_string = new JSONObject(cert_json_string).getString(ConfigHelper.main_cert_key);
+ if(!cert_string.isEmpty()) {
+ ConfigHelper.addTrustedCertificate("recovered_certificate", cert_string);
+ }
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
}
return client;