mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Merge pull request #149 from owncloud/recover_preemptive_authentication
Use preemptive authentication except in server versions where it is n…
This commit is contained in:
commit
71bdd1d035
@ -42,10 +42,10 @@ public class OwnCloudBasicCredentials implements OwnCloudCredentials {
|
|||||||
mAuthenticationPreemptive = true;
|
mAuthenticationPreemptive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OwnCloudBasicCredentials(String username, String password, boolean sessionEnabled) {
|
public OwnCloudBasicCredentials(String username, String password, boolean preemptiveMode) {
|
||||||
mUsername = username != null ? username : "";
|
mUsername = username != null ? username : "";
|
||||||
mPassword = password != null ? password : "";
|
mPassword = password != null ? password : "";
|
||||||
mAuthenticationPreemptive = !sessionEnabled;
|
mAuthenticationPreemptive = preemptiveMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -121,7 +121,7 @@ public class OwnCloudClientFactory {
|
|||||||
OwnCloudCredentialsFactory.newBasicCredentials(
|
OwnCloudCredentialsFactory.newBasicCredentials(
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
(version != null && version.isSessionMonitoringSupported())
|
(version != null && version.isPreemptiveAuthenticationPreferred())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ public class OwnCloudClientFactory {
|
|||||||
OwnCloudCredentialsFactory.newBasicCredentials(
|
OwnCloudCredentialsFactory.newBasicCredentials(
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
(version != null && version.isSessionMonitoringSupported())
|
(version != null && version.isPreemptiveAuthenticationPreferred())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,9 @@ public class OwnCloudCredentialsFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static OwnCloudCredentials newBasicCredentials(
|
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) {
|
public static OwnCloudCredentials newBearerCredentials(String authToken) {
|
||||||
|
@ -230,7 +230,7 @@ public class AccountUtils {
|
|||||||
credentials = OwnCloudCredentialsFactory.newBasicCredentials(
|
credentials = OwnCloudCredentialsFactory.newBasicCredentials(
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
version.isSessionMonitoringSupported()
|
version.isPreemptiveAuthenticationPreferred()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 = 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;
|
private static final int MAX_DOTS = 3;
|
||||||
|
|
||||||
// format is in version
|
// format is in version
|
||||||
@ -168,4 +171,18 @@ public class OwnCloudVersion implements Comparable<OwnCloudVersion> {
|
|||||||
public boolean isSessionMonitoringSupported() {
|
public boolean isSessionMonitoringSupported() {
|
||||||
return (mVersion >= MINIMUM_VERSION_WITH_SESSION_MONITORING);
|
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)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user