const char* const SECURITY_ORIGIN_DB_NAME = ".security_origin.db";
const char* const SECURITY_ORIGIN_DB_SQL_PATH =
"/usr/share/wrt-engine/security_origin_db.sql";
+const char* const SECURITY_DATABASE_JOURNAL_FILENAME = "-journal";
+
+const int WEB_APPLICATION_UID = 5000;
+const int WEB_APPLICATION_GUID = 5000;
std::string createDatabasePath(const WrtDB::WidgetPkgName &pkgName)
{
SECURITY_ORIGIN_DB_OPTION);
con.ExecCommand(ssBuffer.str().c_str());
}
+
+ if(chown(databasePath.c_str(),
+ WEB_APPLICATION_UID,
+ WEB_APPLICATION_GUID) != 0)
+ {
+ ThrowMsg(SecurityOriginDAO::Exception::DatabaseError,
+ "Fail to change uid/guid");
+ }
+ std::string databaseJournal =
+ databasePath + SECURITY_DATABASE_JOURNAL_FILENAME;
+ if(chown(databaseJournal.c_str(),
+ WEB_APPLICATION_UID,
+ WEB_APPLICATION_GUID) != 0)
+ {
+ ThrowMsg(SecurityOriginDAO::Exception::DatabaseError,
+ "Fail to change uid/guid");
+ }
}
SQL_CONNECTION_EXCEPTION_HANDLER_END("Fail to get database Path")
}
"Failed to get result for security origin")
}
-void SecurityOriginDAO::setSecurityOriginData(
- const SecurityOriginData &securityOriginData,
- const Result result)
+bool SecurityOriginDAO::isReadOnly(const SecurityOriginData &securityOriginData)
+{
+ SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+ {
+ SECURITY_ORIGIN_DB_SELECT(select, SecurityOriginInfo, &m_securityOriginDBInterface);
+ select->Where(
+ And(And(And(Equals<SecurityOriginInfo::feature>(securityOriginData.feature),
+ Equals<SecurityOriginInfo::scheme>(securityOriginData.origin.scheme)),
+ Equals<SecurityOriginInfo::host>(securityOriginData.origin.host)),
+ Equals<SecurityOriginInfo::port>(securityOriginData.origin.port)));
+ SecurityOriginInfo::Select::RowList rows = select->GetRowList();
+
+ if (rows.empty()) {
+ return RESULT_UNKNOWN;
+ }
+ SecurityOriginInfo::Row row = rows.front();
+ return row.Get_readonly() ? true : false;
+ }
+ SQL_CONNECTION_EXCEPTION_HANDLER_END("Fail to get readonly property")
+}
+
+void SecurityOriginDAO::setSecurityOriginData(const SecurityOriginData &securityOriginData,
+ const Result result,
+ const bool readOnly)
{
SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
{
row.Set_host(securityOriginData.origin.host);
row.Set_port(securityOriginData.origin.port);
row.Set_result(result);
+ row.Set_readonly(readOnly ? 1 : 0);
if (true == hasResult(securityOriginData)) {
SECURITY_ORIGIN_DB_UPDATE(update,
SQL_CONNECTION_EXCEPTION_HANDLER_END("Fail to set security origin data")
}
+void SecurityOriginDAO::setPrivilegeSecurityOriginData(const Feature feature)
+{
+ Origin origin(DPL::FromUTF8String("file"),
+ DPL::FromUTF8String(""),
+ 0);
+ SecurityOriginData data(feature, origin);
+ setSecurityOriginData(data, RESULT_ALLOW_ALWAYS, true);
+}
+
void SecurityOriginDAO::removeSecurityOriginData(
const SecurityOriginData &securityOriginData)
{
#include <wrt-commons/security-origin-dao/security_origin_dao_types.h>
#include <dpl/log/log.h>
-namespace SecurityOriginDB {} // namespace SecurityOriginDB
\ No newline at end of file
+namespace SecurityOriginDB {
+const std::map<std::string, Feature> g_W3CPrivilegeTextMap = {
+ {"http://tizen.org/privilege/location", FEATURE_GEOLOCATION},
+ {"http://tizen.org/privilege/notification", FEATURE_WEB_NOTIFICATION},
+ {"http://tizen.org/privilege/unlimitedstorage", FEATURE_WEB_DATABASE},
+ {"http://tizen.org/privilege/filesystem.write", FEATURE_FILE_SYSTEM_ACCESS}
+};
+} // namespace SecurityOriginDB
SQL(BEGIN TRANSACTION;)
CREATE_TABLE(SecurityOriginInfo)
- COLUMN_NOT_NULL(feature, INT, )
- COLUMN_NOT_NULL(scheme, TEXT,DEFAULT '')
- COLUMN_NOT_NULL(host, TEXT,DEFAULT '')
- COLUMN_NOT_NULL(port, INT, DEFAULT 0)
- COLUMN_NOT_NULL(result, INT, DEFAULT 0)
+ COLUMN_NOT_NULL(feature, INT, )
+ COLUMN_NOT_NULL(scheme, TEXT,DEFAULT '')
+ COLUMN_NOT_NULL(host, TEXT,DEFAULT '')
+ COLUMN_NOT_NULL(port, INT, DEFAULT 0)
+ COLUMN_NOT_NULL(result, INT, DEFAULT 0)
+ COLUMN_NOT_NULL(readonly, INT, DEFAULT 0)
TABLE_CONSTRAINTS(PRIMARY KEY(feature,scheme,host,port))
CREATE_TABLE_END()