org.whispersystems.signalservice.internal.push.UnsupportedDataMessageException Java Examples
The following examples show how to use
org.whispersystems.signalservice.internal.push.UnsupportedDataMessageException.
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 File: PushDecryptMessageJob.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private static PushProcessMessageJob.ExceptionMetadata toExceptionMetadata(@NonNull UnsupportedDataMessageException e) throws NoSenderException { String sender = e.getSender(); if (sender == null) throw new NoSenderException(); GroupId groupId = null; try { groupId = GroupUtil.idFromGroupContext(e.getGroup().orNull()); } catch (BadGroupIdException ex) { Log.w(TAG, "Bad group id found in unsupported data message", ex); } return new PushProcessMessageJob.ExceptionMetadata(sender, e.getSenderDevice(), groupId); }
Example #2
Source File: SignalServiceContent.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
public static SignalServiceContent deserialize(byte[] data) { try { if (data == null) return null; SignalServiceContentProto signalServiceContentProto = SignalServiceContentProto.parseFrom(data); return createFromProto(signalServiceContentProto); } catch (InvalidProtocolBufferException | ProtocolInvalidMessageException | ProtocolInvalidKeyException | UnsupportedDataMessageException e) { // We do not expect any of these exceptions if this byte[] has come from serialize. throw new AssertionError(e); } }
Example #3
Source File: Manager.java From signald with GNU General Public License v3.0 | 5 votes |
private SignalServiceContent decryptMessage(SignalServiceEnvelope envelope) throws NoSessionException, LegacyMessageException, InvalidVersionException, InvalidMessageException, DuplicateMessageException, InvalidKeyException, InvalidKeyIdException, org.whispersystems.libsignal.UntrustedIdentityException, InvalidMetadataMessageException, InvalidMetadataVersionException, UntrustedIdentityException, ProtocolInvalidKeyIdException, ProtocolUntrustedIdentityException, ProtocolLegacyMessageException, ProtocolNoSessionException, ProtocolInvalidVersionException, ProtocolInvalidMessageException, ProtocolInvalidKeyException, ProtocolDuplicateMessageException, SelfSendException, UnsupportedDataMessageException { SignalServiceCipher cipher = new SignalServiceCipher(new SignalServiceAddress(accountData.username), accountData.axolotlStore, getCertificateValidator()); try { return cipher.decrypt(envelope); } catch (ProtocolUntrustedIdentityException e) { // TODO We don't get the new untrusted identity from ProtocolUntrustedIdentityException anymore ... we need to get it from somewhere else // signalProtocolStore.saveIdentity(e.getSource(), e, TrustLevel.UNTRUSTED); throw e; } }
Example #4
Source File: Manager.java From signal-cli with GNU General Public License v3.0 | 5 votes |
private SignalServiceContent decryptMessage(SignalServiceEnvelope envelope) throws InvalidMetadataMessageException, ProtocolInvalidMessageException, ProtocolDuplicateMessageException, ProtocolLegacyMessageException, ProtocolInvalidKeyIdException, InvalidMetadataVersionException, ProtocolInvalidVersionException, ProtocolNoSessionException, ProtocolInvalidKeyException, SelfSendException, UnsupportedDataMessageException, org.whispersystems.libsignal.UntrustedIdentityException { SignalServiceCipher cipher = new SignalServiceCipher(account.getSelfAddress(), account.getSignalProtocolStore(), Utils.getCertificateValidator()); try { return cipher.decrypt(envelope); } catch (ProtocolUntrustedIdentityException e) { if (e.getCause() instanceof org.whispersystems.libsignal.UntrustedIdentityException) { org.whispersystems.libsignal.UntrustedIdentityException identityException = (org.whispersystems.libsignal.UntrustedIdentityException) e.getCause(); account.getSignalProtocolStore().saveIdentity(resolveSignalServiceAddress(identityException.getName()), identityException.getUntrustedIdentity(), TrustLevel.UNTRUSTED); throw identityException; } throw new AssertionError(e); } }
Example #5
Source File: SignalServiceContent.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
private static SignalServiceDataMessage createSignalServiceMessage(SignalServiceMetadata metadata, SignalServiceProtos.DataMessage content) throws ProtocolInvalidMessageException, UnsupportedDataMessageException { SignalServiceGroup groupInfoV1 = createGroupV1Info(content); SignalServiceGroupV2 groupInfoV2 = createGroupV2Info(content); Optional<SignalServiceGroupContext> groupContext; try { groupContext = SignalServiceGroupContext.createOptional(groupInfoV1, groupInfoV2); } catch (InvalidMessageException e) { throw new ProtocolInvalidMessageException(e, null, 0); } List<SignalServiceAttachment> attachments = new LinkedList<>(); boolean endSession = ((content.getFlags() & SignalServiceProtos.DataMessage.Flags.END_SESSION_VALUE ) != 0); boolean expirationUpdate = ((content.getFlags() & SignalServiceProtos.DataMessage.Flags.EXPIRATION_TIMER_UPDATE_VALUE) != 0); boolean profileKeyUpdate = ((content.getFlags() & SignalServiceProtos.DataMessage.Flags.PROFILE_KEY_UPDATE_VALUE ) != 0); SignalServiceDataMessage.Quote quote = createQuote(content); List<SharedContact> sharedContacts = createSharedContacts(content); List<SignalServiceDataMessage.Preview> previews = createPreviews(content); SignalServiceDataMessage.Sticker sticker = createSticker(content); SignalServiceDataMessage.Reaction reaction = createReaction(content); SignalServiceDataMessage.RemoteDelete remoteDelete = createRemoteDelete(content); if (content.getRequiredProtocolVersion() > SignalServiceProtos.DataMessage.ProtocolVersion.CURRENT_VALUE) { throw new UnsupportedDataMessageProtocolVersionException(SignalServiceProtos.DataMessage.ProtocolVersion.CURRENT_VALUE, content.getRequiredProtocolVersion(), metadata.getSender().getIdentifier(), metadata.getSenderDevice(), groupContext); } for (SignalServiceProtos.AttachmentPointer pointer : content.getAttachmentsList()) { attachments.add(createAttachmentPointer(pointer)); } if (content.hasTimestamp() && content.getTimestamp() != metadata.getTimestamp()) { throw new ProtocolInvalidMessageException(new InvalidMessageException("Timestamps don't match: " + content.getTimestamp() + " vs " + metadata.getTimestamp()), metadata.getSender().getIdentifier(), metadata.getSenderDevice()); } return new SignalServiceDataMessage(metadata.getTimestamp(), groupInfoV1, groupInfoV2, attachments, content.hasBody() ? content.getBody() : null, endSession, content.getExpireTimer(), expirationUpdate, content.hasProfileKey() ? content.getProfileKey().toByteArray() : null, profileKeyUpdate, quote, sharedContacts, previews, sticker, content.getIsViewOnce(), reaction, remoteDelete); }
Example #6
Source File: SignalServiceCipher.java From libsignal-service-java with GNU General Public License v3.0 | 4 votes |
private SignalServiceDataMessage createSignalServiceMessage(Metadata metadata, DataMessage content) throws ProtocolInvalidMessageException, UnsupportedDataMessageException { SignalServiceGroup groupInfo = createGroupInfo(content); List<SignalServiceAttachment> attachments = new LinkedList<>(); boolean endSession = ((content.getFlags() & DataMessage.Flags.END_SESSION_VALUE ) != 0); boolean expirationUpdate = ((content.getFlags() & DataMessage.Flags.EXPIRATION_TIMER_UPDATE_VALUE) != 0); boolean profileKeyUpdate = ((content.getFlags() & DataMessage.Flags.PROFILE_KEY_UPDATE_VALUE ) != 0); SignalServiceDataMessage.Quote quote = createQuote(content); List<SharedContact> sharedContacts = createSharedContacts(content); List<Preview> previews = createPreviews(content); Sticker sticker = createSticker(content); if (content.getRequiredProtocolVersion() > DataMessage.ProtocolVersion.CURRENT.getNumber()) { throw new UnsupportedDataMessageException(DataMessage.ProtocolVersion.CURRENT.getNumber(), content.getRequiredProtocolVersion(), metadata.getSender().getIdentifier(), metadata.getSenderDevice(), Optional.fromNullable(groupInfo)); } for (AttachmentPointer pointer : content.getAttachmentsList()) { attachments.add(createAttachmentPointer(pointer)); } if (content.hasTimestamp() && content.getTimestamp() != metadata.getTimestamp()) { throw new ProtocolInvalidMessageException(new InvalidMessageException("Timestamps don't match: " + content.getTimestamp() + " vs " + metadata.getTimestamp()), metadata.getSender().getIdentifier(), metadata.getSenderDevice()); } return new SignalServiceDataMessage(metadata.getTimestamp(), groupInfo, attachments, content.getBody(), endSession, content.getExpireTimer(), expirationUpdate, content.hasProfileKey() ? content.getProfileKey().toByteArray() : null, profileKeyUpdate, quote, sharedContacts, previews, sticker, content.getIsViewOnce()); }