Skip to content

Commit 349d5f6

Browse files
committed
feat: adapt token renewal process to the new setup for Kiteworks servers
1 parent 97591b5 commit 349d5f6

3 files changed

Lines changed: 24 additions & 5 deletions

File tree

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
* @author Christian Schabesberger
66
* @author David González Verdugo
77
* @author Juan Carlos Garrote Gascón
8+
* @author Jorge Aguado Recio
89
*
910
* Copyright (C) 2012 Bartek Przybylski
10-
* Copyright (C) 2024 ownCloud GmbH.
11+
* Copyright (C) 2025 ownCloud GmbH.
1112
*
1213
* This program is free software: you can redistribute it and/or modify
1314
* it under the terms of the GNU General Public License version 2,
@@ -346,13 +347,23 @@ private String refreshToken(
346347
String clientIdForRequest = null;
347348
String clientSecretForRequest = null;
348349

350+
boolean isKiteworksServer = Boolean.parseBoolean(accountManager.getUserData(account, AccountUtils.Constants.KEY_IS_KITEWORKS_SERVER));
351+
349352
if (clientId == null) {
350353
Timber.d("Client Id not stored. Let's use the hardcoded one");
351-
clientId = mContext.getString(R.string.oauth2_client_id);
354+
if (isKiteworksServer) {
355+
clientId = mContext.getString(R.string.kiteworks_client_id);
356+
} else {
357+
clientId = mContext.getString(R.string.oauth2_client_id);
358+
}
352359
}
353360
if (clientSecret == null) {
354361
Timber.d("Client Secret not stored. Let's use the hardcoded one");
355-
clientSecret = mContext.getString(R.string.oauth2_client_secret);
362+
if (isKiteworksServer) {
363+
clientSecret = mContext.getString(R.string.kiteworks_client_secret);
364+
} else {
365+
clientSecret = mContext.getString(R.string.oauth2_client_secret);
366+
}
356367
}
357368

358369
if (oidcServerConfigurationUseCaseResult.isSuccess()) {
@@ -376,7 +387,12 @@ private String refreshToken(
376387

377388
String clientAuth = OAuthUtils.Companion.getClientAuth(clientSecret, clientId);
378389

379-
String scope = mContext.getResources().getString(R.string.oauth2_openid_scope);
390+
String scope;
391+
if (isKiteworksServer) {
392+
scope = mContext.getResources().getString(R.string.kiteworks_openid_scope);
393+
} else {
394+
scope = mContext.getResources().getString(R.string.oauth2_openid_scope);
395+
}
380396

381397
TokenRequest oauthTokenRequest = new TokenRequest.RefreshToken(
382398
baseUrl,

owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/ConnectionValidator.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class ConnectionValidator(
5959

6060
client.account = baseClient.account
6161
client.credentials = baseClient.credentials
62+
client.isKiteworksServer = baseClient.isKiteworksServer
63+
6264
while (validationRetryCount < VALIDATION_RETRY_COUNT) {
6365
Timber.d("validationRetryCount %d", validationRetryCount)
6466
var successCounter = 0

owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ private int saveExecuteHttpMethod(HttpBaseMethod method) throws Exception {
144144

145145
HttpUrl originalUrl = method.getHttpUrl();
146146
String encodedPath = originalUrl.encodedPath();
147-
if (mIsKiteworksServer && !encodedPath.startsWith(WELL_KNOWN_PATH) && !encodedPath.equals(OAUTH_TOKEN_PATH)) {
147+
if (mIsKiteworksServer && !encodedPath.startsWith(WELL_KNOWN_PATH) && !encodedPath.equals(OAUTH_TOKEN_PATH)
148+
&& !encodedPath.contains(KWDAV_PATH)) {
148149
HttpUrl newUrl = originalUrl.newBuilder().encodedPath(KWDAV_PATH + encodedPath).build();
149150
method.setUrl(newUrl);
150151
}

0 commit comments

Comments
 (0)