From: hb.min Date: Thu, 18 Apr 2013 16:47:13 +0000 (+0900) Subject: Modifty getting method of undefined privilege description X-Git-Tag: accepted/tizen_2.1/20130425.034849~36^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5311e78a1ad0f6684296c2ef7044dfbe3c5f032b;p=framework%2Fosp%2Fappfw.git Modifty getting method of undefined privilege description Change-Id: If63066390808e73e48817922155cf63617750be5 Signed-off-by: hb.min --- diff --git a/src/security/FSec_PrivilegeInfoImpl.cpp b/src/security/FSec_PrivilegeInfoImpl.cpp index e0f712e..f3688ae 100755 --- a/src/security/FSec_PrivilegeInfoImpl.cpp +++ b/src/security/FSec_PrivilegeInfoImpl.cpp @@ -32,11 +32,13 @@ #include #include #include +#include #include "FSec_PrivilegeInfoImpl.h" using namespace Tizen::Base::Runtime; using namespace Tizen::Base; +using namespace Tizen::Base::Utility; using namespace Tizen::Base::Collection; using namespace Tizen::Io; @@ -165,7 +167,16 @@ _PrivilegeInfoImpl::GetName(const String& privilege) const } else { - SysLogException(NID_SEC, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] Privilege information is not found. [%ls]", privilegeString.GetPointer()); + SysLog(NID_SEC, "Privilege information is not found. [%ls]", privilegeString.GetPointer()); + + String displayName; + StringTokenizer strTok(__privilegeId, L"/"); + while(strTok.HasMoreTokens() == true) + { + strTok.GetNextToken(displayName); + } + + name = displayName; } CATCH: @@ -212,7 +223,7 @@ _PrivilegeInfoImpl::GetDescription(const String& privilege) const } else { - SysLogException(NID_SEC, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] Privilege information is not found. [%ls]", privilegeString.GetPointer()); + description.Append("Undefined"); } CATCH: @@ -276,6 +287,52 @@ _PrivilegeInfoImpl::ExecuteStatementN(Database& db, const DbStatement* pStmt) return pEnum; } +bool +_PrivilegeInfoImpl::CheckExternalPrivilege(const Tizen::Base::String& privilegeId) +{ + result r = E_SUCCESS; + bool flag = false; + + String query; + DbStatement* pStmt = null; + DbEnumerator* pEnum = null; + + Database* pDb = new Database; + SysTryReturn(NID_SEC, pDb != null, false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = pDb->Construct(EXTERNAL_PRIVILEGE_DATABASE_FILE_NAME, false); + SysTryCatch(NID_SEC, r == E_SUCCESS, flag = false, E_DATABASE, "External PrivilegeDb is not exist."); + + query.Format(1024, L"SELECT PRIVILEGE_ID FROM PrivilegeInfo WHERE PRIVILEGE_ID = '%ls'", privilegeId.GetPointer()); + + pStmt = CreateStatementN(*pDb, query); + SysTryCatch(NID_SEC, pStmt != null, flag = false, E_DATABASE, "[E_DATABASE] An error occurs while creating a database statement."); + + pEnum = ExecuteStatementN(*pDb, pStmt); + if (pEnum != null) + { + if (pEnum->MoveNext() == E_SUCCESS) + { + flag = true; + } + + delete pEnum; + pEnum = null; + } + else + { + flag = false; + SysLog(NID_SEC, "[%ls] is not exist in PrivilegeDb.", privilegeId.GetPointer()); + } + +CATCH: + + delete pDb; + delete pStmt; + + return flag; +} + result _PrivilegeInfoImpl::Construct(const Tizen::Base::String& privilegeId) { @@ -302,6 +359,14 @@ _PrivilegeInfoImpl::Construct(const Tizen::Base::String& privilegeId) } } + if (validStringFlag != true) + { + if (CheckExternalPrivilege(privilegeId)) + { + validStringFlag = true; + } + } + SysTryReturnResult(NID_SEC, validStringFlag == true, E_INVALID_ARG, "Invalid privilege ID [%ls]", privilegeId.GetPointer()); r = Construct(); diff --git a/src/security/inc/FSec_PrivilegeInfoImpl.h b/src/security/inc/FSec_PrivilegeInfoImpl.h index 5c8b996..10d3a94 100755 --- a/src/security/inc/FSec_PrivilegeInfoImpl.h +++ b/src/security/inc/FSec_PrivilegeInfoImpl.h @@ -43,6 +43,7 @@ class PrivilegeInfo; static const int MAX_DATABASE_RETRY_COUNT = 30; static const wchar_t PRIVILEGE_DESCRIPTION_DATABASE_FILE_NAME[] = L"/usr/share/osp/.privilege-description.db"; +static const wchar_t EXTERNAL_PRIVILEGE_DATABASE_FILE_NAME[] = L"/opt/dbspace/.privilegelist.db"; class _OSP_EXPORT_ _PrivilegeInfoImpl : public Tizen::Base::Object @@ -70,6 +71,8 @@ private: result CheckDatabase(void); static void InitInstance(void); + bool CheckExternalPrivilege(const Tizen::Base::String& privilegeId); + static Tizen::Io::DbStatement* CreateStatementN(Tizen::Io::Database& db, const Tizen::Base::String& query); static Tizen::Io::DbEnumerator* ExecuteStatementN(Tizen::Io::Database& db, const Tizen::Io::DbStatement* pStmt);