-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: check Certificate Revocation List for current client (WPB-3243) (…
…#2570) * feat: check Certificate Revocation List for current client (WPB-3243) (#2498) * feat: check CRL for current client * chore: resolve conflicts * chore: unused imports * chore: unused imports * fix: url format * chore: cleanup * chore: cleanup * chore: check if E2ei is enabled before running CheckRevocationListForCurrentClientUseCase * chore: cleanup * chore: empty commit --------- Co-authored-by: Oussama Hassine <[email protected]>
- Loading branch information
1 parent
5c7e158
commit 78f34ed
Showing
9 changed files
with
327 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
.../com/wire/kalium/logic/feature/e2ei/usecase/CheckRevocationListForCurrentClientUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.feature.e2ei.usecase | ||
|
||
import com.wire.kalium.logic.configuration.UserConfigRepository | ||
import com.wire.kalium.logic.data.e2ei.CertificateRevocationListRepository | ||
import com.wire.kalium.logic.feature.e2ei.CertificateRevocationListCheckWorker | ||
import com.wire.kalium.logic.feature.user.IsE2EIEnabledUseCase | ||
import com.wire.kalium.logic.functional.onFailure | ||
import com.wire.kalium.logic.functional.onSuccess | ||
import com.wire.kalium.logic.kaliumLogger | ||
|
||
/** | ||
* Use case to check the revocation list for the current client and store it in the DB. | ||
* This will run once as [CertificateRevocationListCheckWorker] is constantly checking the CRLs that are stored in DB. | ||
*/ | ||
interface CheckRevocationListForCurrentClientUseCase { | ||
suspend operator fun invoke() | ||
} | ||
|
||
internal class CheckRevocationListForCurrentClientUseCaseImpl( | ||
private val checkRevocationList: CheckRevocationListUseCase, | ||
private val certificateRevocationListRepository: CertificateRevocationListRepository, | ||
private val userConfigRepository: UserConfigRepository, | ||
private val isE2EIEnabledUseCase: IsE2EIEnabledUseCase | ||
) : CheckRevocationListForCurrentClientUseCase { | ||
override suspend fun invoke() { | ||
if (isE2EIEnabledUseCase() && userConfigRepository.shouldCheckCrlForCurrentClient()) { | ||
certificateRevocationListRepository.getCurrentClientCrlUrl().onSuccess { url -> | ||
kaliumLogger.i("Checking CRL for current client..") | ||
checkRevocationList(url) | ||
.onSuccess { expiration -> | ||
kaliumLogger.i("Successfully checked CRL for current client..") | ||
expiration?.let { | ||
certificateRevocationListRepository.addOrUpdateCRL(url, it) | ||
userConfigRepository.setShouldCheckCrlForCurrentClient(false) | ||
} | ||
} | ||
.onFailure { | ||
kaliumLogger.i("Failed to check CRL for current client..") | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.