• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DuplicateMessageException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: decrypt

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的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


示例2: tryFetchLatestMessage

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的package包/类
@WorkerThread
private IncomingMessage tryFetchLatestMessage() throws TimeoutException {
    if (this.messagePipe == null) {
        this.messagePipe = messageReceiver.createMessagePipe();
    }

    try {
        final SignalServiceEnvelope envelope = messagePipe.read(INCOMING_MESSAGE_TIMEOUT, TimeUnit.SECONDS);
        return decryptIncomingSignalServiceEnvelope(envelope);
    } catch (final TimeoutException ex) {
        throw new TimeoutException(ex.getMessage());
    } catch (final IllegalStateException | InvalidKeyException | InvalidKeyIdException | DuplicateMessageException | InvalidVersionException | LegacyMessageException | InvalidMessageException | NoSessionException | org.whispersystems.libsignal.UntrustedIdentityException | IOException e) {
        LogUtil.exception(getClass(), "Error while fetching latest message", e);
    }
    return null;
}
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:17,代码来源:SofaMessageReceiver.java


示例3: handleIncomingSofaMessage

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的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: decrypt

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的package包/类
public IncomingTextMessage decrypt(Context context, IncomingTextMessage message)
    throws LegacyMessageException, InvalidMessageException,
           DuplicateMessageException, NoSessionException
{
  try {
    byte[]        decoded       = transportDetails.getDecodedMessage(message.getMessageBody().getBytes());
    SignalMessage signalMessage = new SignalMessage(decoded);
    SessionCipher sessionCipher = new SessionCipher(signalProtocolStore, new SignalProtocolAddress(message.getSender(), 1));
    byte[]        padded        = sessionCipher.decrypt(signalMessage);
    byte[]        plaintext     = transportDetails.getStrippedPaddingMessageBody(padded);

    if (message.isEndSession() && "TERMINATE".equals(new String(plaintext))) {
      signalProtocolStore.deleteSession(new SignalProtocolAddress(message.getSender(), 1));
    }

    return message.withMessageBody(new String(plaintext));
  } catch (IOException | IllegalArgumentException | NullPointerException e) {
    throw new InvalidMessageException(e);
  }
}
 
开发者ID:SilenceIM,项目名称:Silence,代码行数:21,代码来源:SmsCipher.java


示例5: getSenderKey

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的package包/类
private SenderMessageKey getSenderKey(SenderKeyState senderKeyState, int iteration)
    throws DuplicateMessageException, InvalidMessageException
{
  SenderChainKey senderChainKey = senderKeyState.getSenderChainKey();

  if (senderChainKey.getIteration() > iteration) {
    if (senderKeyState.hasSenderMessageKey(iteration)) {
      return senderKeyState.removeSenderMessageKey(iteration);
    } else {
      throw new DuplicateMessageException("Received message with old counter: " +
                                          senderChainKey.getIteration() + " , " + iteration);
    }
  }

  if (iteration - senderChainKey.getIteration() > 2000) {
    throw new InvalidMessageException("Over 2000 messages into the future!");
  }

  while (senderChainKey.getIteration() < iteration) {
    senderKeyState.addSenderMessageKey(senderChainKey.getSenderMessageKey());
    senderChainKey = senderChainKey.getNext();
  }

  senderKeyState.setSenderChainKey(senderChainKey.getNext());
  return senderChainKey.getSenderMessageKey();
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:27,代码来源:GroupCipher.java


示例6: testNoSession

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的package包/类
public void testNoSession() throws InvalidMessageException, LegacyMessageException, NoSessionException, DuplicateMessageException {
    InMemorySenderKeyStore aliceStore = new InMemorySenderKeyStore();
    InMemorySenderKeyStore bobStore   = new InMemorySenderKeyStore();

    GroupSessionBuilder aliceSessionBuilder = new GroupSessionBuilder(aliceStore);
    GroupSessionBuilder bobSessionBuilder   = new GroupSessionBuilder(bobStore);

    GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, GROUP_SENDER);
    GroupCipher bobGroupCipher   = new GroupCipher(bobStore, GROUP_SENDER);

    SenderKeyDistributionMessage sentAliceDistributionMessage     = aliceSessionBuilder.create(GROUP_SENDER);
    SenderKeyDistributionMessage receivedAliceDistributionMessage = new SenderKeyDistributionMessage(sentAliceDistributionMessage.serialize());

//    bobSessionBuilder.process(GROUP_SENDER, receivedAliceDistributionMessage);

    byte[] ciphertextFromAlice = aliceGroupCipher.encrypt("smert ze smert".getBytes());
    try {
      byte[] plaintextFromAlice  = bobGroupCipher.decrypt(ciphertextFromAlice);
      throw new AssertionError("Should be no session!");
    } catch (NoSessionException e) {
      // good
    }
  }
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:24,代码来源:GroupCipherTest.java


