Ignore decomissioned KBS enclaves when encountered during getToken.

This commit is contained in:
Cody Henthorne 2022-12-08 09:47:39 -05:00 committed by Alex Hart
parent aba51da932
commit 04bf2cd0c2

View file

@ -14,6 +14,7 @@ import org.whispersystems.signalservice.api.KeyBackupService;
import org.whispersystems.signalservice.api.KeyBackupServicePinException; import org.whispersystems.signalservice.api.KeyBackupServicePinException;
import org.whispersystems.signalservice.api.KeyBackupSystemNoDataException; import org.whispersystems.signalservice.api.KeyBackupSystemNoDataException;
import org.whispersystems.signalservice.api.kbs.HashedPin; import org.whispersystems.signalservice.api.kbs.HashedPin;
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
import org.whispersystems.signalservice.internal.ServiceResponse; import org.whispersystems.signalservice.internal.ServiceResponse;
import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException; import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException;
import org.whispersystems.signalservice.internal.contacts.entities.TokenResponse; import org.whispersystems.signalservice.internal.contacts.entities.TokenResponse;
@ -64,11 +65,21 @@ public class KbsRepository {
for (KbsEnclave enclave : KbsEnclaves.all()) { for (KbsEnclave enclave : KbsEnclaves.all()) {
KeyBackupService kbs = ApplicationDependencies.getKeyBackupService(enclave); KeyBackupService kbs = ApplicationDependencies.getKeyBackupService(enclave);
TokenResponse token;
authorization = authorization == null ? kbs.getAuthorization() : authorization; try {
authorization = authorization == null ? kbs.getAuthorization() : authorization;
token = kbs.getToken(authorization);
} catch (NonSuccessfulResponseCodeException e) {
if (e.getCode() == 404) {
Log.i(TAG, "Enclave decommissioned, skipping", e);
continue;
} else {
throw e;
}
}
TokenResponse token = kbs.getToken(authorization); TokenData tokenData = new TokenData(enclave, authorization, token);
TokenData tokenData = new TokenData(enclave, authorization, token);
if (tokenData.getTriesRemaining() > 0) { if (tokenData.getTriesRemaining() > 0) {
Log.i(TAG, "Found data! " + enclave.getEnclaveName()); Log.i(TAG, "Found data! " + enclave.getEnclaveName());