--- a/smf/smfcredentialmgr/smfcredmgrserver/src/smfcredmgrdbuser.cpp Thu Aug 05 16:46:37 2010 +0530
+++ b/smf/smfcredentialmgr/smfcredmgrserver/src/smfcredmgrdbuser.cpp Thu Aug 05 16:48:48 2010 +0530
@@ -7,7 +7,10 @@
* at the URL "http://www.eclipse.org/legal/epl-v10.html"
*
* Initial Contributors:
- * Pritam Roy Biswas, Sasken Communication Technologies Ltd - Initial contribution
+ * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
+ *
+ * Contributors:
+ * Pritam Roy Biswas, Nalina Hariharan, Sasken Communication Technologies Ltd
*
* Description:
* This file contains routines to handle the data-base operations like insertion, query etc.
@@ -15,9 +18,15 @@
*/
#include <BAUTILS.H>
+
#include "smfcredmgrdbuser.h"
#include "smfcredmgrdb.h"
+/**
+ * NewL function
+ * @param aSession the session object using this class
+ * @return The constructed CSmfCredMgrDbUser instance
+ */
CSmfCredMgrDbUser* CSmfCredMgrDbUser::NewL(CSmfCredMgrServerSession* aSession)
{
CSmfCredMgrDbUser* self = CSmfCredMgrDbUser::NewLC(aSession);
@@ -25,6 +34,12 @@
return (self);
}
+/**
+ * NewLC function. This method adds the return value to the
+ * Cleanup Stack if constructed
+ * @param aSession the session object using this class
+ * @return The constructed CSmfCredMgrDbUser instance
+ */
CSmfCredMgrDbUser* CSmfCredMgrDbUser::NewLC(CSmfCredMgrServerSession* aSession)
{
CSmfCredMgrDbUser* self = new (ELeave) CSmfCredMgrDbUser(aSession);
@@ -33,6 +48,9 @@
return (self);
}
+/**
+ * Two phase constructor
+ */
void CSmfCredMgrDbUser::ConstructL()
{
TInt err = iFileSession.Connect();
@@ -71,17 +89,33 @@
}
}
+/**
+ * Constructor
+ * @param aSession The CSmfCredMgrServerSession instance
+ */
CSmfCredMgrDbUser::CSmfCredMgrDbUser(CSmfCredMgrServerSession* aSession) :
iSession(aSession)
{
}
+/**
+ * Destructor
+ */
CSmfCredMgrDbUser::~CSmfCredMgrDbUser()
{
iFileSession.Close();
iDataBase.Close();
}
+/**
+ * Method to insert PluginIDTable
+ * @param aPluginID The ID of the plugin
+ * @param aAuthAppId The ID of the Authentication app associated with the plugin
+ * @param aEnableFlag A flag to indicate if the plugin is enabled,
+ * i.e, aEnableFlag = 0 for a disabled plugin
+ * @return Returns KErrNone if success. Refer ESqlDbError and system-wide
+ * error codes for detailed error description.
+ */
TInt CSmfCredMgrDbUser::PluginIDTableInsert(const TDesC& aPluginId,
const TDesC& aAuthAppId, TBool aEnableFlag)
{
@@ -135,6 +169,13 @@
return err;
}
+/**
+ * Method to insert URLTable
+ * @param aAuthAppId The ID of the Authentication app associated with the URLs
+ * @param aURL The URL to be stored
+ * @return Returns KErrNone if success. Refer ESqlDbError and system-wide
+ * error codes for detailed error description.
+ */
TInt CSmfCredMgrDbUser::URLTableInsert(const TDesC& aAuthAppId,
const TDesC& aURL)
{
@@ -185,6 +226,14 @@
return err;
}
+/**
+ * Method to insert RegTokenValidityTable
+ * @param aRegToken The Registration token for the authentication app
+ * @param aAuthAppId The ID of the Authentication app
+ * @param aValidity The time by which the set will expire
+ * @return Returns KErrNone if success. Refer ESqlDbError and system-wide
+ * error codes for detailed error description.
+ */
TInt CSmfCredMgrDbUser::RegTokenValidityTableInsert(const TDesC& aRegToken,
const TDesC& aAuthAppId, const TUint aValidity)
{
@@ -239,6 +288,14 @@
}
+/**
+ * Method to insert AuthParamsTable
+ * @param aAuthAppId The ID of the Authentication app
+ * @param aKey The Key
+ * @param aSecret The Secret
+ * @return Returns KErrNone if success. Refer ESqlDbError and system-wide
+ * error codes for detailed error description.
+ */
TInt CSmfCredMgrDbUser::AuthParamsTableInsert(const TDesC& aAuthAppId,
const TDesC& aKey, const TDesC& aSecret)
{
@@ -293,55 +350,25 @@
return err;
}
-void CSmfCredMgrDbUser::readFlagInPluginIdTable(const TDesC& aPluginID,
- TInt& aFlag)
+/**
+ * Method to fetch all the plugins associated with the registration token
+ * @param aRegToken The Registration token of the authentication app
+ * @param aArray [out] The array to be updated with plugin ids
+ */
+void CSmfCredMgrDbUser::fetchPluginListL(const TDesC& aRegToken, RPointerArray<
+ HBufC>& aArray)
{
- TInt err(KErrNone);
-
- RSqlStatement sqlReadStatement;
- TInt paramIndex(KErrNone);
-
- err = sqlReadStatement.Prepare(iDataBase, KSmfDbReadFlagInPluginTable);
-
- paramIndex = sqlReadStatement.ParameterIndex(_L(":iID"));
- err = sqlReadStatement.BindText(paramIndex, aPluginID);
-
- while ((err = sqlReadStatement.Next()) == KSqlAtRow)
- {
- //sometimes sqlStmt.Next returns KSqlAtRow even if no row is present
- if (!sqlReadStatement.IsNull(0))
- {
- aFlag = sqlReadStatement.ColumnInt(0);
- }
- }
- sqlReadStatement.Close();
+ TBuf<KMaxBufSize> authAppID;
+ readAuthAppIdInRegTokenTable(aRegToken, authAppID);
+ readPluginIdL(authAppID, aArray);
}
-void CSmfCredMgrDbUser::readAuthAppIdInPluginIdTable(const TDesC& aPluginID,
- TDes& aAuthAppId)
- {
- TInt err(KErrNone);
-
- RSqlStatement sqlReadStatement;
- TInt paramIndex(KErrNone);
-
- err = sqlReadStatement.Prepare(iDataBase, KSmfDbReadAuthAppIdInPluginTable);
-
- paramIndex = sqlReadStatement.ParameterIndex(_L(":iID"));
- err = sqlReadStatement.BindText(paramIndex, aPluginID);
-
- while ((err = sqlReadStatement.Next()) == KSqlAtRow)
- {
- //sometimes sqlStmt.Next returns KSqlAtRow even if no row is present
- if (!sqlReadStatement.IsNull(0))
- {
- sqlReadStatement.ColumnText(0, aAuthAppId);
- }
- }
- sqlReadStatement.Close();
- }
-
-void CSmfCredMgrDbUser::readAuthTokens(const TDesC& aAuthAppId, RArray<
+/**
+ * Method to Key-Secret pairs of the Authentication app
+ * @param aAuthAppId The ID of the Authentication app
+ * @param aArray [out] The array containing the key-secret pair
+ */
+void CSmfCredMgrDbUser::readAuthTokensL(const TDesC& aAuthAppId, RArray<
TSmfAuthToken>& aArray)
{
TInt err(KErrNone);
@@ -383,14 +410,112 @@
sqlReadStatement.Close();
}
-void CSmfCredMgrDbUser::fetchPluginList(const TDesC& aRegToken, RPointerArray<
- HBufC>& aArray)
+/**
+ * Method to fetch all the URLs associated with the Authentication app
+ * @param aAuthAppId The ID of the Authentication app
+ * @param aArray [out] The array to be updated with URLs
+ */
+void CSmfCredMgrDbUser::readUrlL(const TDesC& aAuthAppId,
+ RPointerArray<HBufC>& aArray)
{
- TBuf<KMaxBufSize> authAppID;
- readAuthAppIdInRegTokenTable(aRegToken, authAppID);
- readPluginId(authAppID, aArray);
+ TInt err(KErrNone);
+
+ RSqlStatement sqlReadStatement;
+ TInt paramIndex(KErrNone);
+
+ err = sqlReadStatement.Prepare(iDataBase, KSmfDbReadURL);
+ paramIndex = sqlReadStatement.ParameterIndex(_L(":iID"));
+ err = sqlReadStatement.BindText(paramIndex, aAuthAppId);
+
+ while ((err = sqlReadStatement.Next()) == KSqlAtRow)
+ {
+ //sometimes sqlStmt.Next returns KSqlAtRow even if no row is present
+ if (!sqlReadStatement.IsNull(0))
+ {
+ TBuf<KMaxBufSize> urlBuf;
+ HBufC* buf = HBufC::NewL(KMaxBufSize);
+ sqlReadStatement.ColumnText(0, urlBuf);
+ buf->Des().Copy(urlBuf);
+ aArray.Append(buf);
+ }
+ else
+ {
+ __ASSERT_DEBUG( 0, User::Invariant());
+ }
+ }
+ sqlReadStatement.Close();
}
+/**
+ * Method to fetch Validity of the Authentication app
+ * @param aAuthAppId The ID of the Authentication app
+ * @param aValidity [out] The time by which the Auth set will expire
+ */
+void CSmfCredMgrDbUser::readValidity(const TDesC& aAuthAppId, TInt64& aValidity)
+ {
+ TInt err(KErrNone);
+
+ RSqlStatement sqlReadStatement;
+ TInt paramIndex(KErrNone);
+
+ err = sqlReadStatement.Prepare(iDataBase, KSmfDbReadValidity);
+ paramIndex = sqlReadStatement.ParameterIndex(_L(":iID"));
+ err = sqlReadStatement.BindText(paramIndex, aAuthAppId);
+
+ while ((err = sqlReadStatement.Next()) == KSqlAtRow)
+ {
+ //sometimes sqlStmt.Next returns KSqlAtRow even if no row is present
+ if (!sqlReadStatement.IsNull(0))
+ {
+ aValidity = sqlReadStatement.ColumnInt64(1);
+ }
+ else
+ {
+ __ASSERT_DEBUG( 0, User::Invariant());
+ }
+ }
+ sqlReadStatement.Close();
+
+ }
+
+/**
+ * Method to fetch Registration token of the Authentication app from RegTokenValidityTable
+ * @param aAuthAppId The ID of the Authentication app
+ * @param aRegToken [out] The Registration token of the authentication app
+ */
+void CSmfCredMgrDbUser::readRegistrationTokenL(const TDesC& aAuthAppId,
+ TDesC& aRegToken)
+ {
+ TInt err(KErrNone);
+
+ RSqlStatement sqlReadStatement;
+ TInt paramIndex(KErrNone);
+
+ err = sqlReadStatement.Prepare(iDataBase, KSmfDbReadRegistrationToken);
+ paramIndex = sqlReadStatement.ParameterIndex(_L(":iID"));
+ err = sqlReadStatement.BindText(paramIndex, aAuthAppId);
+
+ while ((err = sqlReadStatement.Next()) == KSqlAtRow)
+ {
+ //sometimes sqlStmt.Next returns KSqlAtRow even if no row is present
+ if (!sqlReadStatement.IsNull(0))
+ {
+ aRegToken = sqlReadStatement.ColumnTextL(0);//aKey.AllocL();
+ }
+ else
+ {
+ __ASSERT_DEBUG( 0, User::Invariant());
+ }
+ }
+ sqlReadStatement.Close();
+ }
+
+/**
+ * Method to fetch Authentication app ID from RegTokenValidityTable
+ * giving the reg token
+ * @param aRegToken The Registration token of the authentication app
+ * @param aAuthAppId [out] The ID of the Authentication app
+ */
void CSmfCredMgrDbUser::readAuthAppIdInRegTokenTable(const TDesC& aRegToken,
TDes& aAuthAppId)
{
@@ -423,126 +548,76 @@
}
sqlReadStatement.Close();
}
-void CSmfCredMgrDbUser::readPluginId(const TDesC& aAuthAppId, RPointerArray<
- HBufC>& aArray)
- {
- TInt err(KErrNone);
- RSqlStatement sqlReadStatement;
- TInt paramIndex(KErrNone);
- TInt flag;
- err = sqlReadStatement.Prepare(iDataBase, KSmfDbReadPluginID);
- paramIndex = sqlReadStatement.ParameterIndex(_L(":iID"));
- err = sqlReadStatement.BindText(paramIndex, aAuthAppId);
- while ((err = sqlReadStatement.Next()) == KSqlAtRow)
- {
- //sometimes sqlStmt.Next returns KSqlAtRow even if no row is present
- if (!sqlReadStatement.IsNull(0))
- {
- flag = sqlReadStatement.ColumnInt(1);
- if (flag > 0)
- {
- TBuf<KMaxBufSize> pluginbuf;
- HBufC* buf = HBufC::NewL(KMaxBufSize);
- sqlReadStatement.ColumnText(0, pluginbuf);
- buf->Des().Copy(pluginbuf);
- aArray.Append(buf);
- }
- }
- else
- {
- __ASSERT_DEBUG( 0, User::Invariant());
- }
- }
- sqlReadStatement.Close();
- }
-
-void CSmfCredMgrDbUser::readURL(const TDesC& aAuthAppId,
- RPointerArray<HBufC>& aArray)
+/**
+ * Method to fetch Authentication app ID from PluginIDTable giving the plugin ID
+ * @param aPluginID the ID of the plugin
+ * @param aAuthAppId [out] ID of the Authentication app
+ */
+void CSmfCredMgrDbUser::readAuthAppIdInPluginIdTable(const TDesC& aPluginID,
+ TDes& aAuthAppId)
{
TInt err(KErrNone);
RSqlStatement sqlReadStatement;
TInt paramIndex(KErrNone);
- err = sqlReadStatement.Prepare(iDataBase, KSmfDbReadURL);
+ err = sqlReadStatement.Prepare(iDataBase, KSmfDbReadAuthAppIdInPluginTable);
+
paramIndex = sqlReadStatement.ParameterIndex(_L(":iID"));
- err = sqlReadStatement.BindText(paramIndex, aAuthAppId);
+ err = sqlReadStatement.BindText(paramIndex, aPluginID);
while ((err = sqlReadStatement.Next()) == KSqlAtRow)
{
//sometimes sqlStmt.Next returns KSqlAtRow even if no row is present
if (!sqlReadStatement.IsNull(0))
{
- TBuf<KMaxBufSize> urlBuf;
- HBufC* buf = HBufC::NewL(KMaxBufSize);
- sqlReadStatement.ColumnText(0, urlBuf);
- buf->Des().Copy(urlBuf);
- aArray.Append(buf);
- }
- else
- {
- __ASSERT_DEBUG( 0, User::Invariant());
+ sqlReadStatement.ColumnText(0, aAuthAppId);
}
}
sqlReadStatement.Close();
}
-void CSmfCredMgrDbUser::readValidity(const TDesC& aAuthAppId, TInt64& aValidity)
+/**
+ * Method to read the IsEnabled flag from plugin Id table
+ * @param aPluginID The ID of the plugin
+ * @param aFlag [out] The flag that indicates the plugin id is enables or disabled
+ */
+void CSmfCredMgrDbUser::readFlagInPluginIdTable(const TDesC& aPluginID,
+ TInt& aFlag)
{
TInt err(KErrNone);
RSqlStatement sqlReadStatement;
TInt paramIndex(KErrNone);
- err = sqlReadStatement.Prepare(iDataBase, KSmfDbReadValidity);
+ err = sqlReadStatement.Prepare(iDataBase, KSmfDbReadFlagInPluginTable);
+
paramIndex = sqlReadStatement.ParameterIndex(_L(":iID"));
- err = sqlReadStatement.BindText(paramIndex, aAuthAppId);
+ err = sqlReadStatement.BindText(paramIndex, aPluginID);
while ((err = sqlReadStatement.Next()) == KSqlAtRow)
{
//sometimes sqlStmt.Next returns KSqlAtRow even if no row is present
if (!sqlReadStatement.IsNull(0))
{
- aValidity = sqlReadStatement.ColumnInt64(1);
- }
- else
- {
- __ASSERT_DEBUG( 0, User::Invariant());
- }
- }
- sqlReadStatement.Close();
-
- }
-
-void CSmfCredMgrDbUser::readRegistrationToken(const TDesC& aAuthAppId,
- TDesC& aRegToken)
- {
- TInt err(KErrNone);
-
- RSqlStatement sqlReadStatement;
- TInt paramIndex(KErrNone);
-
- err = sqlReadStatement.Prepare(iDataBase, KSmfDbReadRegistrationToken);
- paramIndex = sqlReadStatement.ParameterIndex(_L(":iID"));
- err = sqlReadStatement.BindText(paramIndex, aAuthAppId);
-
- while ((err = sqlReadStatement.Next()) == KSqlAtRow)
- {
- //sometimes sqlStmt.Next returns KSqlAtRow even if no row is present
- if (!sqlReadStatement.IsNull(0))
- {
- aRegToken = sqlReadStatement.ColumnTextL(0);//aKey.AllocL();
- }
- else
- {
- __ASSERT_DEBUG( 0, User::Invariant());
+ aFlag = sqlReadStatement.ColumnInt(0);
}
}
sqlReadStatement.Close();
}
+
+
+/**
+ * Method to change a plugin id in plugin Id table
+ * @param aNewPluginID The ID of the new plugin
+ * @param aFlag The flag that indicates the plugin id is enables or disabled
+ * @param aOldPluginID The ID of the plugin to be replaced
+ * @return Returns KErrNone if success. Refer ESqlDbError and system-wide
+ * error codes for detailed error description.
+ */
TInt CSmfCredMgrDbUser::updatePlugin(const TDesC& aPluginID,
const TBool& aFlag, const TDesC& aOldPluginID)
{
@@ -595,3 +670,44 @@
}
return err;
}
+
+/**
+ * Method to fetch the list of plugin ids associated with Authentication App id,
+ * it is called internally by fetchPluginList().
+ * @param aAuthAppId ID of the Authentication app
+ * @param aArray [out] The array to be updated with plugin ids
+ */
+void CSmfCredMgrDbUser::readPluginIdL(const TDesC& aAuthAppId, RPointerArray<
+ HBufC>& aArray)
+ {
+ TInt err(KErrNone);
+ RSqlStatement sqlReadStatement;
+ TInt paramIndex(KErrNone);
+ TInt flag;
+
+ err = sqlReadStatement.Prepare(iDataBase, KSmfDbReadPluginID);
+ paramIndex = sqlReadStatement.ParameterIndex(_L(":iID"));
+ err = sqlReadStatement.BindText(paramIndex, aAuthAppId);
+
+ while ((err = sqlReadStatement.Next()) == KSqlAtRow)
+ {
+ //sometimes sqlStmt.Next returns KSqlAtRow even if no row is present
+ if (!sqlReadStatement.IsNull(0))
+ {
+ flag = sqlReadStatement.ColumnInt(1);
+ if (flag > 0)
+ {
+ TBuf<KMaxBufSize> pluginbuf;
+ HBufC* buf = HBufC::NewL(KMaxBufSize);
+ sqlReadStatement.ColumnText(0, pluginbuf);
+ buf->Des().Copy(pluginbuf);
+ aArray.Append(buf);
+ }
+ }
+ else
+ {
+ __ASSERT_DEBUG( 0, User::Invariant());
+ }
+ }
+ sqlReadStatement.Close();
+ }