Add sample plugin of validator in test package 54/51354/2
authorKyungwook Tak <k.tak@samsung.com>
Mon, 9 Nov 2015 05:44:36 +0000 (14:44 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Mon, 9 Nov 2015 07:54:11 +0000 (16:54 +0900)
Change-Id: Ib5a471e9b3672c5b6873b2e6aa4adeb71c500d69
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
packaging/cert-svc.spec
tests/CMakeLists.txt
tests/plugin/CMakeLists.txt [new file with mode: 0644]
tests/plugin/plugin-sample.cpp [new file with mode: 0644]

index 6d9321c..77f1afd 100644 (file)
@@ -180,4 +180,5 @@ rm %{TZ_SYS_ETC}/ssl/certs/ba70bb69.0
 %{TZ_SYS_SHARE}/ca-certificates/tizen/*
 %{TZ_SYS_SHARE}/cert-svc/cert-type/*
 %{TZ_SYS_SHARE}/cert-svc/tests/*
+%{_libdir}/libcert-svc-validator-plugin.so
 %endif
index 97be24d..3ab883e 100644 (file)
@@ -16,6 +16,7 @@
 SET(TARGET_CAPI_TEST "cert-svc-tests-capi")
 SET(TARGET_PKCS12_TEST "cert-svc-tests-pkcs12")
 SET(TARGET_VCORE_TEST "cert-svc-tests-vcore")
+SET(TARGET_PLUGIN_SAMPLE "cert-svc-validator-plugin")
 
 PKG_CHECK_MODULES(TEST_DEP
     REQUIRED
@@ -52,3 +53,4 @@ INCLUDE_DIRECTORIES(
 ADD_SUBDIRECTORY(capi)
 ADD_SUBDIRECTORY(pkcs12)
 ADD_SUBDIRECTORY(vcore)
+ADD_SUBDIRECTORY(plugin)
diff --git a/tests/plugin/CMakeLists.txt b/tests/plugin/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4c0bf1b
--- /dev/null
@@ -0,0 +1,38 @@
+# 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        CMakeLists.txt
+# @author      Kyungwook Tak (k.tak@samsung.com)
+# @brief
+#
+
+PKG_CHECK_MODULES(PLUGIN_SAMPLE_DEP REQUIRED dlog)
+
+SET(PLUGIN_SAMPLE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/plugin-sample.cpp)
+
+INCLUDE_DIRECTORIES(
+    SYSTEM
+    ${PLUGIN_SAMPLE_DEP_INCLUDE_DIRS}
+    ${CMAKE_CURRENT_SOURCE_DIR}
+    ${PROJECT_SOURCE_DIR}/vcore
+    )
+
+ADD_LIBRARY(${TARGET_PLUGIN_SAMPLE} SHARED ${PLUGIN_SAMPLE_SOURCES})
+
+TARGET_LINK_LIBRARIES(${TARGET_PLUGIN_SAMPLE}
+    ${PLUGIN_SAMPLE_DEP_LIBRARIES}
+    ${TARGET_VCORE_LIB}
+    )
+
+INSTALL(TARGETS ${TARGET_PLUGIN_SAMPLE} DESTINATION ${LIBDIR})
diff --git a/tests/plugin/plugin-sample.cpp b/tests/plugin/plugin-sample.cpp
new file mode 100644 (file)
index 0000000..edf4b65
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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        plugin-sample.cpp
+ * @author      Kyungwook Tak (k.tak@samsung.com)
+ * @version     1.0
+ * @brief       signature validator plugin sample.
+ */
+
+#include <dlog.h>
+
+#include <vcore/ValidatorPluginApi.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "CERT_SVC_PLUGIN"
+
+#define PLUGIN_API __attribute__((visibility("default")))
+
+extern "C" {
+ValidationCore::ValidatorPlugin *create(void);
+void destroy(ValidationCore::ValidatorPlugin *obj);
+}
+
+namespace ValidationCore {
+
+class PLUGIN_API Plugin : public ValidatorPlugin {
+public:
+       Plugin() {}
+       virtual ~Plugin() {}
+
+       virtual SignatureValidator::Result step(SignatureValidator::Result result, SignatureData &data);
+};
+
+SignatureValidator::Result Plugin::step(SignatureValidator::Result result, SignatureData &data)
+{
+       (void)data;
+       SLOGI("Plugin::Step called!");
+       return result;
+}
+
+} // namespace ValidationCore
+
+PLUGIN_API
+ValidationCore::ValidatorPlugin *create(void)
+{
+       ValidationCore::Plugin *plugin = new ValidationCore::Plugin;
+
+       SLOGI("Plugin create!");
+
+       return plugin;
+}
+
+PLUGIN_API
+void destroy(ValidationCore::ValidatorPlugin *obj)
+{
+       delete obj;
+
+       SLOGI("Plugin destroy!");
+}