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

Java InvalidMessageException类代码示例

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

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



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

示例1: initializeKey

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
private void initializeKey()
    throws InvalidKeyException, InvalidVersionException,
           InvalidMessageException, LegacyMessageException
{
  IncomingTextMessage message = new IncomingTextMessage(recipient.getNumber(),
                                                        recipientDeviceId,
                                                        System.currentTimeMillis(),
                                                        getIntent().getStringExtra("body"),
                                                        Optional.<TextSecureGroup>absent());

  if (getIntent().getBooleanExtra("is_bundle", false)) {
    this.message = new IncomingPreKeyBundleMessage(message, message.getMessageBody());
  } else if (getIntent().getBooleanExtra("is_identity_update", false)) {
    this.message = new IncomingIdentityUpdateMessage(message, message.getMessageBody());
  } else {
    this.message = new IncomingKeyExchangeMessage(message, message.getMessageBody());
  }

  this.identityKey = getIdentityKey(this.message);
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:21,代码来源:ReceiveKeyActivity.java


示例2: getIdentityKey

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
private IdentityKey getIdentityKey(IncomingKeyExchangeMessage message)
    throws InvalidKeyException, InvalidVersionException,
           InvalidMessageException, LegacyMessageException
{
  try {
    if (message.isIdentityUpdate()) {
      return new IdentityKey(Base64.decodeWithoutPadding(message.getMessageBody()), 0);
    } else if (message.isPreKeyBundle()) {
      boolean isPush = getIntent().getBooleanExtra("is_push", false);

      if (isPush) return new PreKeyWhisperMessage(Base64.decode(message.getMessageBody())).getIdentityKey();
      else        return new PreKeyWhisperMessage(Base64.decodeWithoutPadding(message.getMessageBody())).getIdentityKey();
    } else {
      return new KeyExchangeMessage(Base64.decodeWithoutPadding(message.getMessageBody())).getIdentityKey();
    }
  } catch (IOException e) {
    throw new AssertionError(e);
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:20,代码来源:ReceiveKeyActivity.java


示例3: getBody

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
private DisplayRecord.Body getBody(Cursor cursor) {
  try {
    String body = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.BODY));
    long box    = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.MESSAGE_BOX));

    if (!TextUtils.isEmpty(body) && masterCipher != null && Types.isSymmetricEncryption(box)) {
      return new DisplayRecord.Body(masterCipher.decryptBody(body), true);
    } else if (!TextUtils.isEmpty(body) && masterCipher == null && Types.isSymmetricEncryption(box)) {
      return new DisplayRecord.Body(body, false);
    } else {
      return new DisplayRecord.Body(body == null ? "" : body, true);
    }
  } catch (InvalidMessageException e) {
    Log.w("MmsDatabase", e);
    return new DisplayRecord.Body("Error decrypting message.", true);
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:18,代码来源:MmsDatabase.java


示例4: getDrafts

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
public List<Draft> getDrafts(MasterCipher masterCipher, long threadId) {
  SQLiteDatabase db   = databaseHelper.getReadableDatabase();
  List<Draft> results = new LinkedList<Draft>();
  Cursor cursor       = null;

  try {
    cursor = db.query(TABLE_NAME, null, THREAD_ID + " = ?", new String[] {threadId+""}, null, null, null);

    while (cursor != null && cursor.moveToNext()) {
      try {
        String encryptedType  = cursor.getString(cursor.getColumnIndexOrThrow(DRAFT_TYPE));
        String encryptedValue = cursor.getString(cursor.getColumnIndexOrThrow(DRAFT_VALUE));

        results.add(new Draft(masterCipher.decryptBody(encryptedType),
                              masterCipher.decryptBody(encryptedValue)));
      } catch (InvalidMessageException ime) {
        Log.w("DraftDatabase", ime);
      }
    }

    return results;
  } finally {
    if (cursor != null)
      cursor.close();
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:27,代码来源:DraftDatabase.java


示例5: getPlaintextBody

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
private DisplayRecord.Body getPlaintextBody(Cursor cursor) {
  try {
    long type   = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.SNIPPET_TYPE));
    String body = cursor.getString(cursor.getColumnIndexOrThrow(SNIPPET));

    if (!TextUtils.isEmpty(body) && masterCipher != null && MmsSmsColumns.Types.isSymmetricEncryption(type)) {
      return new DisplayRecord.Body(masterCipher.decryptBody(body), true);
    } else if (!TextUtils.isEmpty(body) && masterCipher == null && MmsSmsColumns.Types.isSymmetricEncryption(type)) {
      return new DisplayRecord.Body(body, false);
    } else {
      return new DisplayRecord.Body(body, true);
    }
  } catch (InvalidMessageException e) {
    Log.w("ThreadDatabase", e);
    return new DisplayRecord.Body("Error decrypting message.", true);
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:18,代码来源:ThreadDatabase.java


示例6: decrypt

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
public IncomingTextMessage decrypt(Context context, IncomingTextMessage message)
    throws LegacyMessageException, InvalidMessageException,
           DuplicateMessageException, NoSessionException
{
  try {
    Recipients     recipients     = RecipientFactory.getRecipientsFromString(context, message.getSender(), false);
    long           recipientId    = recipients.getPrimaryRecipient().getRecipientId();
    byte[]         decoded        = transportDetails.getDecodedMessage(message.getMessageBody().getBytes());
    WhisperMessage whisperMessage = new WhisperMessage(decoded);
    SessionCipher  sessionCipher  = new SessionCipher(axolotlStore, recipientId, 1);
    byte[]         padded         = sessionCipher.decrypt(whisperMessage);
    byte[]         plaintext      = transportDetails.getStrippedPaddingMessageBody(padded);

    if (message.isEndSession() && "TERMINATE".equals(new String(plaintext))) {
      axolotlStore.deleteSession(recipientId, 1);
    }

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


示例7: process

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
public OutgoingKeyExchangeMessage process(Context context, IncomingKeyExchangeMessage message)
    throws UntrustedIdentityException, StaleKeyExchangeException,
           InvalidVersionException, LegacyMessageException, InvalidMessageException
{
  try {
    Recipient          recipient       = RecipientFactory.getRecipientsFromString(context, message.getSender(), false).getPrimaryRecipient();
    KeyExchangeMessage exchangeMessage = new KeyExchangeMessage(transportDetails.getDecodedMessage(message.getMessageBody().getBytes()));
    SessionBuilder     sessionBuilder  = new SessionBuilder(axolotlStore, recipient.getRecipientId(), 1);

    KeyExchangeMessage response        = sessionBuilder.process(exchangeMessage);

    if (response != null) {
      byte[] serializedResponse = transportDetails.getEncodedMessage(response.serialize());
      return new OutgoingKeyExchangeMessage(recipient, new String(serializedResponse));
    } else {
      return null;
    }
  } catch (RecipientFormattingException | IOException | InvalidKeyException e) {
    throw new InvalidMessageException(e);
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:22,代码来源:SmsCipher.java


示例8: decryptBody

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
public String decryptBody(String body) throws IOException, InvalidMessageException {
  try {
    byte[]    combined       = Base64.decode(body);
    byte[][]  parts          = Util.split(combined, PublicKey.KEY_SIZE, combined.length - PublicKey.KEY_SIZE);
    PublicKey theirPublicKey = new PublicKey(parts[0], 0);

    ECPrivateKey ourPrivateKey = asymmetricMasterSecret.getPrivateKey();
    byte[]       secret        = Curve.calculateAgreement(theirPublicKey.getKey(), ourPrivateKey);
    MasterCipher masterCipher  = getMasterCipherForSecret(secret);
    byte[]       decryptedBody = masterCipher.decryptBytes(parts[1]);

    return new String(decryptedBody);
  } catch (InvalidKeyException | InvalidMessageException ike) {
    throw new InvalidMessageException(ike);
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:17,代码来源:AsymmetricMasterCipher.java


示例9: loadSignedPreKeys

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
@Override
public List<SignedPreKeyRecord> loadSignedPreKeys() {
  synchronized (FILE_LOCK) {
    File                     directory = getSignedPreKeyDirectory();
    List<SignedPreKeyRecord> results   = new LinkedList<>();

    for (File signedPreKeyFile : directory.listFiles()) {
      try {
        results.add(new SignedPreKeyRecord(loadSerializedRecord(signedPreKeyFile)));
      } catch (IOException | InvalidMessageException e) {
        Log.w(TAG, e);
      }
    }

    return results;
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:18,代码来源:TextSecurePreKeyStore.java


示例10: deserialize

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
@Override
public Job deserialize(EncryptionKeys keys, boolean encrypted, String serialized) throws IOException {
  try {
    String plaintext;

    if (encrypted) {
      MasterSecret masterSecret = ParcelUtil.deserialize(keys.getEncoded(), MasterSecret.CREATOR);
      MasterCipher masterCipher = new MasterCipher(masterSecret);
      plaintext = masterCipher.decryptBody(serialized);
    } else {
      plaintext = serialized;
    }

    return delegate.deserialize(keys, encrypted, plaintext);
  } catch (InvalidMessageException e) {
    throw new IOException(e);
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:19,代码来源:EncryptingJobSerializer.java


示例11: retrievePart

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
private void retrievePart(MasterSecret masterSecret, PduPart part, long messageId, long partId)
    throws IOException
{
  PartDatabase database       = DatabaseFactory.getPartDatabase(context);
  File         attachmentFile = null;

  try {
    attachmentFile = createTempFile();

    TextSecureAttachmentPointer pointer    = createAttachmentPointer(masterSecret, part);
    InputStream                 attachment = messageReceiver.retrieveAttachment(pointer, attachmentFile);

    database.updateDownloadedPart(masterSecret, messageId, partId, part, attachment);
  } catch (InvalidPartException | NonSuccessfulResponseCodeException | InvalidMessageException | MmsException e) {
    Log.w(TAG, e);
    markFailed(messageId, part, partId);
  } finally {
    if (attachmentFile != null)
      attachmentFile.delete();
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:22,代码来源:AttachmentDownloadJob.java


示例12: createAttachmentPointer

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
private TextSecureAttachmentPointer createAttachmentPointer(MasterSecret masterSecret, PduPart part)
    throws InvalidPartException
{
  try {
    MasterCipher masterCipher = new MasterCipher(masterSecret);
    long         id           = Long.parseLong(Util.toIsoString(part.getContentLocation()));
    byte[]       key          = masterCipher.decryptBytes(Base64.decode(Util.toIsoString(part.getContentDisposition())));
    String       relay        = null;

    if (part.getName() != null) {
      relay = Util.toIsoString(part.getName());
    }

    return new TextSecureAttachmentPointer(id, null, key, relay);
  } catch (InvalidMessageException | IOException e) {
    Log.w(TAG, e);
    throw new InvalidPartException(e);
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:20,代码来源:AttachmentDownloadJob.java


示例13: retrieveAndStore

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
private void retrieveAndStore(MasterSecret masterSecret, MmsRadio radio,
                              long messageId, long threadId,
                              String contentLocation, byte[] transactionId,
                              boolean radioEnabled, boolean useProxy)
    throws IOException, MmsException, ApnUnavailableException,
           DuplicateMessageException, NoSessionException,
           InvalidMessageException, LegacyMessageException
{
  Apn                   dbApn      = MmsConnection.getApn(context, radio.getApnInformation());
  Apn                   contentApn = new Apn(contentLocation, dbApn.getProxy(), Integer.toString(dbApn.getPort()), dbApn.getUsername(), dbApn.getPassword());
  IncomingMmsConnection connection = new IncomingMmsConnection(context, contentApn);
  RetrieveConf          retrieved  = connection.retrieve(radioEnabled, useProxy);

  storeRetrievedMms(masterSecret, contentLocation, messageId, threadId, retrieved);
  sendRetrievedAcknowledgement(radio, transactionId, radioEnabled, useProxy);
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:17,代码来源:MmsDownloadJob.java


示例14: decrypt

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
public TextSecureMessage decrypt(TextSecureEnvelope envelope)
    throws InvalidVersionException, InvalidMessageException, InvalidKeyException,
           DuplicateMessageException, InvalidKeyIdException, UntrustedIdentityException,
           LegacyMessageException, NoSessionException
{
  try {
    byte[] paddedMessage;

    if (envelope.isPreKeyWhisperMessage()) {
      paddedMessage = sessionCipher.decrypt(new PreKeyWhisperMessage(envelope.getMessage()));
    } else if (envelope.isWhisperMessage()) {
      paddedMessage = sessionCipher.decrypt(new WhisperMessage(envelope.getMessage()));
    } else if (envelope.isPlaintext()) {
      paddedMessage = envelope.getMessage();
    } else {
      throw new InvalidMessageException("Unknown type: " + envelope.getType());
    }

    PushTransportDetails transportDetails = new PushTransportDetails(sessionCipher.getSessionVersion());
    PushMessageContent   content          = PushMessageContent.parseFrom(transportDetails.getStrippedPaddingMessageBody(paddedMessage));

    return createTextSecureMessage(envelope, content);
  } catch (InvalidProtocolBufferException e) {
    throw new InvalidMessageException(e);
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:27,代码来源:TextSecureCipher.java


示例15: getBody

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
private DisplayRecord.Body getBody(Cursor cursor) {
  try {
    String body = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.BODY));
    long box    = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.MESSAGE_BOX));

    if (!TextUtils.isEmpty(body) && masterCipher != null && Types.isSymmetricEncryption(box)) {
      return new DisplayRecord.Body(masterCipher.decryptBody(body), true);
    } else if (!TextUtils.isEmpty(body) && masterCipher == null && Types.isSymmetricEncryption(box)) {
      return new DisplayRecord.Body(body, false);
    } else {
      return new DisplayRecord.Body(body == null ? "" : body, true);
    }
  } catch (InvalidMessageException e) {
    Log.w("MmsDatabase", e);
    return new DisplayRecord.Body(context.getString(R.string.MmsDatabase_error_decrypting_message), true);
  }
}
 
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:18,代码来源:MmsDatabase.java


示例16: getPlaintextBody

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
private DisplayRecord.Body getPlaintextBody(Cursor cursor) {
  try {
    long type   = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.SNIPPET_TYPE));
    String body = cursor.getString(cursor.getColumnIndexOrThrow(SNIPPET));

    if (!TextUtils.isEmpty(body) && masterCipher != null && MmsSmsColumns.Types.isSymmetricEncryption(type)) {
      return new DisplayRecord.Body(masterCipher.decryptBody(body), true);
    } else if (!TextUtils.isEmpty(body) && masterCipher == null && MmsSmsColumns.Types.isSymmetricEncryption(type)) {
      return new DisplayRecord.Body(body, false);
    } else {
      return new DisplayRecord.Body(body, true);
    }
  } catch (InvalidMessageException e) {
    Log.w("ThreadDatabase", e);
    return new DisplayRecord.Body(context.getString(R.string.ThreadDatabase_error_decrypting_message), true);
  }
}
 
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:18,代码来源:ThreadDatabase.java


示例17: decrypt

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
public TextSecureSMPMessage decrypt(TextSecureEnvelope envelope) throws InvalidVersionException,
	InvalidMessageException, InvalidKeyException, DuplicateMessageException, InvalidKeyIdException, UntrustedIdentityException, LegacyMessageException, NoSessionException {
	try {
		AxolotlAddress e = new AxolotlAddress(envelope.getSource(), envelope.getSourceDevice());
		SessionCipher sessionCipher = new SessionCipher(this.axolotlStore, e);
		byte[] paddedMessage;
		if(envelope.isPreKeyWhisperMessage()) {
			paddedMessage = sessionCipher.decrypt(new PreKeyWhisperMessage(envelope.getMessage()));
		} else {
			if(!envelope.isWhisperMessage()) {
				throw new InvalidMessageException("Unknown type: " + envelope.getType());
			}

			paddedMessage = sessionCipher.decrypt(new WhisperMessage(envelope.getMessage()));
		}

		PushTransportDetails transportDetails = new PushTransportDetails(sessionCipher.getSessionVersion());
		PushMessageProtos.PushMessageContent content = PushMessageProtos.PushMessageContent.parseFrom(transportDetails.getStrippedPaddingMessageBody(paddedMessage));
		return this.createTextSecureSMPMessage(envelope, content);
	} catch (InvalidProtocolBufferException var7) {
		throw new InvalidMessageException(var7);
	}
}
 
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:24,代码来源:TextSecureSMPCipher.java


示例18: sendTextMessage

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
private void sendTextMessage(final boolean forceSms)
    throws InvalidMessageException
{
  final Context context = getApplicationContext();
  OutgoingTextMessage message;

  if (isEncryptedConversation && !forceSms) {
    message = new OutgoingEncryptedMessage(recipients, getMessage());
  } else {
    message = new OutgoingTextMessage(recipients, getMessage());
  }

  this.composeText.setText("");

  new AsyncTask<OutgoingTextMessage, Void, Long>() {
    @Override
    protected Long doInBackground(OutgoingTextMessage... messages) {
      return MessageSender.send(context, masterSecret, messages[0], threadId, forceSms);
    }

    @Override
    protected void onPostExecute(Long result) {
      sendComplete(result);
    }
  }.execute(message);
}
 
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:27,代码来源:ConversationActivity.java


示例19: retrievePart

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
private void retrievePart(MasterSecret masterSecret, PduPart part, long messageId)
    throws IOException
{
  PartDatabase        database       = DatabaseFactory.getPartDatabase(context);
  File                attachmentFile = null;
  PartDatabase.PartId partId         = part.getPartId();

  try {
    attachmentFile = createTempFile();

    TextSecureAttachmentPointer pointer    = createAttachmentPointer(masterSecret, part);
    InputStream                 attachment = messageReceiver.retrieveAttachment(pointer, attachmentFile);

    database.updateDownloadedPart(masterSecret, messageId, partId, part, attachment);
  } catch (InvalidPartException | NonSuccessfulResponseCodeException | InvalidMessageException | MmsException e) {
    Log.w(TAG, e);
    markFailed(messageId, part, partId);
  } finally {
    if (attachmentFile != null)
      attachmentFile.delete();
  }
}
 
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:23,代码来源:AttachmentDownloadJob.java


示例20: storeRetrievedMms

import org.whispersystems.libaxolotl.InvalidMessageException; //导入依赖的package包/类
private void storeRetrievedMms(MasterSecret masterSecret, String contentLocation,
                               long messageId, long threadId, RetrieveConf retrieved)
    throws MmsException, NoSessionException, DuplicateMessageException, InvalidMessageException,
           LegacyMessageException
{
  MmsDatabase          database = DatabaseFactory.getMmsDatabase(context);
  IncomingMediaMessage message  = new IncomingMediaMessage(retrieved);

  Pair<Long, Long> messageAndThreadId;

  if (retrieved.getSubject() != null && WirePrefix.isEncryptedMmsSubject(retrieved.getSubject().getString())) {
    database.markAsLegacyVersion(messageId, threadId);
    messageAndThreadId = new Pair<>(messageId, threadId);
  } else {
    messageAndThreadId = database.insertMessageInbox(masterSecret, message,
                                                     contentLocation, threadId);
    database.delete(messageId);
  }

  MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
}
 
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:22,代码来源:MmsDownloadJob.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java SingleThreadedTransExecutor类代码示例发布时间:2022-05-22
下一篇:
Java AttributeStatement类代码示例发布时间: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