use of org.signal.zkgroup.InvalidInputException in project Signal-Android by WhisperSystems.
the class ProtoTestUtils method randomProfileKey.
static ProfileKey randomProfileKey() {
byte[] contents = new byte[32];
new SecureRandom().nextBytes(contents);
try {
return new ProfileKey(contents);
} catch (InvalidInputException e) {
throw new AssertionError();
}
}
use of org.signal.zkgroup.InvalidInputException 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);
}
}
use of org.signal.zkgroup.InvalidInputException in project Signal-Android by WhisperSystems.
the class ThreadDatabase method applyStorageSyncUpdate.
public void applyStorageSyncUpdate(@NonNull RecipientId recipientId, @NonNull SignalAccountRecord record) {
SQLiteDatabase db = databaseHelper.getSignalWritableDatabase();
db.beginTransaction();
try {
applyStorageSyncUpdate(recipientId, record.isNoteToSelfArchived(), record.isNoteToSelfForcedUnread());
ContentValues clearPinnedValues = new ContentValues();
clearPinnedValues.put(PINNED, 0);
db.update(TABLE_NAME, clearPinnedValues, null, null);
int pinnedPosition = 1;
for (SignalAccountRecord.PinnedConversation pinned : record.getPinnedConversations()) {
ContentValues pinnedValues = new ContentValues();
pinnedValues.put(PINNED, pinnedPosition);
Recipient pinnedRecipient;
if (pinned.getContact().isPresent()) {
pinnedRecipient = Recipient.externalPush(pinned.getContact().get());
} else if (pinned.getGroupV1Id().isPresent()) {
try {
pinnedRecipient = Recipient.externalGroupExact(context, GroupId.v1(pinned.getGroupV1Id().get()));
} catch (BadGroupIdException e) {
Log.w(TAG, "Failed to parse pinned groupV1 ID!", e);
pinnedRecipient = null;
}
} else if (pinned.getGroupV2MasterKey().isPresent()) {
try {
pinnedRecipient = Recipient.externalGroupExact(context, GroupId.v2(new GroupMasterKey(pinned.getGroupV2MasterKey().get())));
} catch (InvalidInputException e) {
Log.w(TAG, "Failed to parse pinned groupV2 master key!", e);
pinnedRecipient = null;
}
} else {
Log.w(TAG, "Empty pinned conversation on the AccountRecord?");
pinnedRecipient = null;
}
if (pinnedRecipient != null) {
db.update(TABLE_NAME, pinnedValues, RECIPIENT_ID + " = ?", SqlUtil.buildArgs(pinnedRecipient.getId()));
}
pinnedPosition++;
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
notifyConversationListListeners();
}
use of org.signal.zkgroup.InvalidInputException in project Signal-Android by WhisperSystems.
the class ProfileUtil method getProfileKey.
private static ProfileKey getProfileKey(@NonNull Recipient recipient) throws IOException {
byte[] profileKeyBytes = recipient.getProfileKey();
if (profileKeyBytes == null) {
Log.w(TAG, "Profile key unknown for " + recipient.getId());
throw new IOException("No profile key");
}
ProfileKey profileKey;
try {
profileKey = new ProfileKey(profileKeyBytes);
} catch (InvalidInputException e) {
Log.w(TAG, "Profile key invalid for " + recipient.getId());
throw new IOException("Invalid profile key");
}
return profileKey;
}
use of org.signal.zkgroup.InvalidInputException in project Signal-Android by WhisperSystems.
the class SignalCallManager method onGroupCallRingUpdate.
@Override
public void onGroupCallRingUpdate(@NonNull byte[] groupIdBytes, long ringId, @NonNull UUID uuid, @NonNull CallManager.RingUpdate ringUpdate) {
try {
GroupId.V2 groupId = GroupId.v2(new GroupIdentifier(groupIdBytes));
Optional<GroupDatabase.GroupRecord> group = SignalDatabase.groups().getGroup(groupId);
if (group.isPresent()) {
process((s, p) -> p.handleGroupCallRingUpdate(s, new RemotePeer(group.get().getRecipientId()), groupId, ringId, uuid, ringUpdate));
} else {
Log.w(TAG, "Unable to ring unknown group.");
}
} catch (InvalidInputException e) {
Log.w(TAG, "Unable to ring group due to invalid group id", e);
}
}
Aggregations