Skip to content

Commit 3e32f1e

Browse files
- removed useNextcloudUserAgent -> we now use this everytime
- removed any oAuth and saml stuff, as we rely on weblogin flow Signed-off-by: tobiasKaminsky <[email protected]>
1 parent 182b65e commit 3e32f1e

33 files changed

+117
-1448
lines changed

.idea/codeStyles/Project.xml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ dependencies {
247247
// dependencies for app building
248248
implementation 'androidx.multidex:multidex:2.0.1'
249249
// implementation project('nextcloud-android-library')
250-
genericImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
251-
gplayImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
252-
versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
250+
genericImplementation 'com.github.nextcloud:android-library:userId-SNAPSHOT'
251+
gplayImplementation 'com.github.nextcloud:android-library:userId-SNAPSHOT'
252+
versionDevImplementation 'com.github.nextcloud:android-library:userId-SNAPSHOT'
253253
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
254254
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
255255
implementation 'com.google.android.material:material:1.0.0'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
441
1+
441

src/gplay/AndroidManifest.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@
4040
android:exported="true"
4141
android:launchMode="singleTask"
4242
android:theme="@style/Theme.ownCloud.noActionBar.Login">
43-
<intent-filter>
44-
<action android:name="android.intent.action.VIEW" />
45-
46-
<category android:name="android.intent.category.DEFAULT" />
47-
<category android:name="android.intent.category.BROWSABLE" />
48-
49-
<data android:scheme="@string/oauth2_redirect_scheme" />
50-
</intent-filter>
5143
<intent-filter>
5244
<action android:name="com.owncloud.android.workaround.accounts.CREATE" />
5345

src/main/AndroidManifest.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,6 @@
265265
android:launchMode="singleTask"
266266
android:configChanges="orientation|screenSize|keyboardHidden"
267267
android:theme="@style/Theme.ownCloud.noActionBar.Login">
268-
<intent-filter>
269-
<action android:name="android.intent.action.VIEW" />
270-
271-
<category android:name="android.intent.category.DEFAULT" />
272-
<category android:name="android.intent.category.BROWSABLE" />
273-
274-
<data android:scheme="@string/oauth2_redirect_scheme" />
275-
</intent-filter>
276268
<intent-filter>
277269
<action android:name="com.owncloud.android.workaround.accounts.CREATE" />
278270

src/main/java/com/nextcloud/client/account/UserAccountManagerImpl.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -161,23 +161,6 @@ private Account migrateAccount(Context context, Account currentAccount, AccountM
161161
accountMgr.getUserData(account, com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_COOKIES)
162162
);
163163

164-
// copy type of authentication
165-
final String isSamlStr = accountMgr.getUserData(account, com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO);
166-
if (Boolean.parseBoolean(isSamlStr)) {
167-
accountMgr.setUserData(newAccount, com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO, "TRUE");
168-
}
169-
170-
final String isOauthStr = accountMgr.getUserData(account, com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_SUPPORTS_OAUTH2);
171-
if (Boolean.parseBoolean(isOauthStr)) {
172-
accountMgr.setUserData(newAccount, com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_SUPPORTS_OAUTH2, "TRUE");
173-
}
174-
175-
/* TODO - study if it's possible to run this method in a background thread to copy the authToken
176-
if (isOAuth || isSaml) {
177-
accountMgr.setAuthToken(newAccount, mAuthTokenType, mAuthToken);
178-
}
179-
*/
180-
181164
// don't forget the account saved in preferences as the current one
182165
if (currentAccount.name.equals(account.name)) {
183166
AccountUtils.setCurrentOwnCloudAccount(context, newAccountName);

src/main/java/com/owncloud/android/MainApp.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
import com.owncloud.android.jobs.MediaFoldersDetectionJob;
6464
import com.owncloud.android.jobs.NCJobCreator;
6565
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
66-
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory.Policy;
6766
import com.owncloud.android.lib.common.utils.Log_OC;
6867
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
6968
import com.owncloud.android.ui.activity.ContactsPreferenceActivity;
@@ -187,16 +186,8 @@ public void onCreate() {
187186

188187
MainApp.storagePath = preferences.getStoragePath(getApplicationContext().getFilesDir().getAbsolutePath());
189188

190-
boolean isSamlAuth = AUTH_ON.equals(getString(R.string.auth_method_saml_web_sso));
191-
192189
OwnCloudClientManagerFactory.setUserAgent(getUserAgent());
193190
OwnCloudClientManagerFactory.setNextcloudUserAgent(getNextcloudUserAgent());
194-
if (isSamlAuth) {
195-
OwnCloudClientManagerFactory.setDefaultPolicy(Policy.SINGLE_SESSION_PER_ACCOUNT);
196-
} else {
197-
OwnCloudClientManagerFactory
198-
.setDefaultPolicy(Policy.SINGLE_SESSION_PER_ACCOUNT_IF_SERVER_SUPPORTS_SERVER_MONITORING);
199-
}
200191

201192
// initialise thumbnails cache on background thread
202193
new ThumbnailsCacheManager.InitDiskCacheTask().execute();

src/main/java/com/owncloud/android/authentication/AccountAuthenticator.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@
4040

4141
/**
4242
* Authenticator for ownCloud accounts.
43-
*
43+
*
4444
* Controller class accessed from the system AccountManager,
4545
* providing integration of ownCloud accounts with the Android system.
46-
*
46+
*
4747
* TODO - better separation in operations for OAuth-capable and regular ownCloud accounts.
4848
* TODO - review completeness
4949
*/
5050
public class AccountAuthenticator extends AbstractAccountAuthenticator {
51-
51+
5252
/**
5353
* Is used by android system to assign accounts to authenticators.
5454
* Should be used by application and all extensions.
@@ -59,9 +59,9 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
5959
public static final String KEY_ACCOUNT = "account";
6060

6161
private static final String TAG = AccountAuthenticator.class.getSimpleName();
62-
62+
6363
private Context mContext;
64-
64+
6565
private Handler mHandler;
6666

6767
public AccountAuthenticator(Context context) {
@@ -101,17 +101,17 @@ public Bundle addAccount(AccountAuthenticatorResponse response,
101101
intent.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_CREATE);
102102

103103
setIntentFlags(intent);
104-
104+
105105
bundle.putParcelable(AccountManager.KEY_INTENT, intent);
106106
} else {
107107
// Return an error
108108
bundle.putInt(AccountManager.KEY_ERROR_CODE, AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION);
109-
final String message = String.format(mContext.getString(R.string.auth_unsupported_multiaccount), mContext.getString(R.string.app_name));
109+
final String message = String.format(mContext.getString(R.string.auth_unsupported_multiaccount), mContext.getString(R.string.app_name));
110110
bundle.putString(AccountManager.KEY_ERROR_MESSAGE, message);
111-
111+
112112
mHandler.post(() -> Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show());
113113
}
114-
114+
115115
return bundle;
116116
}
117117

@@ -160,7 +160,7 @@ public Bundle getAuthToken(AccountAuthenticatorResponse response,
160160
Log_OC.e(TAG, "Failed to validate account type " + account.type + ": " + e.getMessage(), e);
161161
return e.getFailureBundle();
162162
}
163-
163+
164164
/// check if required token is stored
165165
final AccountManager am = AccountManager.get(mContext);
166166
String accessToken;
@@ -176,15 +176,15 @@ public Bundle getAuthToken(AccountAuthenticatorResponse response,
176176
result.putString(AccountManager.KEY_AUTHTOKEN, accessToken);
177177
return result;
178178
}
179-
179+
180180
/// if not stored, return Intent to access the AuthenticatorActivity and UPDATE the token for the account
181181
Intent intent = new Intent(mContext, AuthenticatorActivity.class);
182182
intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
183183
intent.putExtra(KEY_AUTH_TOKEN_TYPE, authTokenType);
184184
intent.putExtra(KEY_LOGIN_OPTIONS, options);
185185
intent.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, account);
186186
intent.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN);
187-
187+
188188

189189
final Bundle bundle = new Bundle();
190190
bundle.putParcelable(AccountManager.KEY_INTENT, intent);
@@ -242,10 +242,7 @@ private void validateAuthTokenType(String authTokenType) throws UnsupportedAuthT
242242
String accountType = MainApp.getAccountType(mContext);
243243

244244
if (!authTokenType.equals(accountType) &&
245-
!authTokenType.equals(AccountTypeUtils.getAuthTokenTypePass(accountType)) &&
246-
!authTokenType.equals(AccountTypeUtils.getAuthTokenTypeAccessToken(accountType)) &&
247-
!authTokenType.equals(AccountTypeUtils.getAuthTokenTypeRefreshToken(accountType)) &&
248-
!authTokenType.equals(AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(accountType))) {
245+
!authTokenType.equals(AccountTypeUtils.getAuthTokenTypePass(accountType))) {
249246
throw new UnsupportedAuthTokenTypeException();
250247
}
251248
}

0 commit comments

Comments
 (0)