Class CryptoPhoneApp

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by CryptoPhoneApp
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants, PBXClient.Context, Log.AttentionContext

public class CryptoPhoneApp
extends javax.swing.JFrame
implements java.awt.event.ActionListener, java.awt.event.KeyListener, PBXClient.Context, Log.AttentionContext

The Swing based GUI front-end of the Kryptofon application that implements simple VoIP phone and chat client with encrypted peer-to-peer communication.

Author:
Mikica B Kocic
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private static java.lang.String appTitle
          The common application title prefix.
private  AudioInterface audioInterface
          The instance of the Audio interface used to access microphone and speaker.
private  javax.swing.JCheckBox autoAnswer
           
private  java.lang.String currentInvite
          The remote peer (its user id) that we are currently inviting to a call.
private static java.lang.String defaultInputMsg
          The initial message content of the input text message field.
private static java.lang.String defaultLogAreaDumpFilename
          The default file name where to dump log area contents with :dump command
private  JImageButton dialButton
           
private  JImageButton hangupButton
           
private  javax.swing.JLabel idLabel
           
private  javax.swing.JLabel imsgLabel
           
private  javax.swing.JTextField inputMsg
           
private  int inviteTimeout
          Timer used to detect unresolved invite (i.e. invite to non-existing peer).
private  PBXClient.ControlMessage lastMessageFromPBX
          The last PBX control message sent to us (waiting to be handled)
private  JImageButton listPeersButton
           
private  int localUdpPort
          The default local UDP port.
private  javax.swing.JEditorPane logArea
          The log area formatted in HTML
private  javax.swing.Timer mainTimer
          Main timer (elapses every 1000 ms)
private  boolean monitorIfPeerIsSendingVoice
          Indicates whether to monitor if peer is sending voice PDUs to us.
private  PBXClient pbxChannel
          The instance of PBX client connected to remote chat server.
private  java.lang.String pbxChannelStatus
          The last status message of the PBX channel (posted by the setPbxStatus()).
private  int reconnectRetryCount
          Retry counter of number of failed reconnecting attempts.
private  int reconnectTimeout
          The reconnect delay timer (for timing delay between two reconnections).
(package private)  PublicEncryptor remotePublicKey
          The last public key received from remote peer
private  JImageButton secureDialButton
           
private  JSecState securityState
           
private  JImageButton sendButton
           
private static long serialVersionUID
          Implements java.io.Serializable interface
private  java.lang.String serverName
          The host name or IP address of the remote chat server
private  int serverPort
          The TCP port where to connect to on remote chat server
private  DatagramChannel udpChannel
          The instance of the UDP transceiver responsible for peer-to-peer communication between two Kryptofons.
private  javax.swing.JTextField userId
           
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
CryptoPhoneApp(java.lang.String[] args)
          Creates a new instance of the CryptoPhoneApp.
 
Method Summary
private  void acceptIncomingCall(boolean securedIfPossible)
          Accepts incoming invite.
 void actionPerformed(java.awt.event.ActionEvent ae)
          Handles events from Swing timer and buttons.
 void attention(java.lang.String message)
          Displays attention messages to the user from Log subsystem.
 void clearLogArea()
          Clears log area (with the contents of the "empty" template)
private  void createEventListeners()
          Creates event listeners
