org.openuat.apps.j2me
Class OpenUATmidlet

java.lang.Object
  extended by javax.microedition.midlet.MIDlet
      extended by org.openuat.apps.j2me.OpenUATmidlet
All Implemented Interfaces:
javax.microedition.lcdui.CommandListener, AuthenticationProgressHandler, BluetoothPeerManager.PeerEventsListener

public class OpenUATmidlet
extends javax.microedition.midlet.MIDlet
implements javax.microedition.lcdui.CommandListener, BluetoothPeerManager.PeerEventsListener, AuthenticationProgressHandler

This MIDlet demonstrates four out-of-band peer verification: visual, audio, madlib, slowcodec.

Version:
1.0
Author:
Rene Mayrhofer, Iulia Ion

Field Summary
protected  javax.microedition.lcdui.Image audio
           
protected  byte[] authKey
          The key resulting from the message exchange during the authentication process
protected  javax.microedition.lcdui.Command back
          Chosen by the user to indicate the verification outcome in manual verification cases
protected  javax.microedition.lcdui.Gauge bluetoothProgressGauge
           
protected  javax.microedition.lcdui.Image buttoncancel
           
protected  javax.microedition.lcdui.Image buttonok
           
protected  javax.microedition.lcdui.Command decreaseVolume
           
protected  javax.microedition.lcdui.List dev_list
          screen that shows what Bluetooth devices have been found
protected  javax.microedition.lcdui.Display display
           
protected  javax.microedition.lcdui.Image error
           
protected  javax.microedition.lcdui.Command exit
           
protected  javax.microedition.lcdui.Form failure_form
           
protected  javax.microedition.lcdui.Command failureCmd
           
protected  javax.microedition.lcdui.List home_screen
          Initial screen with options
protected  javax.microedition.lcdui.Command increaseVolume
           
protected  boolean initiator
          Tells whether this device initiated the set-up or not.
protected  javax.microedition.lcdui.Command log
           
protected  javax.microedition.lcdui.Displayable logScreen
           
protected  javax.microedition.lcdui.Image madlib
           
protected  BluetoothPeerManager peerManager
           
protected  javax.microedition.lcdui.Image print
           
protected  ProgressScreen progressScreen
           
protected  javax.microedition.lcdui.Image replay
           
protected  BluetoothRFCOMMServer rfcommServer
           
protected  javax.microedition.lcdui.Image running
           
protected  javax.microedition.lcdui.Image search
           
protected  javax.microedition.lcdui.Image secure
           
protected  javax.microedition.lcdui.List serv_list
          The list of Bluetooth services offered by a device
protected  java.util.Vector services
          Discovered Bluetooth services
static javax.bluetooth.UUID serviceUUID
           
protected  javax.microedition.lcdui.Image slowcodec
           
 long startTime
          starting of verification time
 long startTimeMadLib
           
protected  javax.microedition.lcdui.Form success_form
          The result of the verification method
protected  javax.microedition.lcdui.Command successCmd
           
protected  javax.microedition.lcdui.Image vCard
           
protected  javax.microedition.lcdui.List verify_method
          displays the available verification methods: visual, audio, madlib, slowcodec
protected  javax.microedition.lcdui.Image visual
           
 int volume
          Play volume, how loud the phone should play the tunes
 
Fields inherited from interface org.openuat.util.BluetoothPeerManager.PeerEventsListener
DEVICE_NOT_REACHABLE, SEARCH_ABORTED, SEARCH_COMPLETE, SEARCH_FAILED
 
Constructor Summary
OpenUATmidlet()
           
 
Method Summary
 void AuthenticationFailure(java.lang.Object sender, java.lang.Object remote, java.lang.Exception e, java.lang.String msg)
          Upon authentication failure, an exception might have been thrown and a message might have been created.
 void AuthenticationProgress(java.lang.Object sender, java.lang.Object remote, int cur, int max, java.lang.String msg)
          This event is raised during the authentication protocol to indicate progress.
 boolean AuthenticationStarted(java.lang.Object sender, java.lang.Object remote)
          This event is raised when the authentication protocol is started, to indicate that further events might follow.
 void AuthenticationSuccess(java.lang.Object sender, java.lang.Object remote, java.lang.Object result)
          Upon successful authentication, the established shared key can be used with the remote host.
 void commandAction(javax.microedition.lcdui.Command com, javax.microedition.lcdui.Displayable dis)
           
protected  void connectTo(java.lang.String connectionURL)
          Starts the connection and authentication process to the given Bluetooth address.
