Simplified Login Token
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,11 +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;
|
||||
|
||||
@@ -20,24 +17,16 @@ import de.sebse.fuplanner.tools.logging.Logger;
|
||||
*/
|
||||
|
||||
public class LoginToken implements Serializable {
|
||||
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 +54,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 +71,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 +94,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 +103,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(
|
||||
|
||||
Reference in New Issue
Block a user