Simplified Login Token

This commit is contained in:
Caesar2011
2019-01-16 23:34:52 +01:00
parent 31cea12d16
commit 697740e20b
3 changed files with 4 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(