OTR A) Fixed: When you verify a partner, the padlock icon remains with the little triangle (unverified) <-> Icon does not update. B) Added a dropdown which controls verification status in OtrAuthenticationBuddy dialog

cusax-fix
George Politis 16 years ago
parent 28f2f8e22a
commit 39b0e25151

@ -811,6 +811,9 @@ plugin.otr.authbuddydialog.CANCEL=Cancel
plugin.otr.authbuddydialog.HELP=Help
plugin.otr.authbuddydialog.TITLE=Authenticate Buddy
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.configform.TITLE=Off-the-Record Messaging
plugin.otr.configform.DEFAULT_SETTINGS=Default Off-the-Record Settings
plugin.otr.configform.MY_PRIVATE_KEYS=My Private Keys

@ -31,9 +31,13 @@ public OtrBuddyAuthenticationDialog(Contact contact)
loadContact();
}
JTextArea txtLocalFingerprint;
private JTextArea txtLocalFingerprint;
JTextArea txtRemoteFingerprint;
private JTextArea txtRemoteFingerprint;
private JComboBox cbAction;
private JTextArea txtAction;
private void loadContact()
{
@ -55,6 +59,59 @@ private void loadContact()
.getI18NString("plugin.otr.authbuddydialog.REMOTE_FINGERPRINT",
new String[]
{ user, remoteFingerprint }));
// Action
txtAction.setText(OtrActivator.resourceService.getI18NString(
"plugin.otr.authbuddydialog.VERIFY_ACTION", new String[]
{ user }));
}
class CustomTextArea
extends JTextArea
{
public CustomTextArea()
{
this.setBackground(new java.awt.Color(212, 208, 200));
this.setColumns(20);
this.setEditable(false);
this.setLineWrap(true);
this.setWrapStyleWord(true);
}
}
enum ActionComboBoxItemIndex
{
I_HAVE, I_HAVE_NOT
}
class ActionComboBoxItem
{
public ActionComboBoxItemIndex action;
private String text;
public ActionComboBoxItem(ActionComboBoxItemIndex actionIndex)
{
this.action = actionIndex;
switch (action)
{
case I_HAVE:
text =
OtrActivator.resourceService
.getI18NString("plugin.otr.authbuddydialog.I_HAVE");
break;
case I_HAVE_NOT:
text =
OtrActivator.resourceService
.getI18NString("plugin.otr.authbuddydialog.I_HAVE_NOT");
break;
}
}
public String toString()
{
return text;
}
}
private void initComponents()
@ -67,35 +124,46 @@ private void initComponents()
mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
mainPanel.setPreferredSize(new Dimension(400, 300));
JTextArea generalInformation = new JTextArea();
generalInformation.setBackground(new java.awt.Color(212, 208, 200));
generalInformation.setColumns(20);
generalInformation.setEditable(false);
generalInformation.setLineWrap(true);
generalInformation.setWrapStyleWord(true);
JTextArea generalInformation = new CustomTextArea();
generalInformation.setText(OtrActivator.resourceService
.getI18NString("plugin.otr.authbuddydialog.AUTHENTICATION_INFO"));
mainPanel.add(generalInformation);
txtLocalFingerprint = new JTextArea();
txtLocalFingerprint.setBackground(new java.awt.Color(212, 208, 200));
txtLocalFingerprint.setColumns(20);
txtLocalFingerprint.setEditable(false);
txtLocalFingerprint.setLineWrap(true);
generalInformation.setWrapStyleWord(true);
txtLocalFingerprint = new CustomTextArea();
mainPanel.add(txtLocalFingerprint);
txtRemoteFingerprint = new JTextArea();
txtRemoteFingerprint.setBackground(new java.awt.Color(212, 208, 200));
txtRemoteFingerprint.setColumns(20);
txtRemoteFingerprint.setEditable(false);
txtRemoteFingerprint.setLineWrap(true);
generalInformation.setWrapStyleWord(true);
txtRemoteFingerprint = new CustomTextArea();
mainPanel.add(txtRemoteFingerprint);
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
// Action Panel (the panel that holds the I have/I have not dropdown)
JPanel pnlAction = new JPanel(new GridBagLayout());
pnlAction.setBorder(BorderFactory.createEtchedBorder());
mainPanel.add(pnlAction);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.insets = new Insets(5, 5, 5, 5);
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.setSelectedItem(OtrActivator.scOtrEngine
.isContactVerified(contact) ? iHave : iHaveNot);
pnlAction.add(cbAction, c);
txtAction = new CustomTextArea();
c.weightx = 1.0;
pnlAction.add(txtAction, c);
// Buttons panel.
JPanel buttonPanel = new JPanel(new GridBagLayout());
JButton helpButton =
new JButton(OtrActivator.resourceService
@ -107,7 +175,15 @@ public void actionPerformed(ActionEvent arg0)
OtrActivator.scOtrEngine.launchHelp();
}
});
buttonPanel.add(helpButton);
c.weightx = 0.0;
buttonPanel.add(helpButton, c);
// Provide space between help and the other two button, not sure if this
// is optimal..
c.weightx = 1.0;
buttonPanel.add(new JLabel(), c);
c.weightx = 0.0;
JButton cancelButton =
new JButton(OtrActivator.resourceService
@ -119,7 +195,7 @@ public void actionPerformed(ActionEvent e)
dispose();
}
});
buttonPanel.add(cancelButton);
buttonPanel.add(cancelButton, c);
JButton authenticateButton =
new JButton(OtrActivator.resourceService
@ -128,11 +204,22 @@ public void actionPerformed(ActionEvent e)
{
public void actionPerformed(ActionEvent e)
{
OtrActivator.scOtrEngine.verifyContactFingerprint(contact);
ActionComboBoxItem actionItem =
(ActionComboBoxItem) cbAction.getSelectedItem();
switch (actionItem.action)
{
case I_HAVE:
OtrActivator.scOtrEngine.verifyContactFingerprint(contact);
break;
case I_HAVE_NOT:
OtrActivator.scOtrEngine.forgetContactFingerprint(contact);
break;
}
dispose();
}
});
buttonPanel.add(authenticateButton);
buttonPanel.add(authenticateButton, c);
mainPanel.add(buttonPanel);