示例7: testBasicEncryptDecrypt

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的package包/类
public void testBasicEncryptDecrypt()
    throws LegacyMessageException, DuplicateMessageException, InvalidMessageException, NoSessionException
{
  InMemorySenderKeyStore aliceStore = new InMemorySenderKeyStore();
  InMemorySenderKeyStore bobStore   = new InMemorySenderKeyStore();

  GroupSessionBuilder aliceSessionBuilder = new GroupSessionBuilder(aliceStore);
  GroupSessionBuilder bobSessionBuilder   = new GroupSessionBuilder(bobStore);

  GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, GROUP_SENDER);
  GroupCipher bobGroupCipher   = new GroupCipher(bobStore, GROUP_SENDER);

  SenderKeyDistributionMessage sentAliceDistributionMessage     = aliceSessionBuilder.create(GROUP_SENDER);
  SenderKeyDistributionMessage receivedAliceDistributionMessage = new SenderKeyDistributionMessage(sentAliceDistributionMessage.serialize());
  bobSessionBuilder.process(GROUP_SENDER, receivedAliceDistributionMessage);

  byte[] ciphertextFromAlice = aliceGroupCipher.encrypt("smert ze smert".getBytes());
  byte[] plaintextFromAlice  = bobGroupCipher.decrypt(ciphertextFromAlice);

  assertTrue(new String(plaintextFromAlice).equals("smert ze smert"));
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:22,代码来源:GroupCipherTest.java


示例8: testLargeMessages

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的package包/类
public void testLargeMessages() throws InvalidMessageException, LegacyMessageException, NoSessionException, DuplicateMessageException {
  InMemorySenderKeyStore aliceStore = new InMemorySenderKeyStore();
  InMemorySenderKeyStore bobStore   = new InMemorySenderKeyStore();

  GroupSessionBuilder aliceSessionBuilder = new GroupSessionBuilder(aliceStore);
  GroupSessionBuilder bobSessionBuilder   = new GroupSessionBuilder(bobStore);

  GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, GROUP_SENDER);
  GroupCipher bobGroupCipher   = new GroupCipher(bobStore, GROUP_SENDER);

  SenderKeyDistributionMessage sentAliceDistributionMessage     = aliceSessionBuilder.create(GROUP_SENDER);
  SenderKeyDistributionMessage receivedAliceDistributionMessage = new SenderKeyDistributionMessage(sentAliceDistributionMessage.serialize());
  bobSessionBuilder.process(GROUP_SENDER, receivedAliceDistributionMessage);

  byte[] plaintext = new byte[1024 * 1024];
  new Random().nextBytes(plaintext);

  byte[] ciphertextFromAlice = aliceGroupCipher.encrypt(plaintext);
  byte[] plaintextFromAlice  = bobGroupCipher.decrypt(ciphertextFromAlice);

  assertTrue(Arrays.equals(plaintext, plaintextFromAlice));
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:23,代码来源:GroupCipherTest.java


