OTR: Fingerprint comparison field (Patch by Daniel Perren, FHNW)

cusax-fix
Ingo Bauersachs 14 years ago
parent 8bed1ed0fd
commit c813493c60

@ -1277,6 +1277,7 @@ plugin.otr.authbuddydialog.AUTHENTICATE_BUDDY=Authenticate Buddy
plugin.otr.authbuddydialog.I_HAVE=I have
plugin.otr.authbuddydialog.I_HAVE_NOT=I have not
plugin.otr.authbuddydialog.VERIFY_ACTION=verified that this is in fact the correct fingerprint for {0}.
plugin.otr.authbuddydialog.FINGERPRINT_CHECK=Please enter the fingerprint you recieved from {0}.
plugin.otr.configform.MY_PRIVATE_KEYS=My Private Keys
plugin.otr.configform.KNOWN_FINGERPRINTS=Known Fingerprints
plugin.otr.configform.CB_AUTO=Automatically initiate private messaging

@ -9,6 +9,7 @@
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.swing.*;
@ -19,6 +20,7 @@
@SuppressWarnings("serial")
public class OtrBuddyAuthenticationDialog
extends SIPCommDialog
implements DocumentListener
{
private final Contact contact;
@ -37,11 +39,17 @@ public OtrBuddyAuthenticationDialog(Contact contact)
loadContact();
}
private SIPCommTextField txtRemoteFingerprintComparison;
private JTextArea txtLocalFingerprint;
private JTextArea txtRemoteFingerprint;
private JComboBox cbAction;
ActionComboBoxItem actionIHave =
new ActionComboBoxItem(ActionComboBoxItemIndex.I_HAVE);
ActionComboBoxItem actionIHaveNot =
new ActionComboBoxItem(ActionComboBoxItemIndex.I_HAVE_NOT);
private JTextArea txtAction;
@ -179,15 +187,10 @@ private void initComponents()
c.weightx = 0.0;
cbAction = new JComboBox();
ActionComboBoxItem iHave =
new ActionComboBoxItem(ActionComboBoxItemIndex.I_HAVE);
ActionComboBoxItem iHaveNot =
new ActionComboBoxItem(ActionComboBoxItemIndex.I_HAVE_NOT);
cbAction.addItem(iHave);
cbAction.addItem(iHaveNot);
cbAction.addItem(actionIHave);
cbAction.addItem(actionIHaveNot);
cbAction.setSelectedItem(OtrActivator.scOtrKeyManager
.isVerified(contact) ? iHave : iHaveNot);
.isVerified(contact) ? actionIHave : actionIHaveNot);
pnlAction.add(cbAction, c);
@ -195,6 +198,18 @@ private void initComponents()
c.weightx = 1.0;
pnlAction.add(txtAction, c);
txtRemoteFingerprintComparison = new SIPCommTextField(
OtrActivator.resourceService
.getI18NString("plugin.otr.authbuddydialog.FINGERPRINT_CHECK",
new String[]{contact.getDisplayName()}));
txtRemoteFingerprintComparison.getDocument().addDocumentListener(this);
c.gridwidth = 2;
c.gridy = 1;
pnlAction.add(txtRemoteFingerprintComparison, c);
c.gridwidth = 1;
c.gridy = 0;
// Buttons panel.
JPanel buttonPanel = new TransparentPanel(new GridBagLayout());
buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5));
@ -210,7 +225,6 @@ public void actionPerformed(ActionEvent arg0)
}
});
c.weightx = 0.0;
buttonPanel.add(helpButton, c);
// Provide space between help and the other two button, not sure if this
@ -259,4 +273,41 @@ public void actionPerformed(ActionEvent e)
this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
this.pack();
}
public void removeUpdate(DocumentEvent e)
{
compareFingerprints();
}
public void insertUpdate(DocumentEvent e)
{
compareFingerprints();
}
public void changedUpdate(DocumentEvent e)
{
compareFingerprints();
}
public void compareFingerprints()
{
if(txtRemoteFingerprintComparison.getText() == null
|| txtRemoteFingerprintComparison.getText().length() == 0)
{
txtRemoteFingerprintComparison.setBackground(Color.white);
return;
}
if(txtRemoteFingerprintComparison.getText().contains(
OtrActivator.scOtrKeyManager.getRemoteFingerprint(contact)))
{
txtRemoteFingerprintComparison.setBackground(Color.green);
cbAction.setSelectedItem(actionIHave);
}
else
{
txtRemoteFingerprintComparison.setBackground(
new Color(243, 72, 48));
cbAction.setSelectedItem(actionIHaveNot);
}
}
}

@ -18,6 +18,7 @@ Import-Package: org.osgi.framework,
javax.swing,
javax.swing.border,
javax.swing.table,
javax.swing.text,
javax.swing.event,
javax.crypto,
javax.crypto.interfaces,

Loading…
Cancel
Save