private  void createLayout()
          Creates layout of the GUI components
 void deferredOnAccept(PBXClient.ControlMessage m)
          On ACCEPT call-back is triggered when PBXClient receives accepting message (indicating that the peer has accepted our invite).
 void deferredOnBye(PBXClient.ControlMessage m)
          On BYE call-back is triggered when PBXClient receives 'bye' message (indicating that the peer is clearing i.e. hanging-up the call).
 void deferredOnInstantMessage(PBXClient.ControlMessage m)
          On IMSG call-back is triggered when PBXClient receives private instant message (encrypted with session's secret key).
 void deferredOnInvite(PBXClient.ControlMessage m)
          On INVITE call-back is triggered when PBXClient receives inviting message (indicating that someone is calling us).
 void deferredOnRing(PBXClient.ControlMessage m)
          On RING call-back is triggered when PBXClient receives ringing message (indicating that the peer is alerting end-user).
private  void dialButton_Clicked()
          Performs :invite command.
 void displayHelp()
          Displays help
 void displayUsage()
          Displays usage information
 void dumpLogArea(java.lang.String fileName)
          Dumps log area into html file
private  boolean executeCommand(java.lang.String cmd, java.lang.String[] args)
          Parses commands prefixed with ':' character.
private  void formWindowClosing(java.awt.event.WindowEvent evt)
          Closes application by gracefully terminating all threads.
 java.lang.StringBuffer getContentsFromResourceOrFile(java.lang.String path)
          Reads contents of the text file using URL class.
 java.lang.String getUserId()
          Returns configured user ID (username).
private  void hangupButton_Clicked()
          Performs :bye command.
 void keyPressed(java.awt.event.KeyEvent ke)
          Implements KeyListener's key pressed event.
 void keyReleased(java.awt.event.KeyEvent ke)
          Implements KeyListener's key released event.
 void keyTyped(java.awt.event.KeyEvent ke)
          Implements KeyListener's key typed event.
private  void listPeersButton_Clicked()
          Performs :list command.
 void logMessage(java.lang.String str)
          Logs message formated with limited HTML (limited because of JEditorPane)
static void main(java.lang.String[] args)
          Main entry point.
private  void mainTimerEvent()
          Handles events from application's mainTimer (an instance of the Swing timer).
 void onAccept(PBXClient.ControlMessage m)
          Handles on ACCEPT call-back from the PBXClient.
 void onBye(PBXClient.ControlMessage m)
          Handles on BYE call-back from the PBXClient.
 void onInstantMessage(PBXClient.ControlMessage m)
          Handles on IMSG call-back from the PBXClient.
 void onInvite(PBXClient.ControlMessage m)
          Handles on INVITE call-back from the PBXClient.
 void onRing(PBXClient.ControlMessage m)
          Handles on RING call-back from the PBXClient.
private  void parseInputMessage()
          Parses input message from inputMsg and sends it to chat server.
 void report(java.lang.String cssClass, java.lang.String str)
          Reports a system message to log
 void reportIncomingTextMessage(java.lang.String cssClass, java.lang.String userId, java.lang.String message)
          Reports incoming message
private  void secureDialButton_Clicked()
          Performs :invite+ command.
private  void sendButton_Clicked()
          Parses input text entered by the user in inputMsg.
private  void sendInstantMessage(java.lang.String message, boolean forceUnencrypted)
          Sends chat message (encrypted if we have established secure channel with the user).
 void setPbxStatus(java.lang.String str)
          Updates status message by updating window title
 void startKryptofonServices()
          Starts audio interface and UDP peer-to-peer channel.
 void stopKryptofonServices()
          Stops audio interface and UDP peer-to-peer channel.
private  java.lang.String[] tokenizeInputMessage()
          Tokenizes inputMsg into words and returns array of strings.
private  PublicEncryptor tryToVerifyInvitingCall(boolean silent)
          Verifies invitor's public key (signed by invitor's private key) against the public keys from authorized keys file.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Implements java.io.Serializable interface

See Also:
Constant Field Values

appTitle

private static final java.lang.String appTitle
The common application title prefix.

See Also:
Constant Field Values

defaultInputMsg

private static final java.lang.String defaultInputMsg
The initial message content of the input text message field.

See Also:
Constant Field Values

defaultLogAreaDumpFilename

private static final java.lang.String defaultLogAreaDumpFilename
The default file name where to dump log area contents with :dump command

See Also:
Constant Field Values

serverName

private java.lang.String serverName
The host name or IP address of the remote chat server


serverPort

private int serverPort
The TCP port where to connect to on remote chat server


pbxChannel

private PBXClient pbxChannel
The instance of PBX client connected to remote chat server.


pbxChannelStatus

private java.lang.String pbxChannelStatus
The last status message of the PBX channel (posted by the setPbxStatus()).


mainTimer

private javax.swing.Timer mainTimer
Main timer (elapses every 1000 ms)


reconnectTimeout

private int reconnectTimeout
The reconnect delay timer (for timing delay between two reconnections). Value -1 means 'disabled'.


reconnectRetryCount

private int reconnectRetryCount
Retry counter of number of failed reconnecting attempts.


localUdpPort

private int localUdpPort
The default local UDP port.


udpChannel

private DatagramChannel udpChannel
The instance of the UDP transceiver responsible for peer-to-peer communication between two Kryptofons.


audioInterface

private AudioInterface audioInterface
The instance of the Audio interface used to access microphone and speaker.


lastMessageFromPBX

private PBXClient.ControlMessage lastMessageFromPBX
The last PBX control message sent to us (waiting to be handled)


remotePublicKey

PublicEncryptor remotePublicKey
The last public key received from remote peer


currentInvite

private java.lang.String currentInvite
The remote peer (its user id) that we are currently inviting to a call. Null if we are not inviting anyone.


inviteTimeout

private int inviteTimeout
Timer used to detect unresolved invite (i.e. invite to non-existing peer). Value -1 means 'disabled'.


monitorIfPeerIsSendingVoice

private boolean monitorIfPeerIsSendingVoice
Indicates whether to monitor if peer is sending voice PDUs to us. Should be set to 'true' always when set call established.


logArea

private javax.swing.JEditorPane logArea
The log area formatted in HTML


securityState

private JSecState securityState

sendButton

private JImageButton sendButton

listPeersButton

private JImageButton listPeersButton

dialButton

private JImageButton dialButton

secureDialButton

private JImageButton secureDialButton

hangupButton

private JImageButton hangupButton

imsgLabel

private javax.swing.JLabel imsgLabel

inputMsg

private javax.swing.JTextField inputMsg

idLabel

private javax.swing.JLabel idLabel

userId

private javax.swing.JTextField userId

autoAnswer

private javax.swing.JCheckBox autoAnswer
Constructor Detail

CryptoPhoneApp

public CryptoPhoneApp(java.lang.String[] args)
Creates a new instance of the CryptoPhoneApp.

Parameters:
args - the command line arguments passed to main
Method Detail

createLayout

private void createLayout()
Creates layout of the GUI components


createEventListeners

private void createEventListeners()
Creates event listeners


startKryptofonServices

public void startKryptofonServices()
Starts audio interface and UDP peer-to-peer channel.


stopKryptofonServices

public void stopKryptofonServices()
Stops audio interface and UDP peer-to-peer channel.


sendButton_Clicked

private void sendButton_Clicked()
Parses input text entered by the user in inputMsg.


listPeersButton_Clicked

private void listPeersButton_Clicked()
Performs :list command.


dialButton_Clicked

private void dialButton_Clicked()
Performs :invite command.


secureDialButton_Clicked

private void secureDialButton_Clicked()
Performs :invite+ command.


hangupButton_Clicked

private void hangupButton_Clicked()
Performs :bye command.


formWindowClosing

private void formWindowClosing(java.awt.event.WindowEvent evt)
Closes application by gracefully terminating all threads.


keyPressed

public void keyPressed(java.awt.event.KeyEvent ke)
Implements KeyListener's key pressed event. Parses input message on ENTER (the same action as it was sendButton_Clicked).

Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent ke)
Implements KeyListener's key released event.

Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent ke)
Implements KeyListener's key typed event.

Specified by:
keyTyped in interface java.awt.event.KeyListener

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ae)
Handles events from Swing timer and buttons.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

mainTimerEvent

private void mainTimerEvent()
Handles events from application's mainTimer (an instance of the Swing timer). It monitors status of: -# PBXClient connection -# connection to remote peer (if any) -# awaiting acknowledgment for our last invite message (if any) If PBXClient connection is detected to be down, the procedure will try to reconnect to chat server after some period of time. If reconnection retry count exceeded maximum, timer will stop retrying. In case of dead remote peer (not sending UDP packets to us), udpChannel.isPearDead() timer will clear down the call. In case of unacknowledged invite message, inviteTimeout timer will cancel current inviting.


logMessage

public void logMessage(java.lang.String str)
Logs message formated with limited HTML (limited because of JEditorPane)


attention

public void attention(java.lang.String message)
Displays attention messages to the user from Log subsystem.

Specified by:
attention in interface Log.AttentionContext

getUserId

public java.lang.String getUserId()
Returns configured user ID (username).

Specified by:
getUserId in interface PBXClient.Context

setPbxStatus

public void setPbxStatus(java.lang.String str)
Updates status message by updating window title

Specified by:
setPbxStatus in interface PBXClient.Context

report

public void report(java.lang.String cssClass,
                   java.lang.String str)
Reports a system message to log

Specified by:
report in interface PBXClient.Context

reportIncomingTextMessage

public void reportIncomingTextMessage(java.lang.String cssClass,
                                      java.lang.String userId,
                                      java.lang.String message)
Reports incoming message

Specified by:
reportIncomingTextMessage in interface PBXClient.Context

onInvite

public void onInvite(PBXClient.ControlMessage m)
Handles on INVITE call-back from the PBXClient.

Specified by:
onInvite in interface PBXClient.Context

onRing

public void onRing(PBXClient.ControlMessage m)
Handles on RING call-back from the PBXClient.

Specified by:
onRing in interface PBXClient.Context

onAccept

public void onAccept(PBXClient.ControlMessage m)
Handles on ACCEPT call-back from the PBXClient.

Specified by:
onAccept in interface PBXClient.Context

onBye

public void onBye(PBXClient.ControlMessage m)
Handles on BYE call-back from the PBXClient.

Specified by:
onBye in interface PBXClient.Context

onInstantMessage

