Re-initialise the client to access the cloud when credentials changes
Fixes #395
This commit is contained in:
parent
ce9e76bf23
commit
c685cc3645
@ -56,5 +56,9 @@ class DropboxClientFactory {
|
|||||||
return HttpLoggingInterceptor(logger, context)
|
return HttpLoggingInterceptor(logger, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun logout() {
|
||||||
|
instance = null
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ internal class DropboxCloudContentRepository(private val cloud: DropboxCloud, co
|
|||||||
|
|
||||||
@Throws(BackendException::class)
|
@Throws(BackendException::class)
|
||||||
override fun logout(cloud: DropboxCloud) {
|
override fun logout(cloud: DropboxCloud) {
|
||||||
// empty
|
this.cloud.logout()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -372,6 +372,10 @@ internal class DropboxImpl(cloud: DropboxCloud, context: Context) {
|
|||||||
return currentAccount.name.displayName
|
return currentAccount.name.displayName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun logout() {
|
||||||
|
DropboxClientFactory.logout()
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private const val CHUNKED_UPLOAD_CHUNK_SIZE = 8L shl 20
|
private const val CHUNKED_UPLOAD_CHUNK_SIZE = 8L shl 20
|
||||||
|
@ -59,5 +59,10 @@ class OnedriveClientFactory private constructor() {
|
|||||||
|
|
||||||
return HttpLoggingInterceptor(logger, context)
|
return HttpLoggingInterceptor(logger, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
fun logout() {
|
||||||
|
instance = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -481,6 +481,8 @@ internal class OnedriveImpl(cloud: OnedriveCloud, context: Context, nodeInfoCach
|
|||||||
} catch (e: ExecutionException) {
|
} catch (e: ExecutionException) {
|
||||||
throw FatalBackendException(e)
|
throw FatalBackendException(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OnedriveClientFactory.logout()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -53,5 +53,10 @@ class PCloudClientFactory {
|
|||||||
|
|
||||||
return HttpLoggingInterceptor(logger, context)
|
return HttpLoggingInterceptor(logger, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
fun logout() {
|
||||||
|
instance = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ internal class PCloudContentRepository(private val cloud: PCloud, context: Conte
|
|||||||
|
|
||||||
@Throws(BackendException::class)
|
@Throws(BackendException::class)
|
||||||
override fun logout(cloud: PCloud) {
|
override fun logout(cloud: PCloud) {
|
||||||
// empty
|
this.cloud.logout()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -359,6 +359,10 @@ internal class PCloudImpl(context: Context, cloud: PCloud) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun logout() {
|
||||||
|
PCloudClientFactory.logout()
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (cloud.accessToken() == null) {
|
if (cloud.accessToken() == null) {
|
||||||
throw NoAuthenticationProvidedException(cloud)
|
throw NoAuthenticationProvidedException(cloud)
|
||||||
|
@ -85,5 +85,10 @@ class S3ClientFactory private constructor() {
|
|||||||
val activeNetworkInfo = connectivityManager.activeNetworkInfo
|
val activeNetworkInfo = connectivityManager.activeNetworkInfo
|
||||||
return activeNetworkInfo != null && activeNetworkInfo.isConnected
|
return activeNetworkInfo != null && activeNetworkInfo.isConnected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
fun logout() {
|
||||||
|
instance = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ internal class S3CloudContentRepository(private val cloud: S3Cloud, context: Con
|
|||||||
|
|
||||||
@Throws(BackendException::class)
|
@Throws(BackendException::class)
|
||||||
override fun logout(cloud: S3Cloud) {
|
override fun logout(cloud: S3Cloud) {
|
||||||
// empty
|
this.cloud.logout()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -366,6 +366,10 @@ internal class S3Impl(context: Context, cloud: S3Cloud) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun logout() {
|
||||||
|
S3ClientFactory.logout()
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private const val DELIMITER = "/"
|
private const val DELIMITER = "/"
|
||||||
|
@ -110,12 +110,11 @@ internal class WebDavCompatibleHttpClient(cloud: WebDavCloud, context: Context)
|
|||||||
val credentials = Credentials(webDavCloud.username(), decryptPassword(context, webDavCloud.password()))
|
val credentials = Credentials(webDavCloud.username(), decryptPassword(context, webDavCloud.password()))
|
||||||
val basicAuthenticator = BasicAuthenticator(credentials, StandardCharsets.UTF_8)
|
val basicAuthenticator = BasicAuthenticator(credentials, StandardCharsets.UTF_8)
|
||||||
val digestAuthenticator = DigestAuthenticator(credentials)
|
val digestAuthenticator = DigestAuthenticator(credentials)
|
||||||
var result: Authenticator = DispatchingAuthenticator.Builder() //
|
val authenticator = DispatchingAuthenticator.Builder() //
|
||||||
.with("digest", digestAuthenticator) //
|
.with("digest", digestAuthenticator) //
|
||||||
.with("basic", basicAuthenticator) //
|
.with("basic", basicAuthenticator) //
|
||||||
.build()
|
.build()
|
||||||
result = CachingAuthenticatorDecorator(result, authCache)
|
return CachingAuthenticatorDecorator(authenticator, authCache)
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Throws(UnableToDecryptWebdavPasswordException::class)
|
@Throws(UnableToDecryptWebdavPasswordException::class)
|
||||||
|
@ -61,5 +61,9 @@ class GoogleDriveClientFactory internal constructor() {
|
|||||||
}
|
}
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun invalidateClient() {
|
||||||
|
instance = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ internal class GoogleDriveCloudContentRepository(context: Context, private val c
|
|||||||
|
|
||||||
@Throws(BackendException::class)
|
@Throws(BackendException::class)
|
||||||
override fun logout(cloud: GoogleDriveCloud) {
|
override fun logout(cloud: GoogleDriveCloud) {
|
||||||
// empty
|
impl.logout()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -382,6 +382,10 @@ internal class GoogleDriveImpl(context: Context, googleDriveCloud: GoogleDriveCl
|
|||||||
return about.user.displayName
|
return about.user.displayName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun logout() {
|
||||||
|
GoogleDriveClientFactory.invalidateClient()
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private const val STATUS_REQUEST_RANGE_NOT_SATISFIABLE = 416
|
private const val STATUS_REQUEST_RANGE_NOT_SATISFIABLE = 416
|
||||||
|
Loading…
x
Reference in New Issue
Block a user