diff --git a/src/net/java/sip/communicator/impl/media/CallSessionImpl.java b/src/net/java/sip/communicator/impl/media/CallSessionImpl.java index 7ec7e6581..76a230a7e 100644 --- a/src/net/java/sip/communicator/impl/media/CallSessionImpl.java +++ b/src/net/java/sip/communicator/impl/media/CallSessionImpl.java @@ -2766,7 +2766,7 @@ private void zrtpChangeStatus(RTPManager manager, SecureEvent event) logger.trace("GoSecure call event processing"); // This point isn't reached if GoClear is not enabled - SCCallback cb = (SCCallback)engine.getUserCallback(); + SCCallback cb = engine.getUserCallback(); cb.setGCGSByPeerFlag(false); engine.requestGoSecure(); } @@ -2780,7 +2780,7 @@ private void zrtpChangeStatus(RTPManager manager, SecureEvent event) // to re-enable GoClear uncomment the specific code parts in ZRTP4J logger.trace("GoClear call event processing"); - SCCallback cb = (SCCallback)engine.getUserCallback(); + SCCallback cb = engine.getUserCallback(); cb.setGCGSByPeerFlag(false); engine.requestGoClear(); } diff --git a/src/net/java/sip/communicator/impl/media/transform/zrtp/SCCallback.java b/src/net/java/sip/communicator/impl/media/transform/zrtp/SCCallback.java index 82cf448ec..95a80e519 100644 --- a/src/net/java/sip/communicator/impl/media/transform/zrtp/SCCallback.java +++ b/src/net/java/sip/communicator/impl/media/transform/zrtp/SCCallback.java @@ -26,82 +26,85 @@ * This class provides means to communicate events to the user through * GUI elements, and also allows the user to control the ZRTP activation * and deactivation. - * - * @author Emanuel Onica + * + * @author Emanuel Onica * */ -public class SCCallback - extends ZrtpUserCallback - implements ActionListener +public class SCCallback + extends ZrtpUserCallback + implements ActionListener { - private static final Logger logger + private static final Logger logger = Logger.getLogger(SCCallback.class); - - /** - * The UI Service needed to provide the means to display - * popup dialogs and other possible informative elements - */ + + /** + * The UI Service needed to provide the means to display + * popup dialogs and other possible informative elements + */ private UIService uiService; - + /** * The popup dialog used to display announcements to the user */ private PopupDialog popupDialog; - + /** * The label from the ZRTP GUI plugin used to display the SAS */ private JLabel zrtpLabel = null; - + /** * The button from the ZRTP GUI plugin used to activate and * deactivate the secure state of the call */ private JButton zrtpButton = null; - + /** * The panel from the ZRTP GUI plugin holding the ZRTP related * GUI components */ private JPanel zrtpPanel = null; - + /** * Flags needed for specific GUI setting indicating if the call - * securing change was issued by a GoClear/GoSecure request from the other peer + * securing change was issued by a GoClear/GoSecure request from the other + * peer */ - private boolean gcgsByPeerFlag = true; + private boolean gcgsByPeerFlag = true; private boolean firstSecuring = true; - + ActionListener [] listeners; - + private CallSession callSession = null; - + /** * The class constructor. - * Gets a reference to the ZRTP GUI plugin and initializes the + * Gets a reference to the ZRTP GUI plugin and initializes the * ZRTP GUI component members. */ public SCCallback(CallSession callSession) { BundleContext bc = MediaActivator.getBundleContext(); - - ServiceReference uiServiceRef = + + ServiceReference uiServiceRef = bc.getServiceReference(UIService.class.getName()); - + uiService = (UIService)bc.getService(uiServiceRef); - + popupDialog = uiService.getPopupDialog(); - + ServiceReference[] serRefs = null; - + this.callSession = callSession; String osgiFilter = "(" + Container.CONTAINER_ID + "="+Container.CONTAINER_MAIN_TOOL_BAR.getID()+")"; - zrtpButton = (JButton) callSession.getCall().getSecureGUIComponent("secureButton"); - zrtpLabel = (JLabel) callSession.getCall().getSecureGUIComponent("secureLabel"); + zrtpButton = (JButton) callSession.getCall() + .getSecureGUIComponent("secureButton"); + zrtpLabel = (JLabel) callSession.getCall() + .getSecureGUIComponent("secureLabel"); } /* @@ -110,150 +113,154 @@ public SCCallback(CallSession callSession) */ public void init() { - gcgsByPeerFlag = true; - firstSecuring = true; - - listeners = zrtpButton.getActionListeners(); - - for (int i=0; i subCode) + public void showMessage(ZrtpCodes.MessageSeverity sev, EnumSet subCode) { Iterator ii = subCode.iterator(); Object msgCode = ii.next(); logger.info("Show message sub code: " + msgCode); - System.err.println("Show message sub code: " + msgCode); - - if (msgCode.equals(CallSessionImpl.ZRTPCustomInfoCodes.ZRTPNotEnabledByUser)) + + if (msgCode.equals( + CallSessionImpl.ZRTPCustomInfoCodes.ZRTPNotEnabledByUser)) { - zrtpLabel.setBorder(BorderFactory.createLineBorder(Color.RED)); + zrtpLabel.setBorder(BorderFactory.createLineBorder(Color.RED)); zrtpLabel.setText(SCCallbackResources.SAS_NOT_SECURED_MESSAGE); - zrtpLabel.setToolTipText(SCCallbackResources.SAS_NOT_SECURED_TOOLTIP); + zrtpLabel.setToolTipText( + SCCallbackResources.SAS_NOT_SECURED_TOOLTIP); showTooltip(); } - - if (msgCode.equals(CallSessionImpl.ZRTPCustomInfoCodes.ZRTPDisabledByCallEnd)) + + if (msgCode.equals( + CallSessionImpl.ZRTPCustomInfoCodes.ZRTPDisabledByCallEnd)) { zrtpLabel.setBorder(BorderFactory.createLineBorder(Color.BLUE)); zrtpLabel.setText(SCCallbackResources.DEFAULT_SAS_MESSAGE); zrtpLabel.setToolTipText(SCCallbackResources.DEFAULT_SAS_TOOLTIP); - + String command = zrtpButton.getActionCommand(); if (!command.equals("startSecureMode")) { - zrtpButton.removeActionListener(this); - - for (int i=0; i subCode) + EnumSet subCode) { Iterator ii = subCode.iterator(); Object msgCode = ii.next(); logger.warn("Negotiation failed sub code: " + msgCode); - System.err.println("Negotiation failed sub code: " + msgCode); - + zrtpLabel.setBorder(BorderFactory.createLineBorder(Color.RED)); zrtpLabel.setText(SCCallbackResources.SAS_NOT_SECURED_MESSAGE); zrtpLabel.setToolTipText(SCCallbackResources.SAS_SECURING_FAIL_TOOLTIP); - + String prevCommand = zrtpButton.getActionCommand(); zrtpButton.setActionCommand("revertToUnsecured"); zrtpButton.doClick(); zrtpButton.setActionCommand(prevCommand); - + showTooltip(); } - + // public void goClearProcedureFailed(ZrtpCodes.MessageSeverity severity, -// EnumSet subCode, boolean maintainSecurity) +// EnumSet subCode, boolean maintainSecurity) // { // Iterator ii = subCode.iterator(); // Object msgCode = ii.next(); // logger.warn("ZRTP negotiation failed sub code: " + msgCode); -// System.err.println("ZRTP negotiation failed sub code: " + msgCode); // // String prevCommand = zrtpButton.getActionCommand(); // -// if (msgCode.equals(ZrtpCodes.WarningCodes.WarningGoClearRequestInvalid)) +// if (msgCode.equals(ZrtpCodes.WarningCodes. +// WarningGoClearRequestInvalid)) // { // zrtpButton.setActionCommand("revertFromAllowClearFailure"); // zrtpButton.doClick(); @@ -263,7 +270,8 @@ public void zrtpNegotiationFailed(ZrtpCodes.MessageSeverity severity, // { // zrtpLabel.setBorder(BorderFactory.createLineBorder(Color.RED)); // zrtpLabel.setText(SCCallbackResources.SAS_NOT_SECURED_MESSAGE); -// zrtpLabel.setToolTipText(SCCallbackResources.SAS_SECURING_FAIL_TOOLTIP); +// zrtpLabel.setToolTipText( +// SCCallbackResources.SAS_SECURING_FAIL_TOOLTIP); // // zrtpButton.setActionCommand("revertToUnsecured"); // zrtpButton.doClick(); @@ -276,7 +284,7 @@ public void zrtpNegotiationFailed(ZrtpCodes.MessageSeverity severity, // zrtpButton.doClick(); // zrtpButton.setActionCommand(prevCommand); // } -// +// // showTooltip(); // } @@ -284,20 +292,20 @@ public void zrtpNegotiationFailed(ZrtpCodes.MessageSeverity severity, * (non-Javadoc) * @see gnu.java.zrtp.ZrtpUserCallback#secureOff() */ - public void secureOff() + public void secureOff() { logger.info("Security off"); - System.err.println("Security off"); - + // this is the case of locally GoClear request // be sure to reset the flag after handling it - if (!gcgsByPeerFlag) + if (!gcgsByPeerFlag) { - zrtpLabel.setBorder(BorderFactory.createLineBorder(Color.RED)); - zrtpLabel.setText(SCCallbackResources.SAS_NOT_SECURED_MESSAGE); - zrtpLabel.setToolTipText(SCCallbackResources.SAS_UNSECURED_AT_REQUEST_TOOLTIP); - showTooltip(); - gcgsByPeerFlag = true; + zrtpLabel.setBorder(BorderFactory.createLineBorder(Color.RED)); + zrtpLabel.setText(SCCallbackResources.SAS_NOT_SECURED_MESSAGE); + zrtpLabel.setToolTipText( + SCCallbackResources.SAS_UNSECURED_AT_REQUEST_TOOLTIP); + showTooltip(); + gcgsByPeerFlag = true; } } @@ -305,90 +313,95 @@ public void secureOff() * (non-Javadoc) * @see gnu.java.zrtp.ZrtpUserCallback#zrtpNotSuppOther() */ - public void zrtpNotSuppOther() + public void zrtpNotSuppOther() { logger.info("ZRTP not supported"); - System.err.println("ZRTP not supported"); - - zrtpButton.setToolTipText(SCCallbackResources.PEER_UNSUPORTED_SECURITY); + + zrtpButton.setToolTipText(SCCallbackResources.PEER_UNSUPORTED_SECURITY); zrtpLabel.setBorder(BorderFactory.createLineBorder(Color.RED)); zrtpLabel.setText(SCCallbackResources.SAS_NOT_SECURED_MESSAGE); - zrtpLabel.setToolTipText(SCCallbackResources.SAS_PEER_UNSUPORTED_TOOLTIP); + zrtpLabel.setToolTipText( + SCCallbackResources.SAS_PEER_UNSUPORTED_TOOLTIP); showTooltip(); } - + /* * (non-Javadoc) * @see gnu.java.zrtp.ZrtpUserCallback#confirmGoClear() */ public void confirmGoClear() { - logger.info("GoClear confirmation requested"); - System.err.println("GoClear confirmation requested"); - - popupDialog.showMessagePopupDialog(SCCallbackResources.PEER_TOGGLED_SECURITY_OFF_MESSAGE, - SCCallbackResources.PEER_TOGGLED_SECURITY_OFF_CAPTION, - PopupDialog.INFORMATION_MESSAGE); - zrtpLabel.setBorder(BorderFactory.createLineBorder(Color.RED)); + logger.info("GoClear confirmation requested"); + + popupDialog.showMessagePopupDialog( + SCCallbackResources.PEER_TOGGLED_SECURITY_OFF_MESSAGE, + SCCallbackResources.PEER_TOGGLED_SECURITY_OFF_CAPTION, + PopupDialog.INFORMATION_MESSAGE); + zrtpLabel.setBorder(BorderFactory.createLineBorder(Color.RED)); zrtpLabel.setText(SCCallbackResources.SAS_NOT_SECURED_MESSAGE); - zrtpLabel.setToolTipText(SCCallbackResources.SAS_UNSECURED_AT_PEER_REQUEST_TOOLTIP); + zrtpLabel.setToolTipText( + SCCallbackResources.SAS_UNSECURED_AT_PEER_REQUEST_TOOLTIP); zrtpButton.setActionCommand("goClearRemoteToggle"); zrtpButton.doClick(); zrtpButton.setActionCommand("defaultZRTPAction"); showTooltip(); } - public void setGCGSByPeerFlag(boolean gcgsByPeerFlag) - { - this.gcgsByPeerFlag = gcgsByPeerFlag; - } - - /** - * Force tooltip show function - * (Not really necessary but could draw user's attention on some events; - * Seems no version from below works however... - * TODO: Search some other way - or better see what's wrong with the ones found) - * - */ - public void showTooltip() - { - //version 1 - /*ToolTipManager.sharedInstance().mouseMoved( - new MouseEvent(zrtpLabel, 0, 0, 0, - 0, 0, - 0, false));*/ - - //version 2 - /*Action toolTipAction = component.getActionMap().get("postTip"); - if (toolTipAction != null) - { - ActionEvent postTip = new ActionEvent(component, ActionEvent.ACTION_PERFORMED, ""); - toolTipAction.actionPerformed( postTip ); - }*/ - - //version 3 - zrtpLabel.dispatchEvent(new KeyEvent - ( - zrtpLabel, - KeyEvent.KEY_PRESSED, - 0, - KeyEvent.CTRL_MASK, - KeyEvent.VK_F1, - KeyEvent.CHAR_UNDEFINED - )); - } - - /* - * (non-Javadoc) - * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) - */ - public void actionPerformed(ActionEvent e) + public void setGCGSByPeerFlag(boolean gcgsByPeerFlag) + { + this.gcgsByPeerFlag = gcgsByPeerFlag; + } + + /** + * Force tooltip show function + * (Not really necessary but could draw user's attention on some events; + * Seems no version from below works however... + * TODO: Search some other way - or better see what's wrong with the ones + * found) + * + */ + public void showTooltip() + { + //version 1 + /*ToolTipManager.sharedInstance().mouseMoved( + new MouseEvent(zrtpLabel, 0, 0, 0, + 0, 0, + 0, false));*/ + + //version 2 + /*Action toolTipAction = component.getActionMap().get("postTip"); + if (toolTipAction != null) + { + ActionEvent postTip = new ActionEvent( + component, + ActionEvent.ACTION_PERFORMED, ""); + toolTipAction.actionPerformed( postTip ); + }*/ + + //version 3 + zrtpLabel.dispatchEvent(new KeyEvent + ( + zrtpLabel, + KeyEvent.KEY_PRESSED, + 0, + KeyEvent.CTRL_MASK, + KeyEvent.VK_F1, + KeyEvent.CHAR_UNDEFINED + )); + } + + /* + * (non-Javadoc) + * @see java.awt.event.ActionListener#actionPerformed( + * java.awt.event.ActionEvent) + */ + public void actionPerformed(ActionEvent e) { - String command = e.getActionCommand(); - - - if (command.equals("defaultZRTPAction")) - { + String command = e.getActionCommand(); + + + if (command.equals("defaultZRTPAction")) + { if(callSession.getSecureCommunicationStatus()) { updateSecureButton(false); @@ -413,9 +426,9 @@ public void actionPerformed(ActionEvent e) else if (command.equals("firstZRTPTrigger")) { ToolTipManager.sharedInstance().mouseMoved( - new MouseEvent(zrtpButton, 0, 0, 0, - 0, 0, - 0, false)); + new MouseEvent(zrtpButton, 0, 0, 0, + 0, 0, + 0, false)); } else if (command.equals("revertFromAllowClearFailure")) { @@ -427,7 +440,8 @@ else if (command.equals("revertFromAllowClearFailure")) SecureStatusChangeSource. SECURE_STATUS_REVERTED); - zrtpButton.setToolTipText(SCCallbackResources.GOCLEAR_REQUEST_AC_FLAG_FAILURE); + zrtpButton.setToolTipText( + SCCallbackResources.GOCLEAR_REQUEST_AC_FLAG_FAILURE); } else if (command.equals("zrtpInitFail")) { @@ -439,12 +453,13 @@ else if (command.equals("zrtpInitFail")) SecureStatusChangeSource. SECURE_STATUS_REVERTED); - zrtpButton.setToolTipText(SCCallbackResources.ZRTP_ENGINE_INIT_FAILURE); + zrtpButton.setToolTipText( + SCCallbackResources.ZRTP_ENGINE_INIT_FAILURE); } else if (command.equals("revertToSecured")) { updateSecureButton(true); - + callSession. setSecureCommunicationStatus(true, OperationSetSecureTelephony. @@ -464,7 +479,7 @@ else if (command.equals("revertToUnsecured")) else if (command.equals("goClearRemoteToggle")) { updateSecureButton(false); - + callSession. setSecureCommunicationStatus(false, OperationSetSecureTelephony. @@ -483,9 +498,10 @@ else if (command.equals("goSecureRemoteToggle")) } } - /** - * The method used to update the secure button state (pressed or not pressed) - * + /** + * The method used to update the secure button state (pressed or + * not pressed) + * * @param isSecure parameter reflecting the current button state */ public void updateSecureButton(boolean isSecure) diff --git a/src/net/java/sip/communicator/impl/media/transform/zrtp/ZRTPTransformEngine.java b/src/net/java/sip/communicator/impl/media/transform/zrtp/ZRTPTransformEngine.java index e6eaf052c..260316b82 100644 --- a/src/net/java/sip/communicator/impl/media/transform/zrtp/ZRTPTransformEngine.java +++ b/src/net/java/sip/communicator/impl/media/transform/zrtp/ZRTPTransformEngine.java @@ -24,19 +24,19 @@ /** * JMF extension/connector to support GNU ZRTP4J. - * + * * ZRTP was developed by Phil Zimmermann and provides functions to negotiate * keys and other necessary data (crypto data) to set-up the Secure RTP (SRTP) - * crypto context. Refer to Phil's ZRTP specification at his - * Zfone project site to get more + * crypto context. Refer to Phil's ZRTP specification at his + * Zfone project site to get more * detailed information about the capabilities of ZRTP. - * + * *

