smf/smfcredentialmgr/smfcredmgrserver/inc/smfcredmgrdb.h
changeset 14 a469c0e6e7fb
child 18 013a02bf2bb0
equal deleted inserted replaced
13:b5d63d5fc252 14:a469c0e6e7fb
       
     1 /**
       
     2  * Copyright (c) 2010 Sasken Communication Technologies Ltd.
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the "Eclipse Public License v1.0"
       
     6  * which accompanies  this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html"
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Pritam Roy Biswas, Sasken Communication Technologies Ltd - Initial contribution
       
    11  *
       
    12  * Description:
       
    13  * This header defines the database-table and the creation of database that will be 
       
    14  *  used by the Credential Manager Server to store all 
       
    15  *  the credentials related to an Authentication Application
       
    16  */
       
    17 #ifndef SMFCREDMGRDB_H_
       
    18 #define SMFCREDMGRDB_H_
       
    19 #include <sqldb.h>
       
    20 #include <e32base.h>
       
    21 #include <f32file.h>
       
    22 
       
    23 //the private folder of the app
       
    24 _LIT(KSmfCredMgrDbPrivateDir, "C:\\private\\EF0FFBD7\\");
       
    25 _LIT(KSmfCredMgrDbFileName, "[EF0FFBD7]CREDMGRDB.db");
       
    26 
       
    27 //Create Table
       
    28 _LIT8(KCreatePluginIDTable,"CREATE TABLE PluginIDTable(PluginId TEXT PRIMARY KEY, AuthAppId TEXT UNIQUE, IsEnabled INT)");
       
    29 _LIT8(KCreateURLTable,"CREATE TABLE URLTable(AuthAppId TEXT UNIQUE, URL TEXT,PRIMARY KEY(AuthAppId,URL))");
       
    30 _LIT8(KCreateRegTokenValidityTable,"CREATE TABLE RegTokenValidityTable(RegistrationToken TEXT PRIMARY KEY, AuthAppId TEXT UNIQUE, Validity BIGINT)");
       
    31 _LIT8(KCreateAuthParamsTable,"CREATE TABLE AuthParamsTable(AuthAppId TEXT UNIQUE, AuthKey TEXT, AuthSecret TEXT, PRIMARY KEY(AuthAppId,AuthKey))");
       
    32 
       
    33 /**
       
    34  * The creator class of the server database.
       
    35  *  Derives from CBase
       
    36  */
       
    37 class CSmfCredMgrDb : public CBase
       
    38 	{
       
    39 public:
       
    40 	/**
       
    41 	 * New Methods
       
    42 	 */
       
    43 	static CSmfCredMgrDb* NewL();
       
    44 	/**
       
    45 	 * New Methods
       
    46 	 */
       
    47 	static CSmfCredMgrDb* NewLC();
       
    48 
       
    49 	/**
       
    50 	 * destructor
       
    51 	 */
       
    52 	~CSmfCredMgrDb();
       
    53 
       
    54 private:
       
    55 	/**
       
    56 	 * constructor
       
    57 	 */
       
    58 	CSmfCredMgrDb();
       
    59 
       
    60 	/**
       
    61 	 * two phase constructor
       
    62 	 */
       
    63 	void ConstructL();
       
    64 
       
    65 	/**
       
    66 	 * Method to create the Db file
       
    67 	 * @param aFileName The file name
       
    68 	 */
       
    69 	TInt CreateDbFile(const TFileName &aFileName);
       
    70 
       
    71 	/**
       
    72 	 * Method to crete the Db tables
       
    73 	 * @param aFileName The Db file name
       
    74 	 */
       
    75 	void CompleteDBCreationL(const TFileName &aFileName);
       
    76 
       
    77 	/**
       
    78 	 * Creates the Plugin Id table 
       
    79 	 */
       
    80 	TInt PluginIDTableCreate();
       
    81 
       
    82 	/**
       
    83 	 * Creates the URL table 
       
    84 	 */
       
    85 	TInt URLTableCreate();
       
    86 
       
    87 	/**
       
    88 	 * Creates the RegistrationToken-Validity Table  
       
    89 	 */
       
    90 	TInt RegTokenValidityTableCreate();
       
    91 
       
    92 	/**
       
    93 	 * Creates the Authentication Parameters Table  
       
    94 	 */
       
    95 	TInt AuthParamsTableCreate();
       
    96 
       
    97 	/**
       
    98 	 * Deletes the Db 
       
    99 	 * @param aFileName The Db file name
       
   100 	 */
       
   101 	TInt DeleteDbFile(const TFileName &aFileName);
       
   102 
       
   103 private:
       
   104 	RFs iFileSession;
       
   105 	TFileName iDbFilePathName;
       
   106 	RSqlDatabase iDataBase;
       
   107 	};
       
   108 
       
   109 #endif /* SMFCREDMGRDB_H_ */