org.openuat.util
Class BluetoothRFCOMMServer

java.lang.Object
  extended by org.openuat.authentication.AuthenticationEventSender
      extended by org.openuat.util.HostServerBase
          extended by org.openuat.util.BluetoothRFCOMMServer
All Implemented Interfaces:
java.lang.Runnable, HostAuthenticationServer

public class BluetoothRFCOMMServer
extends HostServerBase

This class represents an RFCOMM service which responds to incoming authentication requests by delegating any incoming connection to the HostProtocolHandler class. More specifically, for each incoming RFCOMM connection, the HostProtocolHandler.startIncomingAuthenticationThread is invoked with the connected RFCOMM stream connection. Listening is done in a background thread using blocking accept() calls. After constructing a BluetoothRFCOMMServer object for a specific channel, startListening() needs to be called to start accepting incoming connection. Authentication and encryption as well as authorization on Bluetooth level are deactivated.

Version:
1.0
Author:
Rene Mayrhofer

Field Summary
 
Fields inherited from class org.openuat.util.HostServerBase
keepConnected, protocolCommandHandlers, protocolTimeoutMs, running, useJSSE
 
Fields inherited from class org.openuat.authentication.AuthenticationEventSender
eventsHandlers
 
Constructor Summary
BluetoothRFCOMMServer(java.lang.Integer channel, javax.bluetooth.UUID serviceUUID, java.lang.String serviceName, int protocolTimeoutMs, boolean keepConnected, boolean useJSSE)
          Initializes the listener by creating the RFCOMM service.
 
Method Summary
 void dispose()
          Override the dispose method to make sure that we remove the service record from the local SDB.
 java.lang.String getRegisteredServiceURL()
          After startListening finished successfully, this will return the URL that can be used by RFCOMM clients to connect to this service.
static void main(java.lang.String[] args)
           
 void run()
          This actually implements the listening for new RFCOMM channels.
 void start()
          Need to override the startListening method to register the SDP service.
 void stop()
          Need to override the stopListening method to properly close the RFCOMM service notifier.
 
Methods inherited from class org.openuat.util.HostServerBase
addProtocolCommandHandler, isRunning, removeProtocolCommandHandler, setProtocolCommandHandler, startProtocol
 
Methods inherited from class org.openuat.authentication.AuthenticationEventSender
addAuthenticationProgressHandler, raiseAuthenticationFailureEvent, raiseAuthenticationProgressEvent, raiseAuthenticationStartedEvent, raiseAuthenticationSuccessEvent, removeAuthenticationProgressHandler, setAuthenticationProgressHandlers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openuat.util.HostAuthenticationServer
addAuthenticationProgressHandler, removeAuthenticationProgressHandler
 

Constructor Detail

BluetoothRFCOMMServer

public BluetoothRFCOMMServer(java.lang.Integer channel,
                             javax.bluetooth.UUID serviceUUID,
                             java.lang.String serviceName,
                             int protocolTimeoutMs,
                             boolean keepConnected,
                             boolean useJSSE)
                      throws java.io.IOException
Initializes the listener by creating the RFCOMM service.

Parameters:
channel - The RFCOMM channel to use, or unspecified (dynamically use a free channel) when null.
serviceUUID - The Bluetooth service UUID to register.
serviceName - The name to announce via SDP.
useJSSE - If set to true, the JSSE API with the default JCE provider of the JVM will be used for cryptographic operations. If set to false, an internal copy of the Bouncycastle Lightweight API classes will be used.
protocolTimeoutMs - The maximum duration in milliseconds that this authentication protocol may take before it will abort with an AuthenticationFailed exception. Set to -1 to disable the timeout.
Throws:
java.io.IOException
See Also:
If set to true, the connection to the client will be kept connected after the registered HostProtocolHandler has finished. This allows the socket to be reused for additional communication after the first authentication protocol has been completed.
Method Detail

start

public void start()
           throws java.io.IOException
Need to override the startListening method to register the SDP service.

Specified by:
start in interface HostAuthenticationServer
Overrides:
start in class HostServerBase
Throws:
InternalApplicationException
java.io.IOException

stop

public void stop()
          throws InternalApplicationException
Need to override the stopListening method to properly close the RFCOMM service notifier.

Specified by:
stop in interface HostAuthenticationServer
Overrides:
stop in class HostServerBase
Throws:
InternalApplicationException

getRegisteredServiceURL

public java.lang.String getRegisteredServiceURL()
After startListening finished successfully, this will return the URL that can be used by RFCOMM clients to connect to this service.


run

public void run()
This actually implements the listening for new RFCOMM channels.


dispose

public void dispose()
Override the dispose method to make sure that we remove the service record from the local SDB.


main

public static void main(java.lang.String[] args)
                 throws java.lang.NullPointerException,
                        java.lang.IllegalArgumentException,
                        java.io.IOException,
                        InternalApplicationException
Throws:
java.lang.NullPointerException
java.lang.IllegalArgumentException
java.io.IOException
InternalApplicationException


2005-2006, Rene Mayrhofer.