2 Commits

Author SHA1 Message Date
Caesar2011
22470f58da New preference for FastSync 2019-01-17 00:01:54 +01:00
Caesar2011
697740e20b Simplified Login Token 2019-01-16 23:34:52 +01:00
8 changed files with 26 additions and 39 deletions

View File

@@ -81,17 +81,6 @@ public class UserLoginTask extends AsyncTask<Void, Void, String> {
} else {
return login.get().toJsonString();
}
/*for (String credential : DUMMY_CREDENTIALS) {
String[] pieces = credential.split(":");
if (pieces[0].equals(mEmail)) {
// Account exists, return true if the password matches.
return pieces[1].equals(mPassword) ? "auth token here" : null;
}
}
// TODO: register the new account here.
return null;*/
}
@Override

View File

@@ -62,14 +62,13 @@ public class Login extends HTTPService {
String fuJSESSIONID = success2.get("JSESSIONID");
step3(fuJSESSIONID, success3 -> {
step4(username, password, fuJSESSIONID, success4 -> {
String fuSHIBSession = success4.get("shib_idp_session");
String samlResponse = success4.get("SAMLResponse");
step5(samlResponse, success5 -> {
String shibsessionKey = success5.get("shibsessionKey");
String shibsessionName = success5.get("shibsessionName");
step6(shibsessionKey, shibsessionName, success6 -> {
String kvvJSESSIONID = success6.get("JSESSIONID");
LoginToken token = new LoginToken(username, shibsessionKey, shibsessionName, kvvJSESSIONID);
LoginToken token = new LoginToken(username, kvvJSESSIONID);
callback.onResponse(token);
}, error);
}, error);

View File

@@ -1,12 +1,8 @@
package de.sebse.fuplanner.services.kvv.types;
import android.content.Context;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import androidx.annotation.NonNull;
@@ -19,25 +15,19 @@ import de.sebse.fuplanner.tools.logging.Logger;
* Created by sebastian on 29.10.17.
*/
public class LoginToken implements Serializable {
public class LoginToken {
static Logger log = new Logger("LoginToken");
private static final String FILE_NAME = "LoginTokenSaving";
private final String username;
private final String shibsessionKey;
private final String shibsessionName;
private final String JSESSIONID;
@Nullable private String fullName;
@Nullable private String email;
public LoginToken(String username, String shibsessionKey, String shibsessionName, String JSESSIONID) {
public LoginToken(String username, String JSESSIONID) {
this.username = username;
this.shibsessionKey = shibsessionKey;
this.shibsessionName = shibsessionName;
this.JSESSIONID = JSESSIONID;
}
@Nullable
public static void load(CustomAccountManager manager, LoginTokenInterface callback) {
if (!manager.hasAccounts(AccountGeneral.ACCOUNT_TYPE)) {
callback.run(null);
@@ -65,14 +55,6 @@ public class LoginToken implements Serializable {
return username;
}
private String getShibsessionKey() {
return shibsessionKey;
}
private String getShibsessionName() {
return shibsessionName;
}
private String getJSESSIONID() {
return JSESSIONID;
}
@@ -90,7 +72,6 @@ public class LoginToken implements Serializable {
public HashMap<String, String> getCookies() {
HashMap<String, String> cookies = new HashMap<>();
cookies.put("JSESSIONID", getJSESSIONID());
cookies.put(getShibsessionKey(), getShibsessionName());
cookies.put("pasystem_timezone_ok", "true");
return cookies;
}
@@ -114,8 +95,6 @@ public class LoginToken implements Serializable {
JSONObject json = new JSONObject();
try {
json.put("username", username);
json.put("shibsessionKey", shibsessionKey);
json.put("shibsessionName", shibsessionName);
json.put("JSESSIONID", JSESSIONID);
json.put("fullName", fullName);
json.put("email", email);
@@ -125,13 +104,11 @@ public class LoginToken implements Serializable {
return json.toString();
}
public static LoginToken fromJsonString(String tokenString) {
private static LoginToken fromJsonString(String tokenString) {
try {
JSONObject json = new JSONObject(tokenString);
LoginToken token = new LoginToken(
json.getString("username"),
json.getString("shibsessionName"),
json.getString("shibsessionName"),
json.getString("JSESSIONID"));
if (!json.isNull("fullName"))
token.setAdditionals(

View File

@@ -7,6 +7,11 @@
android:icon="@drawable/ic_local_dining"
android:title="@string/canteen_plan"
android:orderInCategory="200" />
<item
android:id="@+id/nav_settings"
android:icon="@drawable/ic_settings"
android:title="@string/settings"
android:orderInCategory="300"/>
<item
android:id="@+id/nav_news"
android:icon="@drawable/ic_chat_bubble_outline"

View File

@@ -109,4 +109,6 @@
<string name="event_removed">Event entfernt: %1$s</string>
<string name="gradebook_removed">Noteneintrag entfernt: %1$s</string>
<string name="resource_removed">Ressource entfernt: %1$s</string>
<string name="pref_external_server_title">Effizientes Aktualisieren</string>
<string name="pref_external_server_summary">Spart mobile Daten und Akku, verwendet jedoch externen Server zur Sychronisierung.</string>
</resources>

View File

@@ -10,4 +10,12 @@
<string name="pref_last_visited_news" translatable="false">pref_last_visited_news</string>
<string name="pref_set_auto_sync_on_startup" translatable="false">pref_set_auto_sync_on_startup</string>
<string-array name="pref_external_server" translatable="false">
<item>@string/pref_external_server</item>
<item>@string/pref_external_server_default</item>
</string-array>
<string name="pref_external_server" translatable="false">pref_external_server</string>
<string name="pref_external_server_default" translatable="false">all</string>
</resources>

View File

@@ -50,6 +50,8 @@
<string name="pref_price_group_title">Canteen Price Group</string>
<string name="pref_price_group_summary">Only show specific price category</string>
<string name="pref_price_group_dialog">Price Group Selection</string>
<string name="pref_external_server_title">More efficient data sync</string>
<string name="pref_external_server_summary">Uses more battery and data efficient syncing and refreshing, but use an external server.</string>
<string name="meals">Meals</string>
<string name="special_meals">Special meals</string>
<string name="side_dishes">Side Dishes</string>

View File

@@ -9,6 +9,11 @@
android:entries="@array/pref_price_group_entries"
android:entryValues="@array/pref_price_group_values"
android:dialogTitle="@string/pref_price_group_dialog" />
<SwitchPreference
android:key="@string/pref_external_server"
android:defaultValue="@string/pref_external_server_default"
android:title="@string/pref_external_server_title"
android:summary="@string/pref_external_server_summary" />
<PreferenceScreen
android:title="@string/open_data_policy"
android:summary="@string/open_data_policy_summary">