use of org.signal.zkgroup.VerificationFailedException in project Signal-Android by WhisperSystems.
the class GroupsV2Operations_decrypt_change_Test method groupCandidate.
GroupCandidate groupCandidate(UUID uuid, ProfileKey profileKey) {
try {
ClientZkProfileOperations profileOperations = clientZkOperations.getProfileOperations();
ProfileKeyCommitment commitment = profileKey.getCommitment(uuid);
ProfileKeyCredentialRequestContext requestContext = profileOperations.createProfileKeyCredentialRequestContext(uuid, profileKey);
ProfileKeyCredentialRequest request = requestContext.getRequest();
ProfileKeyCredentialResponse profileKeyCredentialResponse = server.getProfileKeyCredentialResponse(request, uuid, commitment);
ProfileKeyCredential profileKeyCredential = profileOperations.receiveProfileKeyCredential(requestContext, profileKeyCredentialResponse);
GroupCandidate groupCandidate = new GroupCandidate(uuid, Optional.of(profileKeyCredential));
ProfileKeyCredentialPresentation presentation = profileOperations.createProfileKeyCredentialPresentation(groupSecretParams, profileKeyCredential);
server.assertProfileKeyCredentialPresentation(groupSecretParams.getPublicParams(), presentation);
return groupCandidate;
} catch (VerificationFailedException e) {
throw new AssertionError(e);
}
}
use of org.signal.zkgroup.VerificationFailedException in project Signal-Android by WhisperSystems.
the class LinkPreviewRepository method fetchGroupLinkPreview.
private static RequestController fetchGroupLinkPreview(@NonNull Context context, @NonNull String groupUrl, @NonNull Callback callback) {
SignalExecutors.UNBOUNDED.execute(() -> {
try {
GroupInviteLinkUrl groupInviteLinkUrl = GroupInviteLinkUrl.fromUri(groupUrl);
if (groupInviteLinkUrl == null) {
throw new AssertionError();
}
GroupMasterKey groupMasterKey = groupInviteLinkUrl.getGroupMasterKey();
GroupId.V2 groupId = GroupId.v2(groupMasterKey);
Optional<GroupDatabase.GroupRecord> group = SignalDatabase.groups().getGroup(groupId);
if (group.isPresent()) {
Log.i(TAG, "Creating preview for locally available group");
GroupDatabase.GroupRecord groupRecord = group.get();
String title = groupRecord.getTitle();
int memberCount = groupRecord.getMembers().size();
String description = getMemberCountDescription(context, memberCount);
Optional<Attachment> thumbnail = Optional.absent();
if (AvatarHelper.hasAvatar(context, groupRecord.getRecipientId())) {
Recipient recipient = Recipient.resolved(groupRecord.getRecipientId());
Bitmap bitmap = AvatarUtil.loadIconBitmapSquareNoCache(context, recipient, 512, 512);
thumbnail = bitmapToAttachment(bitmap, Bitmap.CompressFormat.WEBP, MediaUtil.IMAGE_WEBP);
}
callback.onSuccess(new LinkPreview(groupUrl, title, description, 0, thumbnail));
} else {
Log.i(TAG, "Group is not locally available for preview generation, fetching from server");
DecryptedGroupJoinInfo joinInfo = GroupManager.getGroupJoinInfoFromServer(context, groupMasterKey, groupInviteLinkUrl.getPassword());
String description = getMemberCountDescription(context, joinInfo.getMemberCount());
Optional<Attachment> thumbnail = Optional.absent();
byte[] avatarBytes = AvatarGroupsV2DownloadJob.downloadGroupAvatarBytes(context, groupMasterKey, joinInfo.getAvatar());
if (avatarBytes != null) {
Bitmap bitmap = BitmapFactory.decodeByteArray(avatarBytes, 0, avatarBytes.length);
thumbnail = bitmapToAttachment(bitmap, Bitmap.CompressFormat.WEBP, MediaUtil.IMAGE_WEBP);
if (bitmap != null)
bitmap.recycle();
}
callback.onSuccess(new LinkPreview(groupUrl, joinInfo.getTitle(), description, 0, thumbnail));
}
} catch (ExecutionException | InterruptedException | IOException | VerificationFailedException e) {
Log.w(TAG, "Failed to fetch group link preview.", e);
callback.onError(Error.PREVIEW_NOT_AVAILABLE);
} catch (GroupInviteLinkUrl.InvalidGroupLinkException | GroupInviteLinkUrl.UnknownGroupLinkVersionException e) {
Log.w(TAG, "Bad group link.", e);
callback.onError(Error.PREVIEW_NOT_AVAILABLE);
} catch (GroupLinkNotActiveException e) {
Log.w(TAG, "Group link not active.", e);
callback.onError(Error.GROUP_LINK_INACTIVE);
}
});
return () -> Log.i(TAG, "Cancelled group link preview fetch -- no effect.");
}
use of org.signal.zkgroup.VerificationFailedException 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");
}
}
use of org.signal.zkgroup.VerificationFailedException in project Signal-Android by WhisperSystems.
the class SignalCallManager method peekGroupCallForRingingCheck.
public void peekGroupCallForRingingCheck(@NonNull GroupCallRingCheckInfo info) {
if (callManager == null) {
Log.i(TAG, "Unable to peekGroupCall, call manager is null");
return;
}
networkExecutor.execute(() -> {
try {
Recipient group = Recipient.resolved(info.getRecipientId());
GroupId.V2 groupId = group.requireGroupId().requireV2();
GroupExternalCredential credential = GroupManager.getGroupExternalCredential(context, groupId);
List<GroupCall.GroupMemberInfo> members = GroupManager.getUuidCipherTexts(context, groupId).entrySet().stream().map(entry -> new GroupCall.GroupMemberInfo(entry.getKey(), entry.getValue().serialize())).collect(Collectors.toList());
callManager.peekGroupCall(SignalStore.internalValues().groupCallingServer(), credential.getTokenBytes().toByteArray(), members, peekInfo -> {
receivedGroupCallPeekForRingingCheck(info, peekInfo.getDeviceCount());
});
} catch (IOException | VerificationFailedException | CallException e) {
Log.e(TAG, "error peeking for ringing check", e);
}
});
}
use of org.signal.zkgroup.VerificationFailedException 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");
}
}
Aggregations