public void onInstantMessage(PBXClient.ControlMessage m)
Handles on IMSG call-back from the PBXClient.

Specified by:
onInstantMessage in interface PBXClient.Context

tokenizeInputMessage

private java.lang.String[] tokenizeInputMessage()
Tokenizes inputMsg into words and returns array of strings.


parseInputMessage

private void parseInputMessage()
Parses input message from inputMsg and sends it to chat server. If it is a command (the first word is prefixed with ':' character) it spawns executeCommand() for further parsing.


sendInstantMessage

private void sendInstantMessage(java.lang.String message,
                                boolean forceUnencrypted)
Sends chat message (encrypted if we have established secure channel with the user).


executeCommand

private boolean executeCommand(java.lang.String cmd,
                               java.lang.String[] args)
Parses commands prefixed with ':' character. Recognized commands are:
  VoIP Calls:
  
     :inv[ite]    username             aliases: :ca[ll]
     :inv[ite]+   username             aliases: :ca[ll]+
     :acc[ept]                         aliases: :ans[wer]
     :by[e]                            aliases: :ha[ngup]
     :shk[ey]
     
  VoIP Peers:
  
     :li[st]    [ username-regex ]
     
  Chat Messages:

     :br[oadcast]  message
     
  Connection to Chat Server:
  
     :clo[se]
     :op[en]    [ host  [ port ] ] 
     
  Application:
     :cl[ear]s[creen]
     :reauth
     :newsecret  [ algorithm [ keysize ] ]
     :du[mp]
     :ex[it]                           aliases: :qu[it]
     :he[lp]
  

Parameters:
cmd - command name; must begin with ":"
args - command arguments; may be null or empty array
Returns:
true if command is parsed and executed

deferredOnInvite

public void deferredOnInvite(PBXClient.ControlMessage m)
On INVITE call-back is triggered when PBXClient receives inviting message (indicating that someone is calling us). It starts ringing and if the application is in auto-answer mode, it accepts incoming call immediately. Otherwise it presents alerting message to the user with information about who's calling.


deferredOnRing

public void deferredOnRing(PBXClient.ControlMessage m)
On RING call-back is triggered when PBXClient receives ringing message (indicating that the peer is alerting end-user).


deferredOnAccept

public void deferredOnAccept(PBXClient.ControlMessage m)
On ACCEPT call-back is triggered when PBXClient receives accepting message (indicating that the peer has accepted our invite). It deserializes encrypted secret key used for peer-to-peer communication (if any) and creates instance for the call (CallContext class) as well the remote peer (RemotePeer class), and binds them to specific CODEC (of the audio interface) and the UDP channel (for voice transmission). The call is finally established at this point.


deferredOnBye

public void deferredOnBye(PBXClient.ControlMessage m)
On BYE call-back is triggered when PBXClient receives 'bye' message (indicating that the peer is clearing i.e. hanging-up the call).


deferredOnInstantMessage

public void deferredOnInstantMessage(PBXClient.ControlMessage m)
On IMSG call-back is triggered when PBXClient receives private instant message (encrypted with session's secret key).


tryToVerifyInvitingCall

private PublicEncryptor tryToVerifyInvitingCall(boolean silent)
Verifies invitor's public key (signed by invitor's private key) against the public keys from authorized keys file.


acceptIncomingCall

private void acceptIncomingCall(boolean securedIfPossible)
Accepts incoming invite. Procedure is called either automatically from deferredOnInvite() when the auto-answer is turned on, or manually by the user from :accept command). It first verifies invitor's public key (signed by invitor's private key) against the public keys from authorized keys file. It then signs local secret key with the local private key, then encrypts signed secret key with our with verified invitor's public key and serializes it as Base64 string. It sends ACCEPTING message to the peer with the information how to rich us (local IP address and UDP port as well serialized encrypted secret key) and signed/encrypted/encoded secret key. At the end it creates instance for the call (CallContext class) and the remote peer (RemotePeer class), and binds them to specific CODEC of the audio interface and UDP channel. The call is finally established at this point.


dumpLogArea

public void dumpLogArea(java.lang.String fileName)
Dumps log area into html file


getContentsFromResourceOrFile

public java.lang.StringBuffer getContentsFromResourceOrFile(java.lang.String path)
Reads contents of the text file using URL class.

Returns:
string buffer containing file contents; null in case of error

clearLogArea

public void clearLogArea()
Clears log area (with the contents of the "empty" template)


displayUsage

public void displayUsage()
Displays usage information


displayHelp

public void displayHelp()
Displays help


main

public static void main(java.lang.String[] args)
Main entry point. Creates GUI instance of the CryptoPhoneApp application.

Parameters:
args - the command line arguments