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