Search in sources :

Example 1 with TemporalAuthCredentialResponse

use of org.thoughtcrime.securesms.database.model.databaseprotos.TemporalAuthCredentialResponse in project Signal-Android by WhisperSystems.

the class GroupsV2AuthorizationSignalStoreCache method read.

@Override
@NonNull
public Map<Integer, AuthCredentialResponse> read() {
    byte[] credentialBlob = store.getBlob(KEY, null);
    if (credentialBlob == null) {
        Log.i(TAG, "No credentials responses are cached locally");
        return Collections.emptyMap();
    }
    try {
        TemporalAuthCredentialResponses temporalCredentials = TemporalAuthCredentialResponses.parseFrom(credentialBlob);
        HashMap<Integer, AuthCredentialResponse> result = new HashMap<>(temporalCredentials.getCredentialResponseCount());
        for (TemporalAuthCredentialResponse credential : temporalCredentials.getCredentialResponseList()) {
            result.put(credential.getDate(), new AuthCredentialResponse(credential.getAuthCredentialResponse().toByteArray()));
        }
        Log.i(TAG, String.format(Locale.US, "Loaded %d credentials from local storage", result.size()));
        return result;
    } catch (InvalidProtocolBufferException | InvalidInputException e) {
        throw new AssertionError(e);
    }
}
Also used : TemporalAuthCredentialResponse(org.thoughtcrime.securesms.database.model.databaseprotos.TemporalAuthCredentialResponse) InvalidInputException(org.signal.zkgroup.InvalidInputException) HashMap(java.util.HashMap) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) TemporalAuthCredentialResponses(org.thoughtcrime.securesms.database.model.databaseprotos.TemporalAuthCredentialResponses) AuthCredentialResponse(org.signal.zkgroup.auth.AuthCredentialResponse) TemporalAuthCredentialResponse(org.thoughtcrime.securesms.database.model.databaseprotos.TemporalAuthCredentialResponse) NonNull(androidx.annotation.NonNull)

Example 2 with TemporalAuthCredentialResponse

use of org.thoughtcrime.securesms.database.model.databaseprotos.TemporalAuthCredentialResponse in project Signal-Android by signalapp.

the class GroupsV2AuthorizationSignalStoreCache method read.

@Override
@NonNull
public Map<Integer, AuthCredentialResponse> read() {
    byte[] credentialBlob = store.getBlob(KEY, null);
    if (credentialBlob == null) {
        Log.i(TAG, "No credentials responses are cached locally");
        return Collections.emptyMap();
    }
    try {
        TemporalAuthCredentialResponses temporalCredentials = TemporalAuthCredentialResponses.parseFrom(credentialBlob);
        HashMap<Integer, AuthCredentialResponse> result = new HashMap<>(temporalCredentials.getCredentialResponseCount());
        for (TemporalAuthCredentialResponse credential : temporalCredentials.getCredentialResponseList()) {
            result.put(credential.getDate(), new AuthCredentialResponse(credential.getAuthCredentialResponse().toByteArray()));
        }
        Log.i(TAG, String.format(Locale.US, "Loaded %d credentials from local storage", result.size()));
        return result;
    } catch (InvalidProtocolBufferException | InvalidInputException e) {
        throw new AssertionError(e);
    }
}
Also used : TemporalAuthCredentialResponse(org.thoughtcrime.securesms.database.model.databaseprotos.TemporalAuthCredentialResponse) InvalidInputException(org.signal.zkgroup.InvalidInputException) HashMap(java.util.HashMap) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) TemporalAuthCredentialResponses(org.thoughtcrime.securesms.database.model.databaseprotos.TemporalAuthCredentialResponses) AuthCredentialResponse(org.signal.zkgroup.auth.AuthCredentialResponse) TemporalAuthCredentialResponse(org.thoughtcrime.securesms.database.model.databaseprotos.TemporalAuthCredentialResponse) NonNull(androidx.annotation.NonNull)

Aggregations

NonNull (androidx.annotation.NonNull)2 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)2 HashMap (java.util.HashMap)2 InvalidInputException (org.signal.zkgroup.InvalidInputException)2 AuthCredentialResponse (org.signal.zkgroup.auth.AuthCredentialResponse)2 TemporalAuthCredentialResponse (org.thoughtcrime.securesms.database.model.databaseprotos.TemporalAuthCredentialResponse)2 TemporalAuthCredentialResponses (org.thoughtcrime.securesms.database.model.databaseprotos.TemporalAuthCredentialResponses)2