Add TZ Backend skeleton code 73/173373/2
authorsangwan.kwon <sangwan.kwon@samsung.com>
Wed, 21 Mar 2018 05:23:56 +0000 (14:23 +0900)
committersangwan kwon <sangwan.kwon@samsung.com>
Wed, 4 Apr 2018 02:08:33 +0000 (02:08 +0000)
Change-Id: I35a69caea54d1e4cfbe7df31fa89a9a568fe3932
Signed-off-by: sangwan.kwon <sangwan.kwon@samsung.com>
CMakeLists.txt
src/server/plugin/CMakeLists.txt
src/server/plugin/tz-backend/password-file.cpp [new file with mode: 0644]
src/server/plugin/tz-backend/password-file.h [new file with mode: 0644]

index 3ac53dd9a7e3124f7bf6b494221b8f65fdb12be1..1547eace949cb6ede7cbca8aac00e7500b17b122 100644 (file)
@@ -79,6 +79,7 @@ SET(TARGET_CLIENT ${SERVICE_NAME}-client)
 SET(TARGET_CLIENT_ADMIN ${SERVICE_NAME}-client-admin)
 SET(TARGET_COMMON ${SERVICE_NAME}-commons)
 SET(TARGET_SW_BACKEND ${SERVICE_NAME}-sw-backend)
+SET(TARGET_TZ_BACKEND ${SERVICE_NAME}-tz-backend)
 SET(TARGET_TEST ${SERVICE_NAME}-test)
 
 ADD_SUBDIRECTORY(src)
