summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsangwan.kwon <sangwan.kwon@samsung.com>2016-05-24 16:51:36 +0900
committersangwan.kwon <sangwan.kwon@samsung.com>2016-05-24 17:30:59 +0900
commitc7396c8c09b35dc45f0734f3aab12e40c379d517 (patch)
tree128e80bd918481506089a4adf1a1e5c7eaea7b81
parent2f1c4055b248447276cba35e1d4672f0e3d9e80a (diff)
downloadcert-checker-c7396c8c09b35dc45f0734f3aab12e40c379d517.tar.gz
cert-checker-c7396c8c09b35dc45f0734f3aab12e40c379d517.tar.bz2
cert-checker-c7396c8c09b35dc45f0734f3aab12e40c379d517.zip
Add CAPI for client
Change-Id: Ie618a4248445c1b4bebf3bb47b13486463a4b67f
-rw-r--r--packaging/cert-checker.spec3
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/client/CMakeLists.txt8
-rw-r--r--src/client/ocsp.cpp32
-rw-r--r--src/include/CMakeLists.txt19
-rw-r--r--src/include/cchecker/ocsp.h37
-rw-r--r--tests/test_client.cpp7
7 files changed, 94 insertions, 13 deletions
diff --git a/packaging/cert-checker.spec b/packaging/cert-checker.spec
index 1be983f..271cec8 100644
--- a/packaging/cert-checker.spec
+++ b/packaging/cert-checker.spec
@@ -177,8 +177,7 @@ fi
%{_libdir}/pkgconfig/%{name}.pc
%{_libdir}/lib%{name}-common.so
%{_libdir}/lib%{name}-client.so
-%{_includedir}/cchecker/ocsp-client.h
-%{_includedir}/cchecker/error.h
+%{_includedir}/cchecker/ocsp.h
%files -n %{name}-tests
%defattr(-,%{service_user},%{service_group},-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7e6ee57..eb61641 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -82,6 +82,7 @@ TARGET_LINK_LIBRARIES(${TARGET_CERT_CHECKER}
INSTALL(TARGETS ${TARGET_CERT_CHECKER} DESTINATION ${BIN_DIR})
+ADD_SUBDIRECTORY(include)
ADD_SUBDIRECTORY(main)
ADD_SUBDIRECTORY(service)
ADD_SUBDIRECTORY(common)
diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt
index cd3d78d..fb94c8a 100644
--- a/src/client/CMakeLists.txt
+++ b/src/client/CMakeLists.txt
@@ -23,6 +23,7 @@ PKG_CHECK_MODULES(${TARGET_CERT_CHECKER_CLIENT}_DEP
SET(${TARGET_CERT_CHECKER_CLIENT}_SRCS
${CERT_CHECKER_SRC_PATH}/client/ocsp-client.cpp
+ ${CERT_CHECKER_SRC_PATH}/client/ocsp.cpp
)
INCLUDE_DIRECTORIES(SYSTEM
@@ -51,10 +52,3 @@ TARGET_LINK_LIBRARIES(${TARGET_CERT_CHECKER_CLIENT}
)
INSTALL(TARGETS ${TARGET_CERT_CHECKER_CLIENT} DESTINATION ${LIB_INSTALL_DIR})
-INSTALL(
- FILES
- ocsp-client.h
- error.h
- DESTINATION
- ${INCLUDE_INSTALL_DIR}/cchecker
-)
diff --git a/src/client/ocsp.cpp b/src/client/ocsp.cpp
new file mode 100644
index 0000000..0302687
--- /dev/null
+++ b/src/client/ocsp.cpp
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2016 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 ocsp.cpp
+ * @author Sangwan Kwon (sagnwan.kwon@samsung.com)
+ * @version 1.0
+ * @brief Implementation of CAPI
+ */
+
+#include "cchecker/ocsp.h"
+
+#include "client/ocsp-client.h"
+#include "client/error.h"
+
+__attribute__((visibility("default")))
+int cchecker_ocsp_request() {
+ CCHECKER::OcspClient oc;
+ return oc.request() == CCHECKER::E_CC_NONE ? 0 : -1;
+};
diff --git a/src/include/CMakeLists.txt b/src/include/CMakeLists.txt
new file mode 100644
index 0000000..345973b
--- /dev/null
+++ b/src/include/CMakeLists.txt
@@ -0,0 +1,19 @@
+# Copyright (c) 2016 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 Sangwan Kwon (sangwan.kwon@samsung.com)
+# @brief Install headers for API
+#
+INSTALL(FILES cchecker/ocsp.h DESTINATION ${INCLUDE_INSTALL_DIR}/cchecker)
diff --git a/src/include/cchecker/ocsp.h b/src/include/cchecker/ocsp.h
new file mode 100644
index 0000000..779fb0b
--- /dev/null
+++ b/src/include/cchecker/ocsp.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016 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 ocsp.h
+ * @author Sangwan Kwon (sagnwan.kwon@samsung.com)
+ * @version 1.0
+ * @brief CAPI header for client
+ */
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Launch ocsp-service for client request.
+ * @return zero on success, otherwise a negative value.
+ */
+int cchecker_ocsp_request();
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/tests/test_client.cpp b/tests/test_client.cpp
index ad549cf..a0fc0c2 100644
--- a/tests/test_client.cpp
+++ b/tests/test_client.cpp
@@ -23,15 +23,14 @@
#define BOOST_TEST_MODULE CERT_CHECKER_TESTS
#include <boost/test/unit_test.hpp>
-#include "client/ocsp-client.h"
-#include "common/log.h"
+#include <cchecker/ocsp.h>
BOOST_AUTO_TEST_SUITE(CLIENT_TEST)
BOOST_AUTO_TEST_CASE(client_api) {
- CCHECKER::OcspClient oc;
- BOOST_REQUIRE(oc.request() == CCHECKER::E_CC_NONE);
+ auto ret = cchecker_ocsp_request();
+ BOOST_REQUIRE(ret == 0);
}