Exemplo n.º 1
0
  @Nullable
  private XmppAxolotlMessage buildHeader(Contact contact) {
    final XmppAxolotlMessage axolotlMessage =
        new XmppAxolotlMessage(contact.getJid().toBareJid(), getOwnDeviceId());

    Set<XmppAxolotlSession> contactSessions = findSessionsforContact(contact);
    Set<XmppAxolotlSession> ownSessions = findOwnSessions();
    if (contactSessions.isEmpty()) {
      return null;
    }
    Log.d(
        Config.LOGTAG,
        AxolotlService.getLogprefix(account) + "Building axolotl foreign keyElements...");
    for (XmppAxolotlSession session : contactSessions) {
      Log.v(
          Config.LOGTAG,
          AxolotlService.getLogprefix(account) + session.getRemoteAddress().toString());
      axolotlMessage.addDevice(session);
    }
    Log.d(
        Config.LOGTAG,
        AxolotlService.getLogprefix(account) + "Building axolotl own keyElements...");
    for (XmppAxolotlSession session : ownSessions) {
      Log.v(
          Config.LOGTAG,
          AxolotlService.getLogprefix(account) + session.getRemoteAddress().toString());
      axolotlMessage.addDevice(session);
    }

    return axolotlMessage;
  }
Exemplo n.º 2
0
  public XmppAxolotlMessage.XmppAxolotlKeyTransportMessage processReceivingKeyTransportMessage(
      XmppAxolotlMessage message) {
    XmppAxolotlMessage.XmppAxolotlKeyTransportMessage keyTransportMessage = null;

    XmppAxolotlSession session = getReceivingSession(message);
    keyTransportMessage = message.getParameters(session, getOwnDeviceId());

    if (session.isFresh() && keyTransportMessage != null) {
      sessions.put(session);
    }

    return keyTransportMessage;
  }
Exemplo n.º 3
0
 private void setTrustOnSessions(
     final Jid jid,
     @NonNull final Set<Integer> deviceIds,
     final XmppAxolotlSession.Trust from,
     final XmppAxolotlSession.Trust to) {
   for (Integer deviceId : deviceIds) {
     AxolotlAddress address = new AxolotlAddress(jid.toBareJid().toString(), deviceId);
     XmppAxolotlSession session = sessions.get(address);
     if (session != null && session.getFingerprint() != null && session.getTrust() == from) {
       session.setTrust(to);
     }
   }
 }
Exemplo n.º 4
0
  public XmppAxolotlMessage.XmppAxolotlPlaintextMessage processReceivingPayloadMessage(
      XmppAxolotlMessage message) {
    XmppAxolotlMessage.XmppAxolotlPlaintextMessage plaintextMessage = null;

    XmppAxolotlSession session = getReceivingSession(message);
    try {
      plaintextMessage = message.decrypt(session, getOwnDeviceId());
      Integer preKeyId = session.getPreKeyId();
      if (preKeyId != null) {
        publishBundlesIfNeeded();
        session.resetPreKeyId();
      }
    } catch (CryptoFailedException e) {
      Log.w(Config.LOGTAG, getLogprefix(account) + "Failed to decrypt message: " + e.getMessage());
    }

    if (session.isFresh() && plaintextMessage != null) {
      sessions.put(session);
    }

    return plaintextMessage;
  }
Exemplo n.º 5
0
 public void put(XmppAxolotlSession session) {
   this.put(session.getRemoteAddress(), session);
 }
Exemplo n.º 6
0
 @Override
 public void put(AxolotlAddress address, XmppAxolotlSession value) {
   super.put(address, value);
   value.setNotFresh();
   xmppConnectionService.syncRosterToDisk(account);
 }