Java Code Examples for org.whispersystems.signalservice.api.crypto.UntrustedIdentityException
The following examples show how to use
org.whispersystems.signalservice.api.crypto.UntrustedIdentityException. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: mollyim-android Source File: SignalServiceMessageSender.java License: GNU General Public License v3.0 | 6 votes |
/** * Send a message to a group. * * @param recipients The group members. * @param message The group message. * @throws IOException */ public List<SendMessageResult> sendMessage(List<SignalServiceAddress> recipients, List<Optional<UnidentifiedAccessPair>> unidentifiedAccess, boolean isRecipientUpdate, SignalServiceDataMessage message) throws IOException, UntrustedIdentityException { byte[] content = createMessageContent(message); long timestamp = message.getTimestamp(); List<SendMessageResult> results = sendMessage(recipients, getTargetUnidentifiedAccess(unidentifiedAccess), timestamp, content, false); boolean needsSyncInResults = false; for (SendMessageResult result : results) { if (result.getSuccess() != null && result.getSuccess().isNeedsSync()) { needsSyncInResults = true; break; } } if (needsSyncInResults || isMultiDevice.get()) { byte[] syncMessage = createMultiDeviceSentTranscriptContent(content, Optional.<SignalServiceAddress>absent(), timestamp, results, isRecipientUpdate); sendMessage(localAddress, Optional.<UnidentifiedAccess>absent(), timestamp, syncMessage, false); } return results; }
Example 2
Source Project: mollyim-android Source File: SignalServiceMessageSender.java License: GNU General Public License v3.0 | 6 votes |
private void sendMessage(VerifiedMessage message, Optional<UnidentifiedAccessPair> unidentifiedAccess) throws IOException, UntrustedIdentityException { byte[] nullMessageBody = DataMessage.newBuilder() .setBody(Base64.encodeBytes(Util.getRandomLengthBytes(140))) .build() .toByteArray(); NullMessage nullMessage = NullMessage.newBuilder() .setPadding(ByteString.copyFrom(nullMessageBody)) .build(); byte[] content = Content.newBuilder() .setNullMessage(nullMessage) .build() .toByteArray(); SendMessageResult result = sendMessage(message.getDestination(), getTargetUnidentifiedAccess(unidentifiedAccess), message.getTimestamp(), content, false); if (result.getSuccess().isNeedsSync()) { byte[] syncMessage = createMultiDeviceVerifiedContent(message, nullMessage.toByteArray()); sendMessage(localAddress, Optional.<UnidentifiedAccess>absent(), message.getTimestamp(), syncMessage, false); } }
Example 3
Source Project: mollyim-android Source File: SignalServiceMessageSender.java License: GNU General Public License v3.0 | 6 votes |
private OutgoingPushMessageList getEncryptedMessages(PushServiceSocket socket, SignalServiceAddress recipient, Optional<UnidentifiedAccess> unidentifiedAccess, long timestamp, byte[] plaintext, boolean online) throws IOException, InvalidKeyException, UntrustedIdentityException { List<OutgoingPushMessage> messages = new LinkedList<>(); if (!recipient.matches(localAddress) || unidentifiedAccess.isPresent()) { messages.add(getEncryptedMessage(socket, recipient, unidentifiedAccess, SignalServiceAddress.DEFAULT_DEVICE_ID, plaintext)); } for (int deviceId : store.getSubDeviceSessions(recipient.getIdentifier())) { if (store.containsSession(new SignalProtocolAddress(recipient.getIdentifier(), deviceId))) { messages.add(getEncryptedMessage(socket, recipient, unidentifiedAccess, deviceId, plaintext)); } } return new OutgoingPushMessageList(recipient.getIdentifier(), timestamp, messages, online); }
Example 4
Source Project: mollyim-android Source File: WebRtcCallService.java License: GNU General Public License v3.0 | 6 votes |
@Override public void onFailureContinue(Throwable error) { Log.w(TAG, error); if (callManager != null) { try { callManager.messageSendFailure(getCallId()); } catch (CallException e) { callFailure("callManager.messageSendFailure() failed: ", e); } } if (activePeer == null) { return; } if (error instanceof UntrustedIdentityException) { sendMessage(WebRtcViewModel.State.UNTRUSTED_IDENTITY, activePeer, ((UntrustedIdentityException)error).getIdentityKey(), localCameraState, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled, isRemoteVideoOffer); } else if (error instanceof UnregisteredUserException) { sendMessage(WebRtcViewModel.State.NO_SUCH_USER, activePeer, localCameraState, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled, isRemoteVideoOffer); } else if (error instanceof IOException) { sendMessage(WebRtcViewModel.State.NETWORK_FAILURE, activePeer, localCameraState, remoteVideoEnabled, bluetoothAvailable, microphoneEnabled, isRemoteVideoOffer); } }
Example 5
Source Project: mollyim-android Source File: SendReadReceiptJob.java License: GNU General Public License v3.0 | 6 votes |
@Override public void onRun() throws IOException, UntrustedIdentityException { if (!TextSecurePreferences.isReadReceiptsEnabled(context) || messageIds.isEmpty()) return; if (!RecipientUtil.isMessageRequestAccepted(context, threadId)) { Log.w(TAG, "Refusing to send receipts to untrusted recipient"); return; } Recipient recipient = Recipient.resolved(recipientId); SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); SignalServiceAddress remoteAddress = RecipientUtil.toSignalServiceAddress(context, recipient); SignalServiceReceiptMessage receiptMessage = new SignalServiceReceiptMessage(SignalServiceReceiptMessage.Type.READ, messageIds, timestamp); messageSender.sendReceipt(remoteAddress, UnidentifiedAccessUtil.getAccessFor(context, Recipient.resolved(recipientId)), receiptMessage); }
Example 6
Source Project: mollyim-android Source File: MultiDeviceVerifiedUpdateJob.java License: GNU General Public License v3.0 | 6 votes |
@Override public void onRun() throws IOException, UntrustedIdentityException { try { if (!TextSecurePreferences.isMultiDevice(context)) { Log.i(TAG, "Not multi device..."); return; } if (destination == null) { Log.w(TAG, "No destination..."); return; } SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); Recipient recipient = Recipient.resolved(destination); VerifiedMessage.VerifiedState verifiedState = getVerifiedState(verifiedStatus); SignalServiceAddress verifiedAddress = RecipientUtil.toSignalServiceAddress(context, recipient); VerifiedMessage verifiedMessage = new VerifiedMessage(verifiedAddress, new IdentityKey(identityKey, 0), verifiedState, timestamp); messageSender.sendMessage(SignalServiceSyncMessage.forVerified(verifiedMessage), UnidentifiedAccessUtil.getAccessFor(context, recipient)); } catch (InvalidKeyException e) { throw new IOException(e); } }
Example 7
Source Project: mollyim-android Source File: MultiDeviceContactUpdateJob.java License: GNU General Public License v3.0 | 6 votes |
private void sendUpdate(SignalServiceMessageSender messageSender, File contactsFile, boolean complete) throws IOException, UntrustedIdentityException, NetworkException { if (contactsFile.length() > 0) { FileInputStream contactsFileStream = new FileInputStream(contactsFile); SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder() .withStream(contactsFileStream) .withContentType("application/octet-stream") .withLength(contactsFile.length()) .build(); try { messageSender.sendMessage(SignalServiceSyncMessage.forContacts(new ContactsMessage(attachmentStream, complete)), UnidentifiedAccessUtil.getAccessForSync(context)); } catch (IOException ioe) { throw new NetworkException(ioe); } } }
Example 8
Source Project: mollyim-android Source File: RequestGroupInfoJob.java License: GNU General Public License v3.0 | 6 votes |
@Override public void onRun() throws IOException, UntrustedIdentityException { SignalServiceGroup group = SignalServiceGroup.newBuilder(Type.REQUEST_INFO) .withId(groupId.getDecodedId()) .build(); SignalServiceDataMessage message = SignalServiceDataMessage.newBuilder() .asGroupMessage(group) .withTimestamp(System.currentTimeMillis()) .build(); SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); Recipient recipient = Recipient.resolved(source); messageSender.sendMessage(RecipientUtil.toSignalServiceAddress(context, recipient), UnidentifiedAccessUtil.getAccessFor(context, recipient), message); }
Example 9
Source Project: mollyim-android Source File: MultiDeviceMessageRequestResponseJob.java License: GNU General Public License v3.0 | 6 votes |
@Override public void onRun() throws IOException, UntrustedIdentityException { if (!TextSecurePreferences.isMultiDevice(context)) { Log.i(TAG, "Not multi device, aborting..."); return; } SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); Recipient recipient = Recipient.resolved(threadRecipient); MessageRequestResponseMessage response; if (recipient.isGroup()) { response = MessageRequestResponseMessage.forGroup(recipient.getGroupId().get().getDecodedId(), localToRemoteType(type)); } else { response = MessageRequestResponseMessage.forIndividual(RecipientUtil.toSignalServiceAddress(context, recipient), localToRemoteType(type)); } messageSender.sendMessage(SignalServiceSyncMessage.forMessageRequestResponse(response), UnidentifiedAccessUtil.getAccessForSync(context)); }
Example 10
Source Project: mollyim-android Source File: MultiDeviceReadUpdateJob.java License: GNU General Public License v3.0 | 6 votes |
@Override public void onRun() throws IOException, UntrustedIdentityException { if (!TextSecurePreferences.isMultiDevice(context)) { Log.i(TAG, "Not multi device..."); return; } List<ReadMessage> readMessages = new LinkedList<>(); for (SerializableSyncMessageId messageId : messageIds) { Recipient recipient = Recipient.resolved(RecipientId.from(messageId.recipientId)); readMessages.add(new ReadMessage(RecipientUtil.toSignalServiceAddress(context, recipient), messageId.timestamp)); } SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); messageSender.sendMessage(SignalServiceSyncMessage.forRead(readMessages), UnidentifiedAccessUtil.getAccessForSync(context)); }
Example 11
Source Project: signald Source File: Manager.java License: GNU General Public License v3.0 | 6 votes |
private List<SendMessageResult> sendUpdateGroupMessage(byte[] groupId, String recipient) throws IOException, EncapsulatedExceptions, UntrustedIdentityException, GroupNotFoundException, NotAGroupMemberException, AttachmentInvalidException { if (groupId == null) { return null; } GroupInfo g = getGroupForSending(groupId); if (!g.members.contains(recipient)) { return null; } SignalServiceDataMessage.Builder messageBuilder = getGroupUpdateMessageBuilder(g); // Send group message only to the recipient who requested it final List<String> membersSend = new ArrayList<>(); membersSend.add(recipient); return sendMessage(messageBuilder, membersSend); }
Example 12
Source Project: signal-cli Source File: Manager.java License: GNU General Public License v3.0 | 6 votes |
/** * Trust this the identity with this fingerprint * * @param name username of the identity * @param fingerprint Fingerprint */ public boolean trustIdentityVerified(String name, byte[] fingerprint) throws InvalidNumberException { SignalServiceAddress address = canonicalizeAndResolveSignalServiceAddress(name); List<JsonIdentityKeyStore.Identity> ids = account.getSignalProtocolStore().getIdentities(address); if (ids == null) { return false; } for (JsonIdentityKeyStore.Identity id : ids) { if (!Arrays.equals(id.getIdentityKey().serialize(), fingerprint)) { continue; } account.getSignalProtocolStore().setIdentityTrustLevel(address, id.getIdentityKey(), TrustLevel.TRUSTED_VERIFIED); try { sendVerifiedMessage(address, id.getIdentityKey(), TrustLevel.TRUSTED_VERIFIED); } catch (IOException | UntrustedIdentityException e) { e.printStackTrace(); } account.save(); return true; } return false; }
Example 13
Source Project: signald Source File: Manager.java License: GNU General Public License v3.0 | 6 votes |
public SendMessageResult sendReceipt(SignalServiceReceiptMessage message, String recipient) throws IOException { SignalServiceAddress address = getSignalServiceAddress(recipient); if (address == null) { accountData.save(); return null; } try { SignalServiceMessageSender messageSender = new SignalServiceMessageSender(serviceConfiguration, accountData.username, accountData.password, accountData.deviceId, accountData.axolotlStore, USER_AGENT, true, Optional.fromNullable(messagePipe), Optional.fromNullable(unidentifiedMessagePipe), Optional.<SignalServiceMessageSender.EventListener>absent()); try { messageSender.sendReceipt(address, getAccessFor(address), message); return null; } catch (UntrustedIdentityException e) { accountData.axolotlStore.identityKeyStore.saveIdentity(e.getE164Number(), e.getIdentityKey(), TrustLevel.UNTRUSTED); return SendMessageResult.identityFailure(address, e.getIdentityKey()); } } finally { accountData.save(); } }
Example 14
Source Project: signald Source File: Manager.java License: GNU General Public License v3.0 | 6 votes |
/** * Trust this the identity with this fingerprint * * @param name username of the identity * @param fingerprint Fingerprint * @param level level at with to trust the identity */ public boolean trustIdentity(String name, byte[] fingerprint, TrustLevel level) throws IOException { List<IdentityKeyStore.Identity> ids = accountData.axolotlStore.identityKeyStore.getIdentities(name); if (ids == null) { return false; } for (IdentityKeyStore.Identity id : ids) { if (!Arrays.equals(id.getIdentityKey().serialize(), fingerprint)) { continue; } accountData.axolotlStore.identityKeyStore.saveIdentity(name, id.getIdentityKey(), level); try { sendVerifiedMessage(name, id.getIdentityKey(), level); } catch (IOException | UntrustedIdentityException e) { logger.catching(e); } accountData.save(); return true; } return false; }
Example 15
Source Project: signald Source File: Manager.java License: GNU General Public License v3.0 | 6 votes |
/** * Trust this the identity with this safety number * * @param name username of the identity * @param safetyNumber Safety number * @param level level to trust the identity */ public boolean trustIdentitySafetyNumber(String name, String safetyNumber, TrustLevel level) throws IOException { List<IdentityKeyStore.Identity> ids = accountData.axolotlStore.identityKeyStore.getIdentities(name); if (ids == null) { return false; } for (IdentityKeyStore.Identity id : ids) { if (!safetyNumber.equals(computeSafetyNumber(name, id.getIdentityKey()))) { continue; } accountData.axolotlStore.identityKeyStore.saveIdentity(name, id.getIdentityKey(), level); try { sendVerifiedMessage(name, id.getIdentityKey(), level); } catch (IOException | UntrustedIdentityException e) { logger.catching(e); } accountData.save(); return true; } return false; }
Example 16
Source Project: signal-cli Source File: Manager.java License: GNU General Public License v3.0 | 6 votes |
private SendMessageResult sendSelfMessage(SignalServiceDataMessage message) throws IOException { SignalServiceMessageSender messageSender = getMessageSender(); SignalServiceAddress recipient = account.getSelfAddress(); final Optional<UnidentifiedAccessPair> unidentifiedAccess = getAccessFor(recipient); SentTranscriptMessage transcript = new SentTranscriptMessage(Optional.of(recipient), message.getTimestamp(), message, message.getExpiresInSeconds(), Collections.singletonMap(recipient, unidentifiedAccess.isPresent()), false); SignalServiceSyncMessage syncMessage = SignalServiceSyncMessage.forSentTranscript(transcript); try { messageSender.sendMessage(syncMessage, unidentifiedAccess); return SendMessageResult.success(recipient, unidentifiedAccess.isPresent(), false); } catch (UntrustedIdentityException e) { account.getSignalProtocolStore().saveIdentity(resolveSignalServiceAddress(e.getIdentifier()), e.getIdentityKey(), TrustLevel.UNTRUSTED); return SendMessageResult.identityFailure(recipient, e.getIdentityKey()); } }
Example 17
Source Project: libsignal-service-java Source File: SignalServiceMessageSender.java License: GNU General Public License v3.0 | 6 votes |
/** * Send a message to a group. * * @param recipients The group members. * @param message The group message. * @throws IOException */ public List<SendMessageResult> sendMessage(List<SignalServiceAddress> recipients, List<Optional<UnidentifiedAccessPair>> unidentifiedAccess, boolean isRecipientUpdate, SignalServiceDataMessage message) throws IOException, UntrustedIdentityException { byte[] content = createMessageContent(message); long timestamp = message.getTimestamp(); List<SendMessageResult> results = sendMessage(recipients, getTargetUnidentifiedAccess(unidentifiedAccess), timestamp, content, false); boolean needsSyncInResults = false; for (SendMessageResult result : results) { if (result.getSuccess() != null && result.getSuccess().isNeedsSync()) { needsSyncInResults = true; break; } } if (needsSyncInResults || isMultiDevice.get()) { byte[] syncMessage = createMultiDeviceSentTranscriptContent(content, Optional.<SignalServiceAddress>absent(), timestamp, results, isRecipientUpdate); sendMessage(localAddress, Optional.<UnidentifiedAccess>absent(), timestamp, syncMessage, false); } return results; }
Example 18
Source Project: libsignal-service-java Source File: SignalServiceMessageSender.java License: GNU General Public License v3.0 | 6 votes |
private void sendMessage(VerifiedMessage message, Optional<UnidentifiedAccessPair> unidentifiedAccess) throws IOException, UntrustedIdentityException { byte[] nullMessageBody = DataMessage.newBuilder() .setBody(Base64.encodeBytes(Util.getRandomLengthBytes(140))) .build() .toByteArray(); NullMessage nullMessage = NullMessage.newBuilder() .setPadding(ByteString.copyFrom(nullMessageBody)) .build(); byte[] content = Content.newBuilder() .setNullMessage(nullMessage) .build() .toByteArray(); SendMessageResult result = sendMessage(message.getDestination(), getTargetUnidentifiedAccess(unidentifiedAccess), message.getTimestamp(), content, false); if (result.getSuccess().isNeedsSync()) { byte[] syncMessage = createMultiDeviceVerifiedContent(message, nullMessage.toByteArray()); sendMessage(localAddress, Optional.<UnidentifiedAccess>absent(), message.getTimestamp(), syncMessage, false); } }
Example 19
Source Project: libsignal-service-java Source File: SignalServiceMessageSender.java License: GNU General Public License v3.0 | 6 votes |
private OutgoingPushMessageList getEncryptedMessages(PushServiceSocket socket, SignalServiceAddress recipient, Optional<UnidentifiedAccess> unidentifiedAccess, long timestamp, byte[] plaintext, boolean online) throws IOException, InvalidKeyException, UntrustedIdentityException { List<OutgoingPushMessage> messages = new LinkedList<>(); if (!recipient.matches(localAddress) || unidentifiedAccess.isPresent()) { messages.add(getEncryptedMessage(socket, recipient, unidentifiedAccess, SignalServiceAddress.DEFAULT_DEVICE_ID, plaintext)); } for (int deviceId : store.getSubDeviceSessions(recipient.getIdentifier())) { if (store.containsSession(new SignalProtocolAddress(recipient.getIdentifier(), deviceId))) { messages.add(getEncryptedMessage(socket, recipient, unidentifiedAccess, deviceId, plaintext)); } } return new OutgoingPushMessageList(recipient.getIdentifier(), timestamp, messages, online); }
Example 20
Source Project: mollyim-android Source File: SignalServiceMessageSender.java License: GNU General Public License v3.0 | 5 votes |
/** * Send a read receipt for a received message. * * @param recipient The sender of the received message you're acknowledging. * @param message The read receipt to deliver. * @throws IOException * @throws UntrustedIdentityException */ public void sendReceipt(SignalServiceAddress recipient, Optional<UnidentifiedAccessPair> unidentifiedAccess, SignalServiceReceiptMessage message) throws IOException, UntrustedIdentityException { byte[] content = createReceiptContent(message); sendMessage(recipient, getTargetUnidentifiedAccess(unidentifiedAccess), message.getWhen(), content, false); }
Example 21
Source Project: mollyim-android Source File: SignalServiceMessageSender.java License: GNU General Public License v3.0 | 5 votes |
/** * Send a typing indicator. * * @param recipient The destination * @param message The typing indicator to deliver * @throws IOException * @throws UntrustedIdentityException */ public void sendTyping(SignalServiceAddress recipient, Optional<UnidentifiedAccessPair> unidentifiedAccess, SignalServiceTypingMessage message) throws IOException, UntrustedIdentityException { byte[] content = createTypingContent(message); sendMessage(recipient, getTargetUnidentifiedAccess(unidentifiedAccess), message.getTimestamp(), content, true); }
Example 22
Source Project: mollyim-android Source File: SignalServiceMessageSender.java License: GNU General Public License v3.0 | 5 votes |
/** * Send a call setup message to a single recipient. * * @param recipient The message's destination. * @param message The call message. * @throws IOException */ public void sendCallMessage(SignalServiceAddress recipient, Optional<UnidentifiedAccessPair> unidentifiedAccess, SignalServiceCallMessage message) throws IOException, UntrustedIdentityException { byte[] content = createCallContent(message); sendMessage(recipient, getTargetUnidentifiedAccess(unidentifiedAccess), System.currentTimeMillis(), content, false); }
Example 23
Source Project: mollyim-android Source File: SignalServiceMessageSender.java License: GNU General Public License v3.0 | 5 votes |
/** * Send a message to a single recipient. * * @param recipient The message's destination. * @param message The message. * @throws UntrustedIdentityException * @throws IOException */ public SendMessageResult sendMessage(SignalServiceAddress recipient, Optional<UnidentifiedAccessPair> unidentifiedAccess, SignalServiceDataMessage message) throws UntrustedIdentityException, IOException { byte[] content = createMessageContent(message); long timestamp = message.getTimestamp(); SendMessageResult result = sendMessage(recipient, getTargetUnidentifiedAccess(unidentifiedAccess), timestamp, content, false); if (result.getSuccess() != null && result.getSuccess().isNeedsSync()) { byte[] syncMessage = createMultiDeviceSentTranscriptContent(content, Optional.of(recipient), timestamp, Collections.singletonList(result), false); sendMessage(localAddress, Optional.<UnidentifiedAccess>absent(), timestamp, syncMessage, false); } if (message.isEndSession()) { if (recipient.getUuid().isPresent()) { store.deleteAllSessions(recipient.getUuid().get().toString()); } if (recipient.getNumber().isPresent()) { store.deleteAllSessions(recipient.getNumber().get()); } if (eventListener.isPresent()) { eventListener.get().onSecurityEvent(recipient); } } return result; }
Example 24
Source Project: mollyim-android Source File: SignalServiceMessageSender.java License: GNU General Public License v3.0 | 5 votes |
public void sendMessage(SignalServiceSyncMessage message, Optional<UnidentifiedAccessPair> unidentifiedAccess) throws IOException, UntrustedIdentityException { byte[] content; if (message.getContacts().isPresent()) { content = createMultiDeviceContactsContent(message.getContacts().get().getContactsStream().asStream(), message.getContacts().get().isComplete()); } else if (message.getGroups().isPresent()) { content = createMultiDeviceGroupsContent(message.getGroups().get().asStream()); } else if (message.getRead().isPresent()) { content = createMultiDeviceReadContent(message.getRead().get()); } else if (message.getViewOnceOpen().isPresent()) { content = createMultiDeviceViewOnceOpenContent(message.getViewOnceOpen().get()); } else if (message.getBlockedList().isPresent()) { content = createMultiDeviceBlockedContent(message.getBlockedList().get()); } else if (message.getConfiguration().isPresent()) { content = createMultiDeviceConfigurationContent(message.getConfiguration().get()); } else if (message.getSent().isPresent()) { content = createMultiDeviceSentTranscriptContent(message.getSent().get(), unidentifiedAccess); } else if (message.getStickerPackOperations().isPresent()) { content = createMultiDeviceStickerPackOperationContent(message.getStickerPackOperations().get()); } else if (message.getFetchType().isPresent()) { content = createMultiDeviceFetchTypeContent(message.getFetchType().get()); } else if (message.getMessageRequestResponse().isPresent()) { content = createMultiDeviceMessageRequestResponseContent(message.getMessageRequestResponse().get()); } else if (message.getKeys().isPresent()) { content = createMultiDeviceSyncKeysContent(message.getKeys().get()); } else if (message.getVerified().isPresent()) { sendMessage(message.getVerified().get(), unidentifiedAccess); return; } else { throw new IOException("Unsupported sync message!"); } long timestamp = message.getSent().isPresent() ? message.getSent().get().getTimestamp() : System.currentTimeMillis(); sendMessage(localAddress, Optional.<UnidentifiedAccess>absent(), timestamp, content, false); }
Example 25
Source Project: mollyim-android Source File: EncapsulatedExceptions.java License: GNU General Public License v3.0 | 5 votes |
public EncapsulatedExceptions(List<UntrustedIdentityException> untrustedIdentities, List<UnregisteredUserException> unregisteredUsers, List<NetworkFailureException> networkExceptions) { this.untrustedIdentityExceptions = untrustedIdentities; this.unregisteredUserExceptions = unregisteredUsers; this.networkExceptions = networkExceptions; }
Example 26
Source Project: mollyim-android Source File: EncapsulatedExceptions.java License: GNU General Public License v3.0 | 5 votes |
public EncapsulatedExceptions(UntrustedIdentityException e) { this.untrustedIdentityExceptions = new LinkedList<>(); this.unregisteredUserExceptions = new LinkedList<>(); this.networkExceptions = new LinkedList<>(); this.untrustedIdentityExceptions.add(e); }
Example 27
Source Project: mollyim-android Source File: MultiDeviceBlockedUpdateJob.java License: GNU General Public License v3.0 | 5 votes |
@Override public void onRun() throws IOException, UntrustedIdentityException { if (!TextSecurePreferences.isMultiDevice(context)) { Log.i(TAG, "Not multi device, aborting..."); return; } RecipientDatabase database = DatabaseFactory.getRecipientDatabase(context); try (RecipientReader reader = database.readerForBlocked(database.getBlocked())) { List<SignalServiceAddress> blockedIndividuals = new LinkedList<>(); List<byte[]> blockedGroups = new LinkedList<>(); Recipient recipient; while ((recipient = reader.getNext()) != null) { if (recipient.isPushGroup()) { blockedGroups.add(recipient.requireGroupId().getDecodedId()); } else if (recipient.hasServiceIdentifier()) { blockedIndividuals.add(RecipientUtil.toSignalServiceAddress(context, recipient)); } } SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); messageSender.sendMessage(SignalServiceSyncMessage.forBlocked(new BlockedListMessage(blockedIndividuals, blockedGroups)), UnidentifiedAccessUtil.getAccessForSync(context)); } }
Example 28
Source Project: mollyim-android Source File: MultiDeviceGroupUpdateJob.java License: GNU General Public License v3.0 | 5 votes |
private void sendUpdate(SignalServiceMessageSender messageSender, File contactsFile) throws IOException, UntrustedIdentityException { FileInputStream contactsFileStream = new FileInputStream(contactsFile); SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder() .withStream(contactsFileStream) .withContentType("application/octet-stream") .withLength(contactsFile.length()) .build(); messageSender.sendMessage(SignalServiceSyncMessage.forGroups(attachmentStream), UnidentifiedAccessUtil.getAccessForSync(context)); }
Example 29
Source Project: mollyim-android Source File: MultiDeviceProfileKeyUpdateJob.java License: GNU General Public License v3.0 | 5 votes |
@Override public void onRun() throws IOException, UntrustedIdentityException { if (!TextSecurePreferences.isMultiDevice(context)) { Log.i(TAG, "Not multi device..."); return; } Optional<ProfileKey> profileKey = Optional.of(ProfileKeyUtil.getSelfProfileKey()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); DeviceContactsOutputStream out = new DeviceContactsOutputStream(baos); out.write(new DeviceContact(RecipientUtil.toSignalServiceAddress(context, Recipient.self()), Optional.absent(), Optional.absent(), Optional.absent(), Optional.absent(), profileKey, false, Optional.absent(), Optional.absent(), false)); out.close(); SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder() .withStream(new ByteArrayInputStream(baos.toByteArray())) .withContentType("application/octet-stream") .withLength(baos.toByteArray().length) .build(); SignalServiceSyncMessage syncMessage = SignalServiceSyncMessage.forContacts(new ContactsMessage(attachmentStream, false)); messageSender.sendMessage(syncMessage, UnidentifiedAccessUtil.getAccessForSync(context)); }
Example 30
Source Project: mollyim-android Source File: MultiDeviceConfigurationUpdateJob.java License: GNU General Public License v3.0 | 5 votes |
@Override public void onRun() throws IOException, UntrustedIdentityException { if (!TextSecurePreferences.isMultiDevice(context)) { Log.i(TAG, "Not multi device, aborting..."); return; } SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender(); messageSender.sendMessage(SignalServiceSyncMessage.forConfiguration(new ConfigurationMessage(Optional.of(readReceiptsEnabled), Optional.of(unidentifiedDeliveryIndicatorsEnabled), Optional.of(typingIndicatorsEnabled), Optional.of(linkPreviewsEnabled))), UnidentifiedAccessUtil.getAccessForSync(context)); }