@ -57,6 +57,15 @@ public void globalPolicyChanged()
setOtrPolicy(policy);
}
public void contactVerificationStatusChanged(Contact contact)
{
SessionStatus status =
OtrActivator.scOtrEngine.getSessionStatus(contact);
if (contact.equals(OtrContactMenu.this.contact))
setSessionStatus(status);
}
});
setSessionStatus(OtrActivator.scOtrEngine.getSessionStatus(contact));
@ -123,30 +132,27 @@ public void actionPerformed(ActionEvent e)
refreshOtr.setEnabled(policy.getEnableManual());
this.add(refreshOtr);
if (!OtrActivator.scOtrEngine.isContactVerified(contact))
JMenuItem authBuddy = new JMenuItem();
authBuddy.setText(OtrActivator.resourceService
.getI18NString("plugin.otr.menu.AUTHENTICATE_BUDDY"));
authBuddy.addActionListener(new ActionListener()
{
JMenuItem authBuddy = new JMenuItem();
authBuddy.setText(OtrActivator.resourceService
.getI18NString("plugin.otr.menu.AUTHENTICATE_BUDDY"));
authBuddy.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
{
public void actionPerformed(ActionEvent e)
{
// Launch auth buddy dialog.
OtrBuddyAuthenticationDialog authenticateBuddyDialog =
new OtrBuddyAuthenticationDialog(contact);
authenticateBuddyDialog.setLocation(Toolkit
.getDefaultToolkit().getScreenSize().width
/ 2 - authenticateBuddyDialog.getWidth() / 2,
Toolkit.getDefaultToolkit().getScreenSize().height
/ 2 - authenticateBuddyDialog.getHeight() / 2);
authenticateBuddyDialog.setVisible(true);
}
});
this.add(authBuddy);
}
// Launch auth buddy dialog.
OtrBuddyAuthenticationDialog authenticateBuddyDialog =
new OtrBuddyAuthenticationDialog(contact);
authenticateBuddyDialog.setLocation(Toolkit
.getDefaultToolkit().getScreenSize().width
/ 2 - authenticateBuddyDialog.getWidth() / 2, Toolkit
.getDefaultToolkit().getScreenSize().height
/ 2 - authenticateBuddyDialog.getHeight() / 2);
authenticateBuddyDialog.setVisible(true);
}
});
this.add(authBuddy);
break;
case FINISHED:
this.setIcon(OtrActivator.resourceService

@ -67,6 +67,17 @@ public void globalPolicyChanged()
setPolicy(OtrActivator.scOtrEngine
.getContactPolicy(contact));
}
public void contactVerificationStatusChanged(Contact contact)
{
// OtrMetaContactButton.this.contact can be null.
if (contact.equals(OtrMetaContactButton.this.contact))
{
setStatus(OtrActivator.scOtrEngine
.getSessionStatus(contact));
}
}
});
this.addActionListener(new ActionListener()

@ -343,8 +343,14 @@ public void verifyContactFingerprint(Contact contact)
if (contact == null)
return;
if (isContactVerified(contact))
return;
this.configurator.setProperty(getSessionID(contact)
+ "publicKey.verified", true);
for (ScOtrEngineListener l : listeners)
l.contactVerificationStatusChanged(contact);
}
public void forgetContactFingerprint(Contact contact)
@ -352,9 +358,14 @@ public void forgetContactFingerprint(Contact contact)
if (contact == null)
return;
if (!isContactVerified(contact))
return;
this.configurator.removeProperty(getSessionID(contact)
+ "publicKey.verified");
for (ScOtrEngineListener l : listeners)
l.contactVerificationStatusChanged(contact);
}
public OtrPolicy getGlobalPolicy()

@ -1,6 +1,6 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
*
* Distributable under LGPL license. See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.otr;
@ -10,13 +10,15 @@
/**
*
* @author George Politis
*
*
*/
public interface ScOtrEngineListener
{
public abstract void contactVerificationStatusChanged(Contact contact);
public abstract void sessionStatusChanged(Contact contact);
public abstract void contactPolicyChanged(Contact contact);
public abstract void globalPolicyChanged();
}

Loading…
Cancel
Save