smf/smfcredentialmgr/smfcredmgrserver/inc/smfcredmgrdbuser.h
changeset 18 013a02bf2bb0
parent 14 a469c0e6e7fb
child 26 83d6a149c755
equal deleted inserted replaced
17:106a4bfcb866 18:013a02bf2bb0
     5  * under the terms of the "Eclipse Public License v1.0"
     5  * under the terms of the "Eclipse Public License v1.0"
     6  * which accompanies  this distribution, and is available
     6  * which accompanies  this distribution, and is available
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html"
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html"
     8  *
     8  *
     9  * Initial Contributors:
     9  * Initial Contributors:
    10  * Pritam Roy Biswas, Sasken Communication Technologies Ltd - Initial contribution
    10  * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
       
    11  * 
       
    12  * Contributors:
       
    13  * Pritam Roy Biswas, Nalina Hariharan, Sasken Communication Technologies Ltd
    11  *
    14  *
    12  * Description:
    15  * Description:
    13  * This header provides a handle to use the data-base operations like insertion, query etc. which
    16  * This header provides a handle to use the data-base operations like insertion, query etc. which
    14  *  is used by the Credential Manager Server Sessions to operate on
    17  * is used by the Credential Manager Server Sessions to operate on
    15  *  Credential Manager Server Database
    18  * Credential Manager Server Database
    16  */
    19  */
       
    20 
    17 #ifndef SMFCREDMGRDBUSER_H_
    21 #ifndef SMFCREDMGRDBUSER_H_
    18 #define SMFCREDMGRDBUSER_H_
    22 #define SMFCREDMGRDBUSER_H_
    19 
    23 
    20 #include <sqldb.h>
    24 #include <sqldb.h>
    21 #include <e32base.h>
    25 #include <e32base.h>
    22 #include <f32file.h>
    26 #include <f32file.h>
       
    27 
    23 #include "smfcredmgrserversession.h"
    28 #include "smfcredmgrserversession.h"
    24 
    29 
    25 //INSERTION
    30 //DB COMMANDS
    26 _LIT(KBegin , "BEGIN");
    31 _LIT(KBegin , "BEGIN");
    27 _LIT(KCommit, "COMMIT");
    32 _LIT(KCommit, "COMMIT");
    28 _LIT(KRollback, "ROLLBACK");
    33 _LIT(KRollback, "ROLLBACK");
    29 _LIT(KSmfPluginIDTableInsert, "INSERT INTO PluginIDTable(PluginId, AuthAppId, IsEnabled) VALUES(:Val1, :Val2, :Val3)");
    34 
    30 _LIT(KSmfURLTableInsert, "INSERT INTO URLTable(AuthAppId, URL) VALUES(:Val1, :Val2)");
    35 //INSERTION
    31 _LIT(KSmfRegTokenValidityTableInsert, "INSERT INTO RegTokenValidityTable(RegistrationToken, AuthAppId, Validity) VALUES(:Val1, :Val2, :Val3)");
    36 _LIT(KSmfPluginIDTableInsert, "INSERT OR REPLACE INTO PluginIDTable(PluginId, AuthAppId, IsEnabled) VALUES(:Val1, :Val2, :Val3)");
    32 _LIT(KSmfAuthParamsTableInsert, "INSERT INTO AuthParamsTable(AuthAppId, AuthKey, AuthSecret) VALUES(:Val1, :Val2, :Val3)");
    37 _LIT(KSmfURLTableInsert, "INSERT OR REPLACE INTO URLTable(AuthAppId, URL) VALUES(:Val1, :Val2)");
       
    38 _LIT(KSmfRegTokenValidityTableInsert, "INSERT OR REPLACE INTO RegTokenValidityTable(RegistrationToken, AuthAppId, Validity) VALUES(:Val1, :Val2, :Val3)");
       
    39 _LIT(KSmfAuthParamsTableInsert, "INSERT OR REPLACE INTO AuthParamsTable(AuthAppId, AuthKey, AuthSecret) VALUES(:Val1, :Val2, :Val3)");
       
    40 
    33 //READ
    41 //READ
    34 _LIT(KSmfDbReadValidity, "SELECT Validity FROM RegTokenValidityTable WHERE AuthAppId = :iID");
    42 _LIT(KSmfDbReadValidity, "SELECT Validity FROM RegTokenValidityTable WHERE AuthAppId = :iID");
    35 _LIT(KSmfDbReadRegistrationToken, "SELECT RegistrationToken FROM RegTokenValidityTable WHERE AuthAppId = :iID");
    43 _LIT(KSmfDbReadRegistrationToken, "SELECT RegistrationToken FROM RegTokenValidityTable WHERE AuthAppId = :iID");
    36 _LIT(KSmfDbReadAuthTokens, "SELECT AuthKey, AuthSecret FROM AuthParamsTable WHERE AuthAppId = :iID");
    44 _LIT(KSmfDbReadAuthTokens, "SELECT AuthKey, AuthSecret FROM AuthParamsTable WHERE AuthAppId = :iID");
    37 _LIT(KSmfDbReadPluginID, "SELECT PluginId, IsEnabled FROM PluginIDTable WHERE AuthAppId = :iID");
    45 _LIT(KSmfDbReadPluginID, "SELECT PluginId, IsEnabled FROM PluginIDTable WHERE AuthAppId = :iID");
    38 _LIT(KSmfDbReadURL, "SELECT URL FROM URLTable WHERE AuthAppId = :iID");
    46 _LIT(KSmfDbReadURL, "SELECT URL FROM URLTable WHERE AuthAppId = :iID");
    39 _LIT(KSmfDbReadAuthAppIdInPluginTable, "SELECT AuthAppId FROM PluginIDTable WHERE PluginId = :iID");
    47 _LIT(KSmfDbReadAuthAppIdInPluginTable, "SELECT AuthAppId FROM PluginIDTable WHERE PluginId = :iID");
    40 _LIT(KSmfDbReadFlagInPluginTable, "SELECT IsEnabled FROM PluginIDTable WHERE PluginId = :iID");
    48 _LIT(KSmfDbReadFlagInPluginTable, "SELECT IsEnabled FROM PluginIDTable WHERE PluginId = :iID");
    41 _LIT(KSmfDbReadAuthAppIdInRegTokenTable, "SELECT AuthAppId, Validity FROM RegTokenValidityTable WHERE RegistrationToken = :iID");
    49 _LIT(KSmfDbReadAuthAppIdInRegTokenTable, "SELECT AuthAppId, Validity FROM RegTokenValidityTable WHERE RegistrationToken = :iID");
       
    50 
    42 //UPDATE 
    51 //UPDATE 
    43 _LIT( KUpdatePluginID, "UPDATE PluginIDTable SET PluginId =:iText, IsEnabled =:iFlag WHERE PluginId = :iID");
    52 _LIT( KUpdatePluginID, "UPDATE PluginIDTable SET PluginId =:iText, IsEnabled =:iFlag WHERE PluginId = :iID");
    44 
    53 
    45 /**
    54 /**
    46  * The class to use the server database i.e insert table in Db, query from Db.
    55  * The class to use the server database i.e insert table in Db, query from Db.
    47  */
    56  */
    48 class CSmfCredMgrDbUser : public CBase
    57 class CSmfCredMgrDbUser : public CBase
    49 	{
    58 	{
    50 public:
    59 public:
    51 	/**
    60 	/**
    52 	 * New functions
    61 	 * NewL function
    53 	 * @param aSession the session object using this class
    62 	 * @param aSession the session object using this class
       
    63 	 * @return The constructed CSmfCredMgrDbUser instance
    54 	 */
    64 	 */
    55 	static CSmfCredMgrDbUser* NewL(CSmfCredMgrServerSession* aSession);
    65 	static CSmfCredMgrDbUser* NewL(CSmfCredMgrServerSession* aSession);
       
    66 	
       
    67 	/**
       
    68 	 * NewLC function. This method adds the return value to the 
       
    69 	 * Cleanup Stack if constructed
       
    70 	 * @param aSession the session object using this class
       
    71 	 * @return The constructed CSmfCredMgrDbUser instance
       
    72 	 */
    56 	static CSmfCredMgrDbUser* NewLC(CSmfCredMgrServerSession* aSession);
    73 	static CSmfCredMgrDbUser* NewLC(CSmfCredMgrServerSession* aSession);
    57 
    74 
    58 	/**
    75 	/**
    59 	 * Destructor
    76 	 * Destructor
    60 	 */
    77 	 */
    61 	~CSmfCredMgrDbUser();
    78 	~CSmfCredMgrDbUser();
    62 
    79 
    63 public:
    80 public:
    64 	/**
    81 	/**
    65 	 * Method to insert PluginIDTable
    82 	 * Method to insert PluginIDTable
    66 	 * @param aPluginID ID of the plugin 
    83 	 * @param aPluginID The ID of the plugin 
    67 	 * @param aAuthAppId ID of the Authentication app associated with the plugin
    84 	 * @param aAuthAppId The ID of the Authentication app associated with the plugin
    68 	 * @param aEnableFlag a flag to indicate if the plugin is enabled, 
    85 	 * @param aEnableFlag A flag to indicate if the plugin is enabled, 
    69 	 * 	   i.e aEnableFlag =0 for disabled plugin
    86 	 * i.e, aEnableFlag = 0 for a disabled plugin
    70 	 */
    87 	 * @return Returns KErrNone if success. Refer ESqlDbError and system-wide 
    71 	TInt PluginIDTableInsert(const TDesC& aPluginID, const TDesC& aAuthAppId,
    88 	 * error codes for detailed error description.
       
    89 	 */
       
    90 	TInt PluginIDTableInsert(const TDesC& aPluginID, 
       
    91 			const TDesC& aAuthAppId,
    72 			TBool aEnableFlag);
    92 			TBool aEnableFlag);
    73 
    93 
    74 	/**
    94 	/**
    75 	 * Method to insert URLTable
    95 	 * Method to insert URLTable
    76 	 * @param aAuthAppId ID of the Authentication app associated with the URLs 
    96 	 * @param aAuthAppId The ID of the Authentication app associated with the URLs 
    77 	 * @param aURL the URL to be stored 
    97 	 * @param aURL The URL to be stored
       
    98 	 * @return Returns KErrNone if success. Refer ESqlDbError and system-wide 
       
    99 	 * error codes for detailed error description.
    78 	 */
   100 	 */
    79 	TInt URLTableInsert(const TDesC& aAuthAppId, const TDesC& aURL);
   101 	TInt URLTableInsert(const TDesC& aAuthAppId, const TDesC& aURL);
    80 
   102 
    81 	/**
   103 	/**
    82 	 * Method to insert RegTokenValidityTable
   104 	 * Method to insert RegTokenValidityTable
    83 	 * @param aRegToken the Registration token for the authentication app 
   105 	 * @param aRegToken The Registration token for the authentication app 
    84 	 * @param aAuthAppId ID of the Authentication app
   106 	 * @param aAuthAppId The ID of the Authentication app
    85 	 * @param aValidity time by which the set will expire 
   107 	 * @param aValidity The time by which the set will expire
       
   108 	 * @return Returns KErrNone if success. Refer ESqlDbError and system-wide 
       
   109 	 * error codes for detailed error description. 
    86 	 */
   110 	 */
    87 	TInt RegTokenValidityTableInsert(const TDesC& aRegToken,
   111 	TInt RegTokenValidityTableInsert(const TDesC& aRegToken,
    88 			const TDesC& aAuthAppId, const TUint aValidity);
   112 			const TDesC& aAuthAppId, const TUint aValidity);
       
   113 	
    89 	/**
   114 	/**
    90 	 * Method to insert AuthParamsTable
   115 	 * Method to insert AuthParamsTable
    91 	 * @param aAuthAppId ID of the Authentication app
   116 	 * @param aAuthAppId The ID of the Authentication app
    92 	 * @param aKey The Key
   117 	 * @param aKey The Key
    93 	 * @param aSecret The Secret 
   118 	 * @param aSecret The Secret
       
   119 	 * @return Returns KErrNone if success. Refer ESqlDbError and system-wide 
       
   120 	 * error codes for detailed error description. 
    94 	 */
   121 	 */
    95 	TInt AuthParamsTableInsert(const TDesC& aAuthAppId, const TDesC& aKey,
   122 	TInt AuthParamsTableInsert(const TDesC& aAuthAppId, const TDesC& aKey,
    96 			const TDesC& aSecret);
   123 			const TDesC& aSecret);
    97 
   124 
    98 	/**
   125 	/**
    99 	 * Method to fetch all the plugins associated with the registration token
   126 	 * Method to fetch all the plugins associated with the registration token
   100 	 * @param aRegToken the Registration token of the authentication app
   127 	 * @param aRegToken The Registration token of the authentication app
   101 	 * @param aArray The array to be updated with plugin ids 
   128 	 * @param aArray [out] The array to be updated with plugin ids
   102 	 */
   129 	 */
   103 	void fetchPluginList(const TDesC& aRegToken, RPointerArray<HBufC>& aArray);
   130 	void fetchPluginListL(const TDesC& aRegToken, RPointerArray<HBufC>& aArray);
   104 
   131 
   105 	/**
   132 	/**
   106 	 * Method to Key-Secret pairs of the Authentication app
   133 	 * Method to Key-Secret pairs of the Authentication app
   107 	 * @param aAuthAppId ID of the Authentication app
   134 	 * @param aAuthAppId The ID of the Authentication app
   108 	 * @param aArray The array containing the key-secret pair
   135 	 * @param aArray [out] The array containing the key-secret pair
   109 	 */
   136 	 */
   110 	void readAuthTokens(const TDesC& aAuthAppId, RArray<TSmfAuthToken>& aArray);
   137 	void readAuthTokensL(const TDesC& aAuthAppId, RArray<TSmfAuthToken>& aArray);
   111 
   138 
   112 	/**
   139 	/**
   113 	 * Method to fetch all the URLs associated with the Authentication app
   140 	 * Method to fetch all the URLs associated with the Authentication app
   114 	 * @param aAuthAppId ID of the Authentication app
   141 	 * @param aAuthAppId The ID of the Authentication app
   115 	 * @param aArray The array to be updated with URLs 
   142 	 * @param aArray [out] The array to be updated with URLs 
   116 	 */
   143 	 */
   117 	void readURL(const TDesC& aAuthAppId, RPointerArray<HBufC>& aArray);
   144 	void readUrlL(const TDesC& aAuthAppId, RPointerArray<HBufC>& aArray);
   118 
   145 
   119 	/**
   146 	/**
   120 	 * Method to fetch Validity of the Authentication app
   147 	 * Method to fetch Validity of the Authentication app
   121 	 * @param aAuthAppId ID of the Authentication app
   148 	 * @param aAuthAppId The ID of the Authentication app
   122 	 * @param aValidity time by which the Auth set will expire
   149 	 * @param aValidity [out] The time by which the Auth set will expire
   123 	 */
   150 	 */
   124 	void readValidity(const TDesC& aAuthAppId, TInt64& aValidity);
   151 	void readValidity(const TDesC& aAuthAppId, TInt64& aValidity);
   125 
   152 
   126 	/**
   153 	/**
   127 	 * Method to fetch Registration token of the Authentication app from RegTokenValidityTable
   154 	 * Method to fetch Registration token of the Authentication app from RegTokenValidityTable
   128 	 * @param aAuthAppId ID of the Authentication app
   155 	 * @param aAuthAppId The ID of the Authentication app
   129 	 * @param aRegToken the Registration token of the authentication app
   156 	 * @param aRegToken [out] The Registration token of the authentication app
   130 	 */
   157 	 */
   131 	void readRegistrationToken(const TDesC& aAuthAppId, TDesC& aRegToken);
   158 	void readRegistrationTokenL(const TDesC& aAuthAppId, TDesC& aRegToken);
   132 
   159 
   133 	/**
   160 	/**
   134 	 * Method to fetch Authentication app ID from RegTokenValidityTable
   161 	 * Method to fetch Authentication app ID from RegTokenValidityTable 
   135 	 * @param aRegToken the Registration token of the authentication app
   162 	 * giving the reg token
   136 	 * @param aAuthAppId ID of the Authentication app
   163 	 * @param aRegToken The Registration token of the authentication app
       
   164 	 * @param aAuthAppId [out] The ID of the Authentication app
   137 	 */
   165 	 */
   138 	void readAuthAppIdInRegTokenTable(const TDesC& aRegToken, TDes& aAuthAppId);
   166 	void readAuthAppIdInRegTokenTable(const TDesC& aRegToken, TDes& aAuthAppId);
   139 
   167 
   140 	/**
   168 	/**
   141 	 * Method to fetch Authentication app ID from PluginIDTable
   169 	 * Method to fetch Authentication app ID from PluginIDTable giving the plugin ID
   142 	 * @param aPluginID the ID of the plugin
   170 	 * @param aPluginID the ID of the plugin
   143 	 * @param aAuthAppId ID of the Authentication app
   171 	 * @param aAuthAppId [out] ID of the Authentication app
   144 	 */
   172 	 */
   145 	void readAuthAppIdInPluginIdTable(const TDesC& aPluginID, TDes& aAuthAppId);
   173 	void readAuthAppIdInPluginIdTable(const TDesC& aPluginID, TDes& aAuthAppId);
   146 
   174 
   147 	/**
   175 	/**
   148 	 * Method to read the IsEnabled flag from plugin Id table
   176 	 * Method to read the IsEnabled flag from plugin Id table
   149 	 * @param aPluginID the ID of the plugin
   177 	 * @param aPluginID The ID of the plugin
   150 	 * @param aFlag flag that indicates the plugin id is enables or disabled
   178 	 * @param aFlag [out] The flag that indicates the plugin id is enables or disabled
   151 	 */
   179 	 */
   152 	void readFlagInPluginIdTable(const TDesC& aPluginID, TInt& aFlag);
   180 	void readFlagInPluginIdTable(const TDesC& aPluginID, TInt& aFlag);
   153 
   181 
   154 	/**
   182 	/**
   155 	 * Method to change a plugin id in plugin Id table
   183 	 * Method to change a plugin id in plugin Id table
   156 	 * @param aNewPluginID the ID of the new plugin
   184 	 * @param aNewPluginID The ID of the new plugin
   157 	 * @param aFlag flag that indicates the plugin id is enables or disabled
   185 	 * @param aFlag The flag that indicates the plugin id is enables or disabled
   158 	 * @param aOldPluginID the ID of the plugin to be replaced
   186 	 * @param aOldPluginID The ID of the plugin to be replaced
       
   187 	 * @return Returns KErrNone if success. Refer ESqlDbError and system-wide 
       
   188 	 * error codes for detailed error description.
   159 	 */
   189 	 */
   160 	TInt updatePlugin(const TDesC& aPluginID, const TBool& aFlag,
   190 	TInt updatePlugin(const TDesC& aPluginID, const TBool& aFlag,
   161 			const TDesC& aOldPluginID);
   191 			const TDesC& aOldPluginID);
   162 
   192 
   163 	/**
   193 	/**
   164 	 * Method to fetch a plugin id associated with Authentication App id, it is 
   194 	 * Method to fetch the list of plugin ids associated with Authentication App id, 
   165 	 * 	called internally by fetchPluginList().
   195 	 * it is called internally by fetchPluginList().
   166 	 * @param aAuthAppId ID of the Authentication app
   196 	 * @param aAuthAppId ID of the Authentication app
   167 	 * @param aArray The array to be updated with plugin ids 
   197 	 * @param aArray [out] The array to be updated with plugin ids 
   168 	 */
   198 	 */
   169 	void readPluginId(const TDesC& aAuthAppId, RPointerArray<HBufC>& aArray);
   199 	void readPluginIdL(const TDesC& aAuthAppId, RPointerArray<HBufC>& aArray);
   170 
   200 
   171 private:
   201 private:
   172 	/**
   202 	/**
   173 	 * constructor
   203 	 * Constructor
       
   204 	 * @param aSession The CSmfCredMgrServerSession instance
   174 	 */
   205 	 */
   175 	CSmfCredMgrDbUser(CSmfCredMgrServerSession* aSession);
   206 	CSmfCredMgrDbUser(CSmfCredMgrServerSession* aSession);
   176 
   207 
   177 	/**
   208 	/**
   178 	 * Two phase constructor
   209 	 * Two phase constructor