Short overview of the ZRTP4J implementation

- * + * * ZRTP is a specific protocol to negotiate encryption algorithms and the * required key material. ZRTP uses a RTP session to exchange its protocol * messages. - * + * * A complete GNU ZRTP4J implementation consists of two parts, the GNU ZRTP4J * core and specific code that binds the GNU ZRTP core to the underlying * RTP/SRTP stack and the operating system: @@ -51,17 +51,17 @@ * the binds the GNU ZRTP core to the actual RTP/SRTP implementation and other * operating system specific services such as timers. * - * + * * The GNU ZRTP4J core uses a callback interface class (refer to ZrtpCallback) * to access RTP/SRTP or operating specific methods, for example to send data * via the RTP/SRTP stack, to access timers, provide mutex handling, and to * report events to the application. - * + * *

The ZRTPTransformEngine

- * + * * ZRTPTransformEngine implements code that is specific to the JMF * implementation. - * + * * To perform its tasks ZRTPTransformEngine * - * + * * After instantiating a GNU ZRTP4J session (see below for a short example) * applications may use the ZRTP specific methods of ZRTPTransformEngine to * control and setup GNU ZRTP, for example enable or disable ZRTP processing or * getting ZRTP status information. - * + * * GNU ZRTP4J provides a ZrtpUserCallback class that an application may extend * and register with ZRTPTransformEngine. GNU ZRTP4J and ZRTPTransformEngine use * the ZrtpUserCallback methods to report ZRTP events to the application. The * application may display this information to the user or act otherwise. - * + * * The following figure depicts the relationships between ZRTPTransformEngine, * JMF implementation, the GNU ZRTP4J core, and an application that provides an * ZrtpUserCallback class. - * + * *
- * 
+ *
  *                  +---------------------------+
  *                  |  ZrtpTransformConnector   |
  *                  | extends TransformConnector|
@@ -108,61 +108,62 @@
  *                                                       |                |
  *                                                       +----------------+
  * 
- * + * * The following short code snippets show how an application could instantiate a * ZrtpTransformConnector, get the ZRTP4J engine and initialize it. Then the * code get a RTP manager instance and initializes it with the * ZRTPTransformConnector. Plase note: setting the target must be done with the * connector, not with the RTP manager. - * + * *
  * ...
- *   transConnector = (ZrtpTransformConnector)TransformManager.createZRTPConnector(sa);
+ *   transConnector = (ZrtpTransformConnector)TransformManager
+ *                                                  .createZRTPConnector(sa);
  *   zrtpEngine = transConnector.getEngine();
  *   zrtpEngine.setUserCallback(new MyCallback());
  *   if (!zrtpEngine.initialize("test_t.zid"))
  *       System.out.println("iniatlize failed");
- * 
+ *
  *   // initialize the RTPManager using the ZRTP connector
- * 
+ *
  *   mgr = RTPManager.newInstance();
  *   mgr.initialize(transConnector);
- * 
+ *
  *   mgr.addSessionListener(this);
  *   mgr.addReceiveStreamListener(this);
- * 
+ *
  *   transConnector.addTarget(target);
  *   zrtpEngine.startZrtp();
- * 
+ *
  *   ...
  * 
- * + * * The demo folder contains a small example that shows how to use GNU * ZRTP4J. - * + * * This ZRTPTransformEngine documentation shows the ZRTP specific extensions and * describes overloaded methods and a possible different behaviour. - * + * * @author Werner Dittmann <Werner.Dittmann@t-online.de> - * + * */ public class ZRTPTransformEngine implements TransformEngine, PacketTransformer, ZrtpCallback { - + /** * Very simple Timeout provider class. - * + * * This very simple timeout provider can handle one timeout request at * one time only. A second request would overwrite the first one and would * lead to unexpected results. - * + * * @author Werner Dittmann */ - class TimeoutProvider extends Thread + class TimeoutProvider extends Thread { - public TimeoutProvider(String name) + public TimeoutProvider(String name) { super(name); } @@ -177,9 +178,10 @@ public TimeoutProvider(String name) Object sync = new Object(); - public synchronized void requestTimeout(long delay, ZRTPTransformEngine tt) + public synchronized void requestTimeout(long delay, + ZRTPTransformEngine tt) { - synchronized (sync) + synchronized (sync) { executor = tt; nextDelay = delay; @@ -188,37 +190,37 @@ public synchronized void requestTimeout(long delay, ZRTPTransformEngine tt) } } - public void stopRun() + public void stopRun() { - synchronized (sync) + synchronized (sync) { stop = true; sync.notifyAll(); } } - public void cancelRequest() + public void cancelRequest() { - synchronized (sync) + synchronized (sync) { newTask = false; sync.notifyAll(); } } - - public void run() + + public void run() { - while (!stop) + while (!stop) { - synchronized (sync) + synchronized (sync) { - while (!newTask && !stop) + while (!newTask && !stop) { - try + try { sync.wait(); - } - catch (InterruptedException e) + } + catch (InterruptedException e) { e.printStackTrace(); } @@ -227,20 +229,20 @@ public void run() long endTime = System.currentTimeMillis() + nextDelay; long currentTime = System.currentTimeMillis(); synchronized (sync) { - while ((currentTime <= endTime) && newTask && !stop) + while ((currentTime <= endTime) && newTask && !stop) { - try + try { sync.wait(endTime - currentTime); - } - catch (InterruptedException e) + } + catch (InterruptedException e) { e.printStackTrace(); } currentTime = System.currentTimeMillis(); } } - if (newTask && !stop) + if (newTask && !stop) { newTask = false; executor.handleTimeout(); @@ -252,48 +254,48 @@ public void run() // each ZRTP packet has a fixed header of 12 bytes protected static final int ZRTP_PACKET_HEADER = 12; - + /** * This is the own ZRTP connector, required to send ZRTP packets * via the DatagramSocket. - * (Note: in order to further multistream support this should be + * (Note: in order to further multistream support this should be * replaced with a connector array; each connector would handle * a stream) */ private TransformConnector zrtpConnector = null; - + /** * We need Out and In SRTPTransformer to transform RTP to SRTP and * vice versa. */ private PacketTransformer srtpOutTransformer = null; private PacketTransformer srtpInTransformer = null; - + /** * User callback class. */ - private ZrtpUserCallback userCallback = null; + private SCCallback userCallback = null; /** * The ZRTP engine. */ private ZRtp zrtpEngine = null; - + /** * ZRTP engine enable flag (used for auto-enable at initialization) */ private boolean enableZrtp = false; - + /** * Client ID string initialized with the name of the ZRTP4j library */ private String clientIdString = ZrtpConstants.clientId; - + /** * SSRC identifier for the ZRTP packets */ private int ownSSRC = 0; - + /** * ZRTP packet sequence number */ @@ -304,91 +306,94 @@ public void run() * (currently BouncyCastle is used) */ private Provider cryptoProvider= null; - + /** * The number of sent packets */ private long sendPacketCount = 0; - + /** * The timeout provider instance * This is used for handling the ZRTP timers */ private TimeoutProvider timeoutProvider = null; - + /** * The current condition of the ZRTP engine */ private boolean started = false; - + /** - * The flag used to temporarily stop the media streaming + * The flag used to temporarily stop the media streaming * required by the GoClear transition */ private boolean holdFlag = false; /** * Construct a ZRTPTransformEngine. - * + * */ - public ZRTPTransformEngine() + public ZRTPTransformEngine() { senderZrtpSeqNo = 1; // should be a random number } - + /* * (non-Javadoc) - * + * * @see net.java.sip.communicator.impl.media.transform. * TransformEngine#getRTCPTransformer() */ - public PacketTransformer getRTCPTransformer() + public PacketTransformer getRTCPTransformer() { return new ZRTPCTransformer(this); } /* * (non-Javadoc) - * + * * @see net.java.sip.communicator.impl.media.transform. * TransformEngine#getRTPTransformer() */ - public PacketTransformer getRTPTransformer() + public PacketTransformer getRTPTransformer() { return this; } /** - * Default engine initialization method. + * Default engine initialization method. * Calling this for engine initialization starts it with auto-sensing. - * + * * @param zidFilename The ZID file name * @return true if initialization fails, false if succeeds */ - public synchronized boolean initialize(String zidFilename) + public synchronized boolean initialize(String zidFilename) { return initialize(zidFilename, true); } /** * Custom engine initialization method. - * This allows to explicit specify if the engine starts with auto-sensing or not. - * + * This allows to explicit specify if the engine starts with auto-sensing + * or not. + * * @param zidFilename The ZID file name - * @param autoEnable Set this true to start with auto-sensing and false to disable it. + * @param autoEnable Set this true to start with auto-sensing and false to + * disable it. * @return true if initialization fails, false if succeeds */ - public synchronized boolean initialize(String zidFilename, boolean autoEnable) + public synchronized boolean initialize(String zidFilename, + boolean autoEnable) { // Get a reference to the FileAccessService BundleContext bc = MediaActivator.getBundleContext(); ServiceReference faServiceReference = bc.getServiceReference( FileAccessService.class.getName()); - FileAccessService faService = (FileAccessService) + FileAccessService faService = (FileAccessService) bc.getService(faServiceReference); - - File file = null; - try + + File file = null; + try { // Create the zid file file = faService.getPrivatePersistentFile(zidFilename); @@ -398,9 +403,9 @@ public synchronized boolean initialize(String zidFilename, boolean autoEnable) // TODO Auto-generated catch block e.printStackTrace(); } - + String zidFilePath = null; - try + try { // Get the absolute path of the created zid file zidFilePath = file.getAbsolutePath(); @@ -411,11 +416,11 @@ public synchronized boolean initialize(String zidFilename, boolean autoEnable) e.printStackTrace(); } - if (cryptoProvider == null) + if (cryptoProvider == null) { return false; } - if (timeoutProvider == null) + if (timeoutProvider == null) { timeoutProvider = new TimeoutProvider("ZRTP"); timeoutProvider.setDaemon(true); @@ -423,10 +428,10 @@ public synchronized boolean initialize(String zidFilename, boolean autoEnable) } ZidFile zf = ZidFile.getInstance(); - if (!zf.isOpen()) + if (!zf.isOpen()) { String fname; - if (zidFilePath == null) + if (zidFilePath == null) { String home = System.getenv("HOME"); String baseDir = (home != null) ? ((home) + ("/.")) : "."; @@ -437,33 +442,33 @@ public synchronized boolean initialize(String zidFilename, boolean autoEnable) { zidFilename = zidFilePath; } - - if (zf.open(zidFilename) < 0) + + if (zf.open(zidFilename) < 0) { enableZrtp = false; return false; } } enableZrtp = autoEnable; - try + try { - zrtpEngine = new ZRtp(zf.getZid(), this, clientIdString, cryptoProvider); - } - catch (GeneralSecurityException e) + zrtpEngine = new ZRtp( + zf.getZid(), this, clientIdString, cryptoProvider); + } + catch (GeneralSecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } - if (userCallback instanceof SCCallback) - { - ((SCCallback)userCallback).init(); - } + + userCallback.init(); + return true; } /** * Start the ZRTP stack immediately, not autosensing mode. - * + * */ public void startZrtp() { if (zrtpEngine != null) { @@ -487,12 +492,12 @@ public void stopZrtp() { /** * Cleanup function for any remaining timers */ - public void cleanup() + public void cleanup() { timeoutProvider.stopRun(); timeoutProvider = null; } - + /* (non-Javadoc) * @see net.java.sip.communicator.impl.media.transform.PacketTransformer# * transform(net.java.sip.communicator.impl.media.transform.RawPacket) @@ -507,28 +512,28 @@ public RawPacket transform(RawPacket pkt) /* * Never transform outgoing ZRTP packets. */ - if (zPkt.isZrtpPacket()) + if (zPkt.isZrtpPacket()) { return pkt; } - + /* * Discard the media packets if the hold flag is set - * (Needed in the GoClear transition) + * (Needed in the GoClear transition) */ /* TODO GoClear * To uncomment in order to use the GoClear feature - * (uncomment also the check in write method of TransformOutputStream) + * (uncomment also the check in write method of TransformOutputStream) */ /* if (holdFlag) - return null; + return null; */ - + /* * ZRTP needs the SSRC of the sending stream. */ - if (enableZrtp && ownSSRC == 0) + if (enableZrtp && ownSSRC == 0) { ownSSRC = zPkt.getSSRC(); } @@ -536,7 +541,7 @@ public RawPacket transform(RawPacket pkt) * If SRTP is active then srtpTransformer is set, use it. */ sendPacketCount++; - if (srtpOutTransformer == null) + if (srtpOutTransformer == null) { return pkt; } @@ -545,36 +550,37 @@ public RawPacket transform(RawPacket pkt) /* (non-Javadoc) * @see net.java.sip.communicator.impl.media.transform.PacketTransformer# - * reverseTransform(net.java.sip.communicator.impl.media.transform.RawPacket) + * reverseTransform( + * net.java.sip.communicator.impl.media.transform.RawPacket) */ /* - * The input data stream calls this method to transfrom + * The input data stream calls this method to transfrom * incoming packets. */ - public RawPacket reverseTransform(RawPacket pkt) + public RawPacket reverseTransform(RawPacket pkt) { ZrtpRawPacket zPkt = new ZrtpRawPacket(pkt); - + /* * Check if incoming packt is a ZRTP packet, if no treat * it as normal RTP packet and handle it accordingly. */ - if (!zPkt.isZrtpPacket()) + if (!zPkt.isZrtpPacket()) { - if (!started && enableZrtp && sendPacketCount >= 1) + if (!started && enableZrtp && sendPacketCount >= 1) { startZrtp(); } - if (srtpInTransformer == null) + if (srtpInTransformer == null) { return pkt; } pkt = srtpInTransformer.reverseTransform(pkt); // if packet was valid (i.e. not null) and ZRTP engine started and - // not yet in secure state - emulate a Conf2Ack packet. See ZRTP + // not yet in secure state - emulate a Conf2Ack packet. See ZRTP // specification chap. 5.6 - if (pkt != null && zrtpEngine != null - && !zrtpEngine.inState(ZrtpStateClass.ZrtpStates.SecureState)) + if (pkt != null && zrtpEngine != null + && !zrtpEngine.inState(ZrtpStateClass.ZrtpStates.SecureState)) { zrtpEngine.conf2AckSecure(); } @@ -582,19 +588,19 @@ public RawPacket reverseTransform(RawPacket pkt) } /* - * If ZRTP is enabled process it. In any case return null + * If ZRTP is enabled process it. In any case return null * because ZRTP packets never reach the application. */ - if (enableZrtp) + if (enableZrtp) { - if (!zPkt.checkCrc()) + if (!zPkt.checkCrc()) { - userCallback.showMessage(ZrtpCodes.MessageSeverity.Warning, + userCallback.showMessage(ZrtpCodes.MessageSeverity.Warning, EnumSet.of(ZrtpCodes.WarningCodes.WarningCRCmismatch)); return null; } // Check if it is really a ZRTP packet, if not don't process it - if (!zPkt.hasMagic() || zrtpEngine == null) + if (!zPkt.hasMagic() || zrtpEngine == null) { return null; } @@ -609,11 +615,11 @@ public RawPacket reverseTransform(RawPacket pkt) * First allocate space to hold the complete ZRTP packet, copy * the message part in its place, the initalize the header, counter, * SSRC and crc. - * + * * @param data The ZRTP packet data * @return true if sending succeeds, false if it fails */ - public boolean sendDataZRTP(byte[] data) + public boolean sendDataZRTP(byte[] data) { int totalLength = ZRTP_PACKET_HEADER + data.length; @@ -627,12 +633,12 @@ public boolean sendDataZRTP(byte[] data) packet.setCrc(); - try + try { zrtpConnector.getDataOutputStream().write(packet.getBuffer(), packet.getOffset(), packet.getLength()); - } - catch (IOException e) + } + catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -641,63 +647,66 @@ public boolean sendDataZRTP(byte[] data) return true; } - + /* * (non-Javadoc) - * @see gnu.java.zrtp.ZrtpCallback#srtpSecretsReady(gnu.java.zrtp.ZrtpSrtpSecrets, gnu.java.zrtp.ZrtpCallback.EnableSecurity) + * @see gnu.java.zrtp.ZrtpCallback#srtpSecretsReady( + * gnu.java.zrtp.ZrtpSrtpSecrets, + * gnu.java.zrtp.ZrtpCallback.EnableSecurity) */ - public boolean srtpSecretsReady(ZrtpSrtpSecrets secrets, EnableSecurity part) + public boolean srtpSecretsReady(ZrtpSrtpSecrets secrets, + EnableSecurity part) { SRTPPolicy srtpPolicy = null; - if (part == EnableSecurity.ForSender) + if (part == EnableSecurity.ForSender) { // To encrypt packets: intiator uses initiator keys, // responder uses responder keys // Create a "half baked" crypto context first and store it. This is // the main crypto context for the sending part of the connection. - if (secrets.getRole() == Role.Initiator) + if (secrets.getRole() == Role.Initiator) { srtpPolicy = new SRTPPolicy(SRTPPolicy.AESCM_ENCRYPTION, secrets.getInitKeyLen() / 8, // key length - SRTPPolicy.HMACSHA1_AUTHENTICATION, + SRTPPolicy.HMACSHA1_AUTHENTICATION, 20, // auth key length secrets.getSrtpAuthTagLen() / 8,// auth tag length secrets.getInitSaltLen() / 8 // salt length ); - try + try { SRTPTransformEngine engine = new SRTPTransformEngine(secrets .getKeyInitiator(), secrets.getSaltInitiator(), srtpPolicy, srtpPolicy, cryptoProvider); srtpOutTransformer = engine.getRTPTransformer(); - } - catch (GeneralSecurityException e) + } + catch (GeneralSecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } - } - else + } + else { srtpPolicy = new SRTPPolicy(SRTPPolicy.AESCM_ENCRYPTION, secrets.getRespKeyLen() / 8, // key length - SRTPPolicy.HMACSHA1_AUTHENTICATION, + SRTPPolicy.HMACSHA1_AUTHENTICATION, 20, // auth key length secrets.getSrtpAuthTagLen() / 8,// auth taglength secrets.getRespSaltLen() / 8 // salt length ); - try + try { SRTPTransformEngine engine = new SRTPTransformEngine(secrets .getKeyResponder(), secrets.getSaltResponder(), srtpPolicy, srtpPolicy, cryptoProvider); srtpOutTransformer = engine.getRTPTransformer(); - } - catch (GeneralSecurityException e) + } + catch (GeneralSecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -705,36 +714,36 @@ public boolean srtpSecretsReady(ZrtpSrtpSecrets secrets, EnableSecurity part) } } } - if (part == EnableSecurity.ForReceiver) + if (part == EnableSecurity.ForReceiver) { // To decrypt packets: intiator uses responder keys, // responder initiator keys // See comment above. - if (secrets.getRole() == Role.Initiator) + if (secrets.getRole() == Role.Initiator) { srtpPolicy = new SRTPPolicy(SRTPPolicy.AESCM_ENCRYPTION, secrets.getRespKeyLen() / 8, // key length - SRTPPolicy.HMACSHA1_AUTHENTICATION, + SRTPPolicy.HMACSHA1_AUTHENTICATION, 20, // auth key length secrets.getSrtpAuthTagLen() / 8,// auth tag length secrets.getRespSaltLen() / 8 // salt length ); - try + try { SRTPTransformEngine engine = new SRTPTransformEngine(secrets .getKeyResponder(), secrets.getSaltResponder(), srtpPolicy, srtpPolicy, cryptoProvider); srtpInTransformer = engine.getRTPTransformer(); - } - catch (GeneralSecurityException e) + } + catch (GeneralSecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } - } - else + } + else { srtpPolicy = new SRTPPolicy(SRTPPolicy.AESCM_ENCRYPTION, secrets.getInitKeyLen() / 8, // key length @@ -743,15 +752,15 @@ public boolean srtpSecretsReady(ZrtpSrtpSecrets secrets, EnableSecurity part) secrets.getSrtpAuthTagLen() / 8,// auth tag length secrets.getInitSaltLen() / 8 // salt length ); - - try + + try { SRTPTransformEngine engine = new SRTPTransformEngine(secrets .getKeyInitiator(), secrets.getSaltInitiator(), srtpPolicy, srtpPolicy, cryptoProvider); srtpInTransformer = engine.getRTPTransformer(); - } - catch (GeneralSecurityException e) + } + catch (GeneralSecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -764,11 +773,12 @@ public boolean srtpSecretsReady(ZrtpSrtpSecrets secrets, EnableSecurity part) /* * (non-Javadoc) - * @see gnu.java.zrtp.ZrtpCallback#srtpSecretsOn(java.lang.String, java.lang.String, boolean) + * @see gnu.java.zrtp.ZrtpCallback#srtpSecretsOn(java.lang.String, + * java.lang.String, boolean) */ - public void srtpSecretsOn(String c, String s, boolean verified) + public void srtpSecretsOn(String c, String s, boolean verified) { - if (userCallback != null) + if (userCallback != null) { userCallback.secureOn(c); } @@ -780,19 +790,20 @@ public void srtpSecretsOn(String c, String s, boolean verified) /* * (non-Javadoc) - * @see gnu.java.zrtp.ZrtpCallback#srtpSecretsOff(gnu.java.zrtp.ZrtpCallback.EnableSecurity) + * @see gnu.java.zrtp.ZrtpCallback#srtpSecretsOff( + * gnu.java.zrtp.ZrtpCallback.EnableSecurity) */ - public void srtpSecretsOff(EnableSecurity part) + public void srtpSecretsOff(EnableSecurity part) { - if (part == EnableSecurity.ForSender) + if (part == EnableSecurity.ForSender) { srtpOutTransformer = null; } - if (part == EnableSecurity.ForReceiver) + if (part == EnableSecurity.ForReceiver) { srtpInTransformer = null; } - if (userCallback != null) + if (userCallback != null) { userCallback.secureOff(); } @@ -802,9 +813,9 @@ public void srtpSecretsOff(EnableSecurity part) * (non-Javadoc) * @see gnu.java.zrtp.ZrtpCallback#activateTimer(int) */ - public int activateTimer(int time) + public int activateTimer(int time) { - if (timeoutProvider != null) + if (timeoutProvider != null) { timeoutProvider.requestTimeout(time, this); } @@ -815,9 +826,9 @@ public int activateTimer(int time) * (non-Javadoc) * @see gnu.java.zrtp.ZrtpCallback#cancelTimer() */ - public int cancelTimer() + public int cancelTimer() { - if (timeoutProvider != null) + if (timeoutProvider != null) { timeoutProvider.cancelRequest(); } @@ -828,7 +839,7 @@ public int cancelTimer() * Timeout handling function. * Delegates the handling to the ZRTP engine. */ - public void handleTimeout() + public void handleTimeout() { if (zrtpEngine != null) { zrtpEngine.processTimeout(); @@ -837,39 +848,47 @@ public void handleTimeout() /* * (non-Javadoc) - * @see gnu.java.zrtp.ZrtpCallback#sendInfo(gnu.java.zrtp.ZrtpCodes.MessageSeverity, java.util.EnumSet) + * @see gnu.java.zrtp.ZrtpCallback#sendInfo( + * gnu.java.zrtp.ZrtpCodes.MessageSeverity, + * java.util.EnumSet) */ - public void sendInfo(ZrtpCodes.MessageSeverity severity, EnumSet subCode) + public void sendInfo(ZrtpCodes.MessageSeverity severity, EnumSet subCode) { - if (userCallback != null) + if (userCallback != null) { userCallback.showMessage(severity, subCode); } } - + /* * (non-Javadoc) - * @see gnu.java.zrtp.ZrtpCallback#zrtpNegotiationFailed(gnu.java.zrtp.ZrtpCodes.MessageSeverity, java.util.EnumSet) + * @see gnu.java.zrtp.ZrtpCallback#zrtpNegotiationFailed( + * gnu.java.zrtp.ZrtpCodes.MessageSeverity, + * java.util.EnumSet) */ - public void zrtpNegotiationFailed(ZrtpCodes.MessageSeverity severity, EnumSet subCode) + public void zrtpNegotiationFailed(ZrtpCodes.MessageSeverity severity, + EnumSet subCode) { - if (userCallback != null) + if (userCallback != null) { userCallback.zrtpNegotiationFailed(severity, subCode); } } - + /* * (non-Javadoc) - * @see gnu.java.zrtp.ZrtpCallback#goClearProcedureFailed(gnu.java.zrtp.ZrtpCodes.MessageSeverity, java.util.EnumSet, boolean) + * @see gnu.java.zrtp.ZrtpCallback#goClearProcedureFailed( + * gnu.java.zrtp.ZrtpCodes.MessageSeverity, + * java.util.EnumSet, boolean) */ - public void goClearProcedureFailed(ZrtpCodes.MessageSeverity severity, + public void goClearProcedureFailed(ZrtpCodes.MessageSeverity severity, EnumSet subCode, - boolean maintainSecurity) + boolean maintainSecurity) { -// if (userCallback != null) +// if (userCallback != null) // { -// userCallback.goClearProcedureFailed(severity, subCode, maintainSecurity); +// userCallback.goClearProcedureFailed(severity, +// subCode, maintainSecurity); // } } @@ -877,9 +896,9 @@ public void goClearProcedureFailed(ZrtpCodes.MessageSeverity severity, * (non-Javadoc) * @see gnu.java.zrtp.ZrtpCallback#zrtpNotSuppOther() */ - public void zrtpNotSuppOther() + public void zrtpNotSuppOther() { - if (userCallback != null) + if (userCallback != null) { userCallback.zrtpNotSuppOther(); } @@ -889,9 +908,9 @@ public void zrtpNotSuppOther() * (non-Javadoc) * @see gnu.java.zrtp.ZrtpCallback#zrtpAskEnrollment(java.lang.String) */ - public void zrtpAskEnrollment(String info) + public void zrtpAskEnrollment(String info) { - if (userCallback != null) + if (userCallback != null) { userCallback.zrtpAskEnrollment(info); } @@ -901,9 +920,9 @@ public void zrtpAskEnrollment(String info) * (non-Javadoc) * @see gnu.java.zrtp.ZrtpCallback#zrtpInformEnrollment(java.lang.String) */ - public void zrtpInformEnrollment(String info) + public void zrtpInformEnrollment(String info) { - if (userCallback != null) + if (userCallback != null) { userCallback.zrtpInformEnrollment(info); } @@ -913,9 +932,9 @@ public void zrtpInformEnrollment(String info) * (non-Javadoc) * @see gnu.java.zrtp.ZrtpCallback#signSAS(java.lang.String) */ - public void signSAS(String sas) + public void signSAS(String sas) { - if (userCallback != null) + if (userCallback != null) { userCallback.signSAS(sas); } @@ -925,27 +944,29 @@ public void signSAS(String sas) * (non-Javadoc) * @see gnu.java.zrtp.ZrtpCallback#checkSASSignature(java.lang.String) */ - public boolean checkSASSignature(String sas) + public boolean checkSASSignature(String sas) { - return ((userCallback != null) ? userCallback.checkSASSignature(sas) : false); + return ((userCallback != null) + ? userCallback.checkSASSignature(sas) + : false); } /** * Sets the enableZrtp flag - * - * @param onOff The value for the enableZrtp flag + * + * @param onOff The value for the enableZrtp flag */ - public void setEnableZrtp(boolean onOff) + public void setEnableZrtp(boolean onOff) { enableZrtp = onOff; } /** * Returns the enableZrtp flag - * + * * @return the enableZrtp flag */ - public boolean isEnableZrtp() + public boolean isEnableZrtp() { return enableZrtp; } @@ -953,7 +974,7 @@ public boolean isEnableZrtp() /** * Set the SAS as verified internally if the user confirms it */ - public void SASVerified() + public void SASVerified() { if (zrtpEngine != null) zrtpEngine.SASVerified(); @@ -962,7 +983,7 @@ public void SASVerified() /** * Resets the internal engine SAS verified flag */ - public void resetSASVerified() + public void resetSASVerified() { if (zrtpEngine != null) zrtpEngine.resetSASVerified(); @@ -970,19 +991,20 @@ public void resetSASVerified() /** * Method called when the user requests through GUI to switch a secured call - * to unsecure mode. Just forwards the request to the Zrtp class. + * to unsecure mode. Just forwards the request to the Zrtp class. */ - public void requestGoClear() + public void requestGoClear() { // if (zrtpEngine != null) // zrtpEngine.requestGoClear(); } - + /** * Method called when the user requests through GUI to switch a previously - * unsecured call back to secure mode. Just forwards the request to the Zrtp class. + * unsecured call back to secure mode. Just forwards the request to the + * Zrtp class. */ - public void requestGoSecure() + public void requestGoSecure() { // if (zrtpEngine != null) // zrtpEngine.requestGoSecure(); @@ -990,10 +1012,10 @@ public void requestGoSecure() /** * Sets the srtps secret data (chapter 3.2.1 in the ZRTP specification) - * + * * @param data The srtps secret data */ - public void setSrtpsSecret(byte[] data) + public void setSrtpsSecret(byte[] data) { if (zrtpEngine != null) zrtpEngine.setSrtpsSecret(data); @@ -1001,10 +1023,10 @@ public void setSrtpsSecret(byte[] data) /** * Sets the other secret data (chapter 3.2.1 in the ZRTP specification) - * + * * @param data The other secret data */ - public void setOtherSecret(byte[] data) + public void setOtherSecret(byte[] data) { if (zrtpEngine != null) zrtpEngine.setOtherSecret(data); @@ -1012,20 +1034,20 @@ public void setOtherSecret(byte[] data) /** * Sets the client ID - * + * * @param id The client ID */ - public void setClientId(String id) + public void setClientId(String id) { clientIdString = id; } /** * Gets the Hello packet Hash - * + * * @return the Hello packet hash */ - public String getHelloHash() + public String getHelloHash() { if (zrtpEngine != null) return zrtpEngine.getHelloHash(); @@ -1035,10 +1057,10 @@ public String getHelloHash() /** * Gets the multistream params - * + * * @return the multistream params */ - public byte[] getMultiStrParams() + public byte[] getMultiStrParams() { if (zrtpEngine != null) return zrtpEngine.getMultiStrParams(); @@ -1051,7 +1073,7 @@ public byte[] getMultiStrParams() * (The multistream part needs further development) * @param parameters the multistream params */ - public void setMultiStrParams(byte[] parameters) + public void setMultiStrParams(byte[] parameters) { if (zrtpEngine != null) zrtpEngine.setMultiStrParams(parameters); @@ -1062,7 +1084,7 @@ public void setMultiStrParams(byte[] parameters) * (The multistream part needs further development) * @return the multistream flag */ - public boolean isMultiStream() + public boolean isMultiStream() { return ((zrtpEngine != null) ? zrtpEngine.isMultiStream() : false); } @@ -1072,7 +1094,7 @@ public boolean isMultiStream() * (The PBX part needs further development) * @param accepted The boolean value indicating if the request is accepted */ - public void acceptEnrollment(boolean accepted) + public void acceptEnrollment(boolean accepted) { if (zrtpEngine != null) zrtpEngine.acceptEnrollment(accepted); @@ -1080,22 +1102,22 @@ public void acceptEnrollment(boolean accepted) /** * Sets signature data for the Confirm packets - * + * * @param data the signature data * @return true if signature data was successfully set */ - public boolean setSignatureData(byte[] data) + public boolean setSignatureData(byte[] data) { return ((zrtpEngine != null) ? zrtpEngine.setSignatureData(data) : false); } /** - * Gets signature data - * + * Gets signature data + * * @return the signature data */ - public byte[] getSignatureData() + public byte[] getSignatureData() { if (zrtpEngine != null) return zrtpEngine.getSignatureData(); @@ -1105,10 +1127,10 @@ public byte[] getSignatureData() /** * Gets signature length - * + * * @return the signature length */ - public int getSignatureLength() + public int getSignatureLength() { return ((zrtpEngine != null) ? zrtpEngine.getSignatureLength() : 0); } @@ -1118,81 +1140,81 @@ public int getSignatureLength() * (The PBX part needs further development) * @param yesNo The PBX enrollment flag */ - public void setPBXEnrollment(boolean yesNo) + public void setPBXEnrollment(boolean yesNo) { if (zrtpEngine != null) zrtpEngine.setPBXEnrollment(yesNo); } /** - * Method called by the Zrtp class as result of a GoClear request from the + * Method called by the Zrtp class as result of a GoClear request from the * other peer. An explicit user confirmation is needed before switching to - * unsecured mode. This is asked through the user callback. + * unsecured mode. This is asked through the user callback. */ - public void handleGoClear() + public void handleGoClear() { - userCallback.confirmGoClear(); + userCallback.confirmGoClear(); } /** - * Sets the RTP connector using this ZRTP engine + * Sets the RTP connector using this ZRTP engine * (This method should be changed to an addConnector to a connector array * managed by the engine for implementing multistream mode) - * + * * @param connector the connector to set */ - public void setConnector(TransformConnector connector) + public void setConnector(TransformConnector connector) { zrtpConnector = connector; } - + /** * Sets the user callback class used to maintain the GUI ZRTP part - * + * * @param ub The user callback class */ - public void setUserCallback(ZrtpUserCallback ub) + public void setUserCallback(SCCallback ub) { userCallback = ub; } - + /** * Sets the cryptography provider responsible with the crypto algorithms * (Currently BouncyCastle is used) - * + * * @param cryptoProvider the cryptoProvider to set */ - public void setCryptoProvider(Provider cryptoProvider) + public void setCryptoProvider(Provider cryptoProvider) { this.cryptoProvider = cryptoProvider; } /** * Returns the current status of the ZRTP engine - * + * * @return the current status of the ZRTP engine */ - public boolean isStarted() + public boolean isStarted() { return started; } - + /* * (non-Javadoc) * @see gnu.java.zrtp.ZrtpCallback#stopStreaming(boolean) */ - public void stopStreaming(boolean stop) + public void stopStreaming(boolean stop) { - holdFlag = stop; + holdFlag = stop; } /** * Gets the user callback used to manage the GUI part of ZRTP - * + * * @return the user callback */ - public ZrtpUserCallback getUserCallback() - { - return userCallback; - } + public SCCallback getUserCallback() + { + return userCallback; + } }