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


Java PushTransportDetails类代码示例

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


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

示例1: decrypt

import org.whispersystems.textsecure.internal.push.PushTransportDetails; //导入依赖的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

示例2: encrypt

import org.whispersystems.textsecure.internal.push.PushTransportDetails; //导入依赖的package包/类
public OutgoingPushMessage encrypt(AxolotlAddress destination, byte[] unpaddedMessage) {
	SessionCipher sessionCipher = new SessionCipher(this.axolotlStore, destination);
	PushTransportDetails transportDetails = new PushTransportDetails(sessionCipher.getSessionVersion());
	CiphertextMessage message = sessionCipher.encrypt(transportDetails.getPaddedMessageBody(unpaddedMessage));
	int remoteRegistrationId = sessionCipher.getRemoteRegistrationId();
	String body = Base64.encodeBytes(message.serialize());
	byte type;
	switch(message.getType()) {
		case 2:
			type = 1;
			break;
		case 3:
			type = 3;
			break;
		default:
			throw new AssertionError("Bad type: " + message.getType());
	}

	return new OutgoingPushMessage(type, destination.getDeviceId(), remoteRegistrationId, body);
}
 
开发者ID:Agilitum,项目名称:TextSecureSMP,代码行数:21,代码来源:TextSecureSMPCipher.java

示例3: decrypt

import org.whispersystems.textsecure.internal.push.PushTransportDetails; //导入依赖的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

示例4: encrypt

import org.whispersystems.textsecure.internal.push.PushTransportDetails; //导入依赖的package包/类
public CiphertextMessage encrypt(byte[] unpaddedMessage) {
  PushTransportDetails transportDetails = new PushTransportDetails(sessionCipher.getSessionVersion());
  return sessionCipher.encrypt(transportDetails.getPaddedMessageBody(unpaddedMessage));
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:5,代码来源:TextSecureCipher.java


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