org.signal.libsignal.metadata.ProtocolUntrustedIdentityException Java Examples

The following examples show how to use org.signal.libsignal.metadata.ProtocolUntrustedIdentityException. 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: Manager.java    From signal-cli with GNU General Public License v3.0 5 votes vote down vote up
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);
    }
}