示例9: decryptIncomingSignalServiceEnvelope

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的package包/类
private IncomingMessage decryptIncomingSignalServiceEnvelope(final SignalServiceEnvelope envelope) throws InvalidVersionException, InvalidMessageException, InvalidKeyException, DuplicateMessageException, InvalidKeyIdException, org.whispersystems.libsignal.UntrustedIdentityException, LegacyMessageException, NoSessionException {
       // ToDo -- When do we need to create new keys?
/*       if (envelope.getType() == SignalServiceProtos.Envelope.Type.PREKEY_BUNDLE_VALUE) {
           // New keys need to be registered with the server.
           registerWithServer();
           return;
       }*/
       return handleIncomingSofaMessage(envelope);
   }
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:10,代码来源:SofaMessageReceiver.java


示例10: handleSecureMessage

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的package包/类
private void handleSecureMessage(MasterSecret masterSecret, long messageId, long threadId,
                                 IncomingTextMessage message)
    throws NoSessionException, DuplicateMessageException,
    InvalidMessageException, LegacyMessageException
{
  EncryptingSmsDatabase database  = DatabaseFactory.getEncryptingSmsDatabase(context);
  SmsCipher             cipher    = new SmsCipher(new SilenceSignalProtocolStore(context, masterSecret));
  IncomingTextMessage   plaintext = cipher.decrypt(context, message);

  database.updateMessageBody(masterSecret, messageId, plaintext.getMessageBody());

  if (message.isEndSession()) SecurityEvent.broadcastSecurityUpdateEvent(context, threadId);
}
 
开发者ID:SilenceIM,项目名称:Silence,代码行数:14,代码来源:SmsDecryptJob.java


示例11: handleXmppExchangeMessage

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的package包/类
private void handleXmppExchangeMessage(MasterSecret masterSecret, long messageId, long threadId,
                                       IncomingXmppExchangeMessage message)
   throws NoSessionException, DuplicateMessageException, InvalidMessageException, LegacyMessageException
{
  EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
  database.markAsXmppExchange(messageId);
}
 
开发者ID:SilenceIM,项目名称:Silence,代码行数:8,代码来源:SmsDecryptJob.java


示例12: processReceiving

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的package包/类
@Nullable
public byte[] processReceiving(AxolotlKey encryptedKey) throws CryptoFailedException {
	byte[] plaintext;
	FingerprintStatus status = getTrust();
	if (!status.isCompromised()) {
		try {
			if (encryptedKey.prekey) {
				PreKeySignalMessage preKeySignalMessage = new PreKeySignalMessage(encryptedKey.key);
				Optional<Integer> optionalPreKeyId = preKeySignalMessage.getPreKeyId();
				IdentityKey identityKey = preKeySignalMessage.getIdentityKey();
				if (!optionalPreKeyId.isPresent()) {
					throw new CryptoFailedException("PreKeyWhisperMessage did not contain a PreKeyId");
				}
				preKeyId = optionalPreKeyId.get();
				if (this.identityKey != null && !this.identityKey.equals(identityKey)) {
					throw new CryptoFailedException("Received PreKeyWhisperMessage but preexisting identity key changed.");
				}
				this.identityKey = identityKey;
				plaintext = cipher.decrypt(preKeySignalMessage);
			} else {
				SignalMessage signalMessage = new SignalMessage(encryptedKey.key);
				plaintext = cipher.decrypt(signalMessage);
				preKeyId = null; //better safe than sorry because we use that to do special after prekey handling
			}
		} catch (InvalidVersionException | InvalidKeyException | LegacyMessageException | InvalidMessageException | DuplicateMessageException | NoSessionException | InvalidKeyIdException | UntrustedIdentityException e) {
			if (!(e instanceof DuplicateMessageException)) {
				e.printStackTrace();
			}
			throw new CryptoFailedException("Error decrypting WhisperMessage " + e.getClass().getSimpleName() + ": " + e.getMessage());
		}
		if (!status.isActive()) {
			setTrust(status.toActive());
		}
	} else {
		throw new CryptoFailedException("not encrypting omemo message from fingerprint "+getFingerprint()+" because it was marked as compromised");
	}
	return plaintext;
}
 
开发者ID:siacs,项目名称:Conversations,代码行数:39,代码来源:XmppAxolotlSession.java


