How to set service security requirements

The security requirements that can be set for a service are simple: you can only specify whether authentication, authorisation, and/or encryption are required or not. You cannot, for example, set the security algorithms used: these are the same for all Bluetooth devices.

To set security requirements, take the following steps:

  • Create a security settings object, TBTServiceSecurity . Initialise it with the service's Bluetooth protocol, its port, and a unique identifier for the service (this identifier is not related to the service class UUID).

  • Set in the TBTServiceSecurity object whether authentication, authorisation, and/or encryption are required.

  • Call RBTSecuritySettings::RegisterService() to pass the settings to the security manager.

Example

The following example sets that authentication, authorisation, and encryption are required for a service.

      
       
      
      // Assumes secmanSubSession is an open subsession, and channel
// is the port on which an RFCOMM service is running

// 1. Create security settings object
TUid serviceUID;
serviceUID.iUid = 0X10008AD0;
TBTServiceSecurity secSettings(serviceUID, KSolBtRFCOMM, channel);

// 2. Set the security options
secSettings.SetAuthentication(ETrue);
secSettings.SetAuthorisation(ETrue);
secSettings.SetEncryption(ETrue);

// 3. Register the service
TRequestStatus status;
secmanSubSession.RegisterService(secSettings,status);
User::WaitForRequest(status);