bluetoothmgmt/bluetoothclientlib/inc/btsecurity.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef BTSECURITY_H
       
    17 #define BTSECURITY_H
       
    18 
       
    19 /**
       
    20  @file
       
    21  @publishedAll
       
    22  @released
       
    23 */
       
    24 
       
    25 #include <e32base.h>
       
    26 
       
    27 /**
       
    28 An enumeration to represent the possible levels of Man-in-the-Middle protection
       
    29 that a Bluetooth service may specify.
       
    30 */
       
    31 enum TBluetoothMitmProtection
       
    32 	{
       
    33 	EMitmNotRequired	= 0x0, /*!< No Man-in-the-Middle protection is required. */
       
    34 	EMitmDesired		= 0x1, /*!< Man-in-the-Middle protection should be used where possible. */
       
    35 	EMitmRequired		= 0x2  /*!< Man-in-the-Middle protection is required. */
       
    36 	};
       
    37 
       
    38 NONSHARABLE_CLASS(TBTAccessRequirements)
       
    39 /** The access requirements set up by a bluetooth service.
       
    40 
       
    41 An incoming connection must satisfy these criteria before the connection may proceed.
       
    42 Not spectacularly useful for applications; mainly used by other Bluetooth libraries
       
    43 @publishedAll
       
    44 @released
       
    45 */
       
    46 	{
       
    47 public:
       
    48 	IMPORT_C TBTAccessRequirements();
       
    49 	IMPORT_C void SetAuthentication(TBool aPreference);
       
    50 	IMPORT_C void SetAuthorisation(TBool aPreference);
       
    51 	IMPORT_C void SetEncryption(TBool aPreference);
       
    52 	IMPORT_C void SetDenied(TBool aPreference);
       
    53 	IMPORT_C void SetAuthentication(TBluetoothMitmProtection aPreference);
       
    54 	IMPORT_C TInt SetPasskeyMinLength(TUint aPasskeyMinLength);	
       
    55 	IMPORT_C TBool AuthenticationRequired() const;
       
    56 	IMPORT_C TBool AuthorisationRequired() const;
       
    57 	IMPORT_C TBool EncryptionRequired() const;
       
    58 	IMPORT_C TBool Denied() const;
       
    59 	IMPORT_C TUint PasskeyMinLength() const;
       
    60 	IMPORT_C TBool operator==(const TBTAccessRequirements& aRequirements) const;
       
    61 	IMPORT_C TBluetoothMitmProtection MitmProtection() const;
       
    62 	
       
    63 private:
       
    64 	TUint8 iRequirements;
       
    65 	TUint  iPasskeyMinLength;
       
    66 	
       
    67 private:
       
    68 	enum TBTServiceSecuritySettings
       
    69 		{
       
    70 		EAuthenticate = 0x01,
       
    71 		EAuthorise = 0x02,
       
    72 		EEncrypt = 0x04,
       
    73 		EDenied = 0x08,
       
    74 		EMitm = 0x30, // 2 bit field for MITM
       
    75 		};
       
    76 	
       
    77 	enum TBTAccessRequirementsMitmProtection
       
    78 		{
       
    79 		EAccessRequirementsMitmUndefined = 0x00,
       
    80 		EAccessRequirementsMitmNotRequired = 0x10,
       
    81 		EAccessRequirementsMitmDesired = 0x20,
       
    82 		EAccessRequirementsMitmRequired = 0x30
       
    83 		};
       
    84 	};
       
    85 
       
    86 NONSHARABLE_CLASS(TBTServiceSecurity)
       
    87 /** The security settings of a bluetooth service.
       
    88 
       
    89 Contains information regarding the service UID and the access requirements.
       
    90 @publishedAll
       
    91 @released
       
    92 */
       
    93 	{
       
    94 public:
       
    95 	IMPORT_C TBTServiceSecurity(const TBTServiceSecurity& aService);
       
    96 	IMPORT_C TBTServiceSecurity();
       
    97 	IMPORT_C void SetUid(TUid aUid);
       
    98 	IMPORT_C void SetAuthentication(TBool aPreference);
       
    99 	IMPORT_C void SetAuthorisation(TBool aPreference);
       
   100 	IMPORT_C void SetEncryption(TBool aPreference);
       
   101 	IMPORT_C void SetDenied(TBool aPreference);
       
   102 	IMPORT_C void SetAuthentication(TBluetoothMitmProtection aPreference);
       
   103 	IMPORT_C TInt SetPasskeyMinLength(TUint aPasskeyMinLength);	
       
   104 	IMPORT_C TBool AuthorisationRequired() const;
       
   105 	IMPORT_C TBool EncryptionRequired() const;
       
   106 	IMPORT_C TBool AuthenticationRequired() const;
       
   107 	IMPORT_C TBool Denied() const;
       
   108 	IMPORT_C TUint PasskeyMinLength() const;
       
   109 	IMPORT_C TUid Uid() const;
       
   110 	IMPORT_C TBluetoothMitmProtection MitmProtection() const;
       
   111 	
       
   112 private:
       
   113 	TUid iUid;	//<The UID of the service.  Will be used by the UI to work out the name of the service when prompting the user.
       
   114 	TBTAccessRequirements iSecurityRequirements;	//<Whether the service requires authentication, authorisation, encryption or min passkey len.
       
   115 	};
       
   116 
       
   117 typedef TPckgBuf<TBTServiceSecurity> TBTServiceSecurityPckg;	/*!< Package definition for securty settings */
       
   118 
       
   119 
       
   120 #endif // BTSECURITY_H