BuildRequires: pkgconfig(dpl-utils-efl)
BuildRequires: pkgconfig(dpl-wrt-dao-ro)
BuildRequires: pkgconfig(dpl-wrt-dao-rw)
-BuildRequires: pkgconfig(ecore-x)
-BuildRequires: pkgconfig(security)
BuildRequires: pkgconfig(security-install)
+BuildRequires: pkgconfig(ecore-x)
BuildRequires: pkgconfig(xmlsec1)
BuildRequires: pkgconfig(libidn)
BuildRequires: pkgconfig(libiri)
${INSTALLER_JOBS}/widget_install/task_unzip.cpp
${INSTALLER_JOBS}/widget_install/task_widget_config.cpp
${INSTALLER_JOBS}/widget_install/task_database.cpp
+ ${INSTALLER_JOBS}/widget_install/ace_registration.cpp
${INSTALLER_JOBS}/widget_install/task_file_manipulation.cpp
${INSTALLER_JOBS}/widget_install/task_smack.cpp
${INSTALLER_JOBS}/widget_install/task_ace_check.cpp
openssl
dpl-efl
cert-svc-vcore
- security-core
dpl-event-efl
dpl-utils-efl
dpl-wrt-dao-ro
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file ace_registration.cpp
+ * @author Andrzej Surdej (a.surdej@gmail.com)
+ * @version 1.0
+ * @brief Translate structures to ace api - implementation file
+ */
+
+#include <ace_registration.h>
+#include <dpl/log/log.h>
+#include <dpl/foreach.h>
+#include <ace_api_install.h>
+
+namespace {
+
+char* toAceString(const DPL::OptionalString& os)
+{
+ if (!os.IsNull())
+ return strdup(DPL::ToUTF8String(*os).c_str());
+ else
+ return NULL;
+}
+
+char* toAceString(const std::string& str)
+{
+ if (!str.empty())
+ return strdup(str.c_str());
+ else
+ return NULL;
+}
+
+} //anonymous namespace
+
+namespace AceApi {
+
+bool registerAceWidget(const WrtDB::DbWidgetHandle& widgetHandle,
+ const WrtDB::WidgetRegisterInfo& widgetConfig,
+ const WrtDB::WidgetCertificateDataList& certList)
+{
+ LogDebug("Updating Ace database");
+ struct widget_info wi;
+ DPL::OptionalString os;
+
+ switch(widgetConfig.webAppType.appType)
+ {
+ case WrtDB::APP_TYPE_WAC20:
+ wi.type = WAC20;
+ break;
+ case WrtDB::APP_TYPE_TIZENWEBAPP:
+ wi.type = Tizen;
+ break;
+ default:
+ LogError("Unknown application type");
+ return false;
+ }
+
+ wi.id = toAceString(widgetConfig.configInfo.widget_id);
+ wi.version = toAceString(widgetConfig.configInfo.version);
+ wi.author = toAceString(widgetConfig.configInfo.authorName);
+ wi.shareHerf = strdup(widgetConfig.shareHref.c_str());
+ LogDebug("Basic data converted. Certificates begin.");
+
+ //one more element for NULL termination
+ LogDebug("Found: " << certList.size() << " certificates");
+ ace_certificate_data** certData = new ace_certificate_data*[certList.size() + 1];
+ certData[certList.size()] = NULL; // last element set to NULL
+
+ int i = 0;
+ FOREACH(it, certList)
+ {
+ certData[i] = new ace_certificate_data;
+ switch (it->owner) {
+ case WrtDB::WidgetCertificateData::AUTHOR :
+ certData[i]->owner = AUTHOR;
+ break;
+ case WrtDB::WidgetCertificateData::DISTRIBUTOR :
+ certData[i]->owner = DISTRIBUTOR;
+ break;
+ default :
+ LogDebug("Unknown owner type of cert");
+ certData[i]->owner = UNKNOWN;
+ }
+ switch (it->type) {
+ case WrtDB::WidgetCertificateData::ENDENTITY :
+ certData[i]->type = ENDENTITY;
+ break;
+ case WrtDB::WidgetCertificateData::ROOT :
+ certData[i]->type = ROOT;
+ break;
+ default :
+ LogError("Unknown type of cert");
+ certData[i]->type = ENDENTITY;
+ }
+ certData[i]->chain_id = it->chainId;
+
+ certData[i]->md5_fp = toAceString(it->strMD5Fingerprint);
+ certData[i]->sha1_fp = toAceString(it->strSHA1Fingerprint);
+ certData[i]->common_name = toAceString(DPL::ToUTF8String(it->strCommonName));
+ ++i;
+ }
+
+ LogDebug("Registerign widget in ace");
+ ace_return_t retval = ACE_ACE_UNKNOWN_ERROR;
+ retval = ace_register_widget(
+ static_cast<ace_widget_handle_t>(widgetHandle), &wi, certData);
+
+ //clean up - WidgetInfo
+ free(wi.author);
+ free(wi.id);
+ free(wi.shareHerf);
+ free(wi.version);
+
+ //free cert list
+ i = 0;
+ while (certData[i] != NULL) {
+ free(certData[i]->common_name);
+ free(certData[i]->md5_fp);
+ free(certData[i]->sha1_fp);
+ delete certData[i];
+ ++i;
+ }
+ delete[] certData;
+ return retval == ACE_OK;
+}
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file ace_registration.h
+ * @author Andrzej Surdej (a.surdej@gmail.com)
+ * @version 1.0
+ * @brief Translate structures to ace api - header file
+ */
+#ifndef WRT_SRC_INSTALLER_CORE_ACE_REGISTRATION_H_
+#define WRT_SRC_INSTALLER_CORE_ACE_REGISTRATION_H_
+
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+
+namespace AceApi {
+
+bool registerAceWidget(const WrtDB::DbWidgetHandle& widgetHandle,
+ const WrtDB::WidgetRegisterInfo& widgetConfig,
+ const WrtDB::WidgetCertificateDataList& certList);
+
+}
+
+#endif /* WRT_SRC_INSTALLER_CORE_ACE_REGISTRATION_H_ */
+
#include <widget_install/job_widget_install.h>
#include <widget_install/widget_install_errors.h>
#include <widget_install/widget_install_context.h>
-//#include <dpl/wrt-dao-ro/config_parser_data.h>
#include <dpl/wrt-dao-rw/widget_dao.h>
#include <dpl/foreach.h>
#include <dpl/utils/wrt_utility.h>
#include <dpl/log/log.h>
#include <dpl/assert.h>
-//#include <dpl/wrt-dao-ro/global_config.h>
#include <string>
#include <sstream>
+#include <ace_api_install.h>
+#include <ace_registration.h>
using namespace WrtDB;
namespace WidgetInstall {
TaskDatabase::TaskDatabase(InstallerContext& context) :
DPL::TaskDecl<TaskDatabase>(this),
- m_context(context)
+ m_context(context),
+ m_handleToRemove(INVALID_WIDGET_HANDLE),
+ m_handle(INVALID_WIDGET_HANDLE)
{
AddStep(&TaskDatabase::StepRegisterExternalFiles);
- AddStep(&TaskDatabase::StepDBInsert);
+ AddStep(&TaskDatabase::StepWrtDBInsert);
+ AddStep(&TaskDatabase::StepAceDBInsert);
AddAbortStep(&TaskDatabase::StepAbortDBInsert);
}
-void TaskDatabase::StepDBInsert()
+void TaskDatabase::StepWrtDBInsert()
{
Try
{
if (m_context.existingWidgetInfo.isExist) //update
{
+ m_handleToRemove = WidgetDAOReadOnly::getHandle(
+ m_context.locations->getPkgname());
LogInfo("Registering widget... (update)");
WidgetDAO::registerOrUpdateWidget(
m_context.locations->getPkgname(),
m_context.widgetConfig,
m_context.wacSecurity);
+ m_handle = WidgetDAOReadOnly::getHandle(
+ m_context.locations->getPkgname());
}
else //new installation
{
m_context.locations->getPkgname(),
m_context.widgetConfig,
m_context.wacSecurity);
+ m_handle = WidgetDAOReadOnly::getHandle(
+ m_context.locations->getPkgname());
}
FOREACH (cap, m_context.staticPermittedDevCaps) {
LogError("Database failure!");
ReThrowMsg(Exceptions::InsertNewWidgetFailed, "Database failure!");
}
+}
+
+void TaskDatabase::StepAceDBInsert()
+{
+ LogDebug("Inserting Ace database entry. New handle: " << m_handle);
+ if (INVALID_WIDGET_HANDLE != m_handleToRemove) {
+ LogDebug("Removing old insallation. Handle: " << m_handleToRemove);
+ if (ACE_OK != ace_unregister_widget(
+ static_cast<ace_widget_handle_t>(m_handleToRemove)))
+ {
+ LogWarning("Error while removing ace entry for previous insallation");
+ };
+ }
+
+ if(!AceApi::registerAceWidget(m_handle, m_context.widgetConfig,
+ m_context.wacSecurity.getCertificateList()))
+ {
+ LogError("ace database insert failed");
+ ThrowMsg(Exceptions::NotAllowed, "Update failure. ace_register_widget failed");
+ }
+ LogDebug("Ace data inserted");
m_context.job->UpdateProgress(
InstallerContext::INSTALL_NEW_DB_INSERT,
Try
{
WidgetDAO::unregisterWidget(m_context.locations->getPkgname());
-
LogDebug("Cleaning DB successful!");
}
Catch(DPL::DB::SqlConnection::Exception::Base)
{
LogError("Failed to handle StepAbortDBClean!");
}
+
+ ace_unregister_widget(static_cast<ace_widget_handle_t>(m_handle));
+ // Remove also old one. If it was already updated nothing wrong will happen,
+ // but if not old widget will be removed.
+ if (INVALID_WIDGET_HANDLE != m_handleToRemove)
+ ace_unregister_widget(static_cast<ace_widget_handle_t>(m_handle));
}
} //namespace WidgetInstall
#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_DATABASE_H
#include <dpl/task.h>
+#include <dpl/wrt-dao-ro/common_dao_types.h>
class InstallerContext;
private:
InstallerContext& m_context;
- void StepDBInsert();
+ //TODO: temporary needed until security-server start to use pkgName instead
+ //of widget handle
+ WrtDB::DbWidgetHandle m_handleToRemove;
+ WrtDB::DbWidgetHandle m_handle;
+
void StepRegisterExternalFiles();
+ void StepWrtDBInsert();
+ void StepAceDBInsert();
void StepAbortDBInsert();
#include <widget_uninstall/task_db_update.h>
#include <widget_uninstall/job_widget_uninstall.h>
#include <widget_uninstall/widget_uninstall_errors.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <ace_api_install.h>
#include <dpl/assert.h>
+#include <ace-common/ace_api_common.h>
using namespace WrtDB;
{
Try
{
+ //TODO: widget handle should not be used any more
+ ace_unregister_widget(static_cast<ace_widget_handle_t>(
+ WidgetDAOReadOnly::getHandle(m_context.locations->getPkgname())));
WidgetDAO::unregisterWidget(m_context.locations->getPkgname());
LogDebug("Unregistered widget successfully!");