protected  void connectTo(java.lang.String btAdd, int channel)
          Starts the connection and authentication process to the given Bluetooth address.
 void destroyApp(boolean unconditional)
           
 void do_alert_gauge(java.lang.String title, java.lang.String msg, java.lang.String img, int max_time)
          Display an alert which uses a progress bar.
 void do_alert(java.lang.String msg, int time_out)
          Display an alert to inform the user.
 javax.microedition.lcdui.Command getBack()
           
 javax.microedition.lcdui.Command getFailure()
           
 javax.microedition.lcdui.List getHomeScreen()
           
 javax.microedition.lcdui.Command getSuccessCmd()
           
 void informSuccess(boolean success)
          Displays a screen to the user telling whether the exchanged key was successfully verified.
protected  void initGui()
           
 void inquiryCompleted(java.util.Vector newDevices)
          Called when the Bluetooth device inquire has finished.
 void pauseApp()
           
 void serviceSearchCompleted(javax.bluetooth.RemoteDevice remoteDevice, java.util.Vector serv, int errorReason)
          Called when the Bluetooth service search for the selected device has completed.
 void startApp()
           
 
Methods inherited from class javax.microedition.midlet.MIDlet
checkPermission, getAppProperty, notifyDestroyed, notifyPaused, platformRequest, resumeRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serviceUUID

public static final javax.bluetooth.UUID serviceUUID

authKey

protected byte[] authKey
The key resulting from the message exchange during the authentication process


search

protected javax.microedition.lcdui.Image search

vCard

protected javax.microedition.lcdui.Image vCard

print

protected javax.microedition.lcdui.Image print

visual

protected javax.microedition.lcdui.Image visual

audio

protected javax.microedition.lcdui.Image audio

slowcodec

protected javax.microedition.lcdui.Image slowcodec

madlib

protected javax.microedition.lcdui.Image madlib

running

protected javax.microedition.lcdui.Image running

buttonok

protected javax.microedition.lcdui.Image buttonok

buttoncancel

protected javax.microedition.lcdui.Image buttoncancel

replay

protected javax.microedition.lcdui.Image replay

secure

protected javax.microedition.lcdui.Image secure

error

protected javax.microedition.lcdui.Image error

home_screen

protected javax.microedition.lcdui.List home_screen
Initial screen with options


dev_list

protected javax.microedition.lcdui.List dev_list
screen that shows what Bluetooth devices have been found


serv_list

protected javax.microedition.lcdui.List serv_list
The list of Bluetooth services offered by a device


verify_method

protected javax.microedition.lcdui.List verify_method
displays the available verification methods: visual, audio, madlib, slowcodec


success_form

protected javax.microedition.lcdui.Form success_form
The result of the verification method


failure_form

protected javax.microedition.lcdui.Form failure_form

logScreen

protected javax.microedition.lcdui.Displayable logScreen

back

protected javax.microedition.lcdui.Command back
Chosen by the user to indicate the verification outcome in manual verification cases


exit

protected javax.microedition.lcdui.Command exit

log

protected javax.microedition.lcdui.Command log

successCmd

protected javax.microedition.lcdui.Command successCmd

failureCmd

protected javax.microedition.lcdui.Command failureCmd

increaseVolume

protected javax.microedition.lcdui.Command increaseVolume

decreaseVolume

protected javax.microedition.lcdui.Command decreaseVolume

display

protected javax.microedition.lcdui.Display display

rfcommServer

protected BluetoothRFCOMMServer rfcommServer

peerManager

protected BluetoothPeerManager peerManager

services

protected java.util.Vector services
Discovered Bluetooth services


volume

public int volume
Play volume, how loud the phone should play the tunes


bluetoothProgressGauge

protected javax.microedition.lcdui.Gauge bluetoothProgressGauge

progressScreen

protected ProgressScreen progressScreen

initiator

protected boolean initiator
Tells whether this device initiated the set-up or not. If it did, it will be the one coordinating the verification process.


startTime

public long startTime
starting of verification time


startTimeMadLib

public long startTimeMadLib
Constructor Detail

OpenUATmidlet

public OpenUATmidlet()
Method Detail

initGui

protected void initGui()

startApp

public void startApp()
Specified by:
startApp in class javax.microedition.midlet.MIDlet

commandAction

public void commandAction(javax.microedition.lcdui.Command com,
                          javax.microedition.lcdui.Displayable dis)
Specified by:
commandAction in interface javax.microedition.lcdui.CommandListener

connectTo

protected void connectTo(java.lang.String btAdd,
                         int channel)
Starts the connection and authentication process to the given Bluetooth address.

Parameters:
btAdd - The MAC address to which to connect via Bluetooth
channel - The channel number to which to connect to (and on which the OpenUAT service is running on the remote device)

connectTo

protected void connectTo(java.lang.String connectionURL)
Starts the connection and authentication process to the given Bluetooth address.

Parameters:
btAdd -

do_alert

public void do_alert(java.lang.String msg,
                     int time_out)
Display an alert to inform the user.

Parameters:
msg -
time_out -

do_alert_gauge

public void do_alert_gauge(java.lang.String title,
                           java.lang.String msg,
                           java.lang.String img,
                           int max_time)
