Commit 814b2fa0 authored by Toni Beier's avatar Toni Beier

Convert local cached idm values to new wifi config format

parent f16070e3
......@@ -28,6 +28,7 @@ import com.android.volley.VolleyLog;
import com.android.volley.toolbox.StringRequest;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.ByteArrayInputStream;
......@@ -248,8 +249,30 @@ class Helper {
static boolean buildFromPreferences(Context context) {
SharedPreferences sharedPrefs = context.getApplicationContext().getSharedPreferences("de.tu_chemnitz.de.wlan.config", Context.MODE_PRIVATE);
String savedJsonEduromConfig = sharedPrefs.getString("wifi_json", "{}"); // default is empty JSON {}
try {
JSONObject jsonEduromConfig = new JSONObject(savedJsonEduromConfig);
String anonymousIdentity = jsonEduromConfig.getString("anonymousIdentity");
//Check for old anonymous identity
if( anonymousIdentity.equals(context.getString(R.string.edurom_anonymous_identity_old))) {
//Build and set new identity
String identity = jsonEduromConfig.getString( "identity" );
String idmPrimaryKey = jsonEduromConfig.getString("pk");
String username = identity.substring(0, identity.indexOf('@'));
jsonEduromConfig.put("identity", context.getString(R.string.edurom_identity_pattern, username,idmPrimaryKey));
//Set new Submatch
jsonEduromConfig.put("subjectMatch",context.getString(R.string.edurom_radius_server));
//Set new anonymous identity
jsonEduromConfig.put("anonymousIdentity",context.getString(R.string.edurom_anonymous_identity) );
savedJsonEduromConfig = jsonEduromConfig.toString(2);
}
} catch (JSONException jsonException) {
Log.e("ca_migration","error while old local idm values converted in form", jsonException);
}
return sharedPrefs.contains("wifi_json") &&
buildWifiConfig(sharedPrefs.getString("wifi_json", "{}")); // default is empty JSON {}
buildWifiConfig(savedJsonEduromConfig);
}
static boolean buildWifiConfig(String json) {
......
<resources>
<string name="app_name">TUC WLAN</string>
<string translatable="false" name="edurom_anonymous_identity">androidapp_ca2030@tu-chemnitz.de</string>
<string translatable="false" name="edurom_anonymous_identity_old">anonymous_androidapp@tu-chemnitz.de </string>
<string translatable="false" name="edurom_error_old_configuration">Veraltete Anonyme Identität: %1$s</string>
<string translatable="false" name="edurom_radius_server">radius2030.tu-chemnitz.de</string>
<string translatable="false" name="edurom_identity_pattern">%1$s-%2$s@tu-chemnitz.de</string>
</resources>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment