Committed the rest of the ZRTP implementation from Emanuel Onica:

- added the secure button on the call panel
- added a new operation set for secure call
- removed implementation of the secure mode from jabber/mock
cusax-fix
Romain Kuntz 18 years ago
parent 45389d1fc1
commit e7e71f8c1b

@ -137,7 +137,7 @@ public CallPanel(String contactString, String callType)
}
/**
* Cteates and adds a panel for a call participant.
* Creates and adds a panel for a call participant.
*
* @param participantName the call participant name
* @param callType the type of call: INCOMING or OUTGOING
@ -164,7 +164,7 @@ private CallParticipantPanel addCallParticipant(String participantName,
}
/**
* Cteates and adds a panel for a call participant.
* Creates and adds a panel for a call participant.
*
* @param participant the call participant
* @param callType the type of call - INCOMING of OUTGOING

@ -15,6 +15,7 @@
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.impl.gui.i18n.*;
/**
* The <tt>CallParticipantPanel</tt> is the panel containing data for a call
@ -39,7 +40,9 @@ public class CallParticipantPanel
private JLabel photoLabel = new JLabel(new ImageIcon(
ImageLoader.getImage(ImageLoader.DEFAULT_USER_PHOTO)));
private JLabel secureLabel = new JLabel("Not in call", JLabel.CENTER);
private JPanel northPanel = new JPanel();
private Date callStartTime;
@ -55,7 +58,7 @@ public class CallParticipantPanel
private String participantName;
private CallParticipant callParticipant;
/**
* Creates a <tt>CallParticipantPanel</tt> for the given call participant.
*
@ -67,22 +70,66 @@ public CallParticipantPanel(CallParticipant callParticipant)
this(callParticipant.getAddress());
this.callParticipant = callParticipant;
this.stateLabel.setText(callParticipant.getState().getStateString());
Component holdButton = new HoldButton(this.callParticipant);
holdButton.setBounds(9, 74, 36, 36);
contactPanel.add(holdButton, new Integer(1));
Component muteButton = new MuteButton(this.callParticipant);
muteButton.setBounds(45, 74, 36, 36);
contactPanel.add(muteButton, new Integer(1));
Component transferCallButton = createTransferCallButton();
if (transferCallButton != null)
Component secureButton = createSecureCallButton();
if (secureButton != null)
{
transferCallButton.setBounds(81, 74, 36, 36);
contactPanel.add(transferCallButton, new Integer(1));
holdButton.setBounds(3, 74, 36, 36);
muteButton.setBounds(39, 74, 36, 36);
contactPanel.add(holdButton, new Integer(1));
contactPanel.add(muteButton, new Integer(1));
if (transferCallButton != null)
{
transferCallButton.setBounds(75, 74, 36, 36);
contactPanel.add(transferCallButton, new Integer(1));
}
secureButton.setName("secureButton");
secureButton.setBounds(111, 74, 36, 36);
((JButton)secureButton).setActionCommand("startSecureMode");
((JButton)secureButton).setToolTipText(Messages.
getI18NString("toggleOnSecurity").getText());
contactPanel.add(secureButton, new Integer(1));
this.secureLabel.setName("secureLabel");
callParticipant.getCall().addSecureGUIComponent(secureButton.getName(),
secureButton);
callParticipant.getCall().addSecureGUIComponent(secureLabel.getName(),
secureLabel);
secureLabel.setPreferredSize(new Dimension(110, 50));
secureLabel.setBorder(BorderFactory.createLineBorder(Color.BLUE));
secureLabel.setToolTipText(Messages.
getI18NString("defaultSASMessage").getText());
namePanel.add(secureLabel);
// Resizing some items
contactPanel.setPreferredSize(new Dimension(150, 170));
photoLabel.setBounds(30, 0, 90, 100);
namePanel.setBounds(0, 110, 150, 50);
}
else
{
holdButton.setBounds(9, 74, 36, 36);
muteButton.setBounds(45, 74, 36, 36);
contactPanel.add(holdButton, new Integer(1));
contactPanel.add(muteButton, new Integer(1));
if (transferCallButton != null)
{
transferCallButton.setBounds(81, 74, 36, 36);
contactPanel.add(transferCallButton, new Integer(1));
}
}
}
@ -160,7 +207,34 @@ private Component createTransferCallButton()
}
return null;
}
/**
* Creates a new <code>Component</code> representing a UI means to secure
* the <code>Call</code> of the associated <code>callParticipant</code> or
* <tt>null</tt> if secured call is unsupported.
*
* @return a new <code>Component</code> representing the UI means to
* secure the <code>Call</code> of <code>callParticipant</code> or
* <tt>null</tt> if secured call is unsupported
*/
private Component createSecureCallButton()
{
Call call = callParticipant.getCall();
if (call != null)
{
OperationSetSecuredTelephony secured =
(OperationSetSecuredTelephony) call.getProtocolProvider()
.getOperationSet(OperationSetSecuredTelephony.class);
if (secured != null)
{
return new SecureButton(callParticipant);
}
}
return null;
}
/**
* Sets the state of the contained call participant.
* @param state the state of the contained call participant

@ -43,25 +43,25 @@ public void actionPerformed(ActionEvent evt)
String command = evt.getActionCommand();
if (command.equals("startSecureMode"))
{
OperationSetBasicTelephony telephony =
(OperationSetBasicTelephony) call.getProtocolProvider()
.getOperationSet(OperationSetBasicTelephony.class);
OperationSetSecuredTelephony telephony =
(OperationSetSecuredTelephony) call.getProtocolProvider()
.getOperationSet(OperationSetSecuredTelephony.class);
if (telephony.isSecured(callParticipant))
if (telephony != null && telephony.isSecured(callParticipant))
{
updateSecureButton(false);
telephony.setSecured(callParticipant,
false,
OperationSetBasicTelephony.
OperationSetSecuredTelephony.
SecureStatusChangeSource
.SECURE_STATUS_CHANGE_BY_LOCAL);
}
else
else if (telephony != null)
{
updateSecureButton(true);
telephony.setSecured(callParticipant,
true,
OperationSetBasicTelephony.
OperationSetSecuredTelephony.
SecureStatusChangeSource
.SECURE_STATUS_CHANGE_BY_LOCAL);
}

@ -475,7 +475,7 @@ private void stopStreaming(RTPManager rtpManager,
if (selectedKeyProviderAlgorithm != null
/* TODO: Video securing related code
* remove the next condition as part of enabling video securing
* (see comments insecureStatusChanged method for more info)
* (see comments in secureStatusChanged method for more info)
*/
&& rtpManager.equals(audioRtpManager))
{
@ -1223,12 +1223,10 @@ private void initStreamTargets(Connection globalConnParam,
if (selectedKeyProviderAlgorithm != null
/* TODO: Video securing related code
* remove the next condition as part of enabling video
* securing (see comments insecureStatusChanged method
* securing (see comments in secureStatusChanged method
* for more info)
*/
&& rtpManager.equals(audioRtpManager)
&& usingSRTP
)
&& rtpManager.equals(audioRtpManager))
{
TransformConnector transConnector =
(TransformConnector) this.transConnectors
@ -1975,10 +1973,9 @@ private void initializeRtpManager(RTPManager rtpManager,
if (selectedKeyProviderAlgorithm != null &&
selectedKeyProviderAlgorithm.getProviderType()
== KeyProviderAlgorithm.ProviderType.ZRTP_PROVIDER
&& usingSRTP
/* TODO: Video securing related code
* remove the next condition as part of enabling video securing
* (see comments insecureStatusChanged method for more info)
* (see comments in secureStatusChanged method for more info)
*/
&& rtpManager.equals(audioRtpManager))
{
@ -2030,10 +2027,9 @@ private void initializeRtpManager(RTPManager rtpManager,
KeyProviderAlgorithm.ProviderType.DUMMY_PROVIDER
/* TODO: Video securing related code
* remove the next condition as part of enabling video securing
* (see comments insecureStatusChanged method for more info)
* (see comments in secureStatusChanged method for more info)
*/
&& rtpManager.equals(audioRtpManager)
&& usingSRTP)
&& rtpManager.equals(audioRtpManager))
{
SRTPPolicy srtpPolicy =
new SRTPPolicy(SRTPPolicy.AESF8_ENCRYPTION, 16,
@ -2635,7 +2631,7 @@ public boolean getSecureCommunicationStatus()
* @param source the source of changing the secure status (local or remote)
*/
public void setSecureCommunicationStatus(boolean activator,
OperationSetBasicTelephony.
OperationSetSecuredTelephony.
SecureStatusChangeSource source)
{
@ -2647,7 +2643,7 @@ public void setSecureCommunicationStatus(boolean activator,
// Fire the change event to notify any present CallSession of security change status
// if not the case of a reverted secure state
// (usually case of previous change rejected due to an error)
if (source != OperationSetBasicTelephony.
if (source != OperationSetSecuredTelephony.
SecureStatusChangeSource.SECURE_STATUS_REVERTED)
fireSecureStatusChanged(activator, source);
@ -2660,7 +2656,7 @@ public void setSecureCommunicationStatus(boolean activator,
* @param source the source of changing the secure status (local or remote)
*/
private synchronized void fireSecureStatusChanged(boolean activator,
OperationSetBasicTelephony.
OperationSetSecuredTelephony.
SecureStatusChangeSource source)
{
if (activator)
@ -2691,7 +2687,7 @@ private synchronized void fireSecureStatusChanged(boolean activator,
public void ZRTPChangeStatus(RTPManager manager, SecureEvent event)
{
int newStatus = event.getEventID();
OperationSetBasicTelephony.SecureStatusChangeSource source = event.getSource();
OperationSetSecuredTelephony.SecureStatusChangeSource source = event.getSource();
TransformConnector transConnector =
(TransformConnector) this.transConnectors.get(manager);
@ -2701,7 +2697,7 @@ public void ZRTPChangeStatus(RTPManager manager, SecureEvent event)
// Perform ZRTP engine actions only if triggered by local peer - user commands;
// If the remote peer caused the event only general call session security status
// is changed (done before event processing)
if (source == OperationSetBasicTelephony.
if (source == OperationSetSecuredTelephony.
SecureStatusChangeSource.SECURE_STATUS_CHANGE_BY_LOCAL)
{
if (newStatus == SecureEvent.SECURE_COMMUNICATION)

@ -395,7 +395,7 @@ public void actionPerformed(ActionEvent e)
callSession.
setSecureCommunicationStatus(false,
OperationSetBasicTelephony.
OperationSetSecuredTelephony.
SecureStatusChangeSource.
SECURE_STATUS_CHANGE_BY_LOCAL);
}
@ -405,7 +405,7 @@ public void actionPerformed(ActionEvent e)
callSession.
setSecureCommunicationStatus(true,
OperationSetBasicTelephony.
OperationSetSecuredTelephony.
SecureStatusChangeSource.
SECURE_STATUS_CHANGE_BY_LOCAL);
}
@ -425,7 +425,7 @@ public void actionPerformed(ActionEvent e)
callSession.
setSecureCommunicationStatus(true,
OperationSetBasicTelephony.
OperationSetSecuredTelephony.
SecureStatusChangeSource.
SECURE_STATUS_REVERTED);
@ -438,7 +438,7 @@ public void actionPerformed(ActionEvent e)
callSession.
setSecureCommunicationStatus(false,
OperationSetBasicTelephony.
OperationSetSecuredTelephony.
SecureStatusChangeSource.
SECURE_STATUS_REVERTED);
@ -451,7 +451,7 @@ public void actionPerformed(ActionEvent e)
callSession.
setSecureCommunicationStatus(true,
OperationSetBasicTelephony.
OperationSetSecuredTelephony.
SecureStatusChangeSource.
SECURE_STATUS_REVERTED);
@ -463,7 +463,7 @@ public void actionPerformed(ActionEvent e)
callSession.
setSecureCommunicationStatus(false,
OperationSetBasicTelephony.
OperationSetSecuredTelephony.
SecureStatusChangeSource.
SECURE_STATUS_REVERTED);
@ -475,7 +475,7 @@ public void actionPerformed(ActionEvent e)
callSession.
setSecureCommunicationStatus(false,
OperationSetBasicTelephony.
OperationSetSecuredTelephony.
SecureStatusChangeSource.
SECURE_STATUS_CHANGE_BY_REMOTE);
@ -487,7 +487,7 @@ public void actionPerformed(ActionEvent e)
callSession.
setSecureCommunicationStatus(true,
OperationSetBasicTelephony.
OperationSetSecuredTelephony.
SecureStatusChangeSource.
SECURE_STATUS_CHANGE_BY_REMOTE);

@ -685,32 +685,5 @@ public void sessionMediaReceived(JingleSession jingleSession,
{
logger.info("session media received ");
}
/**
* Sets the secured state of the call session in which a specific participant
* is involved
*
* @param participant the participant who toggled (or for whom is remotely toggled)
* the secure status change for the call
* @param secured the new secure status
* @param source the source who generated the call change
*/
public void setSecured(CallParticipant participant, boolean secured,
SecureStatusChangeSource source)
{
//TODO - implement security for jabber
}
/**
* Gets the secured state of the call session in which a specific participant
* is involved
*
* @param participant the participant for who the call state is required
* @return the call state
*/
public boolean isSecured(CallParticipant participant)
{
return false;
}
}

@ -231,22 +231,4 @@ public void callStateChanged(CallChangeEvent evt)
fireCallEvent(CallEvent.CALL_ENDED, sourceCall);
}
}
/*
* (non-Javadoc)
* @see net.java.sip.communicator.service.protocol.OperationSetBasicTelephony#setSecured(net.java.sip.communicator.service.protocol.CallParticipant, boolean, net.java.sip.communicator.service.media.CallSession.SecureStatusChangeSource)
*/
public void setSecured(CallParticipant participant, boolean secured,
OperationSetBasicTelephony.SecureStatusChangeSource source)
{
}
/*
* (non-Javadoc)
* @see net.java.sip.communicator.service.protocol.OperationSetBasicTelephony#getSecured(net.java.sip.communicator.service.protocol.CallParticipant)
*/
public boolean isSecured(CallParticipant participant)
{
return false;
}
}

@ -31,7 +31,8 @@
public class OperationSetBasicTelephonySipImpl
extends AbstractOperationSetBasicTelephony
implements MethodProcessor,
OperationSetAdvancedTelephony
OperationSetAdvancedTelephony,
OperationSetSecuredTelephony
{
private static final Logger logger =
Logger.getLogger(OperationSetBasicTelephonySipImpl.class);
@ -2947,7 +2948,7 @@ public void setMute(CallParticipant participant, boolean mute)
/*
* (non-Javadoc)
* @see net.java.sip.communicator.service.protocol.OperationSetBasicTelephony#setSecured(net.java.sip.communicator.service.protocol.CallParticipant, boolean, net.java.sip.communicator.service.media.CallSession.SecureStatusChangeSource)
* @see net.java.sip.communicator.service.protocol.OperationSetSecuredTelephony#setSecured(net.java.sip.communicator.service.protocol.CallParticipant, boolean, net.java.sip.communicator.service.protocol.OperationSetSecuredTelephony.SecureStatusChangeSource)
*/
public void setSecured(CallParticipant participant, boolean secured,
SecureStatusChangeSource source)
@ -2958,7 +2959,7 @@ public void setSecured(CallParticipant participant, boolean secured,
/*
* (non-Javadoc)
* @see net.java.sip.communicator.service.protocol.OperationSetBasicTelephony#getSecured(net.java.sip.communicator.service.protocol.CallParticipant)
* @see net.java.sip.communicator.service.protocol.OperationSetSecuredTelephony#getSecured(net.java.sip.communicator.service.protocol.CallParticipant)
*/
public boolean isSecured(CallParticipant participant)
{

@ -683,6 +683,12 @@ protected void initialize(String sipAddress,
OperationSetAdvancedTelephony.class.getName()
, opSetAdvancedTelephony);
// init ZRTP (OperationSetBasicTelephonySipImpl implements
// OperationSetSecureTelephony)
this.supportedOperationSets.put(
OperationSetSecuredTelephony.class.getName()
, opSetAdvancedTelephony);
//init presence op set.
OperationSetPersistentPresence opSetPersPresence
= new OperationSetPresenceSipImpl(this, enablePresence,
@ -713,7 +719,7 @@ protected void initialize(String sipAddress,
OperationSetDTMF opSetDTMF = new OperationSetDTMFSipImpl(this);
this.supportedOperationSets.put(
OperationSetDTMF.class.getName(), opSetDTMF);
//initialize our OPTIONS handler
ClientCapabilities capabilities = new ClientCapabilities(this);

@ -200,7 +200,7 @@ public void processSdpAnswer(CallParticipant responder, String sdpAnswer)
* @param source the initiator of the secure status change (can be local or remote)
*/
public void setSecureCommunicationStatus(boolean activator,
OperationSetBasicTelephony.
OperationSetSecuredTelephony.
SecureStatusChangeSource source);
/**

@ -18,7 +18,6 @@
*
* @author Emil Ivov
* @author Lubomir Marinov
* @author Emanuel Onica
*/
public interface OperationSetBasicTelephony
extends OperationSet
@ -136,35 +135,4 @@ public void hangupCallParticipant(CallParticipant participant)
* <tt>participant</tt>; otherwise, <tt>false</tt>
*/
public void setMute(CallParticipant participant, boolean mute);
/**
* Use this to indicate the source of setting the secure status
* of the communication as being the local or remote peer or reverted by local
*/
public static enum SecureStatusChangeSource {
SECURE_STATUS_CHANGE_BY_LOCAL,
SECURE_STATUS_CHANGE_BY_REMOTE,
SECURE_STATUS_REVERTED;
}
/**
* Sets the secured state of the call session in which a specific participant
* is involved
*
* @param participant the participant who toggled (or for whom is remotely toggled)
* the secure status change for the call
* @param secured the new secure status
* @param source the source who generated the call change
*/
public void setSecured(CallParticipant participant, boolean secured,
SecureStatusChangeSource source);
/**
* Gets the secured state of the call session in which a specific participant
* is involved
*
* @param participant the participant for who the call state is required
* @return the call state
*/
public boolean isSecured(CallParticipant participant);
}

@ -0,0 +1,50 @@
/*
* 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;
import net.java.sip.communicator.service.protocol.event.*;
/**
* An Operation Set defining the encryption operations for telephony.
*
* @author Emanuel Onica
* @author Romain Kuntz
*/
public interface OperationSetSecuredTelephony
extends OperationSet
{
/**
* Sets the secured state of the call session in which a specific participant
* is involved
*
* @param participant the participant who toggled (or for whom is remotely
* toggled) the secure status change for the call
* @param secured the new secure status
* @param source the source who generated the call change
*/
public void setSecured(CallParticipant participant, boolean secured,
SecureStatusChangeSource source);
/**
* Gets the secured state of the call session in which a specific participant
* is involved
*
* @param participant the participant for who the call state is required
* @return the call state
*/
public boolean isSecured(CallParticipant participant);
/**
* Use this to indicate the source of setting the secure status
* of the communication as being the local or remote peer or reverted by local
*/
public static enum SecureStatusChangeSource {
SECURE_STATUS_CHANGE_BY_LOCAL,
SECURE_STATUS_CHANGE_BY_REMOTE,
SECURE_STATUS_REVERTED;
}
}

@ -41,7 +41,7 @@ public class SecureEvent
/**
* The source that triggered the event - local or remote peer
*/
private OperationSetBasicTelephony.SecureStatusChangeSource source;
private OperationSetSecuredTelephony.SecureStatusChangeSource source;
/**
* The event constructor
@ -51,7 +51,7 @@ public class SecureEvent
*/
public SecureEvent(CallSessionImpl callSession,
int eventID,
OperationSetBasicTelephony.SecureStatusChangeSource source)
OperationSetSecuredTelephony.SecureStatusChangeSource source)
{
super(callSession);
this.eventID = eventID;
@ -72,7 +72,7 @@ public int getEventID()
* Retrieves the source that triggered the event
* (change by local peer or remote peer or reverting a previous change)
*/
public OperationSetBasicTelephony.SecureStatusChangeSource getSource()
public OperationSetSecuredTelephony.SecureStatusChangeSource getSource()
{
return source;
}

Loading…
Cancel
Save