当前位置: 首页>>代码示例>>Java>>正文


Java IncomingEncryptedMessage类代码示例

本文整理汇总了Java中org.thoughtcrime.securesms.sms.IncomingEncryptedMessage的典型用法代码示例。如果您正苦于以下问题:Java IncomingEncryptedMessage类的具体用法?Java IncomingEncryptedMessage怎么用?Java IncomingEncryptedMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IncomingEncryptedMessage类属于org.thoughtcrime.securesms.sms包,在下文中一共展示了IncomingEncryptedMessage类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decrypt

import org.thoughtcrime.securesms.sms.IncomingEncryptedMessage; //导入依赖的package包/类
public IncomingEncryptedMessage decrypt(Context context, IncomingPreKeyBundleMessage message)
    throws InvalidVersionException, InvalidMessageException, DuplicateMessageException,
           UntrustedIdentityException, LegacyMessageException
{
  try {
    Recipients           recipients    = RecipientFactory.getRecipientsFromString(context, message.getSender(), false);
    byte[]               decoded       = transportDetails.getDecodedMessage(message.getMessageBody().getBytes());
    PreKeyWhisperMessage preKeyMessage = new PreKeyWhisperMessage(decoded);
    SessionCipher        sessionCipher = new SessionCipher(axolotlStore, recipients.getPrimaryRecipient().getRecipientId(), 1);
    byte[]               padded        = sessionCipher.decrypt(preKeyMessage);
    byte[]               plaintext     = transportDetails.getStrippedPaddingMessageBody(padded);

    return new IncomingEncryptedMessage(message, new String(plaintext));
  } catch (RecipientFormattingException | IOException | InvalidKeyException | InvalidKeyIdException e) {
    throw new InvalidMessageException(e);
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:18,代码来源:SmsCipher.java

示例2: createIncomingTextMessage

import org.thoughtcrime.securesms.sms.IncomingEncryptedMessage; //导入依赖的package包/类
private IncomingTextMessage createIncomingTextMessage(MasterSecret masterSecret, SmsMessageRecord record)
    throws InvalidMessageException
{
  String plaintextBody = record.getBody().getBody();

  if (record.isAsymmetricEncryption()) {
    plaintextBody = getAsymmetricDecryptedBody(masterSecret, record.getBody().getBody());
  }

  IncomingTextMessage message = new IncomingTextMessage(record.getRecipients().getPrimaryRecipient().getNumber(),
                                                        record.getRecipientDeviceId(),
                                                        record.getDateSent(),
                                                        plaintextBody,
                                                        Optional.<TextSecureGroup>absent());

  if (record.isEndSession()) {
    return new IncomingEndSessionMessage(message);
  } else if (record.isBundleKeyExchange()) {
    return new IncomingPreKeyBundleMessage(message, message.getMessageBody());
  } else if (record.isKeyExchange()) {
    return new IncomingKeyExchangeMessage(message, message.getMessageBody());
  } else if (record.isSecure()) {
    return new IncomingEncryptedMessage(message, message.getMessageBody());
  }

  return message;
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:28,代码来源:SmsDecryptJob.java


注:本文中的org.thoughtcrime.securesms.sms.IncomingEncryptedMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。