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

Java InvalidVersionException类代码示例

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

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



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

示例1: decrypt

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

import org.whispersystems.libsignal.InvalidVersionException; //导入依赖的package包/类
/**
 * A blocking call that reads a message off the pipe (see {@link #read(long, java.util.concurrent.TimeUnit)}
 *
 * Unlike {@link #read(long, java.util.concurrent.TimeUnit)}, this method allows you
 * to specify a callback that will be called before the received message is acknowledged.
 * This allows you to write the received message to durable storage before acknowledging
 * receipt of it to the server.
 *
 * @param timeout The timeout to wait for.
 * @param unit The timeout time unit.
 * @param callback A callback that will be called before the message receipt is
 *                 acknowledged to the server.
 * @return The message read (same as the message sent through the callback).
 * @throws TimeoutException
 * @throws IOException
 * @throws InvalidVersionException
 */
public SignalServiceEnvelope read(long timeout, TimeUnit unit, MessagePipeCallback callback)
    throws TimeoutException, IOException, InvalidVersionException
{
  while (true) {
    WebSocketRequestMessage  request  = websocket.readRequest(unit.toMillis(timeout));
    WebSocketResponseMessage response = createWebSocketResponse(request);

    try {
      if (isSignalServiceEnvelope(request)) {
        SignalServiceEnvelope envelope = new SignalServiceEnvelope(request.getBody().toByteArray(),
                                                                   credentialsProvider.getSignalingKey());

        callback.onMessage(envelope);
        return envelope;
      }
    } finally {
      websocket.sendResponse(response);
    }
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-lib,代码行数:38,代码来源:SignalServiceMessagePipe.java


示例3: tryFetchLatestMessage

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


示例4: handleIncomingSofaMessage

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


示例5: decrypt

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

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


示例6: process

import org.whispersystems.libsignal.InvalidVersionException; //导入依赖的package包/类
public OutgoingKeyExchangeMessage process(Context context, IncomingKeyExchangeMessage message)
    throws UntrustedIdentityException, StaleKeyExchangeException,
           InvalidVersionException, LegacyMessageException, InvalidMessageException
{
  try {
    Recipients            recipients            = RecipientFactory.getRecipientsFromString(context, message.getSender(), false);
    SignalProtocolAddress signalProtocolAddress = new SignalProtocolAddress(message.getSender(), 1);
    KeyExchangeMessage    exchangeMessage       = new KeyExchangeMessage(transportDetails.getDecodedMessage(message.getMessageBody().getBytes()));
    SessionBuilder        sessionBuilder        = new SessionBuilder(signalProtocolStore, signalProtocolAddress);

    KeyExchangeMessage response        = sessionBuilder.process(exchangeMessage);

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


示例7: ReceiveKeyDialog

import org.whispersystems.libsignal.InvalidVersionException; //导入依赖的package包/类
public ReceiveKeyDialog(@NonNull Context context,
                        @NonNull MasterSecret masterSecret,
                        @NonNull MessageRecord messageRecord)
{
  super(context);

  try{
    final IncomingKeyExchangeMessage message = getMessage(messageRecord);
    final IdentityKey identityKey = getIdentityKey(message);

    if (isTrusted(masterSecret, identityKey, messageRecord.getIndividualRecipient())){
      setMessage(context.getString(R.string.ReceiveKeyActivity_the_signature_on_this_key_exchange_is_trusted_but));
    } else {
      setUntrustedText(messageRecord, identityKey);
    }

    setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.receive_key_activity__complete), new AcceptListener(masterSecret, messageRecord, message, identityKey));
    setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(android.R.string.cancel), new CancelListener());

  } catch (InvalidKeyException | InvalidVersionException | InvalidMessageException | LegacyMessageException e) {
    throw new AssertionError(e);
  }

}
 
开发者ID:SilenceIM,项目名称:Silence,代码行数:25,代码来源:ReceiveKeyDialog.java


示例8: getMessage

import org.whispersystems.libsignal.InvalidVersionException; //导入依赖的package包/类
private static IncomingKeyExchangeMessage getMessage(MessageRecord messageRecord)
    throws InvalidKeyException, InvalidVersionException,
           InvalidMessageException, LegacyMessageException
{
  IncomingTextMessage message = new IncomingTextMessage(messageRecord.getIndividualRecipient().getNumber(),
                                                        messageRecord.getRecipientDeviceId(),
                                                        System.currentTimeMillis(),
                                                        messageRecord.getBody().getBody());

  if (messageRecord.isBundleKeyExchange()) {
    return new IncomingPreKeyBundleMessage(message, message.getMessageBody());
  } else if (messageRecord.isIdentityUpdate()) {
    return new IncomingIdentityUpdateMessage(message, message.getMessageBody());
  } else {
    return new IncomingKeyExchangeMessage(message, message.getMessageBody());
  }
}
 
开发者ID:SilenceIM,项目名称:Silence,代码行数:18,代码来源:ReceiveKeyDialog.java


示例9: getIdentityKey

import org.whispersystems.libsignal.InvalidVersionException; //导入依赖的package包/类
private static 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()) {
      return new PreKeySignalMessage(Base64.decodeWithoutPadding(message.getMessageBody())).getIdentityKey();
    } else {
      return new KeyExchangeMessage(Base64.decodeWithoutPadding(message.getMessageBody())).getIdentityKey();
    }
  } catch (IOException e) {
    throw new AssertionError(e);
  }
}
 
