1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-07 16:06:08 +00:00

Use preemptive authentication except in server versions where it is not compatible with session tracking

This commit is contained in:
David A. Velasco 2017-02-01 10:34:42 +01:00 committed by davigonz
parent 28d228b296
commit d5e179d7a2
5 changed files with 24 additions and 7 deletions

View File

@ -42,10 +42,10 @@ public class OwnCloudBasicCredentials implements OwnCloudCredentials {
mAuthenticationPreemptive = true;
}
public OwnCloudBasicCredentials(String username, String password, boolean sessionEnabled) {
public OwnCloudBasicCredentials(String username, String password, boolean preemptiveMode) {
mUsername = username != null ? username : "";
mPassword = password != null ? password : "";
mAuthenticationPreemptive = !sessionEnabled;
mAuthenticationPreemptive = preemptiveMode;
}
@Override

View File

@ -121,7 +121,7 @@ public class OwnCloudClientFactory {
OwnCloudCredentialsFactory.newBasicCredentials(
username,
password,
(version != null && version.isSessionMonitoringSupported())
(version != null && version.isPreemptiveAuthenticationPreferred())
)
);
@ -201,7 +201,7 @@ public class OwnCloudClientFactory {
OwnCloudCredentialsFactory.newBasicCredentials(
username,
password,
(version != null && version.isSessionMonitoringSupported())
(version != null && version.isPreemptiveAuthenticationPreferred())
)
);
}

View File

@ -35,9 +35,9 @@ public class OwnCloudCredentialsFactory {
}
public static OwnCloudCredentials newBasicCredentials(
String username, String password, boolean sessionEnabled
String username, String password, boolean preemptiveMode
) {
return new OwnCloudBasicCredentials(username, password, sessionEnabled);
return new OwnCloudBasicCredentials(username, password, preemptiveMode);
}
public static OwnCloudCredentials newBearerCredentials(String authToken) {

View File

@ -230,7 +230,7 @@ public class AccountUtils {
credentials = OwnCloudCredentialsFactory.newBasicCredentials(
username,
password,
version.isSessionMonitoringSupported()
version.isPreemptiveAuthenticationPreferred()
);
}

View File

@ -55,6 +55,9 @@ public class OwnCloudVersion implements Comparable<OwnCloudVersion> {
private static final int MINIMUM_VERSION_WITH_SESSION_MONITORING = 0x09010000; // 9.1
private static final int MINIMUM_VERSION_WITH_SESSION_MONITORING_WORKING_IN_PREEMPTIVE_MODE = 0x09010301;
// 9.1.3.1, final 9.1.3: https://github.com/owncloud/core/commit/f9a867b70c217463289a741d4d26079eb2a80dfd
private static final int MAX_DOTS = 3;
// format is in version
@ -168,4 +171,18 @@ public class OwnCloudVersion implements Comparable<OwnCloudVersion> {
public boolean isSessionMonitoringSupported() {
return (mVersion >= MINIMUM_VERSION_WITH_SESSION_MONITORING);
}
/**
* From OC 9.1 session tracking is a feature, but to get it working in the OC app we need the preemptive
* mode of basic authentication is disabled. This changes in OC 9.1.3, where preemptive mode is compatible
* with session tracking again.
*
* @return True for every version before 9.1 and from 9.1.3, false otherwise
*/
public boolean isPreemptiveAuthenticationPreferred() {
return (
(mVersion < MINIMUM_VERSION_WITH_SESSION_MONITORING) ||
(mVersion >= MINIMUM_VERSION_WITH_SESSION_MONITORING_WORKING_IN_PREEMPTIVE_MODE)
);
}
}