mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Merge branch 'develop'
This commit is contained in:
commit
dbc8c325d7
@ -1,7 +1,7 @@
|
||||
language: android
|
||||
android:
|
||||
components:
|
||||
- build-tools-20.0.0
|
||||
- build-tools-22.0.1
|
||||
- android-19
|
||||
- android-17
|
||||
- android-14
|
||||
|
@ -3,7 +3,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.0.0'
|
||||
classpath 'com.android.tools.build:gradle:1.2.3'
|
||||
}
|
||||
}
|
||||
apply plugin: 'com.android.library'
|
||||
@ -13,14 +13,12 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'commons-httpclient:commons-httpclient:3.1'
|
||||
compile 'org.apache.jackrabbit:jackrabbit-webdav:2.7.2'
|
||||
compile 'org.slf4j:slf4j-api:1.7.5'
|
||||
compile 'org.apache.jackrabbit:jackrabbit-webdav:2.10.1'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 19
|
||||
buildToolsVersion "20.0.0"
|
||||
buildToolsVersion "22.0.1"
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
|
Binary file not shown.
@ -10,7 +10,7 @@ dependencies {
|
||||
|
||||
android {
|
||||
compileSdkVersion 19
|
||||
buildToolsVersion "20.0.0"
|
||||
buildToolsVersion "22.0.1"
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
|
@ -83,6 +83,7 @@ public class OwnCloudClientFactory {
|
||||
am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null;
|
||||
OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso);
|
||||
|
||||
String username = account.name.substring(0, account.name.lastIndexOf('@'));
|
||||
if (isOauth2) {
|
||||
String accessToken = am.blockingGetAuthToken(
|
||||
account,
|
||||
@ -100,11 +101,10 @@ public class OwnCloudClientFactory {
|
||||
false);
|
||||
|
||||
client.setCredentials(
|
||||
OwnCloudCredentialsFactory.newSamlSsoCredentials(accessToken)
|
||||
OwnCloudCredentialsFactory.newSamlSsoCredentials(username, accessToken)
|
||||
);
|
||||
|
||||
} else {
|
||||
String username = account.name.substring(0, account.name.lastIndexOf('@'));
|
||||
//String password = am.getPassword(account);
|
||||
String password = am.blockingGetAuthToken(
|
||||
account,
|
||||
@ -137,6 +137,7 @@ public class OwnCloudClientFactory {
|
||||
am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null;
|
||||
OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso);
|
||||
|
||||
String username = account.name.substring(0, account.name.lastIndexOf('@'));
|
||||
if (isOauth2) { // TODO avoid a call to getUserData here
|
||||
AccountManagerFuture<Bundle> future = am.getAuthToken(
|
||||
account,
|
||||
@ -166,12 +167,11 @@ public class OwnCloudClientFactory {
|
||||
String accessToken = result.getString(AccountManager.KEY_AUTHTOKEN);
|
||||
if (accessToken == null) throw new AuthenticatorException("WTF!");
|
||||
client.setCredentials(
|
||||
OwnCloudCredentialsFactory.newSamlSsoCredentials(accessToken)
|
||||
OwnCloudCredentialsFactory.newSamlSsoCredentials(username, accessToken)
|
||||
);
|
||||
|
||||
|
||||
} else {
|
||||
String username = account.name.substring(0, account.name.lastIndexOf('@'));
|
||||
//String password = am.getPassword(account);
|
||||
//String password = am.blockingGetAuthToken(account, MainApp.getAuthTokenTypePass(),
|
||||
// false);
|
||||
|
@ -36,8 +36,8 @@ public class OwnCloudCredentialsFactory {
|
||||
return new OwnCloudBearerCredentials(authToken);
|
||||
}
|
||||
|
||||
public static OwnCloudCredentials newSamlSsoCredentials(String sessionCookie) {
|
||||
return new OwnCloudSamlSsoCredentials(sessionCookie);
|
||||
public static OwnCloudCredentials newSamlSsoCredentials(String username, String sessionCookie) {
|
||||
return new OwnCloudSamlSsoCredentials(username, sessionCookie);
|
||||
}
|
||||
|
||||
public static final OwnCloudCredentials getAnonymousCredentials() {
|
||||
|
@ -30,9 +30,11 @@ import android.net.Uri;
|
||||
|
||||
public class OwnCloudSamlSsoCredentials implements OwnCloudCredentials {
|
||||
|
||||
private String mUsername;
|
||||
private String mSessionCookie;
|
||||
|
||||
public OwnCloudSamlSsoCredentials(String sessionCookie) {
|
||||
public OwnCloudSamlSsoCredentials(String username, String sessionCookie) {
|
||||
mUsername = username != null ? username : "";
|
||||
mSessionCookie = sessionCookie != null ? sessionCookie : "";
|
||||
}
|
||||
|
||||
@ -63,8 +65,8 @@ public class OwnCloudSamlSsoCredentials implements OwnCloudCredentials {
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
// its unknown
|
||||
return null;
|
||||
// not relevant for authentication, but relevant for informational purposes
|
||||
return mUsername;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -168,6 +168,8 @@ public class AccountUtils {
|
||||
account,
|
||||
AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null;
|
||||
|
||||
String username = account.name.substring(0, account.name.lastIndexOf('@'));
|
||||
|
||||
if (isOauth2) {
|
||||
String accessToken = am.blockingGetAuthToken(
|
||||
account,
|
||||
@ -182,10 +184,9 @@ public class AccountUtils {
|
||||
AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(account.type),
|
||||
false);
|
||||
|
||||
credentials = OwnCloudCredentialsFactory.newSamlSsoCredentials(accessToken);
|
||||
credentials = OwnCloudCredentialsFactory.newSamlSsoCredentials(username, accessToken);
|
||||
|
||||
} else {
|
||||
String username = account.name.substring(0, account.name.lastIndexOf('@'));
|
||||
String password = am.blockingGetAuthToken(
|
||||
account,
|
||||
AccountTypeUtils.getAuthTokenTypePass(account.type),
|
||||
|
@ -12,7 +12,7 @@ dependencies {
|
||||
|
||||
android {
|
||||
compileSdkVersion 19
|
||||
buildToolsVersion "20.0.0"
|
||||
buildToolsVersion "22.0.1"
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
|
@ -135,7 +135,7 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
client.setCredentials(credentials);
|
||||
assertEquals("Bearer credentials not set", credentials, client.getCredentials());
|
||||
|
||||
credentials = OwnCloudCredentialsFactory.newSamlSsoCredentials("samlSessionCookie=124");
|
||||
credentials = OwnCloudCredentialsFactory.newSamlSsoCredentials("user", "samlSessionCookie=124");
|
||||
client.setCredentials(credentials);
|
||||
assertEquals("SAML2 session credentials not set", credentials, client.getCredentials());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user