-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refresh Credential's Auth Keys Daily
- Loading branch information
1 parent
f0fe5ff
commit aa60dd8
Showing
4 changed files
with
45 additions
and
1 deletion.
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
17 changes: 17 additions & 0 deletions
17
appholder/src/main/java/com/android/identity/wallet/util/PeriodicKeysRefreshWorkRequest.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,17 @@ | ||
package com.android.identity.wallet.util | ||
|
||
import android.content.Context | ||
import androidx.work.PeriodicWorkRequestBuilder | ||
import androidx.work.WorkManager | ||
import java.util.concurrent.TimeUnit | ||
|
||
class PeriodicKeysRefreshWorkRequest(context: Context) { | ||
|
||
private val workManager = WorkManager.getInstance(context) | ||
|
||
fun schedulePeriodicKeysRefreshing() { | ||
val workRequest = PeriodicWorkRequestBuilder<RefreshKeysWorker>(1, TimeUnit.DAYS) | ||
.build() | ||
workManager.enqueue(workRequest) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
appholder/src/main/java/com/android/identity/wallet/util/RefreshKeysWorker.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,23 @@ | ||
package com.android.identity.wallet.util | ||
|
||
import android.content.Context | ||
import androidx.work.Worker | ||
import androidx.work.WorkerParameters | ||
import com.android.identity.wallet.document.DocumentManager | ||
|
||
class RefreshKeysWorker( | ||
context: Context, | ||
params: WorkerParameters | ||
) : Worker(context, params) { | ||
|
||
private val documentManager = DocumentManager.getInstance(context) | ||
private val provisioningUtil = ProvisioningUtil.getInstance(context) | ||
|
||
override fun doWork(): Result { | ||
documentManager.getDocuments().forEach { documentInformation -> | ||
val credential = documentManager.getCredentialByName(documentInformation.docName) | ||
credential?.let { provisioningUtil.refreshAuthKeys(it, documentInformation) } | ||
} | ||
return Result.success() | ||
} | ||
} |
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