verify contacts key only on initiating side of smp

This commit is contained in:
iNPUTmice 2014-11-21 13:42:25 +01:00
parent 92ad4cb736
commit de0b36fc78
4 changed files with 20 additions and 7 deletions

View File

@ -20,6 +20,7 @@ import eu.siacs.conversations.Config;
import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.utils.CryptoHelper;
import eu.siacs.conversations.xmpp.jid.InvalidJidException; import eu.siacs.conversations.xmpp.jid.InvalidJidException;
import eu.siacs.conversations.xmpp.jid.Jid; import eu.siacs.conversations.xmpp.jid.Jid;
import eu.siacs.conversations.xmpp.stanzas.MessagePacket; import eu.siacs.conversations.xmpp.stanzas.MessagePacket;
@ -249,14 +250,17 @@ public class OtrEngine implements OtrEngineHost {
} }
@Override @Override
public void verify(SessionID id, String arg1, boolean arg2) { public void verify(SessionID id, String fingerprint, boolean approved) {
Log.d(Config.LOGTAG,"OtrEngine.verify("+id.toString()+","+fingerprint+","+String.valueOf(approved)+")");
try { try {
final Jid jid = Jid.fromSessionID(id); final Jid jid = Jid.fromSessionID(id);
Conversation conversation = this.mXmppConnectionService.find(this.account,jid); Conversation conversation = this.mXmppConnectionService.find(this.account,jid);
if (conversation!=null) { if (conversation!=null) {
if (approved) {
conversation.getContact().addOtrFingerprint(CryptoHelper.prettifyFingerprint(fingerprint));
}
conversation.smp().hint = null; conversation.smp().hint = null;
conversation.smp().status = Conversation.Smp.STATUS_VERIFIED; conversation.smp().status = Conversation.Smp.STATUS_FINISHED;
conversation.verifyOtrFingerprint();
mXmppConnectionService.updateConversationUi(); mXmppConnectionService.updateConversationUi();
mXmppConnectionService.syncRosterToDisk(conversation.getAccount()); mXmppConnectionService.syncRosterToDisk(conversation.getAccount());
} }

View File

@ -529,7 +529,7 @@ public class Conversation extends AbstractEntity {
public static final int STATUS_CONTACT_REQUESTED = 1; public static final int STATUS_CONTACT_REQUESTED = 1;
public static final int STATUS_WE_REQUESTED = 2; public static final int STATUS_WE_REQUESTED = 2;
public static final int STATUS_FAILED = 3; public static final int STATUS_FAILED = 3;
public static final int STATUS_VERIFIED = 4; public static final int STATUS_FINISHED = 4;
public String secret = null; public String secret = null;
public String hint = null; public String hint = null;

View File

@ -285,14 +285,21 @@ public class VerifyOTRActivity extends XmppActivity implements XmppConnectionSer
this.mStatusMessage.setVisibility(View.VISIBLE); this.mStatusMessage.setVisibility(View.VISIBLE);
this.mStatusMessage.setText(R.string.secrets_do_not_match); this.mStatusMessage.setText(R.string.secrets_do_not_match);
this.mStatusMessage.setTextColor(getWarningTextColor()); this.mStatusMessage.setTextColor(getWarningTextColor());
} else if (smp.status == Conversation.Smp.STATUS_VERIFIED) { } else if (smp.status == Conversation.Smp.STATUS_FINISHED) {
this.mSharedSecretHint.setText("");
this.mSharedSecretHint.setVisibility(View.GONE); this.mSharedSecretHint.setVisibility(View.GONE);
this.mSharedSecretSecret.setText("");
this.mSharedSecretSecret.setVisibility(View.GONE); this.mSharedSecretSecret.setVisibility(View.GONE);
this.mStatusMessage.setVisibility(View.VISIBLE); this.mStatusMessage.setVisibility(View.VISIBLE);
this.mStatusMessage.setText(R.string.verified);
this.mStatusMessage.setTextColor(getPrimaryColor()); this.mStatusMessage.setTextColor(getPrimaryColor());
deactivateButton(mButtonSharedSecretNegative, R.string.cancel); deactivateButton(mButtonSharedSecretNegative, R.string.cancel);
if (mConversation.isOtrFingerprintVerified()) {
activateButton(mButtonSharedSecretPositive, R.string.finish, mFinishListener); activateButton(mButtonSharedSecretPositive, R.string.finish, mFinishListener);
this.mStatusMessage.setText(R.string.verified);
} else {
activateButton(mButtonSharedSecretPositive,R.string.reset,mRetrySharedSecretListener);
this.mStatusMessage.setText(R.string.secret_accepted);
}
} else if (session != null && session.isSmpInProgress()) { } else if (session != null && session.isSmpInProgress()) {
deactivateButton(mButtonSharedSecretPositive, R.string.in_progress); deactivateButton(mButtonSharedSecretPositive, R.string.in_progress);
activateButton(mButtonSharedSecretNegative, R.string.cancel, mCancelSharedSecretListener); activateButton(mButtonSharedSecretNegative, R.string.cancel, mCancelSharedSecretListener);

View File

@ -356,4 +356,6 @@
<string name="no_conference_server_found">No conference server found</string> <string name="no_conference_server_found">No conference server found</string>
<string name="conference_creation_failed">Conference creation failed!</string> <string name="conference_creation_failed">Conference creation failed!</string>
<string name="conference_created">Conference created!</string> <string name="conference_created">Conference created!</string>
<string name="secret_accepted">Secret accepted!</string>
<string name="reset">Reset</string>
</resources> </resources>