示例13: decrypt

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的package包/类
/**
 * Decrypt a SenderKey group message.
 *
 * @param senderKeyMessageBytes The received ciphertext.
 * @param callback   A callback that is triggered after decryption is complete,
 *                    but before the updated session state has been committed to the session
 *                    DB.  This allows some implementations to store the committed plaintext
 *                    to a DB first, in case they are concerned with a crash happening between
 *                    the time the session state is updated but before they're able to store
 *                    the plaintext to disk.
 * @return Plaintext
 * @throws LegacyMessageException
 * @throws InvalidMessageException
 * @throws DuplicateMessageException
 */
public byte[] decrypt(byte[] senderKeyMessageBytes, DecryptionCallback callback)
    throws LegacyMessageException, InvalidMessageException, DuplicateMessageException,
           NoSessionException
{
  synchronized (LOCK) {
    try {
      SenderKeyRecord record = senderKeyStore.loadSenderKey(senderKeyId);

      if (record.isEmpty()) {
        throw new NoSessionException("No sender key for: " + senderKeyId);
      }

      SenderKeyMessage senderKeyMessage = new SenderKeyMessage(senderKeyMessageBytes);
      SenderKeyState   senderKeyState   = record.getSenderKeyState(senderKeyMessage.getKeyId());

      senderKeyMessage.verifySignature(senderKeyState.getSigningKeyPublic());

      SenderMessageKey senderKey = getSenderKey(senderKeyState, senderKeyMessage.getIteration());

      byte[] plaintext = getPlainText(senderKey.getIv(), senderKey.getCipherKey(), senderKeyMessage.getCipherText());

      callback.handlePlaintext(plaintext);

      senderKeyStore.storeSenderKey(senderKeyId, record);

      return plaintext;
    } catch (org.whispersystems.libsignal.InvalidKeyException | InvalidKeyIdException e) {
      throw new InvalidMessageException(e);
    }
  }
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:47,代码来源:GroupCipher.java


示例14: testOutOfOrder

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的package包/类
public void testOutOfOrder()
    throws LegacyMessageException, DuplicateMessageException, InvalidMessageException, NoSessionException
{
  InMemorySenderKeyStore aliceStore = new InMemorySenderKeyStore();
  InMemorySenderKeyStore bobStore   = new InMemorySenderKeyStore();

  GroupSessionBuilder aliceSessionBuilder = new GroupSessionBuilder(aliceStore);
  GroupSessionBuilder bobSessionBuilder   = new GroupSessionBuilder(bobStore);

  SenderKeyName aliceName = GROUP_SENDER;

  GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, aliceName);
  GroupCipher bobGroupCipher   = new GroupCipher(bobStore, aliceName);

  SenderKeyDistributionMessage aliceDistributionMessage =
      aliceSessionBuilder.create(aliceName);

  bobSessionBuilder.process(aliceName, aliceDistributionMessage);

  ArrayList<byte[]> ciphertexts = new ArrayList<>(100);

  for (int i=0;i<100;i++) {
    ciphertexts.add(aliceGroupCipher.encrypt("up the punks".getBytes()));
  }

  while (ciphertexts.size() > 0) {
    int    index      = randomInt() % ciphertexts.size();
    byte[] ciphertext = ciphertexts.remove(index);
    byte[] plaintext  = bobGroupCipher.decrypt(ciphertext);

    assertTrue(new String(plaintext).equals("up the punks"));
  }
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:34,代码来源:GroupCipherTest.java


示例15: testTooFarInFuture

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的package包/类
public void testTooFarInFuture() throws DuplicateMessageException, InvalidMessageException, LegacyMessageException, NoSessionException {
  InMemorySenderKeyStore aliceStore = new InMemorySenderKeyStore();
  InMemorySenderKeyStore bobStore   = new InMemorySenderKeyStore();

  GroupSessionBuilder aliceSessionBuilder = new GroupSessionBuilder(aliceStore);
  GroupSessionBuilder bobSessionBuilder   = new GroupSessionBuilder(bobStore);

  SenderKeyName aliceName = GROUP_SENDER;

  GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, aliceName);
  GroupCipher bobGroupCipher   = new GroupCipher(bobStore, aliceName);

  SenderKeyDistributionMessage aliceDistributionMessage = aliceSessionBuilder.create(aliceName);

  bobSessionBuilder.process(aliceName, aliceDistributionMessage);

  for (int i=0;i<2001;i++) {
    aliceGroupCipher.encrypt("up the punks".getBytes());
  }

  byte[] tooFarCiphertext = aliceGroupCipher.encrypt("notta gonna worka".getBytes());
  try {
    bobGroupCipher.decrypt(tooFarCiphertext);
    throw new AssertionError("Should have failed!");
  } catch (InvalidMessageException e) {
    // good
  }
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:29,代码来源:GroupCipherTest.java


示例16: testMessageKeyLimit

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的package包/类
public void testMessageKeyLimit() throws Exception {
  InMemorySenderKeyStore aliceStore = new InMemorySenderKeyStore();
  InMemorySenderKeyStore bobStore   = new InMemorySenderKeyStore();

  GroupSessionBuilder aliceSessionBuilder = new GroupSessionBuilder(aliceStore);
  GroupSessionBuilder bobSessionBuilder   = new GroupSessionBuilder(bobStore);

  SenderKeyName aliceName = GROUP_SENDER;

  GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, aliceName);
  GroupCipher bobGroupCipher   = new GroupCipher(bobStore, aliceName);

  SenderKeyDistributionMessage aliceDistributionMessage = aliceSessionBuilder.create(aliceName);

  bobSessionBuilder.process(aliceName, aliceDistributionMessage);

  List<byte[]> inflight = new LinkedList<>();

  for (int i=0;i<2010;i++) {
    inflight.add(aliceGroupCipher.encrypt("up the punks".getBytes()));
  }

  bobGroupCipher.decrypt(inflight.get(1000));
  bobGroupCipher.decrypt(inflight.get(inflight.size()-1));

  try {
    bobGroupCipher.decrypt(inflight.get(0));
    throw new AssertionError("Should have failed!");
  } catch (DuplicateMessageException e) {
    // good
  }
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:33,代码来源:GroupCipherTest.java


示例17: storeRetrievedMms

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的package包/类
private void storeRetrievedMms(MasterSecret masterSecret, String contentLocation,
                               long messageId, long threadId, RetrieveConf retrieved,
                               int subscriptionId)
    throws MmsException, NoSessionException, DuplicateMessageException, InvalidMessageException,
           LegacyMessageException
{
  MmsDatabase           database    = DatabaseFactory.getMmsDatabase(context);
  SingleUseBlobProvider provider    = SingleUseBlobProvider.getInstance();
  String                from        = null;
  List<String>          to          = new LinkedList<>();
  List<String>          cc          = new LinkedList<>();
  String                body        = null;
  List<Attachment>      attachments = new LinkedList<>();

  if (retrieved.getFrom() != null) {
    from = Util.toIsoString(retrieved.getFrom().getTextString());
  }

  if (retrieved.getTo() != null) {
    for (EncodedStringValue toValue : retrieved.getTo()) {
      to.add(Util.toIsoString(toValue.getTextString()));
    }
  }

  if (retrieved.getCc() != null) {
    for (EncodedStringValue ccValue : retrieved.getCc()) {
      cc.add(Util.toIsoString(ccValue.getTextString()));
    }
  }

  if (retrieved.getBody() != null) {
    body = PartParser.getMessageText(retrieved.getBody());
    PduBody media = PartParser.getSupportedMediaParts(retrieved.getBody());

    for (int i=0;i<media.getPartsNum();i++) {
      PduPart part = media.getPart(i);

      if (part.getData() != null) {
        Uri uri = provider.createUri(part.getData());
        attachments.add(new UriAttachment(uri, Util.toIsoString(part.getContentType()),
                                          AttachmentDatabase.TRANSFER_PROGRESS_DONE,
                                          part.getData().length));
      }
    }
  }



  IncomingMediaMessage   message      = new IncomingMediaMessage(from, to, cc, body, retrieved.getDate() * 1000L, attachments, subscriptionId, 0, false);
  Optional<InsertResult> insertResult = database.insertMessageInbox(new MasterSecretUnion(masterSecret),
                                                                    message, contentLocation, threadId);

  if (insertResult.isPresent()) {
    database.delete(messageId);
    MessageNotifier.updateNotification(context, masterSecret, insertResult.get().getThreadId());
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:58,代码来源:MmsDownloadJob.java


示例18: storeRetrievedMms

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的package包/类
private void storeRetrievedMms(MasterSecret masterSecret, String contentLocation,
                               long messageId, long threadId, RetrieveConf retrieved,
                               int subscriptionId)
    throws MmsException, NoSessionException, DuplicateMessageException, InvalidMessageException,
           LegacyMessageException
{
  MmsDatabase           database    = DatabaseFactory.getMmsDatabase(context);
  SingleUseBlobProvider provider    = SingleUseBlobProvider.getInstance();
  String                from        = null;
  List<String>          to          = new LinkedList<>();
  List<String>          cc          = new LinkedList<>();
  String                body        = null;
  List<Attachment>      attachments = new LinkedList<>();

  if (retrieved.getFrom() != null) {
    from = Util.toIsoString(retrieved.getFrom().getTextString());
  }

  if (retrieved.getTo() != null) {
    for (EncodedStringValue toValue : retrieved.getTo()) {
      to.add(Util.toIsoString(toValue.getTextString()));
    }
  }

  if (retrieved.getCc() != null) {
    for (EncodedStringValue ccValue : retrieved.getCc()) {
      cc.add(Util.toIsoString(ccValue.getTextString()));
    }
  }

  if (retrieved.getBody() != null) {
    body = PartParser.getMessageText(retrieved.getBody());
    PduBody media = PartParser.getSupportedMediaParts(retrieved.getBody());

    for (int i=0;i<media.getPartsNum();i++) {
      PduPart part = media.getPart(i);

      if (part.getData() != null) {
        Uri    uri  = provider.createUri(part.getData());
        String name = null;

        if (part.getName() != null) name = Util.toIsoString(part.getName());

        attachments.add(new UriAttachment(uri, Util.toIsoString(part.getContentType()),
                                          AttachmentDatabase.TRANSFER_PROGRESS_DONE,
                                          part.getData().length, name, false));
      }
    }
  }



  IncomingMediaMessage   message      = new IncomingMediaMessage(from, to, cc, body, retrieved.getDate() * 1000L, attachments, subscriptionId, 0, false);
  Optional<InsertResult> insertResult = database.insertMessageInbox(new MasterSecretUnion(masterSecret),
                                                                    message, contentLocation, threadId);

  if (insertResult.isPresent()) {
    database.delete(messageId);
    MessageNotifier.updateNotification(context, masterSecret, insertResult.get().getThreadId());
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:62,代码来源:MmsDownloadJob.java


示例19: storeRetrievedMms

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的package包/类
private void storeRetrievedMms(MasterSecret masterSecret, String contentLocation,
                               long messageId, long threadId, RetrieveConf retrieved,
                               boolean isSecure, int subscriptionId)
    throws MmsException, NoSessionException, DuplicateMessageException, InvalidMessageException,
           LegacyMessageException
{
  MmsDatabase           database    = DatabaseFactory.getMmsDatabase(context);
  SingleUseBlobProvider provider    = SingleUseBlobProvider.getInstance();
  String                from        = null;
  List<String>          to          = new LinkedList<>();
  List<String>          cc          = new LinkedList<>();
  String                body        = null;
  List<Attachment>      attachments = new LinkedList<>();

  if (retrieved.getFrom() != null) {
    from = Util.toIsoString(retrieved.getFrom().getTextString());
  }

  if (retrieved.getTo() != null) {
    for (EncodedStringValue toValue : retrieved.getTo()) {
      to.add(Util.toIsoString(toValue.getTextString()));
    }
  }

  if (retrieved.getCc() != null) {
    for (EncodedStringValue ccValue : retrieved.getCc()) {
      cc.add(Util.toIsoString(ccValue.getTextString()));
    }
  }

  if (retrieved.getBody() != null) {
    body = PartParser.getMessageText(retrieved.getBody());
    PduBody media = PartParser.getSupportedMediaParts(retrieved.getBody());

    for (int i=0;i<media.getPartsNum();i++) {
      PduPart part = media.getPart(i);

      if (part.getData() != null) {
        Uri uri = provider.createUri(part.getData());
        attachments.add(new UriAttachment(uri, Util.toIsoString(part.getContentType()),
                                          AttachmentDatabase.TRANSFER_PROGRESS_DONE,
                                          part.getData().length));
      }
    }
  }

  IncomingMediaMessage message = new IncomingMediaMessage(from, to, cc, body, retrieved.getDate() * 1000L, attachments, subscriptionId);

  Pair<Long, Long> messageAndThreadId;

  if (isSecure) {
    messageAndThreadId = database.insertSecureDecryptedMessageInbox(masterSecret, message,
                                                                    threadId);
  } else {
    messageAndThreadId = database.insertMessageInbox(masterSecret, message,
                                                     contentLocation, threadId);
  }

  database.delete(messageId);
  MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
}
 
开发者ID:SilenceIM,项目名称:Silence,代码行数:62,代码来源:MmsDownloadJob.java


示例20: testBasicRatchet

import org.whispersystems.libsignal.DuplicateMessageException; //导入依赖的package包/类
public void testBasicRatchet()
    throws LegacyMessageException, DuplicateMessageException, InvalidMessageException, NoSessionException
{
  InMemorySenderKeyStore aliceStore = new InMemorySenderKeyStore();
  InMemorySenderKeyStore bobStore   = new InMemorySenderKeyStore();

  GroupSessionBuilder aliceSessionBuilder = new GroupSessionBuilder(aliceStore);
  GroupSessionBuilder bobSessionBuilder   = new GroupSessionBuilder(bobStore);

  SenderKeyName aliceName = GROUP_SENDER;

  GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, aliceName);
  GroupCipher bobGroupCipher   = new GroupCipher(bobStore, aliceName);

  SenderKeyDistributionMessage sentAliceDistributionMessage =
      aliceSessionBuilder.create(aliceName);
  SenderKeyDistributionMessage receivedAliceDistributionMessage =
      new SenderKeyDistributionMessage(sentAliceDistributionMessage.serialize());

  bobSessionBuilder.process(aliceName, receivedAliceDistributionMessage);

  byte[] ciphertextFromAlice  = aliceGroupCipher.encrypt("smert ze smert".getBytes());
  byte[] ciphertextFromAlice2 = aliceGroupCipher.encrypt("smert ze smert2".getBytes());
  byte[] ciphertextFromAlice3 = aliceGroupCipher.encrypt("smert ze smert3".getBytes());

  byte[] plaintextFromAlice   = bobGroupCipher.decrypt(ciphertextFromAlice);

  try {
    bobGroupCipher.decrypt(ciphertextFromAlice);
    throw new AssertionError("Should have ratcheted forward!");
  } catch (DuplicateMessageException dme) {
    // good
  }

  byte[] plaintextFromAlice2  = bobGroupCipher.decrypt(ciphertextFromAlice2);
  byte[] plaintextFromAlice3  = bobGroupCipher.decrypt(ciphertextFromAlice3);

  assertTrue(new String(plaintextFromAlice).equals("smert ze smert"));
  assertTrue(new String(plaintextFromAlice2).equals("smert ze smert2"));
  assertTrue(new String(plaintextFromAlice3).equals("smert ze smert3"));
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:42,代码来源:GroupCipherTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TextViewTextChangeEvent类代码示例发布时间:2022-05-22
下一篇:
Java ErrorCollection类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap