Zrtp Gui and event modifications. (Issue #463)
|
Before Width: | Height: | Size: 693 B After Width: | Height: | Size: 389 B |
|
Before Width: | Height: | Size: 839 B After Width: | Height: | Size: 543 B |
|
Before Width: | Height: | Size: 287 B After Width: | Height: | Size: 848 B |
|
After Width: | Height: | Size: 695 B |
|
After Width: | Height: | Size: 962 B |
|
After Width: | Height: | Size: 736 B |
|
After Width: | Height: | Size: 781 B |
|
After Width: | Height: | Size: 579 B |
|
After Width: | Height: | Size: 585 B |
@ -0,0 +1,144 @@
|
||||
/*
|
||||
* 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.impl.gui.main.call;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.*;
|
||||
import net.java.sip.communicator.impl.gui.customcontrols.*;
|
||||
import net.java.sip.communicator.impl.gui.main.call.CallParticipantPanel.*;
|
||||
import net.java.sip.communicator.impl.gui.utils.*;
|
||||
import net.java.sip.communicator.service.notification.*;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.service.protocol.event.*;
|
||||
import net.java.sip.communicator.util.swing.*;
|
||||
|
||||
public class SecurityPanel
|
||||
extends TransparentPanel
|
||||
{
|
||||
private CallParticipant participant;
|
||||
|
||||
private Image iconEncr;
|
||||
private Image iconEncrVerified;
|
||||
|
||||
private boolean sasVerified = false;
|
||||
|
||||
private NotificationService notificationService = null;
|
||||
|
||||
private static final String ZRTP_SECURE_NOTIFICATION
|
||||
= "ZrtpSecureNotification";
|
||||
|
||||
private static final String ZRTP_ALERT_NOTIFICATION
|
||||
= "ZrtpAlertNotification";
|
||||
|
||||
private SIPCommButton sasVerificationButton
|
||||
= new SIPCommButton(iconEncr);
|
||||
|
||||
private JLabel securityStringLabel = new JLabel();
|
||||
|
||||
public SecurityPanel(CallParticipant participant)
|
||||
{
|
||||
this.participant = participant;
|
||||
|
||||
this.setLayout(new GridLayout(1, 0, 5, 5));
|
||||
|
||||
this.setBorder(
|
||||
BorderFactory.createTitledBorder("Compare with partner"));
|
||||
|
||||
iconEncrVerified =
|
||||
ImageLoader.getImage(ImageLoader.ENCR_VERIFIED);
|
||||
iconEncr = ImageLoader.getImage(ImageLoader.ENCR);
|
||||
|
||||
notificationService = GuiActivator.getNotificationService();
|
||||
|
||||
if(notificationService != null)
|
||||
{
|
||||
notificationService.registerDefaultNotificationForEvent(
|
||||
ZRTP_SECURE_NOTIFICATION,
|
||||
NotificationService.ACTION_SOUND,
|
||||
SoundProperties.ZRTP_SECURE,
|
||||
null);
|
||||
|
||||
notificationService.registerDefaultNotificationForEvent(
|
||||
ZRTP_ALERT_NOTIFICATION,
|
||||
NotificationService.ACTION_SOUND,
|
||||
SoundProperties.ZRTP_ALERT,
|
||||
null);
|
||||
}
|
||||
|
||||
this.addComponentsToPane();
|
||||
}
|
||||
|
||||
private void addComponentsToPane()
|
||||
{
|
||||
this.add(sasVerificationButton);
|
||||
this.add(securityStringLabel);
|
||||
|
||||
// Action to trigger SAS verification
|
||||
sasVerificationButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
boolean sucess = false;
|
||||
Call call = participant.getCall();
|
||||
|
||||
if (call != null)
|
||||
{
|
||||
OperationSetSecureTelephony secure
|
||||
= (OperationSetSecureTelephony) call
|
||||
.getProtocolProvider().getOperationSet(
|
||||
OperationSetSecureTelephony.class);
|
||||
|
||||
if (secure != null)
|
||||
{
|
||||
sucess = secure.setSasVerified( participant,
|
||||
!sasVerified);
|
||||
}
|
||||
|
||||
if (sucess)
|
||||
{
|
||||
if (sasVerified)
|
||||
{
|
||||
sasVerified = false;
|
||||
sasVerificationButton.setImage(iconEncr);
|
||||
}
|
||||
else
|
||||
{
|
||||
sasVerified = true;
|
||||
sasVerificationButton.setImage(iconEncrVerified);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void refreshStates(CallParticipantSecurityOnEvent event)
|
||||
{
|
||||
String securityString = event.getSecurityString();
|
||||
|
||||
if (securityString != null)
|
||||
{
|
||||
securityStringLabel.setText(securityString);
|
||||
|
||||
if (event.isSecurityVerified())
|
||||
{
|
||||
sasVerificationButton.setImage(iconEncrVerified);
|
||||
}
|
||||
}
|
||||
|
||||
sasVerificationButton.setImage(iconEncr);
|
||||
notificationService.fireNotification(ZRTP_SECURE_NOTIFICATION);
|
||||
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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.impl.gui.main.call;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.utils.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class SecurityStatusLabel extends JLabel
|
||||
{
|
||||
private final CallParticipantPanel callParticipantPanel;
|
||||
|
||||
public SecurityStatusLabel( CallParticipantPanel callParticipantPanel,
|
||||
String text,
|
||||
Icon icon,
|
||||
int alignment)
|
||||
{
|
||||
super(text, icon, alignment);
|
||||
|
||||
this.callParticipantPanel = callParticipantPanel;
|
||||
|
||||
this.setToolTipText("Test");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create tooltip.
|
||||
*/
|
||||
public JToolTip createToolTip()
|
||||
{
|
||||
ExtendedTooltip tip = new ExtendedTooltip();
|
||||
|
||||
tip.setTitle("Security status");
|
||||
|
||||
ImageIcon audioStatusIcon;
|
||||
String audioStatusString;
|
||||
if (callParticipantPanel.isAudioSecurityOn())
|
||||
{
|
||||
audioStatusIcon = new ImageIcon(
|
||||
ImageLoader.getImage(ImageLoader.SECURE_AUDIO_ON));
|
||||
audioStatusString = "Audio security on.";
|
||||
}
|
||||
else
|
||||
{
|
||||
audioStatusIcon = new ImageIcon(
|
||||
ImageLoader.getImage(ImageLoader.SECURE_AUDIO_OFF));
|
||||
audioStatusString = "Audio security off.";
|
||||
}
|
||||
|
||||
ImageIcon videoStatusIcon;
|
||||
String videoStatusString;
|
||||
if (callParticipantPanel.isVideoSecurityOn())
|
||||
{
|
||||
videoStatusIcon = new ImageIcon(
|
||||
ImageLoader.getImage(ImageLoader.SECURE_VIDEO_ON));
|
||||
videoStatusString = "Video security on.";
|
||||
}
|
||||
else
|
||||
{
|
||||
videoStatusIcon = new ImageIcon(
|
||||
ImageLoader.getImage(ImageLoader.SECURE_VIDEO_OFF));
|
||||
videoStatusString = "Video security off.";
|
||||
}
|
||||
|
||||
String cipher = "Cipher: " + callParticipantPanel.getEncryptionCipher();
|
||||
|
||||
tip.addLine(audioStatusIcon,
|
||||
audioStatusString);
|
||||
|
||||
tip.addLine(videoStatusIcon,
|
||||
videoStatusString);
|
||||
|
||||
tip.addLine(null, cipher);
|
||||
|
||||
tip.setComponent(this);
|
||||
|
||||
return tip;
|
||||
}
|
||||
}
|
||||
@ -1,258 +0,0 @@
|
||||
/*
|
||||
* 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.impl.gui.main.call;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.*;
|
||||
import net.java.sip.communicator.impl.gui.utils.*;
|
||||
import net.java.sip.communicator.service.gui.*;
|
||||
import net.java.sip.communicator.service.notification.*;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.service.protocol.event.*;
|
||||
import net.java.sip.communicator.util.swing.*;
|
||||
|
||||
public class ZrtpPanel extends TransparentPanel {
|
||||
/**
|
||||
* Default.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final String ZRTP_SECURE = "ZrtpSecure";
|
||||
private static final String ZRTP_ALERT = "ZrtpAlert";
|
||||
|
||||
private CallParticipant participant;
|
||||
|
||||
private JButton secButton;
|
||||
private JLabel sasLabel;
|
||||
private JLabel secMethod;
|
||||
private JLabel sessionType;
|
||||
|
||||
private JButton secButtonV;
|
||||
private JLabel sasLabelV;
|
||||
private JLabel secMethodV;
|
||||
private JLabel sessionTypeV;
|
||||
|
||||
private ImageIcon iconEncr;
|
||||
private ImageIcon iconEncrVerified;
|
||||
private ImageIcon iconEncrDisabled;
|
||||
|
||||
private boolean sasVerified = false;
|
||||
|
||||
private NotificationService notificationService = null;
|
||||
|
||||
public ZrtpPanel() {
|
||||
iconEncrVerified = new ImageIcon(
|
||||
ImageLoader.getImage(ImageLoader.ENCR_VERIFIED));
|
||||
iconEncr = new ImageIcon(ImageLoader.getImage(ImageLoader.ENCR));
|
||||
iconEncrDisabled = new ImageIcon(
|
||||
ImageLoader.getImage(ImageLoader.ENCR_DISABLED));
|
||||
|
||||
setLayout(new GridLayout(0, 4, 10, 3));
|
||||
|
||||
secButton = new JButton("");
|
||||
sasLabel = new JLabel("", JLabel.CENTER);
|
||||
secMethod = new JLabel("None", JLabel.CENTER);
|
||||
sessionType = new JLabel("", JLabel.CENTER);
|
||||
|
||||
secButtonV = new JButton(iconEncrDisabled);
|
||||
sasLabelV = new JLabel("", JLabel.CENTER);
|
||||
secMethodV = new JLabel("None", JLabel.CENTER);
|
||||
sessionTypeV = new JLabel("", JLabel.CENTER);
|
||||
|
||||
setPreferredSize(new Dimension(350, 80));
|
||||
|
||||
notificationService = GuiActivator.getNotificationService();
|
||||
|
||||
if(notificationService != null) {
|
||||
notificationService.registerDefaultNotificationForEvent(
|
||||
ZRTP_SECURE,
|
||||
NotificationService.ACTION_SOUND,
|
||||
SoundProperties.ZRTP_SECURE,
|
||||
null);
|
||||
notificationService.registerDefaultNotificationForEvent(
|
||||
ZRTP_ALERT,
|
||||
NotificationService.ACTION_SOUND,
|
||||
SoundProperties.ZRTP_ALERT,
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
public void addComponentsToPane() {
|
||||
|
||||
add(new JLabel("Session", JLabel.CENTER));
|
||||
add(new JLabel("SAS", JLabel.CENTER));
|
||||
add(new JLabel("Status", JLabel.CENTER));
|
||||
add(new JLabel("Method", JLabel.CENTER));
|
||||
|
||||
add(sessionType);
|
||||
add(sasLabel);
|
||||
add(secButton);
|
||||
secButton.setEnabled(false);
|
||||
add(secMethod);
|
||||
|
||||
add(sessionTypeV);
|
||||
add(sasLabelV);
|
||||
add(secButtonV);
|
||||
add(secMethodV);
|
||||
|
||||
// Action to trigger SAS verification
|
||||
secButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
boolean sucess = false;
|
||||
Call call = participant.getCall();
|
||||
|
||||
if (call != null) {
|
||||
OperationSetSecureTelephony secure = (OperationSetSecureTelephony) call
|
||||
.getProtocolProvider().getOperationSet(
|
||||
OperationSetSecureTelephony.class);
|
||||
if (secure != null) {
|
||||
sucess = secure.setSasVerified(participant,
|
||||
!sasVerified);
|
||||
}
|
||||
|
||||
if (sucess) {
|
||||
if (sasVerified) {
|
||||
sasVerified = false;
|
||||
secButton.setIcon(iconEncr);
|
||||
// secButton.setText("Sec");
|
||||
} else {
|
||||
sasVerified = true;
|
||||
secButton.setIcon(iconEncrVerified);
|
||||
// secButton.setText("Ver");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
revalidate();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
public void refreshStates(SecurityGUIEventZrtp securityEvent) {
|
||||
HashMap<String, Object> state = securityEvent.getStates();
|
||||
|
||||
if (SecurityGUIEventZrtp.AUDIO.equals((String)state.get(SecurityGUIEventZrtp.SESSION_TYPE))) {
|
||||
refreshStatesAudio(securityEvent);
|
||||
|
||||
}
|
||||
if (SecurityGUIEventZrtp.VIDEO.equals((String)state.get(SecurityGUIEventZrtp.SESSION_TYPE))) {
|
||||
refreshStatesVideo(securityEvent);
|
||||
}
|
||||
if (SecurityGUIEventZrtp.MSG_WARN.equals((String)state.get(SecurityGUIEventZrtp.SESSION_TYPE))) {
|
||||
String text = (String)state.get(SecurityGUIEventZrtp.MSG_TEXT);
|
||||
DisplayPopupMessage popup = new DisplayPopupMessage("ZRTP Security Warning", text);
|
||||
popup.start();
|
||||
}
|
||||
revalidate();
|
||||
}
|
||||
|
||||
private void refreshStatesAudio(SecurityGUIEventZrtp securityEvent) {
|
||||
HashMap<String, Object> state = securityEvent.getStates();
|
||||
|
||||
sessionType.setText("Audio");
|
||||
String sas = (String)state.get(SecurityGUIEventZrtp.SAS);
|
||||
if (sas != null) {
|
||||
// if SAS is provided then this event was sent by the ZRTP master (DH mode)
|
||||
// store this participant for action calls via SecureTelephony operations
|
||||
participant = (CallParticipant)securityEvent.getSource();
|
||||
sasLabel.setText(sas);
|
||||
Boolean verified = (Boolean)state.get(SecurityGUIEventZrtp.SAS_VERIFY);
|
||||
if (verified.booleanValue()) {
|
||||
secButton.setIcon(iconEncrVerified);
|
||||
secButton.setEnabled(true);
|
||||
sasVerified = true;
|
||||
}
|
||||
else {
|
||||
sasVerified = false;
|
||||
}
|
||||
}
|
||||
|
||||
Boolean secure = (Boolean)state.get(SecurityGUIEventZrtp.SECURITY_CHANGE);
|
||||
if (secure != null) {
|
||||
if (secure.booleanValue()) {
|
||||
secButton.setIcon(iconEncr);
|
||||
secButton.setEnabled(true);
|
||||
secMethod.setText((String)state.get(SecurityGUIEventZrtp.CIPHER));
|
||||
notificationService.fireNotification(ZRTP_SECURE);
|
||||
}
|
||||
else {
|
||||
secButton.setIcon(iconEncrDisabled);
|
||||
secButton.setEnabled(false);
|
||||
secMethod.setText("");
|
||||
sasLabel.setText("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshStatesVideo(SecurityGUIEventZrtp securityEvent) {
|
||||
HashMap<String, Object> state = securityEvent.getStates();
|
||||
|
||||
sessionTypeV.setText("Video");
|
||||
String sas = (String)state.get(SecurityGUIEventZrtp.SAS);
|
||||
if (sas != null) {
|
||||
// if SAS is provided then this event was sent by the ZRTP master (DH mode)
|
||||
// store this participant for action calls via SecureTelephony operations
|
||||
participant = (CallParticipant)securityEvent.getSource();
|
||||
sasLabelV.setText(sas);
|
||||
Boolean verified = (Boolean)state.get(SecurityGUIEventZrtp.SAS_VERIFY);
|
||||
if (verified.booleanValue()) {
|
||||
secButtonV.setIcon(iconEncrVerified);
|
||||
}
|
||||
}
|
||||
|
||||
Boolean secure = (Boolean)state.get(SecurityGUIEventZrtp.SECURITY_CHANGE);
|
||||
if (secure != null) {
|
||||
if (secure.booleanValue()) {
|
||||
secButtonV.setIcon(iconEncr);
|
||||
secMethodV.setText((String)state.get(SecurityGUIEventZrtp.CIPHER));
|
||||
}
|
||||
else {
|
||||
secButtonV.setIcon(iconEncrDisabled);
|
||||
secMethodV.setText("");
|
||||
sasLabelV.setText("");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This small thread display messages that are relevant to the end user.
|
||||
* Use an own thread not to block ZRTP processing.
|
||||
*
|
||||
* @author Werner Dittmann <Werner.Dittmann@t-online.de>
|
||||
*
|
||||
*/
|
||||
private class DisplayPopupMessage extends Thread {
|
||||
|
||||
private final PopupDialog popupDialog;
|
||||
private final String message;
|
||||
private final String title;
|
||||
|
||||
DisplayPopupMessage(String title, String message) {
|
||||
|
||||
this.title = title;
|
||||
this.message = message;
|
||||
|
||||
UIService uiService = GuiActivator.getUIService();
|
||||
|
||||
// Obtain the current UI implementation PopupDialog
|
||||
popupDialog = uiService.getPopupDialog();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
popupDialog.showMessagePopupDialog(message, title, PopupDialog.INFORMATION_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,341 +0,0 @@
|
||||
/*
|
||||
* 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.impl.media.transform.zrtp;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.impl.media.CallSessionImpl;
|
||||
import net.java.sip.communicator.impl.media.MediaActivator;
|
||||
import net.java.sip.communicator.service.media.*;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.util.Logger;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.event.*;
|
||||
|
||||
import gnu.java.zrtp.*;
|
||||
|
||||
/**
|
||||
* The user callback class for ZRTP4J.
|
||||
*
|
||||
* This class constructs and sends events to the ZRTP GUI implementation. The
|
||||
* <code>showMessage()<code> function implements a specific check to start
|
||||
* associated ZRTP multi-stream sessions.
|
||||
*
|
||||
* Coordinate this callback class with the associated GUI implementation class
|
||||
* net.java.sip.communicator.impl.gui.main.call.ZrtpPanel
|
||||
*
|
||||
* @see net.java.sip.communicator.impl.gui.main.call.ZrtpPanel
|
||||
*
|
||||
* @author Emanuel Onica
|
||||
* @author Werner Dittmann
|
||||
*
|
||||
*/
|
||||
public class SCCallback extends ZrtpUserCallback {
|
||||
private static final Logger logger = Logger.getLogger(SCCallback.class);
|
||||
|
||||
public static final String WARNING_NO_RS_MATCH = MediaActivator
|
||||
.getResources().getI18NString(
|
||||
"impl.media.security.WARNING_NO_RS_MATCH");
|
||||
|
||||
public static final String WARNING_NO_EXPECTED_RS_MATCH = MediaActivator
|
||||
.getResources().getI18NString(
|
||||
"impl.media.security.WARNING_NO_EXPECTED_RS_MATCH");
|
||||
|
||||
private CallSession callSession = null;
|
||||
|
||||
private SecurityGUIListener guiListener = null;
|
||||
|
||||
private CallParticipant participant;
|
||||
|
||||
/*
|
||||
* Is this a ZRTP DH (Master) session?
|
||||
*/
|
||||
private boolean dhSession = false;
|
||||
|
||||
/*
|
||||
* Type of session. See class SecurityGUIEventZrtp which types are
|
||||
* supported.
|
||||
*/
|
||||
private String sessionType = null;
|
||||
|
||||
/*
|
||||
* Remember the cipher name
|
||||
*/
|
||||
private String cipherName = null;
|
||||
|
||||
/*
|
||||
* Remember the SAS
|
||||
*/
|
||||
private String sasData = null;
|
||||
|
||||
/*
|
||||
* Remember SAS verification state
|
||||
*/
|
||||
private boolean sasVerification = false;
|
||||
|
||||
/**
|
||||
* The class constructor.
|
||||
*/
|
||||
public SCCallback(CallSession callSession) {
|
||||
|
||||
this.callSession = callSession;
|
||||
|
||||
guiListener = callSession.getCall().getSecurityGUIListener("zrtp");
|
||||
Iterator<CallParticipant> participants = callSession.getCall()
|
||||
.getCallParticipants();
|
||||
if (participants.hasNext())
|
||||
participant = participants.next();
|
||||
|
||||
}
|
||||
|
||||
public void init() {
|
||||
SecurityGUIEvent evt = new SecurityGUIEvent(participant,
|
||||
SecurityGUIEvent.NONE, SecurityGUIEvent.SECURITY_ENABLED);
|
||||
|
||||
if (logger.isInfoEnabled())
|
||||
logger.info(sessionType + ": initialize SCCallback");
|
||||
|
||||
fireStateChangedEvent(evt);
|
||||
}
|
||||
|
||||
private void fireStateChangedEvent(SecurityGUIEvent evt) {
|
||||
if (guiListener != null) {
|
||||
guiListener.securityStatusChanged(evt);
|
||||
} else {
|
||||
guiListener = callSession.getCall().getSecurityGUIListener("zrtp");
|
||||
if (guiListener != null) {
|
||||
guiListener.securityStatusChanged(evt);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the type of this session.
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
public void setType(String type) {
|
||||
sessionType = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the DH session flag.
|
||||
*
|
||||
* @param yesNo
|
||||
*/
|
||||
public void setDHSession(boolean yesNo) {
|
||||
dhSession = yesNo;
|
||||
}
|
||||
|
||||
/*
|
||||
* The following methods implement the ZrtpUserCallback interface
|
||||
*/
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see gnu.java.zrtp.ZrtpUserCallback#secureOn(java.lang.String)
|
||||
*/
|
||||
public void secureOn(String cipher) {
|
||||
if (logger.isInfoEnabled())
|
||||
logger.info(sessionType + ": cipher enabled: " + cipher);
|
||||
|
||||
cipherName = cipher;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see gnu.java.zrtp.ZrtpUserCallback#showSAS(java.lang.String, boolean)
|
||||
*/
|
||||
public void showSAS(String sas, boolean verified) {
|
||||
if (logger.isInfoEnabled())
|
||||
logger.info(sessionType + ": SAS is: " + sas);
|
||||
|
||||
sasData = sas;
|
||||
sasVerification = verified;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see gnu.java.zrtp.ZrtpUserCallback#showMessage(
|
||||
* gnu.java.zrtp.ZrtpCodes.MessageSeverity, java.util.EnumSet)
|
||||
*/
|
||||
public void showMessage(ZrtpCodes.MessageSeverity sev, EnumSet<?> subCode) {
|
||||
|
||||
int multiStreams = 0;
|
||||
HashMap<String, Object> state = new HashMap<String, Object>(5);
|
||||
boolean fireEvent = false;
|
||||
|
||||
Iterator<?> ii = subCode.iterator();
|
||||
Object msgCode = ii.next();
|
||||
|
||||
if (sev == ZrtpCodes.MessageSeverity.Info) {
|
||||
if (msgCode instanceof ZrtpCodes.InfoCodes) {
|
||||
ZrtpCodes.InfoCodes inf = (ZrtpCodes.InfoCodes) msgCode;
|
||||
|
||||
// If the ZRTP Master session (DH mode) signals "security on"
|
||||
// then start multi-stream sessions.
|
||||
// Signal SAS to GUI only if this is a DH mode session.
|
||||
// Multi-stream session don't have own SAS data
|
||||
if (inf == ZrtpCodes.InfoCodes.InfoSecureStateOn) {
|
||||
if (dhSession) {
|
||||
multiStreams = ((CallSessionImpl) callSession)
|
||||
.startZrtpMultiStreams();
|
||||
state.put(SecurityGUIEventZrtp.SAS, sasData);
|
||||
if (sasVerification) {
|
||||
state.put(SecurityGUIEventZrtp.SAS_VERIFY,
|
||||
Boolean.TRUE);
|
||||
} else {
|
||||
state.put(SecurityGUIEventZrtp.SAS_VERIFY,
|
||||
Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
state.put(SecurityGUIEventZrtp.SESSION_TYPE, sessionType);
|
||||
state.put(SecurityGUIEventZrtp.SECURITY_CHANGE,
|
||||
Boolean.TRUE);
|
||||
state.put(SecurityGUIEventZrtp.CIPHER, cipherName);
|
||||
fireEvent = true;
|
||||
}
|
||||
|
||||
if (inf == ZrtpCodes.InfoCodes.InfoHelloReceived) {
|
||||
state.put(SecurityGUIEventZrtp.SESSION_TYPE,
|
||||
SecurityGUIEventZrtp.MSG_INFO);
|
||||
fireEvent = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Warning codes usually do not affect encryption or security. Onl
|
||||
* in few cases inform the user and ask to verify SAS
|
||||
*/
|
||||
if (sev == ZrtpCodes.MessageSeverity.Warning) {
|
||||
if (msgCode instanceof ZrtpCodes.WarningCodes) {
|
||||
ZrtpCodes.WarningCodes warn = (ZrtpCodes.WarningCodes) msgCode;
|
||||
|
||||
if (warn == ZrtpCodes.WarningCodes.WarningNoRSMatch) {
|
||||
state.put(SecurityGUIEventZrtp.SESSION_TYPE,
|
||||
SecurityGUIEventZrtp.MSG_WARN);
|
||||
state.put(SecurityGUIEventZrtp.MSG_TEXT,
|
||||
WARNING_NO_RS_MATCH);
|
||||
fireEvent = true;
|
||||
}
|
||||
if (warn == ZrtpCodes.WarningCodes.WarningNoExpectedRSMatch) {
|
||||
state.put(SecurityGUIEventZrtp.SESSION_TYPE,
|
||||
SecurityGUIEventZrtp.MSG_WARN);
|
||||
state.put(SecurityGUIEventZrtp.MSG_TEXT,
|
||||
WARNING_NO_EXPECTED_RS_MATCH);
|
||||
fireEvent = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Severe or ZRTP error codes always signal that security cannot be established.
|
||||
* Inform the user about this.
|
||||
*/
|
||||
if (sev == ZrtpCodes.MessageSeverity.Severe) {
|
||||
String[] param = new String[1];
|
||||
param[0] = msgCode.toString();
|
||||
String msg = MediaActivator
|
||||
.getResources().getI18NString(
|
||||
"impl.media.security.SEVERE_GENERIC_MSG", param);
|
||||
|
||||
state.put(SecurityGUIEventZrtp.SESSION_TYPE,
|
||||
SecurityGUIEventZrtp.MSG_SEVERE);
|
||||
state.put(SecurityGUIEventZrtp.MSG_TEXT, msg);
|
||||
fireEvent = true;
|
||||
}
|
||||
|
||||
|
||||
if (sev == ZrtpCodes.MessageSeverity.ZrtpError) {
|
||||
String[] param = new String[1];
|
||||
param[0] = msgCode.toString();
|
||||
String msg = MediaActivator
|
||||
.getResources().getI18NString(
|
||||
"impl.media.security.ZRTP_GENERIC_MSG", param);
|
||||
|
||||
state.put(SecurityGUIEventZrtp.SESSION_TYPE,
|
||||
SecurityGUIEventZrtp.MSG_ZRTP);
|
||||
state.put(SecurityGUIEventZrtp.MSG_TEXT, msg);
|
||||
fireEvent = true;
|
||||
}
|
||||
|
||||
if (fireEvent) {
|
||||
SecurityGUIEventZrtp evt = new SecurityGUIEventZrtp(participant,
|
||||
state);
|
||||
fireStateChangedEvent(evt);
|
||||
}
|
||||
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info(sessionType + ": " + "ZRTP message: severity: " + sev
|
||||
+ ", sub code: " + msgCode + ", DH session: " + dhSession
|
||||
+ ", multi: " + multiStreams);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see gnu.java.zrtp.ZrtpUserCallback#zrtpNegotiationFailed(
|
||||
* gnu.java.zrtp.ZrtpCodes.MessageSeverity, java.util.EnumSet)
|
||||
*/
|
||||
public void zrtpNegotiationFailed(ZrtpCodes.MessageSeverity severity,
|
||||
EnumSet<?> subCode) {
|
||||
Iterator<?> ii = subCode.iterator();
|
||||
Object msgCode = ii.next();
|
||||
|
||||
if (logger.isInfoEnabled())
|
||||
logger.warn(sessionType
|
||||
+ ": ZRTP key negotiation failed, sub code: " + msgCode);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see gnu.java.zrtp.ZrtpUserCallback#secureOff()
|
||||
*/
|
||||
public void secureOff() {
|
||||
if (logger.isInfoEnabled())
|
||||
logger.info(sessionType + ": Security off");
|
||||
|
||||
HashMap<String, Object> state = new HashMap<String, Object>(2);
|
||||
|
||||
state
|
||||
.put(SecurityGUIEventZrtp.SESSION_TYPE,
|
||||
SecurityGUIEventZrtp.AUDIO);
|
||||
state.put(SecurityGUIEventZrtp.SECURITY_CHANGE, Boolean.FALSE);
|
||||
|
||||
SecurityGUIEventZrtp evt = new SecurityGUIEventZrtp(participant, state);
|
||||
fireStateChangedEvent(evt);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see gnu.java.zrtp.ZrtpUserCallback#zrtpNotSuppOther()
|
||||
*/
|
||||
public void zrtpNotSuppOther() {
|
||||
if (logger.isInfoEnabled())
|
||||
logger
|
||||
.info(sessionType
|
||||
+ ": Other party does not support ZRTP key negotiation protocol, no secure calls possible");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see gnu.java.zrtp.ZrtpUserCallback#confirmGoClear()
|
||||
*/
|
||||
public void confirmGoClear() {
|
||||
if (logger.isInfoEnabled())
|
||||
logger.info(sessionType + ": GoClear confirmation requested");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,333 @@
|
||||
/*
|
||||
* 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.impl.media.transform.zrtp;
|
||||
|
||||
import gnu.java.zrtp.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.impl.media.*;
|
||||
import net.java.sip.communicator.service.media.*;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.service.protocol.event.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
/**
|
||||
* The user callback class for ZRTP4J.
|
||||
*
|
||||
* This class constructs and sends events to the ZRTP GUI implementation. The
|
||||
* <code>showMessage()<code> function implements a specific check to start
|
||||
* associated ZRTP multi-stream sessions.
|
||||
*
|
||||
* Coordinate this callback class with the associated GUI implementation class
|
||||
* net.java.sip.communicator.impl.gui.main.call.ZrtpPanel
|
||||
*
|
||||
* @see net.java.sip.communicator.impl.gui.main.call.SecurityPanel
|
||||
*
|
||||
* @author Emanuel Onica
|
||||
* @author Werner Dittmann
|
||||
* @author Yana Stamcheva
|
||||
*
|
||||
*/
|
||||
public class SecurityEventManager extends ZrtpUserCallback
|
||||
{
|
||||
private static final Logger logger
|
||||
= Logger.getLogger(SecurityEventManager.class);
|
||||
|
||||
public static final String WARNING_NO_RS_MATCH = MediaActivator
|
||||
.getResources().getI18NString(
|
||||
"impl.media.security.WARNING_NO_RS_MATCH");
|
||||
|
||||
public static final String WARNING_NO_EXPECTED_RS_MATCH = MediaActivator
|
||||
.getResources().getI18NString(
|
||||
"impl.media.security.WARNING_NO_EXPECTED_RS_MATCH");
|
||||
|
||||
private CallParticipant callParticipant;
|
||||
|
||||
private CallSession callSession;
|
||||
|
||||
/**
|
||||
* Is this a ZRTP DH (Master) session?
|
||||
*/
|
||||
private boolean isDHSession = false;
|
||||
|
||||
/**
|
||||
* Type of session
|
||||
*/
|
||||
private String sessionType;
|
||||
|
||||
/**
|
||||
* SAS string.
|
||||
*/
|
||||
private String sas;
|
||||
|
||||
/**
|
||||
* Cipher.
|
||||
*/
|
||||
private String cipher;
|
||||
|
||||
/**
|
||||
* Indicates if the SAS has already been verified in a previous session.
|
||||
*/
|
||||
private boolean isSasVerified;
|
||||
|
||||
/**
|
||||
* The class constructor.
|
||||
*/
|
||||
public SecurityEventManager(CallSession callSession)
|
||||
{
|
||||
this.callSession = callSession;
|
||||
|
||||
// At this moment we're supporting a security call between only two
|
||||
// participants. In the future the call participant would be passed
|
||||
// as a parameter to the SecurityEventManager.
|
||||
Iterator<CallParticipant> callParticipants
|
||||
= callSession.getCall().getCallParticipants();
|
||||
|
||||
while (callParticipants.hasNext())
|
||||
{
|
||||
this.callParticipant = callParticipants.next();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the type of this session.
|
||||
*
|
||||
* @param type the session type. The session type could be either
|
||||
* CallSessionImpl.AUDIO_SESSION or CallSessionImpl.VIDEO_SESSION.
|
||||
*/
|
||||
public void setSessionType(String type)
|
||||
{
|
||||
if (type.equals(CallSessionImpl.AUDIO_SESSION))
|
||||
sessionType = CallParticipantSecurityStatusEvent.AUDIO_SESSION;
|
||||
else if (type.equals(CallSessionImpl.VIDEO_SESSION))
|
||||
sessionType = CallParticipantSecurityStatusEvent.VIDEO_SESSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the DH session flag.
|
||||
*
|
||||
* @param isDHSession the DH session flag.
|
||||
*/
|
||||
public void setDHSession(boolean isDHSession)
|
||||
{
|
||||
this.isDHSession = isDHSession;
|
||||
}
|
||||
|
||||
/*
|
||||
* The following methods implement the ZrtpUserCallback interface
|
||||
*/
|
||||
|
||||
/**
|
||||
* Reports the security algorithm that the ZRTP protocol negotiated.
|
||||
*
|
||||
* @see gnu.java.zrtp.ZrtpUserCallback#secureOn(java.lang.String)
|
||||
*/
|
||||
public void secureOn(String cipher)
|
||||
{
|
||||
if (logger.isInfoEnabled())
|
||||
logger.info(sessionType + ": cipher enabled: " + cipher);
|
||||
|
||||
this.cipher = cipher;
|
||||
}
|
||||
|
||||
/**
|
||||
* ZRTP computes the SAS string after nearly all the negotiation
|
||||
* and computations are done internally.
|
||||
*
|
||||
* @see gnu.java.zrtp.ZrtpUserCallback#showSAS(java.lang.String, boolean)
|
||||
*/
|
||||
public void showSAS(String sas, boolean isVerified)
|
||||
{
|
||||
if (logger.isInfoEnabled())
|
||||
logger.info(sessionType + ": SAS is: " + sas);
|
||||
|
||||
this.sas = sas;
|
||||
this.isSasVerified = isVerified;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see gnu.java.zrtp.ZrtpUserCallback#showMessage(
|
||||
* gnu.java.zrtp.ZrtpCodes.MessageSeverity, java.util.EnumSet)
|
||||
*/
|
||||
public void showMessage(ZrtpCodes.MessageSeverity sev,
|
||||
EnumSet<?> subCode)
|
||||
{
|
||||
int multiStreams = 0;
|
||||
|
||||
Iterator<?> ii = subCode.iterator();
|
||||
Object msgCode = ii.next();
|
||||
|
||||
String messageType = null;
|
||||
String message = null;
|
||||
String i18nMessage = null;
|
||||
|
||||
if (msgCode instanceof ZrtpCodes.InfoCodes)
|
||||
{
|
||||
ZrtpCodes.InfoCodes inf = (ZrtpCodes.InfoCodes) msgCode;
|
||||
|
||||
// If the ZRTP Master session (DH mode) signals "security on"
|
||||
// then start multi-stream sessions.
|
||||
// Signal SAS to GUI only if this is a DH mode session.
|
||||
// Multi-stream session don't have own SAS data
|
||||
if (inf == ZrtpCodes.InfoCodes.InfoSecureStateOn)
|
||||
{
|
||||
if (isDHSession)
|
||||
{
|
||||
multiStreams = ((CallSessionImpl) callSession)
|
||||
.startZrtpMultiStreams();
|
||||
|
||||
((AbstractCallParticipant) callParticipant)
|
||||
.setSecurityOn( true,
|
||||
sessionType,
|
||||
cipher,
|
||||
sas,
|
||||
isSasVerified);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (msgCode instanceof ZrtpCodes.WarningCodes)
|
||||
{
|
||||
// Warning codes usually do not affect encryption or security. Only
|
||||
// in few cases inform the user and ask to verify SAS.
|
||||
ZrtpCodes.WarningCodes warn = (ZrtpCodes.WarningCodes) msgCode;
|
||||
|
||||
if (warn == ZrtpCodes.WarningCodes.WarningNoRSMatch)
|
||||
{
|
||||
messageType = CallParticipantSecurityMessageEvent
|
||||
.SECURITY_AUTHENTICATION_REQUIRED;
|
||||
message = "No retained shared secret available.";
|
||||
i18nMessage = WARNING_NO_RS_MATCH;
|
||||
}
|
||||
else if (warn == ZrtpCodes.WarningCodes.WarningNoExpectedRSMatch)
|
||||
{
|
||||
messageType = CallParticipantSecurityMessageEvent
|
||||
.RETAINED_SECURITY_AUTHENTICATION_FAILED;
|
||||
message = "An expected retained shared secret is missing.";
|
||||
i18nMessage = WARNING_NO_EXPECTED_RS_MATCH;
|
||||
}
|
||||
else if (warn == ZrtpCodes.WarningCodes.WarningCRCmismatch)
|
||||
{
|
||||
messageType = CallParticipantSecurityMessageEvent
|
||||
.CHECKSUM_MISMATCH;
|
||||
message = "Internal ZRTP packet checksum mismatch.";
|
||||
i18nMessage = MediaActivator.getResources().getI18NString(
|
||||
"impl.media.security.CHECKSUM_MISMATCH");
|
||||
}
|
||||
}
|
||||
else if (msgCode instanceof ZrtpCodes.SevereCodes)
|
||||
{
|
||||
ZrtpCodes.SevereCodes severe = (ZrtpCodes.SevereCodes) msgCode;
|
||||
|
||||
if (severe == ZrtpCodes.SevereCodes.SevereCannotSend)
|
||||
{
|
||||
messageType = CallParticipantSecurityMessageEvent
|
||||
.DATA_SEND_FAILED;
|
||||
message = "Failed to send data."
|
||||
+ "Internet data connection or peer is down.";
|
||||
i18nMessage = MediaActivator.getResources().getI18NString(
|
||||
"impl.media.security.DATA_SEND_FAILED",
|
||||
new String[]{msgCode.toString()});
|
||||
}
|
||||
else if (severe == ZrtpCodes.SevereCodes.SevereTooMuchRetries)
|
||||
{
|
||||
messageType = CallParticipantSecurityMessageEvent
|
||||
.RETRY_RATE_EXCEEDED;
|
||||
message = "Too much retries during ZRTP negotiation.";
|
||||
i18nMessage = MediaActivator.getResources().getI18NString(
|
||||
"impl.media.security.RETRY_RATE_EXCEEDED",
|
||||
new String[]{msgCode.toString()});
|
||||
}
|
||||
else if (severe == ZrtpCodes.SevereCodes.SevereProtocolError)
|
||||
{
|
||||
messageType = CallParticipantSecurityMessageEvent
|
||||
.INTERNAL_PROTOCOL_ERROR;
|
||||
message = "Internal protocol error occured.";
|
||||
i18nMessage = MediaActivator.getResources().getI18NString(
|
||||
"impl.media.security.INTERNAL_PROTOCOL_ERROR",
|
||||
new String[]{msgCode.toString()});
|
||||
}
|
||||
else
|
||||
{
|
||||
messageType = CallParticipantSecurityMessageEvent.GENERAL_ERROR;
|
||||
message = "General error has occurred.";
|
||||
i18nMessage = MediaActivator.getResources().getI18NString(
|
||||
"impl.media.security.ZRTP_GENERIC_MSG",
|
||||
new String[]{msgCode.toString()});
|
||||
}
|
||||
}
|
||||
else if (msgCode instanceof ZrtpCodes.ZrtpErrorCodes)
|
||||
{
|
||||
messageType = CallParticipantSecurityMessageEvent.NOT_COMPATIBLE;
|
||||
message = "Indicates compatibility problems like for example:"
|
||||
+ "unsupported protocol version, unsupported hash type,"
|
||||
+ "cypher type, SAS scheme, etc.";
|
||||
i18nMessage = MediaActivator.getResources().getI18NString(
|
||||
"impl.media.security.ZRTP_GENERIC_MSG",
|
||||
new String[]{msgCode.toString()});
|
||||
}
|
||||
|
||||
if (messageType != null)
|
||||
((AbstractCallParticipant) callParticipant)
|
||||
.setSecurityMessage(messageType, message, i18nMessage);
|
||||
|
||||
if (logger.isInfoEnabled())
|
||||
{
|
||||
logger.info(sessionType + ": " + "ZRTP message: severity: " + sev
|
||||
+ ", sub code: " + msgCode + ", DH session: " + isDHSession
|
||||
+ ", multi: " + multiStreams);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see gnu.java.zrtp.ZrtpUserCallback#zrtpNegotiationFailed(
|
||||
* gnu.java.zrtp.ZrtpCodes.MessageSeverity, java.util.EnumSet)
|
||||
*/
|
||||
public void zrtpNegotiationFailed( ZrtpCodes.MessageSeverity severity,
|
||||
EnumSet<?> subCode)
|
||||
{
|
||||
Iterator<?> ii = subCode.iterator();
|
||||
Object msgCode = ii.next();
|
||||
|
||||
if (logger.isInfoEnabled())
|
||||
logger.info(sessionType
|
||||
+ ": ZRTP key negotiation failed, sub code: " + msgCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see gnu.java.zrtp.ZrtpUserCallback#secureOff()
|
||||
*/
|
||||
public void secureOff()
|
||||
{
|
||||
if (logger.isInfoEnabled())
|
||||
logger.info(sessionType + ": Security off");
|
||||
|
||||
((AbstractCallParticipant) callParticipant)
|
||||
.setSecurityOff(sessionType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see gnu.java.zrtp.ZrtpUserCallback#zrtpNotSuppOther()
|
||||
*/
|
||||
public void zrtpNotSuppOther()
|
||||
{
|
||||
if (logger.isInfoEnabled())
|
||||
logger.info(sessionType
|
||||
+ ": Other party does not support ZRTP key negotiation protocol,"
|
||||
+ " no secure calls possible.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see gnu.java.zrtp.ZrtpUserCallback#confirmGoClear()
|
||||
*/
|
||||
public void confirmGoClear()
|
||||
{
|
||||
if (logger.isInfoEnabled())
|
||||
logger.info(sessionType + ": GoClear confirmation requested.");
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.service.protocol.event;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
/**
|
||||
* CallParticipantSecurityListener interface extends EventListener. This is the
|
||||
* listener interface used to handle an event related with a change in security
|
||||
* status.
|
||||
*
|
||||
* The change in security status is triggered at the protocol level, which
|
||||
* signal security state changes to the GUI. This modifies the current security
|
||||
* status indicator for the call sessions.
|
||||
*
|
||||
* @author Werner Dittmann
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
|
||||
public interface CallParticipantSecurityListener extends EventListener
|
||||
{
|
||||
/**
|
||||
* The handler for the security event received. The security event
|
||||
* represents an indication of change in the security status.
|
||||
*
|
||||
* @param securityEvent
|
||||
* the security event received
|
||||
*/
|
||||
public void securityOn(
|
||||
CallParticipantSecurityOnEvent securityEvent);
|
||||
|
||||
/**
|
||||
* The handler for the security event received. The security event
|
||||
* represents an indication of change in the security status.
|
||||
*
|
||||
* @param securityEvent
|
||||
* the security event received
|
||||
*/
|
||||
public void securityOff(
|
||||
CallParticipantSecurityOffEvent securityEvent);
|
||||
|
||||
/**
|
||||
* The handler of the security message event.
|
||||
*
|
||||
* @param event the security message event.
|
||||
*/
|
||||
public void securityMessageRecieved(
|
||||
CallParticipantSecurityMessageEvent event);
|
||||
}
|
||||
@ -0,0 +1,168 @@
|
||||
/*
|
||||
* 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.service.protocol.event;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
|
||||
/**
|
||||
* The <tt>CallParticipantSecurityFailedEvent</tt> is triggered whenever
|
||||
* a problem has occurred during call security process.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class CallParticipantSecurityMessageEvent
|
||||
extends EventObject
|
||||
{
|
||||
/**
|
||||
* Indicates that no retained shared secrets are available. The user shall
|
||||
* must verify security strings with the other party.
|
||||
*/
|
||||
public static final String SECURITY_AUTHENTICATION_REQUIRED
|
||||
= "SecurityAuthenticationRequired";
|
||||
|
||||
/**
|
||||
* Indicates that shared secrets retained during previous sessions did not
|
||||
* offer valid identifiers. This can happen if the other party uses another
|
||||
* client software or lost its stored shared secrets. In rare case this
|
||||
* could also signal a Man-In-The-Middle (MITM) attack. Therefore the user
|
||||
* shall must verify the SAS with the other party to prove the correct
|
||||
* exchange ZRTP data.
|
||||
*/
|
||||
public static final String RETAINED_SECURITY_AUTHENTICATION_FAILED
|
||||
= "RetainedSecurityAuthenticationFailed";
|
||||
|
||||
/**
|
||||
* Indicates an internal encryption packet checksum mismatch. In other words
|
||||
* the packet was dropped. If this happens often this may indicate a bad
|
||||
* connection that corrupts data during transmission. In rare cases and if
|
||||
* it happens regularly this could also signal a denial-of-serice attack.
|
||||
*/
|
||||
public static final String CHECKSUM_MISMATCH = "CheckSumMismatch";
|
||||
|
||||
/**
|
||||
* Indicates dropping packet because SRTP authentication failed. This may
|
||||
* happen if the data was corrupted during transmission or during the very
|
||||
* first packets after switching to secure mode. In rare cases and if this
|
||||
* happens later during a secure session this could also signal a
|
||||
* denial-of-serice attack.
|
||||
*/
|
||||
public static final String AUTHENTICATION_FAILED = "AuthenticationFailed";
|
||||
|
||||
/**
|
||||
* Indicates dropping packet because SRTP replay check failed. A duplicate
|
||||
* SRTP packet was detected. This may happen if the data was corrupted
|
||||
* during transmission. In rare cases and if this happens later during a
|
||||
* secure session this could also signal a denial-of-serice attack.
|
||||
*/
|
||||
public static final String REPLAY_CHECK_FAILED = "ReplayCheckFailed";
|
||||
|
||||
/**
|
||||
* Indicates too much retries during security negotiation. This may happen
|
||||
* if the other party stops to proceed the handshake. Usually if Internet
|
||||
* connection is lost or the peer has some problems.
|
||||
*/
|
||||
public static final String RETRY_RATE_EXCEEDED = "RetryRateExceeded";
|
||||
|
||||
/**
|
||||
* Indicates that data cannot be send. Internet data connection or peer is
|
||||
* down.
|
||||
*/
|
||||
public static final String DATA_SEND_FAILED = "DataSendFailed";
|
||||
|
||||
/**
|
||||
* Indicates that an internal protocol error occurred. Usually some sort of
|
||||
* software problem.
|
||||
*/
|
||||
public static final String INTERNAL_PROTOCOL_ERROR = "InternalProtocolError";
|
||||
|
||||
/**
|
||||
* Indicates compatibility problems like for example: unsupported protocol
|
||||
* version, unsupported hash type, cypher type, SAS scheme, etc.
|
||||
*/
|
||||
public static final String NOT_COMPATIBLE = "NotCompatible";
|
||||
|
||||
/**
|
||||
* Indicates that the other party doesn't support the encryption algorithm
|
||||
* we're using or encryption at all.
|
||||
*/
|
||||
public static final String NOT_SUPPORTED = "NotSupported";
|
||||
|
||||
/**
|
||||
* Indicates that a general error has occurred.
|
||||
*/
|
||||
public static final String GENERAL_ERROR = "GeneralError";
|
||||
|
||||
/**
|
||||
* One of the event types defined in this class.
|
||||
*/
|
||||
private String eventType;
|
||||
|
||||
/**
|
||||
* The message associated with this event.
|
||||
*/
|
||||
private String eventMessage;
|
||||
|
||||
/**
|
||||
* The internationalized message associated with this event.
|
||||
*/
|
||||
private String eventI18nMessage;
|
||||
|
||||
/**
|
||||
* Creates a <tt>CallParticipantSecurityFailedEvent</tt> by specifying the
|
||||
* call participant, event type and message associated with this event.
|
||||
*
|
||||
* @param callParticipant the call participant implied in this event.
|
||||
* @param eventType the type of the event. One of the constants defined in
|
||||
* this class.
|
||||
* @param eventMessage the message associated with this event.
|
||||
* @param i18nMessage the internationalized message associated with this
|
||||
* event that could be shown to the user.
|
||||
*/
|
||||
public CallParticipantSecurityMessageEvent( CallParticipant callParticipant,
|
||||
String eventType,
|
||||
String eventMessage,
|
||||
String i18nMessage)
|
||||
{
|
||||
super(callParticipant);
|
||||
|
||||
this.eventType = eventType;
|
||||
this.eventMessage = eventMessage;
|
||||
this.eventI18nMessage = i18nMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of this event.
|
||||
*
|
||||
* @return the type of this event.
|
||||
*/
|
||||
public String getType()
|
||||
{
|
||||
return eventType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the message associated with this event.
|
||||
*
|
||||
* @return the message associated with this event.
|
||||
*/
|
||||
public String getMessage()
|
||||
{
|
||||
return eventMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the internationalized message associated with this event.
|
||||
*
|
||||
* @return the internationalized message associated with this event.
|
||||
*/
|
||||
public String getI18nMessage()
|
||||
{
|
||||
return eventI18nMessage;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.service.protocol.event;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
|
||||
/**
|
||||
* The <tt>CallParticipantSecurityAuthenticationEvent</tt> is triggered whenever
|
||||
* a the security strings are received in a secure call.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class CallParticipantSecurityOffEvent
|
||||
extends CallParticipantSecurityStatusEvent
|
||||
{
|
||||
private final String sessionType;
|
||||
|
||||
/**
|
||||
* The event constructor.
|
||||
*
|
||||
* @param callParticipant
|
||||
* the call participant associated with this event
|
||||
* @param sessionType
|
||||
* the type of the session: audio or video
|
||||
*/
|
||||
public CallParticipantSecurityOffEvent( CallParticipant callParticipant,
|
||||
String sessionType)
|
||||
{
|
||||
super(callParticipant);
|
||||
|
||||
this.sessionType = sessionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the session, either AUDIO_SESSION or VIDEO_SESSION.
|
||||
*
|
||||
* @return the type of the session, either AUDIO_SESSION or VIDEO_SESSION.
|
||||
*/
|
||||
public String getSessionType()
|
||||
{
|
||||
return sessionType;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 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.service.protocol.event;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
|
||||
/**
|
||||
* The <tt>CallParticipantSecurityOnEvent</tt> is triggered whenever a
|
||||
* communication with a given participant is going secure.
|
||||
*
|
||||
* @author Werner Dittmann
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class CallParticipantSecurityOnEvent
|
||||
extends CallParticipantSecurityStatusEvent
|
||||
{
|
||||
private final String sessionType;
|
||||
|
||||
private String securityString;
|
||||
|
||||
private boolean isVerified;
|
||||
|
||||
private String cipher;
|
||||
|
||||
/**
|
||||
* The event constructor
|
||||
*
|
||||
* @param callParticipant
|
||||
* the call participant associated with this event
|
||||
* @param sessionType
|
||||
* the type of the session, either AUDIO_SESSION or VIDEO_SESSION
|
||||
* @param cipher
|
||||
* the cipher used for the encryption
|
||||
* @param securityString
|
||||
* the security string (SAS)
|
||||
* @param isVerified
|
||||
* indicates if the security string has already been verified
|
||||
*/
|
||||
public CallParticipantSecurityOnEvent(
|
||||
CallParticipant callParticipant,
|
||||
String sessionType,
|
||||
String cipher,
|
||||
String securityString,
|
||||
boolean isVerified)
|
||||
{
|
||||
super(callParticipant);
|
||||
|
||||
this.sessionType = sessionType;
|
||||
this.cipher = cipher;
|
||||
this.securityString = securityString;
|
||||
this.isVerified = isVerified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>CallParticipant</tt> for which this event occurred.
|
||||
*
|
||||
* @return the <tt>CallParticipant</tt> for which this event occurred.
|
||||
*/
|
||||
public CallParticipant getCallParticipant()
|
||||
{
|
||||
return (CallParticipant) getSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the session, either AUDIO_SESSION or VIDEO_SESSION.
|
||||
*
|
||||
* @return the type of the session, either AUDIO_SESSION or VIDEO_SESSION.
|
||||
*/
|
||||
public String getSessionType()
|
||||
{
|
||||
return sessionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cipher used for the encryption.
|
||||
*
|
||||
* @return the cipher used for the encryption.
|
||||
*/
|
||||
public String getCipher()
|
||||
{
|
||||
return cipher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the security string.
|
||||
*
|
||||
* @return the security string.
|
||||
*/
|
||||
public String getSecurityString()
|
||||
{
|
||||
return securityString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the security string was already verified
|
||||
* and <code>false</code> - otherwise.
|
||||
*
|
||||
* @return <code>true</code> if the security string was already verified
|
||||
* and <code>false</code> - otherwise.
|
||||
*/
|
||||
public boolean isSecurityVerified()
|
||||
{
|
||||
return isVerified;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.service.protocol.event;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Parent class for SecurityOn and SecurityOff events.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public abstract class CallParticipantSecurityStatusEvent
|
||||
extends EventObject
|
||||
{
|
||||
/**
|
||||
* Constant value defining that security is enabled.
|
||||
*/
|
||||
public static final String AUDIO_SESSION = "AUDIO_SESSION";
|
||||
|
||||
/**
|
||||
* Constant value defining that security is disabled.
|
||||
*/
|
||||
public static final String VIDEO_SESSION = "VIDEO_SESSION";
|
||||
|
||||
/**
|
||||
* Constructor required by the EventObject.
|
||||
*
|
||||
* @param source the source object for this event.
|
||||
*/
|
||||
public CallParticipantSecurityStatusEvent(Object source)
|
||||
{
|
||||
super(source);
|
||||
}
|
||||
}
|
||||
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* 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.service.protocol.event;
|
||||
|
||||
import java.util.EventObject;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.CallParticipant;
|
||||
|
||||
public class SecurityGUIEvent extends EventObject {
|
||||
|
||||
/**
|
||||
* Default
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constant value defining that security status changed.
|
||||
*/
|
||||
public static final int STATUS_CHANGE = 1;
|
||||
|
||||
/**
|
||||
* Constant value defining that security is enabled.
|
||||
*/
|
||||
public static final int SECURITY_ENABLED = 2;
|
||||
|
||||
/**
|
||||
* The actual event value
|
||||
*/
|
||||
private final int eventID;
|
||||
|
||||
/**
|
||||
* Constant value defining the key share provider .
|
||||
*/
|
||||
public static final int NONE = 0;
|
||||
|
||||
public static final int ZRTP = 1;
|
||||
|
||||
private final int provider;
|
||||
|
||||
|
||||
/**
|
||||
* The event constructor
|
||||
*
|
||||
* @param callSession
|
||||
* the event source - the call session for which this event
|
||||
* applies
|
||||
* @param eventID
|
||||
* the change value - going secure or stopping secure
|
||||
* communication
|
||||
*/
|
||||
public SecurityGUIEvent(CallParticipant part,
|
||||
int prov, int eventID) {
|
||||
super(part);
|
||||
this.eventID = eventID;
|
||||
this.provider = prov;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the eventID
|
||||
*/
|
||||
public int getEventID() {
|
||||
return eventID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the provider
|
||||
*/
|
||||
public int getProvider() {
|
||||
return provider;
|
||||
}
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* 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.service.protocol.event;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.CallParticipant;
|
||||
|
||||
|
||||
public class SecurityGUIEventZrtp extends SecurityGUIEvent {
|
||||
|
||||
/**
|
||||
* Default
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* ZRTP security state change actions
|
||||
*/
|
||||
|
||||
public final static String CIPHER = "cipherName";
|
||||
public final static String SECURITY_CHANGE = "secure";
|
||||
public final static String SAS = "sas";
|
||||
public final static String SAS_VERIFY = "sasVerify";
|
||||
public final static String SESSION_TYPE = "type";
|
||||
public final static String AUDIO = "Audio";
|
||||
public final static String VIDEO = "Video";
|
||||
|
||||
public final static String MSG_INFO = "Info";
|
||||
public final static String MSG_WARN = "Warn";
|
||||
public final static String MSG_SEVERE = "Severe";
|
||||
public final static String MSG_ZRTP = "Zrtp";
|
||||
|
||||
public final static String MSG_TEXT = "Msg";
|
||||
|
||||
private final HashMap<String, Object> states;
|
||||
|
||||
public SecurityGUIEventZrtp(CallParticipant part,
|
||||
HashMap<String, Object> states) {
|
||||
super(part, SecurityGUIEvent.ZRTP, SecurityGUIEvent.STATUS_CHANGE);
|
||||
this.states = states;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the states
|
||||
*/
|
||||
public HashMap<String, Object> getStates() {
|
||||
return states;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* 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.service.protocol.event;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
/**
|
||||
* SecureEventListener interface extends EventListener This is the listener
|
||||
* interface used to handle an event related with a change in security status.
|
||||
*
|
||||
* The change in security status is triggered at the protocol level, which
|
||||
* signal security state changes to the GUI. This modifies the current security
|
||||
* status indicator for the call sessions.
|
||||
*
|
||||
*/
|
||||
|
||||
public interface SecurityGUIListener extends EventListener {
|
||||
|
||||
/**
|
||||
* The handler for the security event received. The security event represents an
|
||||
* indication of change in the security status.
|
||||
*
|
||||
* @param securityEvent
|
||||
* the securityEvent received
|
||||
*/
|
||||
public void securityStatusChanged(SecurityGUIEvent securityEvent);
|
||||
}
|
||||