smf/smfcredentialmgr/smfcredmgrclient/smfcredmgrclient.cpp
changeset 26 83d6a149c755
parent 24 1cee9f1b95e0
equal deleted inserted replaced
25:a180113055cb 26:83d6a149c755
    33 
    33 
    34 QString SmfCredMgrClient::StoreAuthData(SmfAuthParams Set, QDateTime Validity,
    34 QString SmfCredMgrClient::StoreAuthData(SmfAuthParams Set, QDateTime Validity,
    35 		QList<QUrl> URLList, QStringList PluginList, QString AuthAppId,
    35 		QList<QUrl> URLList, QStringList PluginList, QString AuthAppId,
    36 		bool Flag)
    36 		bool Flag)
    37 	{
    37 	{
    38 	QString qs = NULL;
    38 	QString regToken;
       
    39 	
    39 	if (!(Set.isEmpty() || URLList.isEmpty() || PluginList.isEmpty()
    40 	if (!(Set.isEmpty() || URLList.isEmpty() || PluginList.isEmpty()
    40 			|| AuthAppId.isEmpty() || Validity.isNull()))
    41 			|| AuthAppId.isEmpty() || Validity.isNull()))
    41 		{
    42 		{
    42 		QT_TRAP_THROWING(qs  = m_SmfClientPrivate->storeAuthDataL(Set, Validity, URLList,
    43 		QT_TRAP_THROWING( regToken = m_SmfClientPrivate->storeAuthDataL(Set, Validity, URLList,
    43 					PluginList, AuthAppId, Flag));
    44 				PluginList, AuthAppId, Flag) );
    44 		}
    45 		}
    45 	return qs;
    46 	return regToken;
    46 	}
    47 	}
    47 
    48 
    48 QStringList SmfCredMgrClient::AuthenticatedPluginList(QString RegistrationToken) const
    49 QStringList SmfCredMgrClient::AuthenticatedPluginList(QString RegistrationToken) const
    49 	{
    50 	{
    50 	QStringList List;
    51 	QStringList List;
    51 	if (RegistrationToken.isEmpty())
    52 	if (!RegistrationToken.isEmpty())
    52 		{
       
    53 		//return the empty list
       
    54 		return List;
       
    55 		}
       
    56 	else
       
    57 		{
       
    58 		QT_TRAP_THROWING( m_SmfClientPrivate->authenticatedPluginListL(RegistrationToken, List));
    53 		QT_TRAP_THROWING( m_SmfClientPrivate->authenticatedPluginListL(RegistrationToken, List));
    59 		return List;
    54 
    60 		}
    55 	return List;
    61 	
       
    62 	}
    56 	}
    63 
    57 
    64 QList<QUrl> SmfCredMgrClient::URLList(QString PluginID) const
    58 QList<QUrl> SmfCredMgrClient::URLList(QString PluginID) const
    65 	{
    59 	{
    66 	QList<QUrl> List;
    60 	QList<QUrl> List;
    85 		}
    79 		}
    86 	}
    80 	}
    87 
    81 
    88 bool SmfCredMgrClient::CheckPluginAuthentication(QString PluginID) const
    82 bool SmfCredMgrClient::CheckPluginAuthentication(QString PluginID) const
    89 	{
    83 	{
    90 	bool tb = false;
    84 	bool result = false;
    91 	if (!(PluginID.isEmpty()))
    85 	if (!(PluginID.isEmpty()))
    92 		{
    86 		{
    93 		QT_TRAP_THROWING (tb = m_SmfClientPrivate->isPluginAuthenticatedL(PluginID));
    87 		TBool check = EFalse;
       
    88 		QT_TRAP_THROWING ( check =  m_SmfClientPrivate->isPluginAuthenticatedL(PluginID) );
       
    89 		if(check)
       
    90 			result = true;
       
    91 		else
       
    92 			result = false;
    94 		}
    93 		}
    95 	return tb;
    94 	return result;
    96 	}
    95 	}
    97 
    96 
    98 bool SmfCredMgrClient::AuthDataSet(QString RegToken, QDateTime Validity,
    97 bool SmfCredMgrClient::AuthDataSet(QString RegToken, QDateTime Validity,
    99 		SmfAuthParams& AuthTokenSet) const
    98 		SmfAuthParams& AuthTokenSet) const
   100 	{
    99 	{
       
   100 	bool datastored = false;
   101 	if (!(RegToken.isEmpty() || Validity.isNull()))
   101 	if (!(RegToken.isEmpty() || Validity.isNull()))
   102 		{
   102 		{
   103 		TBool Flag = EFalse;
   103 		TBool Flag = EFalse;
   104 		QT_TRAP_THROWING ( Flag = m_SmfClientPrivate->AuthDataSetL(RegToken, Validity, AuthTokenSet));
   104 		QT_TRAP_THROWING ( Flag = m_SmfClientPrivate->AuthDataSetL(RegToken, Validity, AuthTokenSet));
   105 		if (Flag)
   105 		if (Flag)
   106 			return true;
   106 			datastored = true;
   107 		else
   107 		else
   108 			return false;
   108 			datastored = false;
   109 		}
   109 		}
   110 	else
   110 	else
   111 		{
   111 		{
   112 		AuthTokenSet.clear();
   112 		AuthTokenSet.clear();
   113 		return false;
       
   114 		}
   113 		}
       
   114 	
       
   115 	return datastored;
   115 	}
   116 	}
   116 
   117 
   117 QString SmfCredMgrClient::StoreRSAKeys(const QString KeyLabel,
   118 QString SmfCredMgrClient::StoreRSAKeys(const QString KeyLabel,
   118 		const QString keydata, const QDateTime Validity)
   119 		const QString keydata, const QDateTime Validity)
   119 	{
   120 	{
   120 	QString qs = NULL;
   121 	QString retData;
       
   122 	
   121 	if (!(KeyLabel.isEmpty() || keydata.isEmpty()) && Validity.isValid())
   123 	if (!(KeyLabel.isEmpty() || keydata.isEmpty()) && Validity.isValid())
   122 		{
   124 		{
   123 		QT_TRAP_THROWING (qs = m_SmfClientPrivate->storeRSAKeysL(KeyLabel, keydata, Validity));
   125 		QT_TRAP_THROWING ( retData = m_SmfClientPrivate->storeRSAKeysL(KeyLabel, keydata, Validity) );
   124 		}
   126 		}
   125 	return qs;
   127 	return retData;
   126 	}
   128 	}
   127 
   129 
   128 SMFCredMgrErrorCode SmfCredMgrClient::SignMessage(QString Message, QString Key,
   130 SMFCredMgrErrorCode SmfCredMgrClient::SignMessage(QString Message, QString Key,
   129 		QString& Signature, SmfSignatureMethod AlgorithmUsed)
   131 		QString& Signature, SmfSignatureMethod AlgorithmUsed)
   130 	{
   132 	{
   131 	SMFCredMgrErrorCode ec = SmfErrBadParameter;
   133 	SMFCredMgrErrorCode errorCode = SmfErrBadParameter;
   132 	if (!(Message.isEmpty() || Key.isEmpty()))
   134 	if (!(Message.isEmpty() || Key.isEmpty()))
   133 		{
   135 		{
   134 		QT_TRAP_THROWING ( ec = m_SmfClientPrivate->signMessageL(Message, Key, 
   136 		QT_TRAP_THROWING ( errorCode =  m_SmfClientPrivate->signMessageL(Message, Key, Signature,
   135 				Signature,AlgorithmUsed));
   137 				AlgorithmUsed) );
   136 		}
   138 		}
   137 	return ec;
   139 	return errorCode;
   138 	}
   140 	}
   139 
   141 
   140 void SmfCredMgrClient::DeleteRSAKey(QString KeyLabel)
   142 void SmfCredMgrClient::DeleteRSAKey(QString KeyLabel)
   141 	{
   143 	{
   142 	if (!(KeyLabel.isEmpty()))
   144 	if (!(KeyLabel.isEmpty()))
   143 		{
   145 		{
   144 		m_SmfClientPrivate->deleteRSAKey(KeyLabel);
   146 		m_SmfClientPrivate->deleteRSAKey(KeyLabel);
   145 		}
   147 		}
   146 	}
   148 	}
       
   149 
       
   150 bool SmfCredMgrClient::CheckServiceAuthorization( const QString& AuthAppId )
       
   151 	{
       
   152 	bool isAuthorised = false;
       
   153 	if (!AuthAppId.isEmpty())
       
   154 		{
       
   155 		TBool Flag = EFalse;
       
   156 		QT_TRAP_THROWING ( Flag = m_SmfClientPrivate->CheckServiceAuthorizationL(AuthAppId));
       
   157 		if (Flag)
       
   158 			isAuthorised = true;
       
   159 		else
       
   160 			isAuthorised = false;
       
   161 		}
       
   162 	
       
   163 	return isAuthorised;
       
   164 	}
       
   165 
       
   166 SMFCredMgrErrorCode SmfCredMgrClient::DeleteAuthData( const QString& AuthAppId,
       
   167 		const QString& RegToken, const QDateTime& Validity )
       
   168 	{
       
   169 	SMFCredMgrErrorCode errorCode = SmfErrBadParameter;
       
   170 	
       
   171 	if (!(AuthAppId.isEmpty() || RegToken.isEmpty() || Validity.isNull()))
       
   172 		{
       
   173 		TBool Flag = EFalse;
       
   174 		QT_TRAP_THROWING ( Flag = m_SmfClientPrivate->DeleteAuthDataL(AuthAppId, RegToken, Validity));
       
   175 		if (Flag)
       
   176 			errorCode = SmfErrNone;
       
   177 		else
       
   178 			errorCode = SmfErrUnAutherised;
       
   179 		}
       
   180 	
       
   181 	return errorCode;
       
   182 	}
       
   183