index 9047e90055171654cbdda7b0c1cbad4eea772565..19791a29434280c4b8fb567a4dde7fb7f21134d0 100644 (file)
@@ -1,3 +1,4 @@
+### SW-BACKEND ############################################################################
 PKG_CHECK_MODULES(SW_BACKEND_DEP
     REQUIRED
     openssl
@@ -31,3 +32,36 @@ SET_TARGET_PROPERTIES(
 TARGET_LINK_LIBRARIES(${TARGET_SW_BACKEND} ${SW_BACKEND_DEP_LIBRARIES} ${TARGET_COMMON})
 
 INSTALL(TARGETS ${TARGET_SW_BACKEND} DESTINATION ${PLUGIN_DIR})
+
+### TZ-BACKEND ############################################################################
+PKG_CHECK_MODULES(TZ_BACKEND_DEP
+    REQUIRED
+    )
+
+INCLUDE_DIRECTORIES(
+    SYSTEM
+    ${TZ_BACKEND_DEP_INCLUDE_DIRS}
+    ${COMMON_PATH}/include
+    ${SERVER_PATH}/service/include
+    ${DPL_PATH}/core/include
+    ${DPL_PATH}/log/include
+    ${PLUGIN_PATH}
+    )
+
+SET(TZ_BACKEND_SOURCES
+    tz-backend/password-file.cpp
+    )
+
+ADD_LIBRARY(${TARGET_TZ_BACKEND} SHARED ${TZ_BACKEND_SOURCES})
+
+SET_TARGET_PROPERTIES(
+    ${TARGET_TZ_BACKEND}
+    PROPERTIES
+        COMPILE_FLAGS "-D_GNU_SOURCE -fPIC -fvisibility=default"
+        SOVERSION ${API_VERSION}
+        VERSION ${VERSION}
+    )
+
+TARGET_LINK_LIBRARIES(${TARGET_TZ_BACKEND} ${TZ_BACKEND_DEP_LIBRARIES} ${TARGET_COMMON})
+
+#INSTALL(TARGETS ${TARGET_TZ_BACKEND} DESTINATION ${PLUGIN_DIR})
diff --git a/src/server/plugin/tz-backend/password-file.cpp b/src/server/plugin/tz-backend/password-file.cpp
new file mode 100644 (file)
index 0000000..9289b66
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+ *  Copyright (c) 2018 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
+ */
+#include <tz-backend/password-file.h>
+
+#include <stdexcept>
+
+#include <generic-backend/password-file-buffer.h>
+
+extern "C" {
+
+AuthPasswd::IPasswordFile* PasswordFileFactory(unsigned int user)
+{
+       return new AuthPasswd::TZBackend::PasswordFile(user);
+}
+
+} // extern "C"
+
+namespace AuthPasswd {
+namespace TZBackend {
+
+PasswordFile::PasswordFile(unsigned int)
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+}
+
+void PasswordFile::writeMemoryToFile() const
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+}
+
+void PasswordFile::writeAttemptToFile() const
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+}
+
+void PasswordFile::setPassword(unsigned int, const std::string &)
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+}
+
+bool PasswordFile::checkPassword(unsigned int,
+                                                                const std::string &) const
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+       return false;
+}
+
+void PasswordFile::setMaxHistorySize(unsigned int)
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+}
+
+unsigned int PasswordFile::getMaxHistorySize() const
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+       return -1;
+}
+
+unsigned int PasswordFile::getExpireTime() const
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+       return -1;
+}
+
+void PasswordFile::setExpireTime(unsigned int)
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+}
+
+void PasswordFile::setExpireTimeLeft(time_t)
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+}
+
+unsigned int PasswordFile::getExpireTimeLeft() const
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+       return -1;
+}
+
+unsigned int PasswordFile::getAttempt() const
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+       return -1;
+}
+
+void PasswordFile::resetAttempt()
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+}
+
+void PasswordFile::incrementAttempt()
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+}
+
+int PasswordFile::getMaxAttempt() const
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+       return -1;
+}
+
+void PasswordFile::setMaxAttempt(unsigned int)
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+}
+
+bool PasswordFile::isPasswordActive(unsigned int) const
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+       return false;
+}
+
+bool PasswordFile::isPasswordReused(const std::string &) const
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+       return false;
+}
+
+bool PasswordFile::checkExpiration() const
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+       return false;
+}
+
+bool PasswordFile::checkIfAttemptsExceeded() const
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+       return false;
+}
+
+bool PasswordFile::isIgnorePeriod() const
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+       return false;
+}
+
+bool PasswordFile::isHistoryActive() const
+{
+       std::runtime_error("TZ-Backend is not implemented.");
+       return false;
+}
+
+} //namespace TZBackend
+} //namespace AuthPasswd
diff --git a/src/server/plugin/tz-backend/password-file.h b/src/server/plugin/tz-backend/password-file.h
new file mode 100644 (file)
index 0000000..7749c91
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ *  Copyright (c) 2018 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
+ */
+#ifndef _TZ_BACKEND_PASSWORD_FILE_H_
+#define _TZ_BACKEND_PASSWORD_FILE_H_
+
+#include <string>
+#include <generic-backend/ipassword-file.h>
+
+namespace AuthPasswd {
+namespace TZBackend {
+
+class PasswordFile : public IPasswordFile {
+public:
+       PasswordFile(unsigned int user);
+
+       void writeMemoryToFile() const override;
+       void writeAttemptToFile() const override;
+
+       void setPassword(unsigned int passwdType, const std::string &password) override;
+       bool checkPassword(unsigned int passwdType,
+                                          const std::string &password) const override;
+
+       void setMaxHistorySize(unsigned int history) override;
+       unsigned int getMaxHistorySize() const override;
+
+       unsigned int getExpireTime() const override;
+       void setExpireTime(unsigned int expireTime) override;
+
+       unsigned int getExpireTimeLeft() const override;
+       void setExpireTimeLeft(time_t expireTimeLeft) override;
+
+       unsigned int getAttempt() const override;
+       void resetAttempt() override;
+       void incrementAttempt() override;
+       int getMaxAttempt() const override;
+       void setMaxAttempt(unsigned int maxAttempt) override;
+
+       bool isPasswordActive(unsigned int passwdType) const override;
+       bool isPasswordReused(const std::string &password) const override;
+
+       bool checkExpiration() const override;
+       bool checkIfAttemptsExceeded() const override;
+       bool isIgnorePeriod() const override;
+
+       bool isHistoryActive() const override;
+};
+
+} // namespace TZBackend
+} // namespace AuthPasswd
+
+#endif