${KEY_MANAGER_PATH}/initial-values/InitialValuesFile.cpp
${KEY_MANAGER_PATH}/initial-values/NoCharactersHandler.cpp
${KEY_MANAGER_PATH}/initial-values/xml-utils.cpp
+ ${KEY_MANAGER_PATH}/initial-values/initial-value-loader.cpp
${KEY_MANAGER_PATH}/dpl/core/src/assert.cpp
${KEY_MANAGER_PATH}/dpl/db/src/sql_connection.cpp
${KEY_MANAGER_PATH}/dpl/db/src/naive_synchronization_object.cpp
--- /dev/null
+/*
+ * Copyright (c) 2015 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 initial-value-loader.cpp
+ * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+#include <dirent.h>
+
+#include <initial-value-loader.h>
+
+#include <ckm-logic.h>
+#include <InitialValuesFile.h>
+
+namespace {
+const char * const INIT_VALUES_DIR = "/opt/data/ckm/initial_values/";
+const char * const INIT_VALUES_XSD = "/usr/share/ckm/initial_values.xsd";
+const char * const INIT_VALUES_FILE_SUFFIX = ".xml";
+} // namespace anonymous
+
+namespace CKM {
+namespace InitialValues {
+
+void LoadFiles(CKMLogic &logic) {
+ try {
+ std::vector<std::string> filesToParse;
+ DIR *dp = opendir(INIT_VALUES_DIR);
+ if(dp)
+ {
+ struct dirent *entry;
+ while ((entry = readdir(dp)))
+ {
+ std::string filename = std::string(entry->d_name);
+
+ // check if XML file
+ std::string lowercaseFilename = filename;
+ std::transform(lowercaseFilename.begin(), lowercaseFilename.end(), lowercaseFilename.begin(), ::tolower);
+ if(lowercaseFilename.find(INIT_VALUES_FILE_SUFFIX) == std::string::npos)
+ continue;
+
+ filesToParse.push_back(std::string(INIT_VALUES_DIR) + filename);
+ }
+ closedir(dp);
+ }
+
+ // parse
+ for(const auto & file : filesToParse)
+ {
+ InitialValues::InitialValuesFile xmlFile(file.c_str(), logic);
+ int rc = xmlFile.Validate(INIT_VALUES_XSD);
+ if(rc == XML::Parser::PARSE_SUCCESS)
+ {
+ rc = xmlFile.Parse();
+ if(rc != XML::Parser::PARSE_SUCCESS)
+ LogError("invalid initial values file: " << file << ", parsing code: " << rc);
+ }
+ else
+ LogError("invalid initial values file: " << file << ", validation code: " << rc);
+ unlink(file.c_str());
+ }
+ } catch (...) {
+ LogError("The implementation of exception handling in xml parser is broken!");
+ }
+}
+
+} // namespace InitialValues
+} // namespace CKM
+
--- /dev/null
+/*
+ * Copyright (c) 2015 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 ckm-logic.cpp
+ * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+#pragma once
+
+namespace CKM {
+
+// forward declaration
+class CKMLogic;
+
+namespace InitialValues {
+
+void LoadFiles(CKMLogic &);
+
+} // namespace InitialValues
+} // namespace CKM
+
#include <key-aes-impl.h>
#include <certificate-config.h>
#include <certificate-store.h>
-#include <dirent.h>
#include <algorithm>
-#include <InitialValuesFile.h>
#include <sw-backend/store.h>
#include <generic-backend/exception.h>
namespace {
const char * const CERT_SYSTEM_DIR = "/etc/ssl/certs";
-const char * const INIT_VALUES_DIR = "/opt/data/ckm/initial_values/";
-const char * const INIT_VALUES_XSD = "/usr/share/ckm/initial_values.xsd";
-const char * const INIT_VALUES_FILE_SUFFIX = ".xml";
const char * const SYSTEM_DB_PASSWD = "cAtRugU7";
bool isLabelValid(const CKM::Label &label) {
CertificateConfig::addSystemCertificateDir(CERT_SYSTEM_DIR);
m_accessControl.updateCCMode();
-
- // make initial file list
- std::vector<std::string> filesToParse;
- DIR *dp = opendir(INIT_VALUES_DIR);
- if(dp)
- {
- struct dirent *entry;
- while ((entry = readdir(dp)))
- {
- std::string filename = std::string(entry->d_name);
-
- // check if XML file
- std::string lowercaseFilename = filename;
- std::transform(lowercaseFilename.begin(), lowercaseFilename.end(), lowercaseFilename.begin(), ::tolower);
- if(lowercaseFilename.find(INIT_VALUES_FILE_SUFFIX) == std::string::npos)
- continue;
-
- filesToParse.push_back(std::string(INIT_VALUES_DIR) + filename);
- }
- closedir(dp);
- }
-
- // parse
- for(const auto & file : filesToParse)
- {
- InitialValues::InitialValuesFile xmlFile(file.c_str(), *this);
- int rc = xmlFile.Validate(INIT_VALUES_XSD);
- if(rc == XML::Parser::PARSE_SUCCESS)
- {
- rc = xmlFile.Parse();
- if(rc != XML::Parser::PARSE_SUCCESS)
- LogError("invalid initial values file: " << file << ", parsing code: " << rc);
- }
- else
- LogError("invalid initial values file: " << file << ", validation code: " << rc);
- unlink(file.c_str());
- }
}
CKMLogic::~CKMLogic(){}
#include <ckm-service.h>
#include <ckm-logic.h>
+#include <initial-value-loader.h>
namespace {
const CKM::InterfaceID SOCKET_ID_CONTROL = 0;
CKMService::CKMService()
: m_logic(new CKMLogic)
-{}
+{
+ InitialValues::LoadFiles(*m_logic);
+}
CKMService::~CKMService() {
delete m_logic;