Search in sources :

Example 1 with TokenResponse

use of org.whispersystems.signalservice.internal.contacts.entities.TokenResponse in project Signal-Android by WhisperSystems.

the class KbsRepository method getTokenSync.

@NonNull
private TokenData getTokenSync(@Nullable String authorization) throws IOException {
    TokenData firstKnownTokenData = null;
    for (KbsEnclave enclave : KbsEnclaves.all()) {
        KeyBackupService kbs = ApplicationDependencies.getKeyBackupService(enclave);
        authorization = authorization == null ? kbs.getAuthorization() : authorization;
        TokenResponse token = kbs.getToken(authorization);
        TokenData tokenData = new TokenData(enclave, authorization, token);
        if (tokenData.getTriesRemaining() > 0) {
            Log.i(TAG, "Found data! " + enclave.getEnclaveName());
            return tokenData;
        } else if (firstKnownTokenData == null) {
            Log.i(TAG, "No data, but storing as the first response. " + enclave.getEnclaveName());
            firstKnownTokenData = tokenData;
        } else {
            Log.i(TAG, "No data, and we already have a 'first response'. " + enclave.getEnclaveName());
        }
    }
    return Objects.requireNonNull(firstKnownTokenData);
}
Also used : KbsEnclave(org.thoughtcrime.securesms.KbsEnclave) TokenResponse(org.whispersystems.signalservice.internal.contacts.entities.TokenResponse) KeyBackupService(org.whispersystems.signalservice.api.KeyBackupService) NonNull(androidx.annotation.NonNull)

Example 2 with TokenResponse

use of org.whispersystems.signalservice.internal.contacts.entities.TokenResponse in project Signal-Android by signalapp.

the class KbsRepository method getTokenSync.

@NonNull
private TokenData getTokenSync(@Nullable String authorization) throws IOException {
    TokenData firstKnownTokenData = null;
    for (KbsEnclave enclave : KbsEnclaves.all()) {
        KeyBackupService kbs = ApplicationDependencies.getKeyBackupService(enclave);
        authorization = authorization == null ? kbs.getAuthorization() : authorization;
        TokenResponse token = kbs.getToken(authorization);
        TokenData tokenData = new TokenData(enclave, authorization, token);
        if (tokenData.getTriesRemaining() > 0) {
            Log.i(TAG, "Found data! " + enclave.getEnclaveName());
            return tokenData;
        } else if (firstKnownTokenData == null) {
            Log.i(TAG, "No data, but storing as the first response. " + enclave.getEnclaveName());
            firstKnownTokenData = tokenData;
        } else {
            Log.i(TAG, "No data, and we already have a 'first response'. " + enclave.getEnclaveName());
        }
    }
    return Objects.requireNonNull(firstKnownTokenData);
}
Also used : KbsEnclave(org.thoughtcrime.securesms.KbsEnclave) TokenResponse(org.whispersystems.signalservice.internal.contacts.entities.TokenResponse) KeyBackupService(org.whispersystems.signalservice.api.KeyBackupService) NonNull(androidx.annotation.NonNull)

Aggregations

NonNull (androidx.annotation.NonNull)2 KbsEnclave (org.thoughtcrime.securesms.KbsEnclave)2 KeyBackupService (org.whispersystems.signalservice.api.KeyBackupService)2 TokenResponse (org.whispersystems.signalservice.internal.contacts.entities.TokenResponse)2