开发者ID:SilenceIM,项目名称:Silence,代码行数:17,代码来源:ReceiveKeyDialog.java


示例10: handleUntrustedIdentityMessage

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


示例11: onRun

import org.whispersystems.libsignal.InvalidVersionException; //导入依赖的package包/类
@Override
public void onRun() {
  try {
    String                sessionKey = TextSecurePreferences.getSignalingKey(context);
    SignalServiceEnvelope envelope   = new SignalServiceEnvelope(data, sessionKey);

    handle(envelope, true);
  } catch (IOException | InvalidVersionException e) {
    Log.w(TAG, e);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:12,代码来源:PushContentReceiveJob.java


示例12: SignalServiceEnvelope

import org.whispersystems.libsignal.InvalidVersionException; //导入依赖的package包/类
/**
 * Construct an envelope from a serialized SignalServiceEnvelope, encrypted with a signaling key.
 *
 * @param ciphertext The serialized and encrypted SignalServiceEnvelope.
 * @param signalingKey The signaling key.
 * @throws InvalidVersionException
 * @throws IOException
 */
public SignalServiceEnvelope(byte[] ciphertext, String signalingKey)
    throws InvalidVersionException, IOException
{
  if (ciphertext.length < VERSION_LENGTH || ciphertext[VERSION_OFFSET] != SUPPORTED_VERSION)
    throw new InvalidVersionException("Unsupported version!");

  SecretKeySpec cipherKey  = getCipherKey(signalingKey);
  SecretKeySpec macKey     = getMacKey(signalingKey);

  verifyMac(ciphertext, macKey);

  this.envelope = Envelope.parseFrom(getPlaintext(ciphertext, cipherKey));
}
 
开发者ID:XecureIT,项目名称:PeSanKita-lib,代码行数:22,代码来源:SignalServiceEnvelope.java


示例13: decryptIncomingSignalServiceEnvelope

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


示例14: KeyExchangeMessage

import org.whispersystems.libsignal.InvalidVersionException; //导入依赖的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.CURRENT_VERSION) {
      throw new LegacyMessageException("Unsupported legacy version: " + this.version);
    }

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

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

    if (!message.hasId()           || !message.hasBaseKey()     ||
        !message.hasRatchetKey()   || !message.hasIdentityKey() ||
        !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:SilenceIM,项目名称:Silence,代码行数:37,代码来源:KeyExchangeMessage.java


示例15: processReceiving

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


示例16: PreKeySignalMessage

import org.whispersystems.libsignal.InvalidVersionException; //导入依赖的package包/类
public PreKeySignalMessage(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);
    }

    if (this.version < CiphertextMessage.CURRENT_VERSION) {
      throw new LegacyMessageException("Legacy version: " + this.version);
    }

    SignalProtos.PreKeySignalMessage preKeyWhisperMessage
        = SignalProtos.PreKeySignalMessage.parseFrom(ByteString.copyFrom(serialized, 1,
                                                                         serialized.length-1));

    if (!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 SignalMessage(preKeyWhisperMessage.getMessage().toByteArray());
  } catch (InvalidProtocolBufferException | InvalidKeyException | LegacyMessageException e) {
    throw new InvalidMessageException(e);
  }
}
 
开发者ID:signalapp,项目名称:libsignal-protocol-java,代码行数:38,代码来源:PreKeySignalMessage.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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