Day align DeviceCheck backup vouchers

This commit is contained in:
Ravi Khadiwala 2024-12-05 16:37:46 -06:00 committed by ravi-signal
parent 20685b6d69
commit f68ddf66e9
1 changed files with 5 additions and 1 deletions

View File

@ -249,7 +249,11 @@ public class BackupAuthManager {
*/
public CompletableFuture<Void> extendBackupVoucher(final Account account, final Account.BackupVoucher backupVoucher) {
return accountsManager.updateAsync(account, a -> {
final Account.BackupVoucher newPayment = backupVoucher;
// Receipt credential expirations must be day aligned. Make sure any manually set backupVoucher is also day
// aligned
final Account.BackupVoucher newPayment = new Account.BackupVoucher(
backupVoucher.receiptLevel(),
backupVoucher.expiration().truncatedTo(ChronoUnit.DAYS));
final Account.BackupVoucher existingPayment = a.getBackupVoucher();
a.setBackupVoucher(merge(existingPayment, newPayment));
}).thenRun(Util.NOOP);