public void savePublicKey(SessionID sessionID, PublicKey pubKey) {
    if (sessionID == null) return;

    X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(pubKey.getEncoded());

    //  if (!Address.hasResource(fullUserId))
    //    return;

    this.store.setProperty(
        sessionID.getRemoteUserId() + ".publicKey", x509EncodedKeySpec.getEncoded());
    // Stash the associated fingerprint.  This saves calculating it in the future
    // and is useful for transferring rosters to other apps.
    try {
      String fingerprintString = new OtrCryptoEngineImpl().getFingerprint(pubKey);
      String verifiedToken =
          buildPublicKeyVerifiedId(sessionID.getRemoteUserId(), fingerprintString.toLowerCase());
      if (!this.store.hasProperty(verifiedToken)) this.store.setProperty(verifiedToken, false);

      this.store.setPropertyHex(
          sessionID.getRemoteUserId() + ".fingerprint", Hex.decode(fingerprintString));
      store.save();
    } catch (OtrCryptoException e) {
      e.printStackTrace();
    }
  }
  public boolean isVerified(SessionID sessionID) {
    if (sessionID == null) return false;

    String remoteFingerprint = getRemoteFingerprint(sessionID.getRemoteUserId());

    if (remoteFingerprint != null) {
      String username = Address.stripResource(sessionID.getRemoteUserId());
      String pubKeyVerifiedToken = buildPublicKeyVerifiedId(username, remoteFingerprint);
      return this.store.getPropertyBoolean(pubKeyVerifiedToken, false);
    } else {
      return false;
    }
  }
  public void verify(SessionID sessionID) {
    if (sessionID == null) return;

    if (this.isVerified(sessionID)) return;

    verifyUser(sessionID.getRemoteUserId());
  }
Exemplo n.º 4
0
    @Override
    public void sessionStatusChanged(SessionID sessionID) {

      if (sessionID
          .getRemoteUserId()
          .equals(mChatSession.getParticipant().getAddress().getAddress()))
        onStatusChanged(mChatSession, OtrChatManager.getInstance().getSessionStatus(sessionID));
    }
  public void unverify(SessionID sessionID) {
    if (sessionID == null) return;

    if (!isVerified(sessionID)) return;

    unverifyUser(sessionID.getRemoteUserId());

    for (OtrKeyManagerListener l : listeners) l.verificationStatusChanged(sessionID);
  }
  public PublicKey loadRemotePublicKey(SessionID sessionID) {

    return loadRemotePublicKeyFromStore(sessionID.getRemoteUserId());
  }
 public String getRemoteFingerprint(SessionID sessionID) {
   return getRemoteFingerprint(sessionID.getRemoteUserId());
 }