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


Java InvalidMessageException类代码示例

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


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


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