Merge branch 'version7'
This commit is contained in:
@@ -7,8 +7,8 @@ android {
|
||||
applicationId "de.sebse.fuplanner"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 28
|
||||
versionCode 6
|
||||
versionName "1.1.4"
|
||||
versionCode 7
|
||||
versionName "1.1.5"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
|
||||
@@ -215,10 +215,16 @@ class KVVLogin extends HTTPService {
|
||||
cookies.put("ROUTEID", ROUTEID);
|
||||
cookies.put("_idp_session", _idp_session);
|
||||
get("https://identity.fu-berlin.de/idp-fub/profile/SAML2/Redirect/SSO", cookies, response -> {
|
||||
String body = response.getParsed();
|
||||
if (body == null) {
|
||||
errorCallback.onError(new NetworkError(100143, -1, "Error on getting SAML response!"));
|
||||
return;
|
||||
}
|
||||
|
||||
HashMap<String, String> object = new HashMap<>();
|
||||
|
||||
Pattern pattern = Pattern.compile("ss:mem:([0-9a-f]+)");
|
||||
Matcher matcher = pattern.matcher(response.getParsed());
|
||||
Matcher matcher = pattern.matcher(body);
|
||||
if (!matcher.find()) {
|
||||
errorCallback.onError(new NetworkError(100142, -1, "Error on getting SAML response!"));
|
||||
return;
|
||||
@@ -226,7 +232,7 @@ class KVVLogin extends HTTPService {
|
||||
object.put("RelayState", "ss:mem:"+matcher.group(1));
|
||||
|
||||
pattern = Pattern.compile("name=\"SAMLResponse\" value=\"([0-9a-zA-Z+]+=*)");
|
||||
matcher = pattern.matcher(response.getParsed());
|
||||
matcher = pattern.matcher(body);
|
||||
if (!matcher.find()) {
|
||||
errorCallback.onError(new NetworkError(100141, -1, "Error on getting SAML response!"));
|
||||
return;
|
||||
|
||||
@@ -20,6 +20,10 @@ final class TestLogin extends HTTPService {
|
||||
static void testLogin(Context context, LoginToken loginToken, NetworkCallback<LoginToken> callback, NetworkErrorCallback errorCallback) {
|
||||
new TestLogin(context).get(String.format("https://kvv.imp.fu-berlin.de/direct/profile/%s.json", loginToken.getUsername()), loginToken.getCookies(), response -> {
|
||||
String body = response.getParsed();
|
||||
if (body == null) {
|
||||
errorCallback.onError(new NetworkError(100202, 403, "Testing login failed!"));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
JSONObject json = new JSONObject(body);
|
||||
String displayName = json.getString("displayName");
|
||||
|
||||
@@ -5,19 +5,24 @@ import com.android.volley.toolbox.HttpHeaderParser;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Map;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 24.10.17.
|
||||
*/
|
||||
public class Result {
|
||||
private final byte[] body;
|
||||
@Nullable private final byte[] body;
|
||||
private final Map<String, String> headers;
|
||||
|
||||
public Result(byte[] body, Map<String, String> headers) {
|
||||
Result(@Nullable byte[] body, Map<String, String> headers) {
|
||||
this.body = body;
|
||||
this.headers = headers;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getParsed() {
|
||||
if (this.body == null)
|
||||
return null;
|
||||
try {
|
||||
return new String(this.body, HttpHeaderParser.parseCharset(headers));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
@@ -25,6 +30,7 @@ public class Result {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public byte[] getBytes() {
|
||||
return body;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user