Display an alert which uses a progress bar.

Parameters:
title - The title of the alert.
msg - The message to be displayed
img - Image to be shown on the gauge
max_time - The maximum steps time on the gauge.

pauseApp

public void pauseApp()
Specified by:
pauseApp in class javax.microedition.midlet.MIDlet

destroyApp

public void destroyApp(boolean unconditional)
Specified by:
destroyApp in class javax.microedition.midlet.MIDlet

inquiryCompleted

public void inquiryCompleted(java.util.Vector newDevices)
Called when the Bluetooth device inquire has finished. It displays the list of devices so the user can select which to connect to.

Specified by:
inquiryCompleted in interface BluetoothPeerManager.PeerEventsListener
Parameters:
newDevices - This vector contains the list of new devices that have been discovered since the last inquiry completed. If no new devices have been found during this inquiry, the vector is empty. Elements of the vector are of type RemoteDevice.
See Also:
to get a list of devices discovered so far.

AuthenticationFailure

public void AuthenticationFailure(java.lang.Object sender,
                                  java.lang.Object remote,
                                  java.lang.Exception e,
                                  java.lang.String msg)
Description copied from interface: AuthenticationProgressHandler
Upon authentication failure, an exception might have been thrown and a message might have been created.

Specified by:
AuthenticationFailure in interface AuthenticationProgressHandler
Parameters:
sender - The object which sent this event.
e - Reason for the failue, can be null.
msg - Reaseon for the failue, can be null

AuthenticationProgress

public void AuthenticationProgress(java.lang.Object sender,
                                   java.lang.Object remote,
                                   int cur,
                                   int max,
                                   java.lang.String msg)
Description copied from interface: AuthenticationProgressHandler
This event is raised during the authentication protocol to indicate progress.

Specified by:
AuthenticationProgress in interface AuthenticationProgressHandler
Parameters:
sender - The object which sent this event.
remote - The remote end with which the authentication is performed.
cur - The current stage in the authentication.
max - The maximum number of stages.
msg - If not null, a message describing the last successful stage.

AuthenticationStarted

public boolean AuthenticationStarted(java.lang.Object sender,
                                     java.lang.Object remote)
Description copied from interface: AuthenticationProgressHandler
This event is raised when the authentication protocol is started, to indicate that further events might follow.

Specified by:
AuthenticationStarted in interface AuthenticationProgressHandler
Parameters:
sender - The object which sent this event.
remote - The remote end with which the authentication is performed. Depends on the sender of the event.
Returns:
true if the handler accepts this authentication to be started, false to "veto" it. If any of the registered handlers (which are called in the order in which they were registered) returns false, the (incoming or outgoing) authentication is aborted.

AuthenticationSuccess

public void AuthenticationSuccess(java.lang.Object sender,
                                  java.lang.Object remote,
                                  java.lang.Object result)
Description copied from interface: AuthenticationProgressHandler
Upon successful authentication, the established shared key can be used with the remote host. The type of the remoteHost object depends on the sender of the event, e.g. an InetAddress object for HostProtocolHandler generated events, but an Integer for DongleProtocolHandler generated events (encapsulating the remote relate id).

Specified by:
AuthenticationSuccess in interface AuthenticationProgressHandler
Parameters:
sender - The object which sent this event.
remote - The remote end with which the authentication is performed. Depends on the sender of the event.
result - The result, if any, of the successful authentication. This can e.g. be a shared key or a set of keys or can even be null if the authentication event is enough to signal successful authentication.

serviceSearchCompleted

public void serviceSearchCompleted(javax.bluetooth.RemoteDevice remoteDevice,
                                   java.util.Vector serv,
                                   int errorReason)
Called when the Bluetooth service search for the selected device has completed. The user can then select the OpenUAT service and start the authentication process.

Specified by:
serviceSearchCompleted in interface BluetoothPeerManager.PeerEventsListener
Parameters:
remoteDevice - The remote device for which new services have been searched for.
serv - The list of services of the remote device. Elements of the vector are of type ServiceRecord. If no services were found, then this vector is empty and the parameter errorReason is set. However, note that this vector may also be empty when no error occurred but when the other device simply offers no services that were searched for.
errorReason - 0 indicates successful completion of service search (either returning a list of matching services or an empty list if there are none), 1 indicates the remote device was not reachable, 2 that the service search ended with an error from the Bluetooth stack, and 3 that the search was canceled prematurely by another thread.

informSuccess

public void informSuccess(boolean success)
Displays a screen to the user telling whether the exchanged key was successfully verified.

Parameters:
success -

getHomeScreen

public javax.microedition.lcdui.List getHomeScreen()

getBack

public javax.microedition.lcdui.Command getBack()

getFailure

public javax.microedition.lcdui.Command getFailure()

getSuccessCmd

public javax.microedition.lcdui.Command getSuccessCmd()


2005-2009, Rene Mayrhofer.