-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEVISACCESSAPP-5283: Delete local data
- Loading branch information
1 parent
ed9acf8
commit b521435
Showing
11 changed files
with
136 additions
and
11 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
26 changes: 26 additions & 0 deletions
26
...rc/main/java/ch/nevis/exampleapp/coroutines/domain/usecase/DeleteAuthenticatorsUseCase.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,26 @@ | ||
/** | ||
* Nevis Mobile Authentication SDK Example App | ||
* | ||
* Copyright © 2023. Nevis Security AG. All rights reserved. | ||
*/ | ||
|
||
package ch.nevis.exampleapp.coroutines.domain.usecase | ||
|
||
import ch.nevis.exampleapp.coroutines.domain.model.response.Response | ||
import ch.nevis.mobile.sdk.api.localdata.Account | ||
|
||
/** | ||
* Interface declaration of delete local authenticators use-case. | ||
*/ | ||
interface DeleteAuthenticatorsUseCase { | ||
|
||
/** | ||
* Executes use-case. | ||
* | ||
* @param accounts The set of enrolled accounts. | ||
* @return A [Response] object, the result of the use-case execution. | ||
*/ | ||
suspend fun execute( | ||
accounts: Set<Account> | ||
): Response | ||
} |
48 changes: 48 additions & 0 deletions
48
...ain/java/ch/nevis/exampleapp/coroutines/domain/usecase/DeleteAuthenticatorsUseCaseImpl.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,48 @@ | ||
/** | ||
* Nevis Mobile Authentication SDK Example App | ||
* | ||
* Copyright © 2023. Nevis Security AG. All rights reserved. | ||
*/ | ||
|
||
package ch.nevis.exampleapp.coroutines.domain.usecase | ||
|
||
import ch.nevis.exampleapp.coroutines.domain.client.ClientProvider | ||
import ch.nevis.exampleapp.coroutines.domain.model.error.BusinessException | ||
import ch.nevis.exampleapp.coroutines.domain.model.operation.Operation | ||
import ch.nevis.exampleapp.coroutines.domain.model.response.CompletedResponse | ||
import ch.nevis.exampleapp.coroutines.domain.model.response.Response | ||
import ch.nevis.mobile.sdk.api.localdata.Account | ||
import kotlinx.coroutines.suspendCancellableCoroutine | ||
import kotlin.coroutines.resume | ||
|
||
class DeleteAuthenticatorsUseCaseImpl( | ||
/** | ||
* An instance of a [ClientProvider] implementation. | ||
*/ | ||
private val clientProvider: ClientProvider | ||
) : DeleteAuthenticatorsUseCase { | ||
//region DeleteAuthenticatorsUseCase | ||
override suspend fun execute(accounts: Set<Account>): Response { | ||
for (account in accounts) { | ||
deleteAuthenticators(account.username()) | ||
} | ||
|
||
return CompletedResponse(Operation.LOCAL_DATA) | ||
} | ||
//endregion | ||
|
||
//region Private Interface | ||
/** | ||
* Deletes all local authenticators of an enrolled account. | ||
* | ||
* @param username The username that identifies the account whose authenticators must be deleted locally. | ||
*/ | ||
private suspend fun deleteAuthenticators(username: String) { | ||
return suspendCancellableCoroutine { cancellableContinuation -> | ||
val client = clientProvider.get() ?: throw BusinessException.clientNotInitialized() | ||
client.localData().deleteAuthenticator(username) | ||
cancellableContinuation.resume(Unit) | ||
} | ||
} | ||
//endregion | ||
} |
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
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