From 17d25bd2efd03b425d773dddd24a6db24fbe1840 Mon Sep 17 00:00:00 2001 From: Kyungwook Tak Date: Mon, 9 Nov 2015 14:44:36 +0900 Subject: [PATCH] Add sample plugin of validator in test package Change-Id: Ib5a471e9b3672c5b6873b2e6aa4adeb71c500d69 Signed-off-by: Kyungwook Tak --- packaging/cert-svc.spec | 1 + tests/CMakeLists.txt | 2 ++ tests/plugin/CMakeLists.txt | 38 ++++++++++++++++++++++ tests/plugin/plugin-sample.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 tests/plugin/CMakeLists.txt create mode 100644 tests/plugin/plugin-sample.cpp diff --git a/packaging/cert-svc.spec b/packaging/cert-svc.spec index 6d9321c..77f1afd 100644 --- a/packaging/cert-svc.spec +++ b/packaging/cert-svc.spec @@ -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 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 97be24d..3ab883e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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 index 0000000..4c0bf1b --- /dev/null +++ b/tests/plugin/CMakeLists.txt @@ -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 index 0000000..edf4b65 --- /dev/null +++ b/tests/plugin/plugin-sample.cpp @@ -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 + +#include + +#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!"); +} -- 2.7.4