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


Java LegacyMessageException类代码示例

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


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

示例1: initializeKey

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

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

示例4: process

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

示例5: retrieveAndStore

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

示例6: decrypt

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

示例7: decrypt

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

示例8: storeRetrievedMms

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

示例9: decrypt

import org.whispersystems.libaxolotl.LegacyMessageException; //导入依赖的package包/类
public byte[] decrypt(byte[] senderKeyMessageBytes)
    throws LegacyMessageException, InvalidMessageException, DuplicateMessageException
{
  synchronized (LOCK) {
    try {
      SenderKeyRecord  record           = senderKeyStore.loadSenderKey(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());

      senderKeyStore.storeSenderKey(senderKeyId, record);

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

示例10: retrieveAndStore

import org.whispersystems.libaxolotl.LegacyMessageException; //导入依赖的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()));
  IncomingMmsConnection connection = new IncomingMmsConnection(context, contentApn);
  RetrieveConf          retrieved  = connection.retrieve(radioEnabled, useProxy);

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

示例11: onCreate

import org.whispersystems.libaxolotl.LegacyMessageException; //导入依赖的package包/类
@Override
protected void onCreate(Bundle state) {
  super.onCreate(state);
  setContentView(R.layout.receive_key_activity);

  initializeResources();

  try {
    initializeKey();
    initializeText();
  } catch (InvalidKeyException | InvalidVersionException | InvalidMessageException | LegacyMessageException ike) {
    Log.w("ReceiveKeyActivity", ike);
  }
  initializeListeners();
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:16,代码来源:ReceiveKeyActivity.java

示例12: storeRetrievedMms

import org.whispersystems.libaxolotl.LegacyMessageException; //导入依赖的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())) {
      MmsCipher            mmsCipher          = new MmsCipher(new TextSecureAxolotlStore(context, masterSecret));
      MultimediaMessagePdu plaintextPdu       = mmsCipher.decrypt(context, retrieved);
      RetrieveConf         plaintextRetrieved = new RetrieveConf(plaintextPdu.getPduHeaders(), plaintextPdu.getBody());
      IncomingMediaMessage plaintextMessage   = new IncomingMediaMessage(plaintextRetrieved);

      messageAndThreadId = database.insertSecureDecryptedMessageInbox(masterSecret, plaintextMessage,
                                                                      threadId);

//      if (masterSecret != null)
//        DecryptingQueue.scheduleDecryption(context, masterSecret, messageAndThreadId.first,
//                                           messageAndThreadId.second, retrieved);

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

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

示例13: handleSecureMessage

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

  database.updateMessageBody(masterSecret, messageId, plaintext.getMessageBody());
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:11,代码来源:SmsDecryptJob.java

示例14: KeyExchangeMessage

import org.whispersystems.libaxolotl.LegacyMessageException; //导入依赖的package包/类
public KeyExchangeMessage(byte[] serialized)
    throws InvalidMessageException, InvalidVersionException, LegacyMessageException
{
  try {
    byte[][] parts        = ByteUtil.split(serialized, 1, serialized.length - 1);
    this.version          = ByteUtil.highBitsToInt(parts[0][0]);
    this.supportedVersion = ByteUtil.lowBitsToInt(parts[0][0]);

    if (this.version <= CiphertextMessage.UNSUPPORTED_VERSION) {
      throw new LegacyMessageException("Unsupported legacy version: " + this.version);
    }

    if (this.version > CiphertextMessage.CURRENT_VERSION) {
      throw new InvalidVersionException("Unknown version: " + this.version);
    }

    WhisperProtos.KeyExchangeMessage message = WhisperProtos.KeyExchangeMessage.parseFrom(parts[1]);

    if (!message.hasId()           || !message.hasBaseKey()     ||
        !message.hasRatchetKey()   || !message.hasIdentityKey() ||
        (this.version >=3 && !message.hasBaseKeySignature()))
    {
      throw new InvalidMessageException("Some required fields missing!");
    }

    this.sequence         = message.getId() >> 5;
    this.flags            = message.getId() & 0x1f;
    this.serialized       = serialized;
    this.baseKey          = Curve.decodePoint(message.getBaseKey().toByteArray(), 0);
    this.baseKeySignature = message.getBaseKeySignature().toByteArray();
    this.ratchetKey       = Curve.decodePoint(message.getRatchetKey().toByteArray(), 0);
    this.identityKey      = new IdentityKey(message.getIdentityKey().toByteArray(), 0);
  } catch (InvalidKeyException | IOException e) {
    throw new InvalidMessageException(e);
  }
}
 
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:37,代码来源:KeyExchangeMessage.java

示例15: PreKeyWhisperMessage

import org.whispersystems.libaxolotl.LegacyMessageException; //导入依赖的package包/类
public PreKeyWhisperMessage(byte[] serialized)
    throws InvalidMessageException, InvalidVersionException
{
  try {
    this.version = ByteUtil.highBitsToInt(serialized[0]);

    if (this.version > CiphertextMessage.CURRENT_VERSION) {
      throw new InvalidVersionException("Unknown version: " + this.version);
    }

    WhisperProtos.PreKeyWhisperMessage preKeyWhisperMessage
        = WhisperProtos.PreKeyWhisperMessage.parseFrom(ByteString.copyFrom(serialized, 1,
                                                                           serialized.length-1));

    if ((version == 2 && !preKeyWhisperMessage.hasPreKeyId())        ||
        (version == 3 && !preKeyWhisperMessage.hasSignedPreKeyId())  ||
        !preKeyWhisperMessage.hasBaseKey()                           ||
        !preKeyWhisperMessage.hasIdentityKey()                       ||
        !preKeyWhisperMessage.hasMessage())
    {
      throw new InvalidMessageException("Incomplete message.");
    }

    this.serialized     = serialized;
    this.registrationId = preKeyWhisperMessage.getRegistrationId();
    this.preKeyId       = preKeyWhisperMessage.hasPreKeyId() ? Optional.of(preKeyWhisperMessage.getPreKeyId()) : Optional.<Integer>absent();
    this.signedPreKeyId = preKeyWhisperMessage.hasSignedPreKeyId() ? preKeyWhisperMessage.getSignedPreKeyId() : -1;
    this.baseKey        = Curve.decodePoint(preKeyWhisperMessage.getBaseKey().toByteArray(), 0);
    this.identityKey    = new IdentityKey(Curve.decodePoint(preKeyWhisperMessage.getIdentityKey().toByteArray(), 0));
    this.message        = new WhisperMessage(preKeyWhisperMessage.getMessage().toByteArray());
  } catch (InvalidProtocolBufferException | InvalidKeyException | LegacyMessageException e) {
    throw new InvalidMessageException(e);
  }
}
 
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:35,代码来源:PreKeyWhisperMessage.java


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