Simplified Login Token
This commit is contained in:
@@ -81,17 +81,6 @@ public class UserLoginTask extends AsyncTask<Void, Void, String> {
|
|||||||
} else {
|
} else {
|
||||||
return login.get().toJsonString();
|
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
|
@Override
|
||||||
|
|||||||
@@ -62,14 +62,13 @@ public class Login extends HTTPService {
|
|||||||
String fuJSESSIONID = success2.get("JSESSIONID");
|
String fuJSESSIONID = success2.get("JSESSIONID");
|
||||||
step3(fuJSESSIONID, success3 -> {
|
step3(fuJSESSIONID, success3 -> {
|
||||||
step4(username, password, fuJSESSIONID, success4 -> {
|
step4(username, password, fuJSESSIONID, success4 -> {
|
||||||
String fuSHIBSession = success4.get("shib_idp_session");
|
|
||||||
String samlResponse = success4.get("SAMLResponse");
|
String samlResponse = success4.get("SAMLResponse");
|
||||||
step5(samlResponse, success5 -> {
|
step5(samlResponse, success5 -> {
|
||||||
String shibsessionKey = success5.get("shibsessionKey");
|
String shibsessionKey = success5.get("shibsessionKey");
|
||||||
String shibsessionName = success5.get("shibsessionName");
|
String shibsessionName = success5.get("shibsessionName");
|
||||||
step6(shibsessionKey, shibsessionName, success6 -> {
|
step6(shibsessionKey, shibsessionName, success6 -> {
|
||||||
String kvvJSESSIONID = success6.get("JSESSIONID");
|
String kvvJSESSIONID = success6.get("JSESSIONID");
|
||||||
LoginToken token = new LoginToken(username, shibsessionKey, shibsessionName, kvvJSESSIONID);
|
LoginToken token = new LoginToken(username, kvvJSESSIONID);
|
||||||
callback.onResponse(token);
|
callback.onResponse(token);
|
||||||
}, error);
|
}, error);
|
||||||
}, error);
|
}, error);
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
package de.sebse.fuplanner.services.kvv.types;
|
package de.sebse.fuplanner.services.kvv.types;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@@ -19,25 +15,19 @@ import de.sebse.fuplanner.tools.logging.Logger;
|
|||||||
* Created by sebastian on 29.10.17.
|
* Created by sebastian on 29.10.17.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class LoginToken implements Serializable {
|
public class LoginToken {
|
||||||
static Logger log = new Logger("LoginToken");
|
static Logger log = new Logger("LoginToken");
|
||||||
private static final String FILE_NAME = "LoginTokenSaving";
|
|
||||||
|
|
||||||
private final String username;
|
private final String username;
|
||||||
private final String shibsessionKey;
|
|
||||||
private final String shibsessionName;
|
|
||||||
private final String JSESSIONID;
|
private final String JSESSIONID;
|
||||||
@Nullable private String fullName;
|
@Nullable private String fullName;
|
||||||
@Nullable private String email;
|
@Nullable private String email;
|
||||||
|
|
||||||
public LoginToken(String username, String shibsessionKey, String shibsessionName, String JSESSIONID) {
|
public LoginToken(String username, String JSESSIONID) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.shibsessionKey = shibsessionKey;
|
|
||||||
this.shibsessionName = shibsessionName;
|
|
||||||
this.JSESSIONID = JSESSIONID;
|
this.JSESSIONID = JSESSIONID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static void load(CustomAccountManager manager, LoginTokenInterface callback) {
|
public static void load(CustomAccountManager manager, LoginTokenInterface callback) {
|
||||||
if (!manager.hasAccounts(AccountGeneral.ACCOUNT_TYPE)) {
|
if (!manager.hasAccounts(AccountGeneral.ACCOUNT_TYPE)) {
|
||||||
callback.run(null);
|
callback.run(null);
|
||||||
@@ -65,14 +55,6 @@ public class LoginToken implements Serializable {
|
|||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getShibsessionKey() {
|
|
||||||
return shibsessionKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getShibsessionName() {
|
|
||||||
return shibsessionName;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getJSESSIONID() {
|
private String getJSESSIONID() {
|
||||||
return JSESSIONID;
|
return JSESSIONID;
|
||||||
}
|
}
|
||||||
@@ -90,7 +72,6 @@ public class LoginToken implements Serializable {
|
|||||||
public HashMap<String, String> getCookies() {
|
public HashMap<String, String> getCookies() {
|
||||||
HashMap<String, String> cookies = new HashMap<>();
|
HashMap<String, String> cookies = new HashMap<>();
|
||||||
cookies.put("JSESSIONID", getJSESSIONID());
|
cookies.put("JSESSIONID", getJSESSIONID());
|
||||||
cookies.put(getShibsessionKey(), getShibsessionName());
|
|
||||||
cookies.put("pasystem_timezone_ok", "true");
|
cookies.put("pasystem_timezone_ok", "true");
|
||||||
return cookies;
|
return cookies;
|
||||||
}
|
}
|
||||||
@@ -114,8 +95,6 @@ public class LoginToken implements Serializable {
|
|||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
try {
|
try {
|
||||||
json.put("username", username);
|
json.put("username", username);
|
||||||
json.put("shibsessionKey", shibsessionKey);
|
|
||||||
json.put("shibsessionName", shibsessionName);
|
|
||||||
json.put("JSESSIONID", JSESSIONID);
|
json.put("JSESSIONID", JSESSIONID);
|
||||||
json.put("fullName", fullName);
|
json.put("fullName", fullName);
|
||||||
json.put("email", email);
|
json.put("email", email);
|
||||||
@@ -125,13 +104,11 @@ public class LoginToken implements Serializable {
|
|||||||
return json.toString();
|
return json.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LoginToken fromJsonString(String tokenString) {
|
private static LoginToken fromJsonString(String tokenString) {
|
||||||
try {
|
try {
|
||||||
JSONObject json = new JSONObject(tokenString);
|
JSONObject json = new JSONObject(tokenString);
|
||||||
LoginToken token = new LoginToken(
|
LoginToken token = new LoginToken(
|
||||||
json.getString("username"),
|
json.getString("username"),
|
||||||
json.getString("shibsessionName"),
|
|
||||||
json.getString("shibsessionName"),
|
|
||||||
json.getString("JSESSIONID"));
|
json.getString("JSESSIONID"));
|
||||||
if (!json.isNull("fullName"))
|
if (!json.isNull("fullName"))
|
||||||
token.setAdditionals(
|
token.setAdditionals(
|
||||||
|
|||||||
Reference in New Issue
Block a user