SET(TARGET_CYNARA "cynara")
SET(TARGET_LIB_CYNARA "cynara-client")
+SET(TARGET_LIB_CYNARA_ASYNC "cynara-client-async")
SET(TARGET_LIB_CYNARA_COMMON "cynara-client-commons")
SET(TARGET_LIB_CYNARA_ADMIN "cynara-admin")
SET(TARGET_CYNARA_COMMON "cynara-commons")
Source0: %{name}-%{version}.tar.gz
Source1001: cynara.manifest
Source1002: libcynara-client.manifest
-Source1003: libcynara-admin.manifest
-Source1004: cynara-tests.manifest
-Source1005: libcynara-client-commons.manifest
-Source1006: libcynara-commons.manifest
-Source1007: libcynara-creds-commons.manifest
-Source1008: libcynara-creds-dbus.manifest
-Source1009: libcynara-creds-socket.manifest
-Source1010: libcynara-session.manifest
-Source1011: libcynara-storage.manifest
+Source1003: libcynara-client-async.manifest
+Source1004: libcynara-admin.manifest
+Source1005: cynara-tests.manifest
+Source1006: libcynara-client-commons.manifest
+Source1007: libcynara-commons.manifest
+Source1008: libcynara-creds-commons.manifest
+Source1009: libcynara-creds-dbus.manifest
+Source1010: libcynara-creds-socket.manifest
+Source1011: libcynara-session.manifest
+Source1012: libcynara-storage.manifest
Requires: default-ac-domains
Requires(pre): pwdutils
Requires(post): smack
%endif
%description
-service, client libraries (libcynara-client, libcynara-admin),
+service, client libraries (libcynara-client, libcynara-client-async, libcynara-admin),
helper libraries (libcynara-session, libcynara-creds-common, libcynara-creds-dbus,
libcynara-creds-socket)
and tests (cynara-tests)
client library (devel) for checking policies
#######################################################
+%package -n libcynara-client-async
+Summary: Cynara - asynchronous client library
+Requires: cynara = %{version}-%{release}
+
+%description -n libcynara-client-async
+asynchronous client library for checking policies
+
+%package -n libcynara-client-async-devel
+Summary: Cynara - asynchronous client library (devel)
+Requires: libcynara-client-async = %{version}-%{release}
+Requires: libcynara-client-commons-devel = %{version}-%{release}
+
+%description -n libcynara-client-async-devel
+asynchronous client library (devel) for checking policies
+
+#######################################################
%package -n libcynara-client-commons
Summary: Cynara - client commons library
Requires: cynara = %{version}-%{release}
cp -a %{SOURCE1009} .
cp -a %{SOURCE1010} .
cp -a %{SOURCE1011} .
+cp -a %{SOURCE1012} .
cp -a test/db/db* .
%build
%postun -n libcynara-client -p /sbin/ldconfig
+%post -n libcynara-client-async -p /sbin/ldconfig
+
+%postun -n libcynara-client-async -p /sbin/ldconfig
+
%post -n libcynara-client-commons -p /sbin/ldconfig
%postun -n libcynara-client-commons -p /sbin/ldconfig
%postun -n libcynara-client-devel -p /sbin/ldconfig
+%post -n libcynara-client-async-devel -p /sbin/ldconfig
+
+%postun -n libcynara-client-async-devel -p /sbin/ldconfig
+
%post -n libcynara-client-commons-devel -p /sbin/ldconfig
%postun -n libcynara-client-commons-devel -p /sbin/ldconfig
%{_libdir}/pkgconfig/cynara-client.pc
%{_libdir}/libcynara-client.so
+%files -n libcynara-client-async
+%manifest libcynara-client-async.manifest
+%license LICENSE
+%{_libdir}/libcynara-client-async.so.*
+
+%files -n libcynara-client-async-devel
+%{_includedir}/cynara/cynara-client-async.h
+%{_libdir}/pkgconfig/cynara-client-async.pc
+%{_libdir}/libcynara-client-async.so
+
%files -n libcynara-client-commons
%manifest libcynara-client-commons.manifest
%license LICENSE
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>
#
ADD_SUBDIRECTORY(cynara-client)
+ADD_SUBDIRECTORY(cynara-client-async)
ADD_SUBDIRECTORY(cynara-admin)
ADD_SUBDIRECTORY(cynara-creds-commons)
ADD_SUBDIRECTORY(cynara-creds-dbus)
--- /dev/null
+# Copyright (c) 2014 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 Marcin Niesluchowski <m.niesluchow@samsung.com>
+#
+
+CONFIGURE_FILE(cynara-client-async.pc.in cynara-client-async.pc @ONLY)
+
+INSTALL(FILES
+ ${CMAKE_BINARY_DIR}/pkgconfig/cynara-client-async/cynara-client-async.pc
+ DESTINATION
+ ${LIB_INSTALL_DIR}/pkgconfig
+ )
--- /dev/null
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=${prefix}
+libdir=@LIB_INSTALL_DIR@
+includedir=${prefix}/include
+
+Name: cynara-client-async
+Description: cynara-client-async package
+Version: @CYNARA_VERSION@
+Requires:
+Libs: -L${libdir} -lcynara-client-async
+Cflags: -I${includedir}/cynara
ADD_SUBDIRECTORY(include)
ADD_SUBDIRECTORY(common)
ADD_SUBDIRECTORY(client)
+ADD_SUBDIRECTORY(client-async)
ADD_SUBDIRECTORY(client-common)
ADD_SUBDIRECTORY(admin)
ADD_SUBDIRECTORY(storage)
--- /dev/null
+# Copyright (c) 2014 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 Marcin Niesluchowski <m.niesluchow@samsung.com>
+#
+
+SET(LIB_CYNARA_ASYNC_VERSION_MAJOR 0)
+SET(LIB_CYNARA_ASYNC_VERSION ${LIB_CYNARA_ASYNC_VERSION_MAJOR}.0.2)
+
+SET(CYNARA_LIB_CYNARA_ASYNC_PATH ${CYNARA_PATH}/client-async)
+
+INCLUDE_DIRECTORIES(
+ ${CYNARA_LIB_CYNARA_ASYNC_PATH}
+ ${CYNARA_PATH}/client-common
+ ${CYNARA_PATH}/common
+ ${CYNARA_PATH}/include
+ )
+
+SET(LIB_CYNARA_ASYNC_SOURCES
+ ${CYNARA_LIB_CYNARA_ASYNC_PATH}/api/client-async-api.cpp
+ ${CYNARA_LIB_CYNARA_ASYNC_PATH}/logic/Logic.cpp
+ )
+
+ADD_LIBRARY(${TARGET_LIB_CYNARA_ASYNC} SHARED ${LIB_CYNARA_ASYNC_SOURCES})
+
+SET_TARGET_PROPERTIES(
+ ${TARGET_LIB_CYNARA_ASYNC}
+ PROPERTIES
+ SOVERSION ${LIB_CYNARA_ASYNC_VERSION_MAJOR}
+ VERSION ${LIB_CYNARA_ASYNC_VERSION}
+ )
+
+TARGET_LINK_LIBRARIES(${TARGET_LIB_CYNARA_ASYNC}
+ ${TARGET_CYNARA_COMMON}
+ )
+
+INSTALL(TARGETS ${TARGET_LIB_CYNARA_ASYNC} DESTINATION ${LIB_INSTALL_DIR})
--- /dev/null
+/*
+ * Copyright (c) 2014 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 src/client-async/api/ApiInterface.h
+ * @author Marcin Niesluchowski <m.niesluchow@samsung.com>
+ * @version 1.0
+ * @brief This file contains libcynara-client-async API interface definition.
+ */
+
+#ifndef SRC_CLIENT_ASYNC_API_APIINTERFACE_H_
+#define SRC_CLIENT_ASYNC_API_APIINTERFACE_H_
+
+#include <string>
+
+#include <cynara-client-async.h>
+
+namespace Cynara {
+
+class ApiInterface {
+public:
+ ApiInterface() = default;
+ virtual ~ApiInterface() {};
+
+ virtual int checkCache(const std::string &client, const std::string &session,
+ const std::string &user, const std::string &privilege) = 0;
+ virtual int createRequest(const std::string &client, const std::string &session,
+ const std::string &user, const std::string &privilege,
+ cynara_check_id &checkId, cynara_response_callback callback,
+ void *userResponseData) = 0;
+ virtual int process(void) = 0;
+ virtual int cancelRequest(cynara_check_id checkId) = 0;
+};
+
+} // namespace Cynara
+
+#endif /* SRC_CLIENT_ASYNC_API_APIINTERFACE_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2014 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 src/client-async/api/client-async-api.cpp
+ * @author Marcin Niesluchowski <m.niesluchow@samsung.com>
+ * @version 1.0
+ * @brief Implementation of external libcynara-client-async API
+ */
+
+#include <new>
+
+#include <common.h>
+#include <exceptions/TryCatch.h>
+#include <log/log.h>
+
+#include <api/ApiInterface.h>
+#include <cynara-client-async.h>
+#include <logic/Logic.h>
+
+struct cynara_async {
+ Cynara::ApiInterface *impl;
+
+ cynara_async(Cynara::ApiInterface *_impl) : impl(_impl) {
+ }
+
+ ~cynara_async() {
+ delete impl;
+ }
+};
+
+CYNARA_API
+int cynara_async_initialize(cynara_async **pp_cynara,
+ const cynara_async_configuration *p_conf UNUSED,
+ cynara_status_callback callback, void *user_status_data) {
+ if (!pp_cynara)
+ return CYNARA_API_INVALID_PARAM;
+
+ return Cynara::tryCatch([&]() {
+ *pp_cynara = new cynara_async(new Cynara::Logic(callback, user_status_data));
+
+ init_log();
+
+ LOGD("Cynara client async initialized");
+
+ return CYNARA_API_SUCCESS;
+ });
+}
+
+CYNARA_API
+void cynara_async_finish(cynara_async *p_cynara) {
+ delete p_cynara;
+}
+
+CYNARA_API
+int cynara_async_check_cache(cynara_async *p_cynara, const char *client, const char *client_session,
+ const char *user, const char *privilege) {
+ if (!p_cynara || !p_cynara->impl)
+ return CYNARA_API_INVALID_PARAM;
+ if (!client || !client_session || !user || !privilege)
+ return CYNARA_API_INVALID_PARAM;
+
+ return Cynara::tryCatch([&]() {
+ std::string clientStr;
+ std::string clientSessionStr;
+ std::string userStr;
+ std::string privilegeStr;
+
+ try {
+ clientStr = client;
+ clientSessionStr = client_session;
+ userStr = user;
+ privilegeStr = privilege;
+ } catch (const std::length_error &e) {
+ LOGE(e.what());
+ return CYNARA_API_INVALID_PARAM;
+ }
+ return p_cynara->impl->checkCache(clientStr, clientSessionStr, userStr, privilegeStr);
+ });
+}
+
+CYNARA_API
+int cynara_async_create_request(cynara_async *p_cynara, const char *client,
+ const char *client_session, const char *user, const char *privilege,
+ cynara_check_id *p_check_id, cynara_response_callback callback,
+ void *user_response_data) {
+ if (!p_cynara || !p_cynara->impl)
+ return CYNARA_API_INVALID_PARAM;
+ if (!client || !client_session || !user || !privilege)
+ return CYNARA_API_INVALID_PARAM;
+
+ return Cynara::tryCatch([&]() {
+ std::string clientStr;
+ std::string clientSessionStr;
+ std::string userStr;
+ std::string privilegeStr;
+
+ try {
+ clientStr = client;
+ clientSessionStr = client_session;
+ userStr = user;
+ privilegeStr = privilege;
+ } catch (const std::length_error &e) {
+ LOGE(e.what());
+ return CYNARA_API_INVALID_PARAM;
+ }
+ cynara_check_id checkId;
+ int ret = p_cynara->impl->createRequest(clientStr, clientSessionStr, userStr, privilegeStr,
+ checkId, callback, user_response_data);
+ if (p_check_id && ret == CYNARA_API_SUCCESS)
+ *p_check_id = checkId;
+ return ret;
+ });
+}
+
+CYNARA_API
+int cynara_async_process(cynara_async *p_cynara) {
+ if (!p_cynara || !p_cynara->impl)
+ return CYNARA_API_INVALID_PARAM;
+
+ return Cynara::tryCatch([&]() {
+ return p_cynara->impl->process();
+ });
+}
+
+CYNARA_API
+int cynara_async_cancel_request(cynara_async *p_cynara, cynara_check_id check_id) {
+ if (!p_cynara || !p_cynara->impl)
+ return CYNARA_API_INVALID_PARAM;
+
+ return Cynara::tryCatch([&]() {
+ return p_cynara->impl->cancelRequest(check_id);
+ });
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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 src/client-async/logic/Logic.cpp
+ * @author Marcin Niesluchowski <m.niesluchow@samsung.com>
+ * @version 1.0
+ * @brief This file contains implementation of Logic class - main
+ * libcynara-client-async class
+ */
+
+#include <common.h>
+
+#include "Logic.h"
+
+namespace Cynara {
+
+Logic::Logic(cynara_status_callback callback UNUSED, void *userStatusData UNUSED) {
+ // MOCKUP
+}
+
+int Logic::checkCache(const std::string &client UNUSED, const std::string &session UNUSED,
+ const std::string &user UNUSED, const std::string &privilege UNUSED) {
+ // MOCKUP
+ return CYNARA_API_CACHE_MISS;
+}
+
+int Logic::createRequest(const std::string &client UNUSED, const std::string &session UNUSED,
+ const std::string &user UNUSED, const std::string &privilege UNUSED,
+ cynara_check_id &checkId UNUSED, cynara_response_callback callback UNUSED,
+ void *userResponseData UNUSED) {
+ // MOCKUP
+ return CYNARA_API_MAX_PENDING_REQUESTS;
+}
+
+
+int Logic::process(void) {
+ // MOCKUP
+ return CYNARA_API_SUCCESS;
+}
+
+int Logic::cancelRequest(cynara_check_id checkId UNUSED) {
+ // MOCKUP
+ return CYNARA_API_SUCCESS;
+}
+
+} // namespace Cynara
--- /dev/null
+/*
+ * Copyright (c) 2014 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 src/client-async/logic/Logic.h
+ * @author Marcin Niesluchowski <m.niesluchow@samsung.com>
+ * @version 1.0
+ * @brief This file contains declaration of Logic class - main
+ * libcynara-client-async class
+ */
+
+#ifndef SRC_CLIENT_ASYNC_LOGIC_LOGIC_H_
+#define SRC_CLIENT_ASYNC_LOGIC_LOGIC_H_
+
+#include <api/ApiInterface.h>
+#include <cynara-client-async.h>
+
+namespace Cynara {
+
+class Logic : public ApiInterface {
+public:
+ Logic(cynara_status_callback callback, void *userStatusData);
+ virtual ~Logic() {};
+
+ virtual int checkCache(const std::string &client, const std::string &session,
+ const std::string &user, const std::string &privilege);
+ virtual int createRequest(const std::string &client, const std::string &session,
+ const std::string &user, const std::string &privilege,
+ cynara_check_id &checkId, cynara_response_callback callback,
+ void *userResponseData);
+ virtual int process(void);
+ virtual int cancelRequest(cynara_check_id checkId);
+};
+
+} // namespace Cynara
+
+#endif /* SRC_CLIENT_ASYNC_LOGIC_LOGIC_H_ */
${CYNARA_PATH}/include/cynara-admin-error.h
${CYNARA_PATH}/include/cynara-admin-types.h
${CYNARA_PATH}/include/cynara-client.h
+ ${CYNARA_PATH}/include/cynara-client-async.h
${CYNARA_PATH}/include/cynara-client-error.h
${CYNARA_PATH}/include/cynara-creds-commons.h
${CYNARA_PATH}/include/cynara-creds-dbus.h
#include <stdint.h>
+#include <cynara-client-error.h>
+
#ifdef __cplusplus
extern "C" {
#endif