,__rootCertType(ROOT_CERTIFICATE_NONE)
,__pApp2ExtHandle(null)
,__pPrivilegeList(null)
+,__pStringPrivilegeList(null)
,__pLiveboxDataList(null)
,__pContentDataList(null)
,__pAuthorCertPath(null)
__pPrivilegeList = null;
}
+ if (__pStringPrivilegeList)
+ {
+ __pStringPrivilegeList->RemoveAll(true);
+ delete __pStringPrivilegeList;
+ __pStringPrivilegeList = null;
+ }
+
if (__pLiveboxDataList)
{
__pLiveboxDataList->RemoveAll();
void* __pApp2ExtHandle;
Tizen::Base::Collection::ArrayList* __pPrivilegeList;
+ Tizen::Base::Collection::ArrayList* __pStringPrivilegeList;
Tizen::Base::Collection::ArrayList* __pLiveboxDataList;
Tizen::Base::Collection::ArrayList* __pContentDataList;
Tizen::Security::Cert::X509CertificatePath* __pAuthorCertPath;
String query;
PackageId packageId = pContext->__packageId;
- query.Format(1024, L"INSERT INTO PkgPrivileges (ID, PRIVILEGES, HMAC_PPRIVILEGES, CERTIFICATE_TYPE) "
- "VALUES ((SELECT PkgInfo.UNIQUE_ID FROM PkgInfo WHERE PkgInfo.PKG_ID = '%ls'), ?, ?, ?)", packageId.GetPointer());
+ query.Format(1024, L"INSERT INTO PkgPrivileges (ID, PRIVILEGES, HMAC_PPRIVILEGES, CERTIFICATE_TYPE, STR_PRIVILEGES) "
+ "VALUES ((SELECT PkgInfo.UNIQUE_ID FROM PkgInfo WHERE PkgInfo.PKG_ID = '%ls'), ?, ?, ?, ?)", packageId.GetPointer());
std::unique_ptr< DbStatement > pStmt(_PackageManagerImpl::CreateStatementN(db, query));
TryReturn(pStmt, false, "CreateStatementN() failed. [%s]", GetErrorMessage(GetLastResult()));
String privileges = pContext->__privileges;
String hmacPrivileges = pContext->__hmacPrivileges;
int certType = pContext->__certType;
+ ArrayList* pStringPrivilegeList = pContext->__pStringPrivilegeList;
if (!privileges.IsEmpty())
{
TryReturn(r == E_SUCCESS, false, "BindInt() failed. [%s]", GetErrorMessage(r));
}
+ if (pStringPrivilegeList != null)
+ {
+ IEnumerator* pEnum = pStringPrivilegeList->GetEnumeratorN();
+ String MergedString;
+ while(pEnum->MoveNext() == E_SUCCESS)
+ {
+ MergedString.Append(*(static_cast<String*>(pEnum->GetCurrent())));
+ MergedString.Append(L"#");
+ }
+ delete pEnum;
+
+ r = pStmt->BindString(3, MergedString);
+ TryReturn(r == E_SUCCESS, false, "BindInt() failed. [%s]", GetErrorMessage(r));
+ }
+
std::unique_ptr< DbEnumerator > pEnum(_PackageManagerImpl::ExecuteStatementN(db, pStmt.get()));
TryReturn(!IsFailed(GetLastResult()), false, "ExecuteStatementN() failed. [%s]", GetErrorMessage(GetLastResult()));
"( ID INTEGER,"
"PRIVILEGES TEXT,"
"HMAC_PPRIVILEGES TEXT,"
- "CERTIFICATE_TYPE INTEGER )");
+ "CERTIFICATE_TYPE INTEGER,"
+ "STR_PRIVILEGES TEXT )");
r = db.ExecuteSql(createQuery, true);
TryReturn(r == E_SUCCESS, false, "db.ExecuteSql is failed. [%s]", GetErrorMessage(r));
createQuery.Clear();
result r = E_SUCCESS;
String privileges;
String hmacPrivileges;
+ ArrayList stringPrivilegeList;
+ stringPrivilegeList.Construct();
const ArrayList* pPrivilegeList = __pContext->GetPrivilegeList();
RootCertificateType certType = __pContext->__rootCertType;
AppLog("PackageId = [%ls], CertType = [%d], ApiVisibility = [%d]", packageId.GetPointer(), certType, apiVisibility);
- r = PrivilegeHandler::GenerateCipherPrivilege(packageId, *pPrivilegeList, apiVisibility, privileges, hmacPrivileges);
+ r = PrivilegeHandler::GenerateCipherPrivilege(packageId, *pPrivilegeList, apiVisibility, privileges, hmacPrivileges, stringPrivilegeList);
TryCatch(!IsFailed(r), error = INSTALLER_ERROR_PRIVILEGE_INVALID, "privMgr.GeneratePrivilegeString() failed");
__pContext->__privileges = privileges;
__pContext->__hmacPrivileges = hmacPrivileges;
__pContext->__certType = apiVisibility;
+ __pContext->__pStringPrivilegeList = new ArrayList;
+ __pContext->__pStringPrivilegeList->Construct(stringPrivilegeList);
CATCH:
GoNextState();
result r = E_SUCCESS;
String privileges;
String hmacPrivileges;
+ ArrayList stringPrivilegeList;
+ stringPrivilegeList.Construct(125);
PackageId packageId = __pContext->__packageId;
- r = PrivilegeHandler::GenerateCipherPrivilege(packageId, *__pPrivilegeList, privileges, hmacPrivileges);
+ r = PrivilegeHandler::GenerateCipherPrivilege(packageId, *__pPrivilegeList, privileges, hmacPrivileges, stringPrivilegeList);
TryReturn(!IsFailed(r), false, "privMgr.GeneratePrivilegeString() failed");
__pContext->__privileges = privileges;
__pContext->__hmacPrivileges = hmacPrivileges;
+ __pContext->__pStringPrivilegeList = new ArrayList;
+ __pContext->__pStringPrivilegeList->Construct(stringPrivilegeList);
}
__pContext->SetPrivilegeList(__pPrivilegeList);
#include <FBaseInternalTypes.h>
#include <FSec_AccessControlTypes.h>
#include <FSec_DeviceKeyGenerator.h>
+#include <FIoFile.h>
#include "InstallerDefs.h"
#include "PrivilegeHandler.h"
using namespace Tizen::Security;
using namespace Tizen::Security::Crypto;
using namespace Tizen::Text;
+using namespace Tizen::Io;
+
+
+result
+PrivilegeHandler::PickExternalPrivilege(const IList& fullPrivilegeList, IList& normalPrivilegeList, IList& externalPrivilegeList)
+{
+ result r = E_SUCCESS;
+ File file;
+ String externalPrivilege;
+ ArrayList privilegeList;
+
+ r = file.Construct(EXTERNAL_PRIVILEGE_FILE_NAME, "r");
+ TryReturnResultTag(OSP_INSTALLER, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ privilegeList.Construct();
+
+ while (file.Read(externalPrivilege) == E_SUCCESS)
+ {
+ externalPrivilege.Remove(externalPrivilege.GetLength()-1, 1);
+ privilegeList.Add(new String(externalPrivilege));
+ }
+
+ IEnumerator* pEnum = fullPrivilegeList.GetEnumeratorN();
+
+ while(pEnum->MoveNext() == E_SUCCESS)
+ {
+ String* tempString = static_cast<String*>(pEnum->GetCurrent());
+
+ if (privilegeList.Contains(*tempString))
+ {
+ externalPrivilegeList.Add(new String(*tempString));
+ }
+ else
+ {
+ normalPrivilegeList.Add(new String(*tempString));
+ }
+ }
+
+ delete pEnum;
+ privilegeList.RemoveAll(true);
+ return r;
+}
result
-PrivilegeHandler::GenerateCipherPrivilege(const AppId& appId, const IList& privilegeList, String& encryptedPrivileges, String& checksum)
+PrivilegeHandler::GenerateCipherPrivilege(const AppId& appId, const IList& privilegeList, String& encryptedPrivileges, String& checksum, IList& stringPrivilegeList)
{
result r = E_SUCCESS;
byte* pBitwisePrivilege = null;
int count = 0;
+ ArrayList normalPrivilegeList;
encryptedPrivileges.Clear();
checksum.Clear();
+ normalPrivilegeList.Construct();
count = privilegeList.GetCount();
if (count == 0)
goto CATCH;
}
- pBitwisePrivilege = PackPrivilegeN(privilegeList);
+ r = PickExternalPrivilege(privilegeList, normalPrivilegeList, stringPrivilegeList);
+ TryReturnResultTag(OSP_INSTALLER, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ pBitwisePrivilege = PackPrivilegeN(normalPrivilegeList);
TryReturnResultTag(OSP_INSTALLER, pBitwisePrivilege != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
r = GetEncryptedBitwise(pBitwisePrivilege, encryptedPrivileges);
free(pBitwisePrivilege);
}
+ normalPrivilegeList.RemoveAll(true);
return r;
}
result
-PrivilegeHandler::GenerateCipherPrivilege(const AppId& appId, const IList& privilegeList, int visibilityLevel, String& encryptedPrivileges, String& checksum)
+PrivilegeHandler::GenerateCipherPrivilege(const AppId& appId, const IList& privilegeList, int visibilityLevel, String& encryptedPrivileges, String& checksum, IList& stringPrivilegeList)
{
result r = E_SUCCESS;
byte* pBitwisePrivilege = null;
int count = 0;
+ ArrayList normalPrivilegeList;
encryptedPrivileges.Clear();
checksum.Clear();
+ normalPrivilegeList.Construct();
count = privilegeList.GetCount();
if (count == 0)
goto CATCH;
}
- r = PackPrivilegeN(privilegeList, visibilityLevel, &pBitwisePrivilege);
+ r = PickExternalPrivilege(privilegeList, normalPrivilegeList, stringPrivilegeList);
+ TryReturnResultTag(OSP_INSTALLER, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ r = PackPrivilegeN(normalPrivilegeList, visibilityLevel, &pBitwisePrivilege);
TryReturnResultTag(OSP_INSTALLER, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
r = GetEncryptedBitwise(pBitwisePrivilege, encryptedPrivileges);
free(pBitwisePrivilege);
}
+ normalPrivilegeList.RemoveAll(true);
return r;
}
class String;
}}
+static const wchar_t EXTERNAL_PRIVILEGE_FILE_NAME[] = L"/usr/share/osp/.external-privilege.ini";
+
/**
* @class PrivilegeHandler
* @brief This class represents the class of PrivilegeHandler.
{
public:
- static result GenerateCipherPrivilege(const Tizen::App::AppId& appId, const Tizen::Base::Collection::IList& privilegeList, Tizen::Base::String& encryptedPrivileges, Tizen::Base::String& checksum);
- static result GenerateCipherPrivilege(const Tizen::App::AppId& appId, const Tizen::Base::Collection::IList& privilegeList, int visibilityLevel, Tizen::Base::String& encryptedPrivileges, Tizen::Base::String& checksum);
+ static result GenerateCipherPrivilege(const Tizen::App::AppId& appId, const Tizen::Base::Collection::IList& privilegeList, Tizen::Base::String& encryptedPrivileges, Tizen::Base::String& checksum, Tizen::Base::Collection::IList& stringPrivilege);
+ static result GenerateCipherPrivilege(const Tizen::App::AppId& appId, const Tizen::Base::Collection::IList& privilegeList, int visibilityLevel, Tizen::Base::String& encryptedPrivileges, Tizen::Base::String& checksum, Tizen::Base::Collection::IList& stringPrivilege);
private:
static byte* PackPrivilegeN(const Tizen::Base::Collection::IList& privilegeList);
static result PackPrivilegeN(const Tizen::Base::Collection::IList& privilegeList, int visibilityLevel, byte** ppBitwisePrivilege);
static result GetEncryptedBitwise(byte* __bitwisePrivilege, Tizen::Base::String& encryptedPrivileges);
static result GetChecksum(Tizen::App::AppId appId, byte* __bitwisePrivilege, Tizen::Base::String& checksum);
+ static result PickExternalPrivilege(const Tizen::Base::Collection::IList& fullPrivilegeList, Tizen::Base::Collection::IList& normalPrivilegeList, Tizen::Base::Collection::IList& externalPrivilegeList);
}; // PrivilegeHandler