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


Java SignalServiceEnvelope.getSource方法代码示例

本文整理汇总了Java中org.whispersystems.signalservice.api.messages.SignalServiceEnvelope.getSource方法的典型用法代码示例。如果您正苦于以下问题:Java SignalServiceEnvelope.getSource方法的具体用法?Java SignalServiceEnvelope.getSource怎么用?Java SignalServiceEnvelope.getSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.whispersystems.signalservice.api.messages.SignalServiceEnvelope的用法示例。


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

示例1: handleExpirationUpdate

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入方法依赖的package包/类
private void handleExpirationUpdate(@NonNull MasterSecretUnion masterSecret,
                                    @NonNull SignalServiceEnvelope envelope,
                                    @NonNull SignalServiceDataMessage message,
                                    @NonNull Optional<Long> smsMessageId)
    throws MmsException
{
  MmsDatabase          database     = DatabaseFactory.getMmsDatabase(context);
  String               localNumber  = TextSecurePreferences.getLocalNumber(context);
  Recipients           recipients   = getMessageDestination(envelope, message);
  IncomingMediaMessage mediaMessage = new IncomingMediaMessage(masterSecret, envelope.getSource(),
                                                               localNumber, message.getTimestamp(), -1,
                                                               message.getExpiresInSeconds() * 1000, true,
                                                               Optional.fromNullable(envelope.getRelay()),
                                                               Optional.<String>absent(), message.getGroupInfo(),
                                                               Optional.<List<SignalServiceAttachment>>absent());



  database.insertSecureDecryptedMessageInbox(masterSecret, mediaMessage, -1);

  DatabaseFactory.getRecipientPreferenceDatabase(context).setExpireMessages(recipients, message.getExpiresInSeconds());

  if (smsMessageId.isPresent()) {
    DatabaseFactory.getSmsDatabase(context).deleteMessage(smsMessageId.get());
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:27,代码来源:PushDecryptJob.java

示例2: decrypt

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入方法依赖的package包/类
private byte[] decrypt(SignalServiceEnvelope envelope, byte[] ciphertext)
    throws InvalidVersionException, InvalidMessageException, InvalidKeyException,
           DuplicateMessageException, InvalidKeyIdException, UntrustedIdentityException,
           LegacyMessageException, NoSessionException
{
  SignalProtocolAddress sourceAddress = new SignalProtocolAddress(envelope.getSource(), envelope.getSourceDevice());
  SessionCipher         sessionCipher = new SessionCipher(signalProtocolStore, sourceAddress);

  byte[] paddedMessage;

  if (envelope.isPreKeySignalMessage()) {
    paddedMessage = sessionCipher.decrypt(new PreKeySignalMessage(ciphertext));
  } else if (envelope.isSignalMessage()) {
    paddedMessage = sessionCipher.decrypt(new SignalMessage(ciphertext));
  } else {
    throw new InvalidMessageException("Unknown type: " + envelope.getType());
  }

  PushTransportDetails transportDetails = new PushTransportDetails(sessionCipher.getSessionVersion());
  return transportDetails.getStrippedPaddingMessageBody(paddedMessage);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-lib,代码行数:22,代码来源:SignalServiceCipher.java

示例3: handleIncomingSofaMessage

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入方法依赖的package包/类
private IncomingMessage handleIncomingSofaMessage(final SignalServiceEnvelope envelope) throws InvalidVersionException, InvalidMessageException, InvalidKeyException, DuplicateMessageException, InvalidKeyIdException, org.whispersystems.libsignal.UntrustedIdentityException, LegacyMessageException, NoSessionException {
    final SignalServiceAddress localAddress = new SignalServiceAddress(this.wallet.getOwnerAddress());
    final SignalServiceCipher cipher = new SignalServiceCipher(localAddress, this.protocolStore);
    final SignalServiceContent content = cipher.decrypt(envelope);
    final String messageSource = envelope.getSource();

    if (isUserBlocked(messageSource)) {
        LogUtil.i(getClass(), "A blocked user is trying to send a message");
        return null;
    }

    if (content.getDataMessage().isPresent()) {
        final SignalServiceDataMessage dataMessage = content.getDataMessage().get();
        if (dataMessage.isGroupUpdate()) return taskGroupUpdate.run(messageSource, dataMessage);
        else return taskHandleMessage.run(messageSource, dataMessage);
    }
    return null;
}
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:19,代码来源:SofaMessageReceiver.java

示例4: handleEndSessionMessage

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入方法依赖的package包/类
private void handleEndSessionMessage(@NonNull MasterSecretUnion        masterSecret,
                                     @NonNull SignalServiceEnvelope    envelope,
                                     @NonNull SignalServiceDataMessage message,
                                     @NonNull Optional<Long>           smsMessageId)
{
  EncryptingSmsDatabase smsDatabase         = DatabaseFactory.getEncryptingSmsDatabase(context);
  IncomingTextMessage   incomingTextMessage = new IncomingTextMessage(envelope.getSource(),
                                                                      envelope.getSourceDevice(),
                                                                      message.getTimestamp(),
                                                                      "", Optional.<SignalServiceGroup>absent(), 0);

  Long threadId;

  if (!smsMessageId.isPresent()) {
    IncomingEndSessionMessage incomingEndSessionMessage = new IncomingEndSessionMessage(incomingTextMessage);
    Optional<InsertResult>    insertResult              = smsDatabase.insertMessageInbox(masterSecret, incomingEndSessionMessage);

    if (insertResult.isPresent()) threadId = insertResult.get().getThreadId();
    else                          threadId = null;
  } else {
    smsDatabase.markAsEndSession(smsMessageId.get());
    threadId = smsDatabase.getThreadIdForMessage(smsMessageId.get());
  }

  if (threadId != null) {
    SessionStore sessionStore = new TextSecureSessionStore(context);
    sessionStore.deleteAllSessions(envelope.getSource());

    SecurityEvent.broadcastSecurityUpdateEvent(context);
    MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), threadId);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:33,代码来源:PushDecryptJob.java

示例5: handleMediaMessage

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入方法依赖的package包/类
private void handleMediaMessage(@NonNull MasterSecretUnion masterSecret,
                                @NonNull SignalServiceEnvelope envelope,
                                @NonNull SignalServiceDataMessage message,
                                @NonNull Optional<Long> smsMessageId)
    throws MmsException
{
  MmsDatabase          database     = DatabaseFactory.getMmsDatabase(context);
  String               localNumber  = TextSecurePreferences.getLocalNumber(context);
  Recipients           recipients   = getMessageDestination(envelope, message);
  IncomingMediaMessage mediaMessage = new IncomingMediaMessage(masterSecret, envelope.getSource(),
                                                               localNumber, message.getTimestamp(), -1,
                                                               message.getExpiresInSeconds() * 1000, false,
                                                               Optional.fromNullable(envelope.getRelay()),
                                                               message.getBody(),
                                                               message.getGroupInfo(),
                                                               message.getAttachments());

  if (message.getExpiresInSeconds() != recipients.getExpireMessages()) {
    handleExpirationUpdate(masterSecret, envelope, message, Optional.<Long>absent());
  }

  Optional<InsertResult> insertResult = database.insertSecureDecryptedMessageInbox(masterSecret, mediaMessage, -1);

  if (insertResult.isPresent()) {
    List<DatabaseAttachment> attachments = DatabaseFactory.getAttachmentDatabase(context).getAttachmentsForMessage(insertResult.get().getMessageId());

    for (DatabaseAttachment attachment : attachments) {
      ApplicationContext.getInstance(context)
                        .getJobManager()
                        .add(new AttachmentDownloadJob(context, insertResult.get().getMessageId(),
                                                       attachment.getAttachmentId()));
    }

    if (smsMessageId.isPresent()) {
      DatabaseFactory.getSmsDatabase(context).deleteMessage(smsMessageId.get());
    }

    MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), insertResult.get().getThreadId());
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:41,代码来源:PushDecryptJob.java

示例6: handleUntrustedIdentityMessage

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入方法依赖的package包/类
private void handleUntrustedIdentityMessage(@NonNull MasterSecretUnion masterSecret,
                                            @NonNull SignalServiceEnvelope envelope,
                                            @NonNull Optional<Long> smsMessageId)
{
  try {
    EncryptingSmsDatabase database       = DatabaseFactory.getEncryptingSmsDatabase(context);
    Recipients            recipients     = RecipientFactory.getRecipientsFromString(context, envelope.getSource(), false);
    long                  recipientId    = recipients.getPrimaryRecipient().getRecipientId();
    byte[]                serialized     = envelope.hasLegacyMessage() ? envelope.getLegacyMessage() : envelope.getContent();
    PreKeySignalMessage   whisperMessage = new PreKeySignalMessage(serialized);
    IdentityKey           identityKey    = whisperMessage.getIdentityKey();
    String                encoded        = Base64.encodeBytes(serialized);

    IncomingTextMessage   textMessage    = new IncomingTextMessage(envelope.getSource(), envelope.getSourceDevice(),
                                                                   envelope.getTimestamp(), encoded,
                                                                   Optional.<SignalServiceGroup>absent(), 0);

    if (!smsMessageId.isPresent()) {
      IncomingPreKeyBundleMessage bundleMessage = new IncomingPreKeyBundleMessage(textMessage, encoded, envelope.hasLegacyMessage());
      Optional<InsertResult>      insertResult  = database.insertMessageInbox(masterSecret, bundleMessage);

      if (insertResult.isPresent()) {
        database.setMismatchedIdentity(insertResult.get().getMessageId(), recipientId, identityKey);
        MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), insertResult.get().getThreadId());
      }
    } else {
      database.updateMessageBody(masterSecret, smsMessageId.get(), encoded);
      database.markAsPreKeyBundle(smsMessageId.get());
      database.setMismatchedIdentity(smsMessageId.get(), recipientId, identityKey);
    }
  } catch (InvalidMessageException | InvalidVersionException e) {
    throw new AssertionError(e);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:35,代码来源:PushDecryptJob.java

示例7: storeMessage

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入方法依赖的package包/类
private static @Nullable Long storeMessage(@NonNull Context context,
                                           @NonNull MasterSecretUnion masterSecret,
                                           @NonNull SignalServiceEnvelope envelope,
                                           @NonNull SignalServiceGroup group,
                                           @NonNull GroupContext storage,
                                           boolean  outgoing)
{
  if (group.getAvatar().isPresent()) {
    ApplicationContext.getInstance(context).getJobManager()
                      .add(new AvatarDownloadJob(context, group.getGroupId()));
  }

  try {
    if (outgoing) {
      MmsDatabase               mmsDatabase     = DatabaseFactory.getMmsDatabase(context);
      Recipients                recipients      = RecipientFactory.getRecipientsFromString(context, GroupUtil.getEncodedId(group.getGroupId()), false);
      OutgoingGroupMediaMessage outgoingMessage = new OutgoingGroupMediaMessage(recipients, storage, null, envelope.getTimestamp(), 0);
      long                      threadId        = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipients);
      long                      messageId       = mmsDatabase.insertMessageOutbox(masterSecret, outgoingMessage, threadId, false);

      mmsDatabase.markAsSent(messageId, true);

      return threadId;
    } else {
      EncryptingSmsDatabase smsDatabase  = DatabaseFactory.getEncryptingSmsDatabase(context);
      String                body         = Base64.encodeBytes(storage.toByteArray());
      IncomingTextMessage   incoming     = new IncomingTextMessage(envelope.getSource(), envelope.getSourceDevice(), envelope.getTimestamp(), body, Optional.of(group), 0);
      IncomingGroupMessage  groupMessage = new IncomingGroupMessage(incoming, storage, body);

      Optional<InsertResult> insertResult = smsDatabase.insertMessageInbox(masterSecret, groupMessage);

      if (insertResult.isPresent()) {
        MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), insertResult.get().getThreadId());
        return insertResult.get().getThreadId();
      } else {
        return null;
      }
    }
  } catch (MmsException e) {
    Log.w(TAG, e);
  }

  return null;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:45,代码来源:GroupMessageProcessor.java

示例8: storeMessage

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入方法依赖的package包/类
private static @Nullable Long storeMessage(@NonNull Context context,
                                           @NonNull MasterSecretUnion masterSecret,
                                           @NonNull SignalServiceEnvelope envelope,
                                           @NonNull SignalServiceGroup group,
                                           @NonNull GroupContext storage,
                                           boolean  outgoing)
{
  if (group.getAvatar().isPresent()) {
    ApplicationContext.getInstance(context).getJobManager()
                      .add(new AvatarDownloadJob(context, group.getGroupId()));
  }

  try {
    if (outgoing) {
      MmsDatabase               mmsDatabase     = DatabaseFactory.getMmsDatabase(context);
      Recipients                recipients      = RecipientFactory.getRecipientsFromString(context, GroupUtil.getEncodedId(group.getGroupId()), false);
      OutgoingGroupMediaMessage outgoingMessage = new OutgoingGroupMediaMessage(recipients, storage, null, envelope.getTimestamp(), 0);
      long                      threadId        = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipients);
      long                      messageId       = mmsDatabase.insertMessageOutbox(masterSecret, outgoingMessage, threadId, false, null);

      mmsDatabase.markAsSent(messageId, true);

      return threadId;
    } else {
      EncryptingSmsDatabase smsDatabase  = DatabaseFactory.getEncryptingSmsDatabase(context);
      String                body         = Base64.encodeBytes(storage.toByteArray());
      IncomingTextMessage   incoming     = new IncomingTextMessage(envelope.getSource(), envelope.getSourceDevice(), envelope.getTimestamp(), body, Optional.of(group), 0);
      IncomingGroupMessage  groupMessage = new IncomingGroupMessage(incoming, storage, body);

      Optional<InsertResult> insertResult = smsDatabase.insertMessageInbox(masterSecret, groupMessage);

      if (insertResult.isPresent()) {
        MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), insertResult.get().getThreadId());
        return insertResult.get().getThreadId();
      } else {
        return null;
      }
    }
  } catch (MmsException e) {
    Log.w(TAG, e);
  }

  return null;
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:45,代码来源:GroupMessageProcessor.java

