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


Java NoSessionException类代码示例

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


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

示例1: decrypt

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

示例2: encrypt

import org.whispersystems.libaxolotl.NoSessionException; //导入依赖的package包/类
public OutgoingTextMessage encrypt(OutgoingTextMessage message) throws NoSessionException {
  byte[] paddedBody  = transportDetails.getPaddedMessageBody(message.getMessageBody().getBytes());
  long   recipientId = message.getRecipients().getPrimaryRecipient().getRecipientId();

  if (!axolotlStore.containsSession(recipientId, PushAddress.DEFAULT_DEVICE_ID)) {
    throw new NoSessionException("No session for: " + recipientId);
  }

  SessionCipher     cipher            = new SessionCipher(axolotlStore, recipientId, PushAddress.DEFAULT_DEVICE_ID);
  CiphertextMessage ciphertextMessage = cipher.encrypt(paddedBody);
  String            encodedCiphertext = new String(transportDetails.getEncodedMessage(ciphertextMessage.serialize()));

  if (ciphertextMessage.getType() == CiphertextMessage.PREKEY_TYPE) {
    return new OutgoingPrekeyBundleMessage(message, encodedCiphertext);
  } else {
    return message.withBody(encodedCiphertext);
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:19,代码来源:SmsCipher.java

示例3: retrieveAndStore

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

示例4: decrypt

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

示例5: decrypt

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

示例6: storeRetrievedMms

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

示例7: encrypt

import org.whispersystems.libaxolotl.NoSessionException; //导入依赖的package包/类
public byte[] encrypt(byte[] paddedPlaintext) throws NoSessionException {
  synchronized (LOCK) {
    try {
      SenderKeyRecord  record         = senderKeyStore.loadSenderKey(senderKeyId);
      SenderKeyState   senderKeyState = record.getSenderKeyState();
      SenderMessageKey senderKey      = senderKeyState.getSenderChainKey().getSenderMessageKey();
      byte[]           ciphertext     = getCipherText(senderKey.getIv(), senderKey.getCipherKey(), paddedPlaintext);

      SenderKeyMessage senderKeyMessage = new SenderKeyMessage(senderKeyState.getKeyId(),
                                                               senderKey.getIteration(),
                                                               ciphertext,
                                                               senderKeyState.getSigningKeyPrivate());

      senderKeyState.setSenderChainKey(senderKeyState.getSenderChainKey().getNext());

      senderKeyStore.storeSenderKey(senderKeyId, record);

      return senderKeyMessage.serialize();
    } catch (InvalidKeyIdException e) {
      throw new NoSessionException(e);
    }
  }
}
 
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:24,代码来源:GroupCipher.java

示例8: retrieveAndStore

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

示例9: encrypt

import org.whispersystems.libaxolotl.NoSessionException; //导入依赖的package包/类
public SendReq encrypt(Context context, SendReq message)
    throws NoSessionException, RecipientFormattingException
{
  EncodedStringValue[] encodedRecipient = message.getTo();
  String               recipientString  = encodedRecipient[0].getString();
  Recipients           recipients       = RecipientFactory.getRecipientsFromString(context, recipientString, false);
  long                 recipientId      = recipients.getPrimaryRecipient().getRecipientId();
  byte[]               pduBytes         = new PduComposer(context, message).make();

  if (!axolotlStore.containsSession(recipientId, PushAddress.DEFAULT_DEVICE_ID)) {
    throw new NoSessionException("No session for: " + recipientId);
  }

  SessionCipher     cipher            = new SessionCipher(axolotlStore, recipientId, PushAddress.DEFAULT_DEVICE_ID);
  CiphertextMessage ciphertextMessage = cipher.encrypt(pduBytes);
  byte[]            encryptedPduBytes = textTransport.getEncodedMessage(ciphertextMessage.serialize());

  PduBody body         = new PduBody();
  PduPart part         = new PduPart();
  SendReq encryptedPdu = new SendReq(message.getPduHeaders(), body);

  part.setContentId((System.currentTimeMillis()+"").getBytes());
  part.setContentType(ContentType.TEXT_PLAIN.getBytes());
  part.setName((System.currentTimeMillis()+"").getBytes());
  part.setData(encryptedPduBytes);
  body.addPart(part);
  encryptedPdu.setSubject(new EncodedStringValue(WirePrefix.calculateEncryptedMmsSubject()));
  encryptedPdu.setBody(body);

  return encryptedPdu;
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:32,代码来源:MmsCipher.java

示例10: getAsymmetricEncrypt

import org.whispersystems.libaxolotl.NoSessionException; //导入依赖的package包/类
private OutgoingTextMessage getAsymmetricEncrypt(MasterSecret masterSecret,
                                                 OutgoingTextMessage message)
    throws InsecureFallbackApprovalException
{
  try {
    return new SmsCipher(new TextSecureAxolotlStore(context, masterSecret)).encrypt(message);
  } catch (NoSessionException e) {
    throw new InsecureFallbackApprovalException(e);
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:11,代码来源:SmsSendJob.java

示例11: storeRetrievedMms

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

示例12: handleSecureMessage

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

示例13: testBasicSessionV2

import org.whispersystems.libaxolotl.NoSessionException; //导入依赖的package包/类
public void testBasicSessionV2()
    throws InvalidKeyException, DuplicateMessageException,
    LegacyMessageException, InvalidMessageException, NoSuchAlgorithmException, NoSessionException
{
  SessionRecord aliceSessionRecord = new SessionRecord();
  SessionRecord bobSessionRecord   = new SessionRecord();

  initializeSessionsV2(aliceSessionRecord.getSessionState(), bobSessionRecord.getSessionState());
  runInteraction(aliceSessionRecord, bobSessionRecord);
}
 
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:11,代码来源:SessionCipherTest.java

示例14: testBasicSessionV3

import org.whispersystems.libaxolotl.NoSessionException; //导入依赖的package包/类
public void testBasicSessionV3()
    throws InvalidKeyException, DuplicateMessageException,
    LegacyMessageException, InvalidMessageException, NoSuchAlgorithmException, NoSessionException
{
  SessionRecord aliceSessionRecord = new SessionRecord();
  SessionRecord bobSessionRecord   = new SessionRecord();

  initializeSessionsV3(aliceSessionRecord.getSessionState(), bobSessionRecord.getSessionState());
  runInteraction(aliceSessionRecord, bobSessionRecord);
}
 
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:11,代码来源:SessionCipherTest.java

示例15: testBasicEncryptDecrypt

import org.whispersystems.libaxolotl.NoSessionException; //导入依赖的package包/类
public void testBasicEncryptDecrypt()
    throws LegacyMessageException, DuplicateMessageException, InvalidMessageException, NoSessionException
{
  InMemorySenderKeyStore aliceStore = new InMemorySenderKeyStore();
  InMemorySenderKeyStore bobStore   = new InMemorySenderKeyStore();

  GroupSessionBuilder aliceSessionBuilder = new GroupSessionBuilder(aliceStore);
  GroupSessionBuilder bobSessionBuilder   = new GroupSessionBuilder(bobStore);

  GroupCipher aliceGroupCipher = new GroupCipher(aliceStore, "groupWithBobInIt");
  GroupCipher bobGroupCipher   = new GroupCipher(bobStore, "groupWithBobInIt::aliceUserName");

  byte[]    aliceSenderKey        = KeyHelper.generateSenderKey();
  ECKeyPair aliceSenderSigningKey = KeyHelper.generateSenderSigningKey();
  int       aliceSenderKeyId      = KeyHelper.generateSenderKeyId();

  SenderKeyDistributionMessage aliceDistributionMessage =
      aliceSessionBuilder.process("groupWithBobInIt", aliceSenderKeyId, 0,
                                  aliceSenderKey, aliceSenderSigningKey);

  bobSessionBuilder.process("groupWithBobInIt::aliceUserName", aliceDistributionMessage);

  byte[] ciphertextFromAlice = aliceGroupCipher.encrypt("smert ze smert".getBytes());
  byte[] plaintextFromAlice  = bobGroupCipher.decrypt(ciphertextFromAlice);

  assertTrue(new String(plaintextFromAlice).equals("smert ze smert"));
}
 
开发者ID:Securecom,项目名称:Securecom-Messaging,代码行数:28,代码来源:GroupCipherTest.java


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