#include "InstallerUtil.h"
-#define OSP_INSTALLER_VERSION "version=[20130409.1]"
+#define OSP_INSTALLER_VERSION "version=[20130409.2]"
#define DIR_BIN L"/bin"
#define DIR_INFO L"/info"
PERM_DIR_ROOT = 10,
};
+enum PrivilegeLevel
+{
+ PRIVILEGE_LEVEL_PUBLIC,
+ PRIVILEGE_LEVEL_PARTNER,
+ PRIVILEGE_LEVEL_PLATFORM,
+
+};
+
#endif // _INSTALLER_DEFS_H_
,__operation(INSTALLER_OPERATION_INSTALL)
,__storage(INSTALLATION_STORAGE_INTERNAL)
,__rootCertType(ROOT_CERTIFICATE_NONE)
+,__privilegeLevel(PRIVILEGE_LEVEL_PUBLIC)
,__pApp2ExtHandle(null)
,__pPrivilegeList(null)
,__pStringPrivilegeList(null)
InstallerOperation __operation;
InstallationStorage __storage;
RootCertificateType __rootCertType;
+ int __privilegeLevel;
int __packageNameType;
void* __pApp2ExtHandle;
,__pLaunchConditionList(null)
,__feature(0)
,__isSubMode(false)
+,__isSubModeAllowed(true)
,__legacyAppControls(false)
,__isSystemService(false)
-,__mainmenuVisible(false)
+,__menuIconVisible(false)
{
}
Tizen::Base::String __name;
Tizen::Base::String __appId;
Tizen::Base::String __displayName;
- Tizen::Base::String __mainmenuIcon;
+ Tizen::Base::String __menuIcon;
Tizen::Base::String __settingIcon;
Tizen::Base::String __notificationIcon;
Tizen::Base::String __type;
int __feature;
bool __isSubMode;
+ bool __isSubModeAllowed;
bool __legacyAppControls;
bool __isSystemService;
- bool __mainmenuVisible;
+ bool __menuIconVisible;
private:
};
path.SubString(prefix.GetLength(), PACKAGE_ID_LENGTH, appId);
+ // check version info
+ String versionFile = path + VERSION_INFO_FILE;
+ if (File::IsFileExist(versionFile) == true)
+ {
+ AppLog("install preloaded app again.")
+ pContext->__isUpdated = true;
+ }
+
String destRootPath(PATH_OPT_USR_APPS);
destRootPath += L"/";
destRootPath += appId;
InstallerUtil::Remove(pXmlPath.get());
}
-// _PackageInfoImpl* pPackageInfoImpl = pContext->GetPackageInfoImpl();
-// TryReturn(pPackageInfoImpl, false, "[osp-installer] pPackageInfoImpl is null.");
-//
-// ArrayList* pAppList = pPackageInfoImpl->GetAppInfoList();
-// for (int i = 0 ; i < pAppList->GetCount(); i++)
-// {
-// _PackageAppInfoImpl* pAppInfoImpl = dynamic_cast<_PackageAppInfoImpl*>(pAppList->GetAt(i));
-// if (pAppInfoImpl)
-// {
-// String packageName = pAppInfoImpl->GetPackageName();
-// String destPath;
-// char dest[772] = {0};
-//
-// destPath.Format(1024, L"%ls/%ls", SLP_APP_PATH, packageName.GetPointer());
-// sprintf(dest, "%ls", destPath.GetPointer());
-// unlink(dest);
-// }
-// }
-
return true;
}
{
String name = pAppData->__name;
String main = pAppData->__main;
- String mainmenuIcon = pAppData->__mainmenuIcon;
+ String mainmenuIcon = pAppData->__menuIcon;
String settingIcon = pAppData->__settingIcon;
String notificationIcon = pAppData->__notificationIcon;
int feature = pAppData->__feature;
std::string("/opt/dbspace/.cert_svc_vcore.db"));
TryReturn(res, false, "ValidationCore::VCoreInit() is failed.");
TryReturn(__pContext->__rootPath.IsEmpty() == false, false, "__pContext->__rootPath is empty.");
- fprintf(stderr, " ## sValidationCore::VCoreInit() is done\n");
+ AppLog("ValidationCore::VCoreInit() is done");
std::unique_ptr<char[]> pRootPath(_StringConverter::CopyToCharArrayN(__pContext->__rootPath));
TryReturn(pRootPath, false, "__pRootPath is null.");
findRes = signatureFinder.find(signatureFiles);
TryReturn(findRes == ValidationCore::SignatureFinder::NO_ERROR , false, "signatureFinder.find() is failed, findRes=[%d]", (int)findRes);
+ AppLog("signatureFinder.find() is done");
- fprintf(stderr, " ## signatureFinder.find() is done\n");
ValidationCore::SignatureFileInfoSet::reverse_iterator iter = signatureFiles.rbegin();
for (; iter != signatureFiles.rend(); ++iter)
{
ValidationCore::SignatureReader xml;
xml.initialize(data, "/usr/share/wrt-engine/schema.xsd");
xml.read(data);
- AppLog("ValidationCore::SignatureReader() done");
- fprintf(stderr, " ## ValidationCore::SignatureReader() is done\n");
+ AppLog("ValidationCore::SignatureReader() is done");
ValidationCore::CertificateList certList = data.getCertList();
ValidationCore::CertificateList::iterator it = certList.begin();
ValidationCore::SignatureValidator validator(appType, false, false, false);
AppLog("validator.check() start >>");
- fprintf(stderr, " ## validator.check() start\n");
-
valRes = validator.check(data, rootPath);
TryReturn(valRes == ValidationCore::SignatureValidator::SIGNATURE_VERIFIED, false, "validator.check() is failed, valRes=[%d]", (int)valRes);
- fprintf(stderr, " ## validator.check() done\n");
- AppLog("validator.check() done <<");
- fprintf(stderr, " ## Signature validator.check success, name=[%s], number=[%d]\n", iter->getFileName().c_str(), iter->getFileNumber());
+ AppLog("Signature validator.check success, name=[%s], number=[%d]", iter->getFileName().c_str(), iter->getFileNumber());
ValidationCore::CertificatePtr pRootCert = data.getRootCaCertificatePtr();
TryReturn(pRootCert, false, "__pRootPath is null.");
}
bool
+SignatureManager::ValidatePartialReferences()
+{
+ AppLog("ValidatePartialReferences start >>");
+
+ bool res = true;
+ std::unique_ptr<char[]> pSignaturePath(_StringConverter::CopyToCharArrayN(__pContext->GetSignatureXmlPath()));
+ TryReturn(pSignaturePath, false, "pSignaturePath is null.");
+
+ std::unique_ptr<char[]> pAuthorSignaturePath(_StringConverter::CopyToCharArrayN(__pContext->GetAuthorSignatureXmlPath()));
+ TryReturn(pAuthorSignaturePath, false, "pAuthorSignaturePath is null.");
+
+ std::unique_ptr<SignatureHandler> pDistributorSignature(new (std::nothrow) SignatureHandler());
+ TryReturn(pDistributorSignature, false, "pDistributorSignature is null.");
+
+ res = pDistributorSignature->Construct(__pContext);
+ TryReturn(res == true, false, "pDistributorSignature->Construct() is failed.");
+
+ res = pDistributorSignature->Parse(pSignaturePath.get());
+ TryReturn(res == true, false, "pDistributorSignature->Parse() is failed.");
+
+ HashMap* pDistributorRefMap = pDistributorSignature->GetReferenceMap();
+ TryReturn(pDistributorRefMap, false, "pDistributorRefMap is null.");
+
+ std::unique_ptr<SignatureHandler> pAuthorSignature(new (std::nothrow) SignatureHandler());
+ TryReturn(pAuthorSignature, false, "pAuthorSignature is null.");
+
+ res = pAuthorSignature->Construct(__pContext);
+ TryReturn(res == true, false, "pAuthorSignature.Construct() is failed.");
+
+ res = pAuthorSignature->Parse(pAuthorSignaturePath.get());
+ TryReturn(res == true, false, "pAuthorSignature->Parse() is failed.");
+
+ HashMap* pAuthorRefMap = pAuthorSignature->GetReferenceMap();
+ TryReturn(pAuthorRefMap, false, "pAuthorRefMap is null.");
+
+ res = CompareReferences(pDistributorRefMap, pAuthorRefMap);
+ TryReturn(res == true, false, "CompareReferences() is failed.");
+
+ return true;
+}
+
+bool
SignatureManager::RegisterCertInfo() const
{
TryReturn(__pContext, false, "__pContext is null");
return apiVisibility;
}
+int
+SignatureManager::GetPrivilegeLevel(int apiVisibility)
+{
+ int privilegeLevel = 0;
+ if (apiVisibility == _API_VISIBILITY_PARTNER_MANUFACTURER || apiVisibility == _API_VISIBILITY_PARTNER_OPERATOR)
+ {
+ privilegeLevel = PRIVILEGE_LEVEL_PLATFORM;
+ }
+ else if (apiVisibility == _API_VISIBILITY_PARTNER)
+ {
+ privilegeLevel = PRIVILEGE_LEVEL_PARTNER;
+ }
+
+ return PRIVILEGE_LEVEL_PUBLIC;
+}
+
bool
SignatureManager::SetSignature()
{
}
bool
+SignatureManager::CompareReferences(HashMap* pDistributorRefMap, HashMap* pAuthorRefMap)
+{
+ TryReturn(__pContext, false, "__pContext is null.");
+ bool res = false;
+
+ std::unique_ptr< IMapEnumerator > pEnum(pAuthorRefMap->GetMapEnumeratorN());
+ TryReturn(pEnum, false, "pEnum is null.");
+
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ String* pAuthorKey = static_cast< String* > (pEnum->GetKey());
+ TryReturn(pAuthorKey, false, "pAuthorKey is null.");
+
+ String* pAuthorValue = static_cast< String* > (pEnum->GetValue());
+ TryReturn(pAuthorValue, false, "pAuthorValue is failed.");
+
+ String* pDistValue = static_cast< String* >(pDistributorRefMap->GetValue(*pAuthorKey));
+ TryReturn(pDistValue, false, "pDistValue is null, failed to compare.");
+
+ AppLog("\n >> pAuthorValue=[%ls]", pAuthorValue->GetPointer());
+ AppLog("\n >> pDistValue=[%ls]", pDistValue->GetPointer());
+ if (*pAuthorValue != *pDistValue)
+ {
+ TryReturn(0, false, "Digest value does not be matched.");
+ }
+
+ String filePath = __pContext->__rootPath + L"/" + *pAuthorKey;
+ String fileDigest;
+
+ AppLog("\n >> filePath=[%ls]", filePath.GetPointer());
+ res = InstallerUtil::GetFileDigest(filePath, fileDigest);
+ TryReturn(res == true, false, "GetFileDigest() is failed.");
+
+ AppLog("\n >> fileDigest=[%ls]", fileDigest.GetPointer());
+ if (*pAuthorValue != fileDigest)
+ {
+ TryReturn(0, false, "Digest value does not be matched.");
+ }
+ }
+
+ return true;
+}
+
+bool
+SignatureManager::PrintCertValue(const String& certValue) const
+{
+ const int certLength = 30;
+
+ String startString;
+ String endString;
+ certValue.SubString(0, certLength, startString);
+ certValue.SubString(certValue.GetLength() - certLength, certLength, endString);
+ AppLog("cert value, start with [%ls]", startString.GetPointer());
+ AppLog("cert value, end with [%ls]", endString.GetPointer());
+
+ return true;
+}
+
+bool
SignatureManager::Validate(X509CertificatePath* pCertPath)
{
TryReturn(pCertPath, false, "pCertPath is null.");
SignatureManager(void);
virtual ~SignatureManager(void);
- bool Construct(InstallationContext *pConext);
+ bool Construct(InstallationContext* pContext);
bool ValidateSignatures();
+ bool ValidatePartialReferences();
bool RegisterCertInfo() const;
bool UnregisterCertInfo() const;
int GetApiVisibility(RootCertificateType certType);
+ int GetPrivilegeLevel(int apiVisibility);
bool SetSignature();
bool AddCert();
bool SetCertificatePath(SignatureFileType type, Tizen::Security::Cert::X509CertificatePath* pCertPath);
bool GetCertValue(Tizen::Security::Cert::ICertificate* pCert, Tizen::Base::String& value) const;
+ bool CompareReferences(Tizen::Base::Collection::HashMap* pDistributorRefMap, Tizen::Base::Collection::HashMap* pAuthorRefMap);
+ bool PrintCertValue(const Tizen::Base::String& certValue) const;
+ //
bool Validate(Tizen::Security::Cert::X509CertificatePath* pCertPath);
bool AddCertificate(Tizen::Security::Cert::X509CertificatePath* pCertPath, Tizen::Base::Collection::IList* pCertChain);
bool AddDistributorRootCert(Tizen::Security::Cert::X509CertificatePath* pCertPath);
TryReturn(pHashValue, false, "pHashValue is null.");
r = StringUtil::EncodeToBase64String(*pHashValue, base64Value);
- TryReturn(r == E_SUCCESS, false, "EncodeToBase64String() is failed.");
+ TryReturn(!IsFailed(r), false, "EncodeToBase64String() is failed.");
+
+ // in smack, '/' is not allowed for label.
+ r = base64Value.Replace(L"/", L"#");
+ TryReturn(!IsFailed(r), false, "base64Value.Replace() is failed.");
std::unique_ptr<char[]> pHashEncodedValue(_StringConverter::CopyToCharArrayN(base64Value));
- TryReturn(pHashEncodedValue, false, "pHashEncodedValue is null.");
+ TryReturn(!IsFailed(r), false, "pHashEncodedValue is null.");
label = pHashEncodedValue.get();
AppLog("pHashEncodedValue = [%s]", pHashEncodedValue.get());
res = EnablePermissions(pPackageId.get(), 1, pList, true);
- if (__pContext->__isPreloaded == true)
+ if ((__pContext->__isPreloaded == true) && (__pContext->__isUpdated == false))
{
String smackFile(L"/etc/smack/accesses2.d/");
smackFile.Append(packageId);
error = OnStateRootCert();
break;
+ case STATE_CONTEXT_AUDIT:
+ AppLog("[STATE_CONTEXT_AUDIT]");
+ error = OnStateContextAudit();
+ break;
+
case STATE_DONE:
AppLog("[STATE_DONE]");
error = OnStateDone();
SignatureStep::OnStateSignerInit(void)
{
InstallerError error = INSTALLER_ERROR_NONE;
- bool ret = true;
+ bool res = true;
__pSignatureManager = new (std::nothrow) SignatureManager();
- TryReturn(__pSignatureManager, error = INSTALLER_ERROR_OUT_OF_MEMORY, "__pSignatureManager is null.");
+ TryReturn(__pSignatureManager, INSTALLER_ERROR_OUT_OF_MEMORY, "__pSignatureManager is null.");
- ret = __pSignatureManager->Construct(__pContext);
- TryReturn(ret == true, error = INSTALLER_ERROR_INTERNAL_STATE, "Construct() failed");
+ res = __pSignatureManager->Construct(__pContext);
+ TryReturn(res == true, INSTALLER_ERROR_INTERNAL_STATE, "Construct() failed");
- ret = __pSignatureManager->ValidateSignatures();
- fprintf(stderr, " ## __pSignatureManager->ValidateSignatures() result = [%d]\n", ret);
+ res = __pSignatureManager->ValidateSignatures();
+ AppLog(" ## __pSignatureManager->ValidateSignatures() result = [%s]", res?"true":"false");
+ fprintf(stderr, " ## __pSignatureManager->ValidateSignatures() result = [%s]\n", res?"true":"false");
- if (ret == true)
+ if (res == true)
{
- AppLog("_pSignatureManager->ValidateSignatures() is ok.");
- __state = STATE_ROOT_CERT;
+ res = __pSignatureManager->ValidatePartialReferences();
+ AppLog(" ## __pSignatureManager->ValidatePartialReferences() result = [%s]", res?"true":"false");
+ fprintf(stderr, " ## __pSignatureManager->ValidatePartialReferences() result = [%s]\n", res?"true":"false");
}
else
{
- AppLog("_pSignatureManager->ValidateSignatures() does not be passed, using another validator.");
-
__pContext->__rootCertType = ROOT_CERTIFICATE_NONE;
__pContext->__pAuthorCertList->RemoveAll();
__pContext->__pDistributorCertList->RemoveAll();
+ }
+ if (res == true)
+ {
+ AppLog("_pSignatureManager->ValidateSignatures() is done.");
+ __state = STATE_ROOT_CERT;
+ }
+ else
+ {
+ AppLog("_pSignatureManager->ValidateSignatures() does not be passed, using another validator.");
GoNextState();
}
PackageId packageId = __pContext->__packageId;
int apiVisibility = __pSignatureManager->GetApiVisibility(certType);
- AppLog("PackageId = [%ls], CertType = [%d], ApiVisibility = [%d]", packageId.GetPointer(), certType, apiVisibility);
+ if (__pContext->__isPreloaded == true)
+ {
+ __pContext->__privilegeLevel = PRIVILEGE_LEVEL_PLATFORM;
+ }
+ else
+ {
+ __pContext->__privilegeLevel = __pSignatureManager->GetPrivilegeLevel(apiVisibility);
+ }
+ AppLog("PackageId = [%ls], CertType = [%d], ApiVisibility = [%d], preloaded = [%d], privilege level = [%d]",
+ packageId.GetPointer(), certType, apiVisibility, __pContext->__isPreloaded, __pContext->__privilegeLevel);
if (pPrivilegeList != null)
{
}
InstallerError
+SignatureStep::OnStateContextAudit(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+#if 0
+ TryCatch(__pContext->__pAppDataList, error = INSTALLER_ERROR_NONE, "__pContext->__pAppDataList is null.");
+
+ if (__pContext->__privilegeLevel == PRIVILEGE_LEVEL_PLATFORM)
+ {
+ TryCatch(__pContext->__privilegeLevel, error = INSTALLER_ERROR_NONE, "__pContext->__privilegeLevel is PRIVILEGE_LEVEL_PLATFORM.");
+ }
+ else if (__pContext->__privilegeLevel == PRIVILEGE_LEVEL_PARTNER)
+ {
+ TryCatch(__pContext->__privilegeLevel, error = INSTALLER_ERROR_NONE, "__pContext->__privilegeLevel is PRIVILEGE_LEVEL_PARTNER.");
+ }
+ else if (__pContext->__privilegeLevel == PRIVILEGE_LEVEL_PUBLIC)
+ {
+ int count = __pContext->__pAppDataList->GetCount();
+ result r = E_SUCCESS;
+
+ for (int i = 0; i < count; i++)
+ {
+ AppData* pAppData = null;
+ r = __pContext->__pAppDataList->GetAt(i, pAppData);
+ TryCatch(!IsFailed(r), error = INSTALLER_ERROR_NONE, "pAppDataList->GetAt() is failed.");
+
+ if (pAppData)
+ {
+ if ((pAppData->__type.Equals(L"UiApp", false) == true)
+ && (pAppData->__main.Equals(L"True", false) == true))
+ {
+ if (pAppData->__menuIconVisible == false)
+ {
+ AppLog("pAppData->__menuIconVisible[%d] does not be allowed in public privilege level", (int)pAppData->__menuIconVisible);
+ pAppData->__menuIconVisible = true;
+ }
+
+ if (pAppData->__launchingHistoryVisible.Equals(L"False", false) == true)
+ {
+ AppLog("pAppData->__launchingHistoryVisible(%ls) does not be allowed in public privilege level",
+ pAppData->__launchingHistoryVisible.GetPointer());
+ pAppData->__launchingHistoryVisible = L"True";
+ }
+ }
+
+ if (pAppData->__isSubMode == true)
+ {
+ AppLog("pAppData->__isSubMode(%d) does not be allowed in public privilege level",
+ pAppData->__isSubMode);
+
+ pAppData->__isSubModeAllowed = false;
+ }
+
+ if (pAppData->__pFeatureList)
+ {
+ String autoStart = L"AutoRestart";
+ String* pValue = static_cast<String *>(pAppData->__pFeatureList->GetValue(autoStart));
+ if (pValue && (pValue->Equals("True", false) == true))
+ {
+ AppLog("AutoRestart does not be allowed in public privilege level");
+ pAppData->__pFeatureList->Remove(autoStart);
+ }
+
+ String launchOnBoot = L"LaunchOnBoot";
+ pValue = static_cast<String *>(pAppData->__pFeatureList->GetValue(launchOnBoot));
+ if (pValue && (pValue->Equals("True", false) == true))
+ {
+ AppLog("LaunchOnBoot does not be allowed in public privilege level");
+ pAppData->__pFeatureList->Remove(launchOnBoot);
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ TryCatch(__pContext->__privilegeLevel, error = INSTALLER_ERROR_SIGNATURE_INVALID, "__pContext->__privilegeLevel is unknown.");
+ }
+
+CATCH:
+#endif
+ GoNextState();
+ return error;
+}
+
+InstallerError
SignatureStep::OnStateDone(void)
{
InstallerError error = INSTALLER_ERROR_NONE;
STATE_SIGNER_CERT,
STATE_CERT_CHAIN,
STATE_ROOT_CERT,
+ STATE_CONTEXT_AUDIT,
STATE_DONE
};
InstallerError OnStateSignerCert(void);
InstallerError OnStateCertChain(void);
InstallerError OnStateRootCert(void);
+ InstallerError OnStateContextAudit(void);
InstallerError OnStateDone(void);
private:
#include <FIoFile.h>
#include <FIoDirectory.h>
#include <FBase_StringConverter.h>
+#include <FSecCryptoSha2Hash.h>
#include "InstallerDefs.h"
#include "InstallerUtil.h"
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
using namespace Tizen::App;
using namespace Tizen::Io;
+using namespace Tizen::Security::Crypto;
InstallerUtil::InstallerUtil(void)
{
String label("_");
smackManager.AddLabelDir(label, newPath);
- AppLog("CreateSymlink(): [%ls] -> [%ls]", newPath.GetPointer(), oldPath.GetPointer());
+ AppLog("\n >> CreateSymlink(): [%ls] -> [%ls]", newPath.GetPointer(), oldPath.GetPointer());
return true;
}
}
}
- AppLog("path=[%ls], mode=[%04o], appOwner=[%s]",
+ AppLog("\n >> path=[%ls], mode=[%04o], appOwner=[%s]",
filePath.GetPointer(), mode, appOwner?"true":"false");
return true;
return "Unknown";
}
+bool
+InstallerUtil::GetFileDigest(const String& filePath, String& digestValue)
+{
+ const int bufSize = 64*1024;
+ int readBytes = 0;
+ result r = E_SUCCESS;
+
+ File file;
+ std::unique_ptr<Sha2Hash> pHash(new (std::nothrow) Sha2Hash());
+
+ r = pHash->SetAlgorithm("SHA2/256");
+ TryReturn(!IsFailed(r), false, "pHash->SetAlgorithm() is failed.");
+
+ r = pHash->Initialize();
+ TryReturn(!IsFailed(r), false, "pHash->Initialize() is failed.");
+
+ std::unique_ptr<char[]> pBuf(new (std::nothrow) char[bufSize]);
+ TryReturn(pBuf, false, "pBuf is null");
+
+ r = file.Construct(filePath, L"r");
+ TryReturn(!IsFailed(r), false, "file.Construct() is failed.");
+
+ do
+ {
+ readBytes = file.Read(pBuf.get(), bufSize);
+ AppLog("readBytes for Hash=[%d]", readBytes);
+
+ if (readBytes > 0)
+ {
+ ByteBuffer buffer;
+ buffer.Construct((const byte*)pBuf.get(), 0, readBytes, bufSize);
+
+ r = pHash->Update(buffer);
+ TryReturn(!IsFailed(r), false, "pHash->Update() is failed.");
+ }
+ }
+ while (readBytes > 0);
+
+ std::unique_ptr<ByteBuffer> pResultBuf(pHash->FinalizeN());
+ TryReturn(pResultBuf, false, "pResultBuf is null.");
+
+ r = StringUtil::EncodeToBase64String(*pResultBuf, digestValue);
+ TryReturn(!IsFailed(r), false, "EncodeToBase64String() is failed.");
+
+ return true;
+}
Tizen::Base::Collection::IList* pModifiedList);
static const char* GetInstallerOperationString(int operation);
+ static bool GetFileDigest(const Tizen::Base::String& filePath, Tizen::Base::String& digestValue);
private:
static char LogChangeHexToStr(int hex);
if (pAppData->__isSubMode == true)
{
AppLog("Write(): pAppData->__isSubMode is detected");
- WriteSubModeApp(i, pAppData);
+
+ if (pAppData->__isSubModeAllowed == true)
+ {
+ AppLog("Write(): WriteSubModeApp()");
+ WriteSubModeApp(i, pAppData);
+ }
+ else
+ {
+ AppLog("Write(): WriteSubModeApp() is skipped because __isSubModeAllowed is false.");
+ }
}
}
while (pEnum->MoveNext() == E_SUCCESS)
{
String* pKey = static_cast< String* > (pEnum->GetKey());
- TryReturn(pEnum, "use-system-setting", "GetKey() failed. [%s]", GetErrorMessage(GetLastResult()));
+ TryReturn(pKey, "use-system-setting", "GetKey() failed. [%s]", GetErrorMessage(GetLastResult()));
if ((*pKey) == L"HwAcceleration" || (*pKey) == L"GlFrame")
{
String* pValue = static_cast< String* > (pEnum->GetValue());
- TryReturn(pEnum, "use-system-setting", "GetValue() failed. [%s]", GetErrorMessage(GetLastResult()));
+ TryReturn(pValue, "use-system-setting", "GetValue() failed. [%s]", GetErrorMessage(GetLastResult()));
if ((*pValue) == L"On")
{
WriteLanguageValue(pLiveboxNameList, label);
- String menuIcon = pAppData->__mainmenuIcon;
+ String menuIcon = pAppData->__menuIcon;
if (menuIcon.IsEmpty() == false)
{
String menuIconPath;
String binaryPath;
binaryPath.Format(1024, L"%ls%ls/%ls", __pContext->__rootPath.GetPointer(), DIR_BIN, pAppData->__name.GetPointer());
- if (pAppData->__main == L"True")
+ if (pAppData->__main.Equals(L"True", false) == true)
{
WriteLanguageValue(pNameList, label);
- if (pAppData->__mainmenuIcon.IsEmpty() == false)
+ if (pAppData->__menuIcon.IsEmpty() == false)
{
String iconPath;
- GetIconPath(pAppData->__mainmenuIcon, iconPath);
+ GetIconPath(pAppData->__menuIcon, iconPath);
__pWriter->StartElement("icon");
__pWriter->WriteString(iconPath);
{
if (pAppData->__launchingHistoryVisible.IsEmpty() == true)
{
- if (pAppData->__mainmenuVisible == true)
+ if (pAppData->__menuIconVisible == true)
{
taskmanage = L"true";
}
taskmanage = history;
}
- if (pAppData->__mainmenuVisible == true)
+ if (pAppData->__menuIconVisible == true)
{
nodisplay = L"false";
}
WriteLanguageValue(pNameList, label);
- if (pAppData->__mainmenuIcon.IsEmpty() == false)
+ if (pAppData->__menuIcon.IsEmpty() == false)
{
String iconPath;
- GetIconPath(pAppData->__mainmenuIcon, iconPath);
+ GetIconPath(pAppData->__menuIcon, iconPath);
__pWriter->StartElement("icon");
__pWriter->WriteString(iconPath);
__pWriter->WriteString(__pContext->__displayName);
__pWriter->EndElement();
- if (pAppData->__mainmenuIcon.IsEmpty() == false)
+ if (pAppData->__menuIcon.IsEmpty() == false)
{
String iconPath;
- GetIconPath(pAppData->__mainmenuIcon, iconPath);
+ GetIconPath(pAppData->__menuIcon, iconPath);
__pWriter->StartElement("icon");
__pWriter->WriteString(iconPath);
{
if (strcasecmp(pSection, "MainMenu") == 0)
{
- __pAppData->__mainmenuIcon = iconRelPath;
+ __pAppData->__menuIcon = iconRelPath;
}
else if (strcasecmp(pSection, "Setting") == 0)
{
{
if (__isDefaultMainmenu == false)
{
- __pAppData->__mainmenuIcon = iconRelPath;
+ __pAppData->__menuIcon = iconRelPath;
}
if (strcasecmp(pType, __pDefaultIconType) == 0)
{
if (strcasecmp(pMenuIconVisible, "True") == 0)
{
- __pAppData->__mainmenuVisible = true;
+ __pAppData->__menuIconVisible = true;
}
else
{
- __pAppData->__mainmenuVisible = false;
+ __pAppData->__menuIconVisible = false;
}
AddAppFeature("MenuIconVisible", pMenuIconVisible);
else
{
__pAppData->__type = L"ServiceApp";
- __pAppData->__mainmenuVisible = false;
+ __pAppData->__menuIconVisible = false;
char *pUseUi = pAttr->Find("UseUi");
if (pUseUi)
,__pDistributorCertChain(null)
,__isAuthorSignature(false)
,__isDistributorSignature(false)
+,__pReferenceMap(null)
+,__isReferenceDetected(false)
{
}
__pDistributorCertChain->RemoveAll(true);
delete __pDistributorCertChain;
}
+
+ if (__pReferenceMap)
+ {
+ __pReferenceMap->RemoveAll(true);
+ delete __pReferenceMap;
+ }
}
bool
SignatureHandler::Construct(InstallationContext* pContext)
{
+ result r = E_SUCCESS;
__pContext = pContext;
+ __pReferenceMap = new (std::nothrow) HashMap;
+ TryReturn(__pReferenceMap, false, "__pReferenceMap is null.");
+
+ r = __pReferenceMap->Construct();
+ TryReturn(!IsFailed(r), false, "__pReferenceMap->Construct() is failed.");
+
return true;
}
AppLog("signature.xml");
AppLog("------------------------------------------");
AppLog("<%s>", pName);
- status = OnSignatureElement();
+ status = OnSignatureStartElement();
+ }
+ else if (strcasecmp(pName, "Reference") == 0)
+ {
+ status = OnReferenceStartElement();
+ }
+ else if (strcasecmp(pName, "DigestMethod") == 0)
+ {
+ status = OnDigestMethodStartElement();
}
if (!status)
__isAuthorSignature = false;
AppLog("</%s>", pName);
}
+ else if (strcasecmp(pName, "Reference") == 0)
+ {
+ OnReferenceEndElement();
+ }
return true;
}
{
status = OnCertificateValue(pCharacters);
}
+ else if (strcasecmp(pName, "DigestValue") == 0)
+ {
+ status = OnDigestValue(pCharacters);
+ }
if (!status)
{
}
bool
-SignatureHandler::OnSignatureElement(void)
+SignatureHandler::OnSignatureStartElement(void)
{
XmlAttribute *pAttr = null;
char *pId = null;
}
bool
+SignatureHandler::OnReferenceStartElement(void)
+{
+ static const char* pRefDir[] = {"bin/", "info/", null};
+
+ XmlAttribute *pAttr = null;
+ char *pUri = null;
+
+ pAttr = GetAttribute();
+ TryReturn(pAttr, true, "pAttr is null");
+
+ pUri = pAttr->Find("URI");
+ TryReturn(pUri, true, "pUri is null");
+
+ if (pUri)
+ {
+ String referenceUri = pUri;
+
+ for (int i = 0; pRefDir[i]; i++)
+ {
+ if (referenceUri.StartsWith(pRefDir[i], 0) == true)
+ {
+ __referenceUri = referenceUri;
+ AppLog("Reference URI=[%ls]", __referenceUri.GetPointer());
+ __isReferenceDetected = true;
+ }
+ }
+ }
+
+ return true;
+}
+
+bool
+SignatureHandler::OnDigestMethodStartElement(void)
+{
+ return true;
+}
+
+bool
SignatureHandler::OnCertificateValue(const char *pCharacters)
{
- AppLog("<X509Certificate>%s</X509Certificate>", pCharacters);
+ //AppLog("<X509Certificate>%s</X509Certificate>", pCharacters);
result r = E_SUCCESS;
bool res = true;
return res;
}
+bool
+SignatureHandler::OnDigestValue(const char *pCharacters)
+{
+ if (__isReferenceDetected == true)
+ {
+ __digestValue = pCharacters;
+ AppLog("digest value=[%ls]", __digestValue.GetPointer());
+ }
+
+ return true;
+}
+
+bool
+SignatureHandler::OnReferenceEndElement(void)
+{
+ TryReturn(__pReferenceMap, true, "__pReferenceMap is null.");
+
+ if (__isReferenceDetected == true)
+ {
+ __pReferenceMap->Add(new String(__referenceUri), new String(__digestValue));
+ __referenceUri.Clear();
+ __digestValue.Clear();
+ }
+
+ __isReferenceDetected = false;
+
+ return true;
+}
+
ArrayList*
SignatureHandler::GetAuthorCertChain(void)
{
{
return __pDistributorCertChain;
}
+
+HashMap*
+SignatureHandler::GetReferenceMap()
+{
+ return __pReferenceMap;
+}
Tizen::Base::Collection::ArrayList* GetAuthorCertChain(void);
Tizen::Base::Collection::ArrayList* GetDistributorCertChain(void);
+ Tizen::Base::Collection::HashMap* GetReferenceMap();
private:
SignatureHandler(const SignatureHandler& value);
virtual bool OnEndElement(const char *pName);
virtual bool OnCharacters(const char *pCharacters);
- bool OnSignatureElement(void);
+ bool OnSignatureStartElement(void);
+ bool OnReferenceStartElement(void);
+ bool OnDigestMethodStartElement(void);
+
bool OnCertificateValue(const char *pCharacters);
+ bool OnDigestValue(const char* pCharacters);
+ bool OnReferenceEndElement();
private:
InstallationContext* __pContext;
bool __isAuthorSignature;
bool __isDistributorSignature;
+ Tizen::Base::String __referenceUri;
+ Tizen::Base::String __digestValue;
+
+ Tizen::Base::Collection::HashMap* __pReferenceMap;
+ bool __isReferenceDetected;
+
}; // SignatureHandler