Name: cynara-client
Description: cynara-client package
Version: 0.0.1
-Requires:
+Requires: security-server
Libs: -L${libdir} -lcynara-client
Cflags: -I${includedir}/cynara
Requires: cynara = %{version}-%{release}
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
+BuildRequires: pkgconfig(security-server)
%description -n libcynara-client
client library for checking policies
SET(LIB_CYNARA_SOURCES
${CYNARA_LIB_CYNARA_PATH}/client-api.cpp
+ ${CYNARA_LIB_CYNARA_PATH}/bootstrap/cynara-client-bootstrap.cpp
+ )
+
+PKG_CHECK_MODULES(CYNARA_CLIENT_DEP
+ REQUIRED
+ security-server
+ )
+
+INCLUDE_DIRECTORIES(
+ ${CYNARA_LIB_CYNARA_PATH}
+ ${CYNARA_CLIENT_DEP_INCLUDE_DIRS}
)
ADD_LIBRARY(${TARGET_LIB_CYNARA} SHARED ${LIB_CYNARA_SOURCES})
TARGET_LINK_LIBRARIES(${TARGET_LIB_CYNARA}
${CYNARA_DEP_LIBRARIES}
+ ${CYNARA_CLIENT_DEP_LIBRARIES}
${TARGET_CYNARA_COMMON}
)
--- /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 cynara-client-bootstrap.cpp
+ * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version 1.0
+ * @brief This file contains bootstrap version of libcynara-client API implementation.
+ */
+
+#include <security-server.h>
+#include "cynara-client-bootstrap.h"
+
+CynaraClientBootstrap :: CynaraClientBootstrap() {
+}
+
+CynaraClientBootstrap :: ~CynaraClientBootstrap() {
+}
+
+cynara_api_result CynaraClientBootstrap :: check(const std::string& client,
+ const std::string& session UNUSED, const std::string& user UNUSED, const std::string& privilege)
+{
+ int is_enabled = 0;
+
+ int ret = security_server_app_has_privilege(client.c_str(), APP_TYPE_WGT, privilege.c_str(),
+ &is_enabled);
+
+ if(ret == PC_OPERATION_SUCCESS && is_enabled)
+ return cynara_api_result::CYNARA_API_SUCCESS;
+ return cynara_api_result::CYNARA_API_ACCESS_DENIED;
+}
--- /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 cynara-client-bootstrap.h
+ * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version 1.0
+ * @brief This file contains bootstrap version of libcynara-client API implementation.
+ */
+
+#ifndef CYNARA_CLIENT_BOOTSTRAP_H
+#define CYNARA_CLIENT_BOOTSTRAP_H
+
+#include <string>
+#include <common.h>
+#include <cynara-client.h>
+#include <cynara-client-interface.h>
+
+class CynaraClientBootstrap : public CynaraClientInterface {
+public:
+ CynaraClientBootstrap();
+ virtual ~CynaraClientBootstrap();
+ virtual cynara_api_result check(const std::string& client, const std::string& session,
+ const std::string& user, const std::string& privilege);
+};
+
+#endif /* CYNARA_CLIENT_BOOTSTRAP_H */
* @brief Implementation of external libcynara-client API
*/
-//empty init commit
+#include <new>
+#include <common.h>
+#include <cynara-client.h>
+#include <cynara-client-interface.h>
+#include <bootstrap/cynara-client-bootstrap.h>
+struct cynara {
+ CynaraClientInterface* impl;
+
+ cynara(CynaraClientInterface *_impl) : impl(_impl) {
+ }
+ ~cynara() {
+ delete impl;
+ }
+};
+
+CYNARA_API
+int cynara_initialize(cynara **pp_cynara, const cynara_configuration *p_conf UNUSED)
+{
+ if (!pp_cynara)
+ return cynara_api_result::CYNARA_API_INVALID_PARAM;
+
+ try {
+ *pp_cynara = new cynara(new CynaraClientBootstrap);
+ } catch (std::bad_alloc& ex) {
+ return cynara_api_result::CYNARA_API_OUT_OF_MEMORY;
+ }
+
+ return cynara_api_result::CYNARA_API_SUCCESS;
+}
+
+CYNARA_API
+int cynara_finish(cynara *p_cynara)
+{
+ delete p_cynara;
+
+ return cynara_api_result::CYNARA_API_SUCCESS;
+}
+
+CYNARA_API
+int cynara_check(cynara *p_cynara, const char *client, const char *client_session, const char *user,
+ const char *privilege)
+{
+ if(!p_cynara || !p_cynara->impl)
+ return cynara_api_result::CYNARA_API_INVALID_PARAM;
+ if(!client || !client_session || !user || !privilege)
+ return cynara_api_result::CYNARA_API_INVALID_PARAM;
+
+ return p_cynara->impl->check(client, client_session, user, privilege);
+}
--- /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 cynara-client-interface.h
+ * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version 1.0
+ * @brief This file contains interface for libcynara-client API implementation.
+ */
+
+
+#ifndef CYNARA_CLIENT_INTERFACE_H
+#define CYNARA_CLIENT_INTERFACE_H
+
+#include <string>
+#include <cynara-client.h>
+
+class CynaraClientInterface {
+public:
+ virtual ~CynaraClientInterface() {
+ }
+ virtual cynara_api_result check(const std::string& client, const std::string& session,
+ const std::string& user, const std::string& privilege) = 0;
+};
+
+#endif /* CYNARA_CLIENT_INTERFACE_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 attributes.h
+ * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version 1.0
+ * @brief This file defines common used attributes
+ */
+
+#ifndef ATTRIBUTES_ATTRIBUTES_H
+#define ATTRIBUTES_ATTRIBUTES_H
+
+#define CYNARA_API __attribute__((visibility("default")))
+#define UNUSED __attribute__((unused))
+
+#endif /* ATTRIBUTES_ATTRIBUTES_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 common.h
+ * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version 1.0
+ * @brief This file binds includes from cynara common library
+ */
+
+
+#ifndef COMMON_H
+#define COMMON_H
+
+#include "attributes/attributes.h"
+
+#endif /* COMMON_H */
*
* \return CYNARA_API_SUCCESS on success, or error code on error.
*/
-int cynara_initialize (cynara **pp_cynara, const cynara_configuration *p_conf);
+int cynara_initialize(cynara **pp_cynara, const cynara_configuration *p_conf);
/**
* \par Description: