Search in sources :

Example 1 with NoCredentialForRedemptionTimeException

use of org.whispersystems.signalservice.api.groupsv2.NoCredentialForRedemptionTimeException in project Signal-Android by WhisperSystems.

the class GroupsV2Authorization method getAuthorizationForToday.

public GroupsV2AuthorizationString getAuthorizationForToday(@NonNull ACI self, @NonNull GroupSecretParams groupSecretParams) throws IOException, VerificationFailedException {
    final int today = currentTimeDays();
    Map<Integer, AuthCredentialResponse> credentials = cache.read();
    try {
        return getAuthorization(self, groupSecretParams, credentials, today);
    } catch (NoCredentialForRedemptionTimeException e) {
        Log.i(TAG, "Auth out of date, will update auth and try again");
        cache.clear();
    } catch (VerificationFailedException e) {
        Log.w(TAG, "Verification failed, will update auth and try again", e);
        cache.clear();
    }
    Log.i(TAG, "Getting new auth credential responses");
    credentials = groupsV2Api.getCredentials(today);
    cache.write(credentials);
    try {
        return getAuthorization(self, groupSecretParams, credentials, today);
    } catch (NoCredentialForRedemptionTimeException e) {
        Log.w(TAG, "The credentials returned did not include the day requested");
        throw new IOException("Failed to get credentials");
    }
}
Also used : IOException(java.io.IOException) AuthCredentialResponse(org.signal.zkgroup.auth.AuthCredentialResponse) NoCredentialForRedemptionTimeException(org.whispersystems.signalservice.api.groupsv2.NoCredentialForRedemptionTimeException) VerificationFailedException(org.signal.zkgroup.VerificationFailedException)

Example 2 with NoCredentialForRedemptionTimeException

use of org.whispersystems.signalservice.api.groupsv2.NoCredentialForRedemptionTimeException in project Signal-Android by signalapp.

the class GroupsV2Authorization method getAuthorizationForToday.

public GroupsV2AuthorizationString getAuthorizationForToday(@NonNull ACI self, @NonNull GroupSecretParams groupSecretParams) throws IOException, VerificationFailedException {
    final int today = currentTimeDays();
    Map<Integer, AuthCredentialResponse> credentials = cache.read();
    try {
        return getAuthorization(self, groupSecretParams, credentials, today);
    } catch (NoCredentialForRedemptionTimeException e) {
        Log.i(TAG, "Auth out of date, will update auth and try again");
        cache.clear();
    } catch (VerificationFailedException e) {
        Log.w(TAG, "Verification failed, will update auth and try again", e);
        cache.clear();
    }
    Log.i(TAG, "Getting new auth credential responses");
    credentials = groupsV2Api.getCredentials(today);
    cache.write(credentials);
    try {
        return getAuthorization(self, groupSecretParams, credentials, today);
    } catch (NoCredentialForRedemptionTimeException e) {
        Log.w(TAG, "The credentials returned did not include the day requested");
        throw new IOException("Failed to get credentials");
    }
}
Also used : IOException(java.io.IOException) AuthCredentialResponse(org.signal.zkgroup.auth.AuthCredentialResponse) NoCredentialForRedemptionTimeException(org.whispersystems.signalservice.api.groupsv2.NoCredentialForRedemptionTimeException) VerificationFailedException(org.signal.zkgroup.VerificationFailedException)

Aggregations

IOException (java.io.IOException)2 VerificationFailedException (org.signal.zkgroup.VerificationFailedException)2 AuthCredentialResponse (org.signal.zkgroup.auth.AuthCredentialResponse)2 NoCredentialForRedemptionTimeException (org.whispersystems.signalservice.api.groupsv2.NoCredentialForRedemptionTimeException)2