fix: move decrypt() for accessToken

This commit is contained in:
Manuel Jenny 2021-03-17 15:33:31 +01:00
parent 091f7eeacf
commit b6cebf16fb
No known key found for this signature in database
GPG Key ID: 1C80FE62B2BEAA18
2 changed files with 9 additions and 8 deletions

View File

@ -8,6 +8,7 @@ import com.pcloud.sdk.PCloudSdk;
import org.cryptomator.data.cloud.okhttplogging.HttpLoggingInterceptor;
import org.cryptomator.util.SharedPreferencesHandler;
import org.cryptomator.util.crypto.CredentialCryptor;
import org.cryptomator.util.file.LruFileCacheUtil;
import okhttp3.Cache;
@ -49,6 +50,12 @@ class PCloudClientFactory {
OkHttpClient okHttpClient = okHttpClientBuilder.build();
return PCloudSdk.newClientBuilder().authenticator(Authenticators.newOAuthAuthenticator(accessToken)).withClient(okHttpClient).apiHost(url).create();
return PCloudSdk.newClientBuilder().authenticator(Authenticators.newOAuthAuthenticator(decrypt(accessToken, context))).withClient(okHttpClient).apiHost(url).create();
}
private String decrypt(String password, Context context) {
return CredentialCryptor //
.getInstance(context) //
.decrypt(password);
}
}

View File

@ -64,13 +64,7 @@ class PCloudImpl {
}
private ApiClient client() {
return clientFactory.getClient(decrypt(cloud.accessToken()), cloud.url(), context);
}
private String decrypt(String password) {
return CredentialCryptor //
.getInstance(context) //
.decrypt(password);
return clientFactory.getClient(cloud.accessToken(), cloud.url(), context);
}
public PCloudFolder root() {