diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 00000000..946d709d
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,3 @@
+android.enableJetifier=true
+android.useAndroidX=true
+org.gradle.jvmargs=-Xmx1536M
\ No newline at end of file
diff --git a/owncloudComLibrary/build.gradle b/owncloudComLibrary/build.gradle
index 031b5383..82949174 100644
--- a/owncloudComLibrary/build.gradle
+++ b/owncloudComLibrary/build.gradle
@@ -8,6 +8,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
api 'com.gitlab.ownclouders:dav4android:oc_support_1.0.1'
api 'com.github.hannesa2:Logcat:1.6.0'
+ api 'net.openid:appauth:0.7.1'
}
allOpen {
@@ -24,6 +25,10 @@ android {
versionCode = 10000401
versionName = "1.0.4.1"
+
+ // This is pretty ugly but manifest placeholders don't seem to work very well when using different modules
+ // See https://github.com/openid/AppAuth-Android/issues/325
+ manifestPlaceholders = [appAuthRedirectScheme: '']
}
lintOptions {
diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java
index 835f50e6..5c4ae8e6 100644
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java
+++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java
@@ -334,7 +334,6 @@ public class OwnCloudClient extends HttpClient {
if (invalidated) {
if (getCredentials().authTokenCanBeRefreshed() &&
repeatCounter < MAX_REPEAT_COUNT_WITH_FRESH_CREDENTIALS) {
-
try {
mAccount.loadCredentials(getContext());
// if mAccount.getCredentials().length() == 0 --> refresh failed
@@ -342,7 +341,9 @@ public class OwnCloudClient extends HttpClient {
credentialsWereRefreshed = true;
} catch (AccountsException | IOException e) {
- Timber.e(e, "Error while trying to refresh auth token for %s", mAccount.getSavedAccount().name);
+ Timber.e(e, "Error while trying to refresh auth token for %s",
+ mAccount.getSavedAccount().name
+ );
}
}
diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientFactory.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientFactory.java
index 94a44c26..99c5641a 100644
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientFactory.java
+++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientFactory.java
@@ -37,8 +37,7 @@ public class OwnCloudClientFactory {
* @param context Android context where the OwnCloudClient is being created.
* @return A OwnCloudClient object ready to be used
*/
- public static OwnCloudClient createOwnCloudClient(Uri uri, Context context,
- boolean followRedirects) {
+ public static OwnCloudClient createOwnCloudClient(Uri uri, Context context, boolean followRedirects) {
OwnCloudClient client = new OwnCloudClient(uri);
client.setFollowRedirects(followRedirects);
diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java
index 309344fa..47107653 100644
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java
+++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java
@@ -315,9 +315,19 @@ public class AccountUtils {
*/
public static final String KEY_DISPLAY_NAME = "oc_display_name";
+ /**
+ * OAuth2 user id
+ **/
+ public static final String KEY_USER_ID = "user_id";
+
/**
* OAuth2 refresh token
**/
public static final String KEY_OAUTH2_REFRESH_TOKEN = "oc_oauth2_refresh_token";
+
+ /**
+ * OAuth2 scope
+ */
+ public static final String KEY_OAUTH2_SCOPE = "oc_oauth2_scope";
}
}
diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/BearerCredentials.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/BearerCredentials.java
deleted file mode 100644
index 6f7e9a6e..00000000
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/BearerCredentials.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/* ownCloud Android Library is available under MIT license
- * Copyright (C) 2019 ownCloud GmbH.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-package com.owncloud.android.lib.common.authentication.oauth;
-
-/**
- * @author David A. Velasco
- * @author Christian Schabesberger
- */
-public class BearerCredentials {
-
- public static final int HASH_SEED = 17;
- public static final int HASH_OFFSET = 37;
-
- private String mAccessToken;
-
- /**
- * The constructor with the bearer token
- *
- * @param token The bearer token
- */
- public BearerCredentials(String token) {
- mAccessToken = (token == null) ? "" : token;
- }
-
- /**
- * Returns the access token
- *
- * @return The access token
- */
- public String getAccessToken() {
- return mAccessToken;
- }
-
- /**
- * Get this object string.
- *
- * @return The access token
- */
- public String toString() {
- return mAccessToken;
- }
-
- /**
- * Does a hash of the access token.
- *
- * @return The hash code of the access token
- */
- public int hashCode() {
- return HASH_SEED * HASH_OFFSET + mAccessToken.hashCode();
- }
-
- /**
- * These credentials are assumed equal if accessToken is the same.
- *
- * @param o The other object to compare with.
- * @return 'True' if the object is equivalent.
- */
- public boolean equals(Object o) {
- if (o == null) {
- return false;
- }
- if (this == o) {
- return true;
- }
- if (this.getClass().equals(o.getClass())) {
- BearerCredentials that = (BearerCredentials) o;
- if (mAccessToken.equals(that.mAccessToken)) {
- return true;
- }
- }
- return false;
- }
-}
\ No newline at end of file
diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2ClientConfiguration.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2ClientConfiguration.java
deleted file mode 100644
index 24814167..00000000
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2ClientConfiguration.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/* ownCloud Android Library is available under MIT license
- *
- * @author David A. Velasco
- * Copyright (C) 2017 ownCloud GmbH.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-package com.owncloud.android.lib.common.authentication.oauth;
-
-public class OAuth2ClientConfiguration {
-
- private String mClientId;
-
- private String mClientSecret;
-
- private String mRedirectUri;
-
- public OAuth2ClientConfiguration(String clientId, String clientSecret, String redirectUri) {
- mClientId = (clientId == null) ? "" : clientId;
- mClientSecret = (clientSecret == null) ? "" : clientSecret;
- mRedirectUri = (redirectUri == null) ? "" : redirectUri;
- }
-
- public String getClientId() {
- return mClientId;
- }
-
- public void setClientId(String clientId) {
- mClientId = (clientId == null) ? "" : clientId;
- }
-
- public String getClientSecret() {
- return mClientSecret;
- }
-
- public void setClientSecret(String clientSecret) {
- mClientSecret = (clientSecret == null) ? "" : clientSecret;
- }
-
- public String getRedirectUri() {
- return mRedirectUri;
- }
-
- public void setRedirectUri(String redirectUri) {
- this.mRedirectUri = (redirectUri == null) ? "" : redirectUri;
- }
-}
diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2Constants.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2Constants.java
deleted file mode 100644
index 97dbfc41..00000000
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2Constants.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ownCloud Android Library is available under MIT license
- *
- * @author David A. Velasco
- * Copyright (C) 2017 ownCloud GmbH.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-package com.owncloud.android.lib.common.authentication.oauth;
-
-/**
- * Constant values for OAuth 2 protocol.
- *
- * Includes required and optional parameter NAMES used in the 'authorization code' grant type.
- */
-
-public class OAuth2Constants {
-
- /// Parameters to send to the Authorization Endpoint
- public static final String KEY_RESPONSE_TYPE = "response_type";
- public static final String KEY_REDIRECT_URI = "redirect_uri";
- public static final String KEY_CLIENT_ID = "client_id";
- public static final String KEY_SCOPE = "scope";
- public static final String KEY_STATE = "state";
-
- /// Additional parameters to send to the Token Endpoint
- public static final String KEY_GRANT_TYPE = "grant_type";
- public static final String KEY_CODE = "code";
-
- // Used to get the Access Token using Refresh Token
- public static final String OAUTH2_REFRESH_TOKEN_GRANT_TYPE = "refresh_token";
-
- /// Parameters received in an OK response from the Token Endpoint
- public static final String KEY_ACCESS_TOKEN = "access_token";
- public static final String KEY_TOKEN_TYPE = "token_type";
- public static final String KEY_EXPIRES_IN = "expires_in";
- public static final String KEY_REFRESH_TOKEN = "refresh_token";
-
- /// Parameters in an ERROR response
- public static final String KEY_ERROR = "error";
- public static final String KEY_ERROR_DESCRIPTION = "error_description";
- public static final String KEY_ERROR_URI = "error_uri";
- public static final String VALUE_ERROR_ACCESS_DENIED = "access_denied";
-
- /// Extra not standard
- public static final String KEY_USER_ID = "user_id";
-
- /// Depends on oauth2 grant type
- public static final String OAUTH2_RESPONSE_TYPE_CODE = "code";
-}
diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2GetAccessTokenOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2GetAccessTokenOperation.java
deleted file mode 100644
index c5273215..00000000
--- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2GetAccessTokenOperation.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/* ownCloud Android Library is available under MIT license
- *
- * @author David A. Velasco
- * @author Christian Schabesberger
- * Copyright (C) 2019 ownCloud GmbH.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-package com.owncloud.android.lib.common.authentication.oauth;
-
-import android.net.Uri;
-
-import com.owncloud.android.lib.common.OwnCloudClient;
-import com.owncloud.android.lib.common.authentication.OwnCloudBasicCredentials;
-import com.owncloud.android.lib.common.authentication.OwnCloudCredentials;
-import com.owncloud.android.lib.common.http.methods.nonwebdav.PostMethod;
-import com.owncloud.android.lib.common.operations.RemoteOperation;
-import com.owncloud.android.lib.common.operations.RemoteOperationResult;
-import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
-import okhttp3.MultipartBody;
-import okhttp3.RequestBody;
-import org.json.JSONObject;
-
-import java.net.URL;
-import java.util.Map;
-
-public class OAuth2GetAccessTokenOperation extends RemoteOperation