示例9: handleMediaMessage

import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; //导入方法依赖的package包/类
private void handleMediaMessage(@NonNull MasterSecretUnion masterSecret,
                                @NonNull SignalServiceEnvelope envelope,
                                @NonNull SignalServiceDataMessage message,
                                @NonNull Optional<Long> smsMessageId)
    throws MmsException
{
  MmsDatabase          database     = DatabaseFactory.getMmsDatabase(context);
  String               localNumber  = TextSecurePreferences.getLocalNumber(context);
  Recipients           recipients   = getMessageDestination(envelope, message);
  IncomingMediaMessage mediaMessage = new IncomingMediaMessage(masterSecret, envelope.getSource(),
                                                               localNumber, message.getTimestamp(), -1,
                                                               message.getExpiresInSeconds() * 1000, false,
                                                               Optional.fromNullable(envelope.getRelay()),
                                                               message.getBody(),
                                                               message.getGroupInfo(),
                                                               message.getAttachments());

  if (message.getExpiresInSeconds() != recipients.getExpireMessages()) {
    handleExpirationUpdate(masterSecret, envelope, message, Optional.<Long>absent());
  }

  Optional<InsertResult> insertResult = database.insertSecureDecryptedMessageInbox(masterSecret, mediaMessage, -1);

  if (insertResult.isPresent()) {
    List<DatabaseAttachment> attachments = DatabaseFactory.getAttachmentDatabase(context).getAttachmentsForMessage(null, insertResult.get().getMessageId());

    for (DatabaseAttachment attachment : attachments) {
      ApplicationContext.getInstance(context)
                        .getJobManager()
                        .add(new AttachmentDownloadJob(context, insertResult.get().getMessageId(),
                                                       attachment.getAttachmentId()));

      if (!masterSecret.getMasterSecret().isPresent()) {
        ApplicationContext.getInstance(context)
                          .getJobManager()
                          .add(new AttachmentFileNameJob(context, masterSecret.getAsymmetricMasterSecret().get(), attachment, mediaMessage));
      }
    }

    if (smsMessageId.isPresent()) {
      DatabaseFactory.getSmsDatabase(context).deleteMessage(smsMessageId.get());
    }

    MessageNotifier.updateNotification(context, masterSecret.getMasterSecret().orNull(), insertResult.get().getThreadId());
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:47,代码来源:PushDecryptJob.java


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