Switch libcynara-client from bootstrap to cynara service version
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Thu, 26 Jun 2014 21:57:10 +0000 (23:57 +0200)
committerRafal Krypa <r.krypa@samsung.com>
Thu, 3 Jul 2014 12:19:10 +0000 (14:19 +0200)
Remove cynara-bootstrap implementation.
Add ApiInterface class.
Add Logic class - main class of cynara client.
Logic class implements ApiInterface.
Fix CMakeFile by removing dependencies and updating source files.

Change-Id: Ic6a9ebe9ad9c1de85620b943523e751382083bc6

src/client/CMakeLists.txt
src/client/api/ApiInterface.h [moved from src/client/cynara-client-interface.h with 72% similarity]
src/client/api/client-api.cpp [moved from src/client/client-api.cpp with 87% similarity]
src/client/logic/Logic.cpp [moved from src/client/bootstrap/cynara-client-bootstrap.cpp with 51% similarity]
src/client/logic/Logic.h [moved from src/client/bootstrap/cynara-client-bootstrap.h with 67% similarity]

index c7e9dbd..89fe001 100644 (file)
 #
 
 SET(LIB_CYNARA_VERSION_MAJOR 0)
-SET(LIB_CYNARA_VERSION ${LIB_CYNARA_VERSION_MAJOR}.0.1)
+SET(LIB_CYNARA_VERSION ${LIB_CYNARA_VERSION_MAJOR}.0.2)
 
 SET(CYNARA_LIB_CYNARA_PATH ${CYNARA_PATH}/client)
 
 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
+    ${CYNARA_LIB_CYNARA_PATH}/api/client-api.cpp
+    ${CYNARA_LIB_CYNARA_PATH}/logic/Logic.cpp
     )
 
 INCLUDE_DIRECTORIES(
     ${CYNARA_LIB_CYNARA_PATH}
-    ${CYNARA_CLIENT_DEP_INCLUDE_DIRS}
     )
 
 ADD_LIBRARY(${TARGET_LIB_CYNARA} SHARED ${LIB_CYNARA_SOURCES})
@@ -48,7 +42,6 @@ SET_TARGET_PROPERTIES(
 
 TARGET_LINK_LIBRARIES(${TARGET_LIB_CYNARA}
     ${CYNARA_DEP_LIBRARIES}
-    ${CYNARA_CLIENT_DEP_LIBRARIES}
     ${TARGET_CYNARA_COMMON}
     )
 
similarity index 72%
rename from src/client/cynara-client-interface.h
rename to src/client/api/ApiInterface.h
index f93958c..c9d6daa 100644 (file)
  *  limitations under the License
  */
 /*
- * @file        cynara-client-interface.h
+ * @file        ApiInterface.h
  * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
  * @version     1.0
- * @brief       This file contains interface for libcynara-client API implementation.
+ * @brief       This file contains libcynara-client API interface definition.
  */
 
-
-#ifndef CYNARA_CLIENT_INTERFACE_H
-#define CYNARA_CLIENT_INTERFACE_H
+#ifndef SRC_CLIENT_API_APIINTERFACE_H_
+#define SRC_CLIENT_API_APIINTERFACE_H_
 
 #include <string>
 #include <cynara-client.h>
 
-class CynaraClientInterface {
+namespace Cynara {
+
+class ApiInterface {
 public:
-    virtual ~CynaraClientInterface() {
-    }
+    ApiInterface() = default;
+    virtual ~ApiInterface() = default;
+
     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 */
+} // namespace Cynara
+
+#endif /* SRC_CLIENT_API_APIINTERFACE_H_ */
similarity index 87%
rename from src/client/client-api.cpp
rename to src/client/api/client-api.cpp
index e0e53cf..d34817d 100644 (file)
 #include <new>
 #include <common.h>
 #include <cynara-client.h>
-#include <cynara-client-interface.h>
-#include <bootstrap/cynara-client-bootstrap.h>
+#include <api/ApiInterface.h>
+#include <logic/Logic.h>
 
 struct cynara {
-    CynaraClientInterface *impl;
+    Cynara::ApiInterface *impl;
 
-    cynara(CynaraClientInterface *_impl) : impl(_impl) {
+    cynara(Cynara::ApiInterface *_impl) : impl(_impl) {
     }
     ~cynara() {
         delete impl;
@@ -43,8 +43,8 @@ int cynara_initialize(cynara **pp_cynara, const cynara_configuration *p_conf UNU
         return cynara_api_result::CYNARA_API_INVALID_PARAM;
 
     try {
-        *pp_cynara = new cynara(new CynaraClientBootstrap);
-    } catch (std::bad_alloc &ex) {
+        *pp_cynara = new cynara(new Cynara::Logic);
+    } catch (const std::bad_alloc &ex) {
         return cynara_api_result::CYNARA_API_OUT_OF_MEMORY;
     }
 
similarity index 51%
rename from src/client/bootstrap/cynara-client-bootstrap.cpp
rename to src/client/logic/Logic.cpp
index ecd7207..cebfb28 100644 (file)
  *  limitations under the License
  */
 /*
- * @file        cynara-client-bootstrap.cpp
+ * @file        Logic.cpp
  * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
  * @version     1.0
- * @brief       This file contains bootstrap version of libcynara-client API implementation.
+ * @brief       This file contains implementation of Logic class - main libcynara-client class
  */
 
-#include <security-server.h>
-#include "cynara-client-bootstrap.h"
+#include <common.h>
 
-CynaraClientBootstrap :: CynaraClientBootstrap() {
-}
+#include "Logic.h"
 
-CynaraClientBootstrap :: ~CynaraClientBootstrap() {
-}
+namespace Cynara {
 
-cynara_api_result CynaraClientBootstrap :: check(const std::string &client,
-    const std::string &session UNUSED, const std::string &user UNUSED, const std::string &privilege)
+cynara_api_result Logic::check(const std::string &client UNUSED, const std::string &session UNUSED,
+                               const std::string &user UNUSED, const std::string &privilege UNUSED)
 {
-    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;
+    //todo - this is a stub
     return cynara_api_result::CYNARA_API_ACCESS_DENIED;
 }
+
+} // namespace Cynara
similarity index 67%
rename from src/client/bootstrap/cynara-client-bootstrap.h
rename to src/client/logic/Logic.h
index 8c720fc..445d940 100644 (file)
  *  limitations under the License
  */
 /*
- * @file        cynara-client-bootstrap.h
+ * @file        Logic.h
  * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
  * @version     1.0
- * @brief       This file contains bootstrap version of libcynara-client API implementation.
+ * @brief       This file contains definition of Logic class - main libcynara-client class
  */
 
-#ifndef CYNARA_CLIENT_BOOTSTRAP_H
-#define CYNARA_CLIENT_BOOTSTRAP_H
+#ifndef SRC_CLIENT_LOGIC_LOGIC_H_
+#define SRC_CLIENT_LOGIC_LOGIC_H_
 
 #include <string>
-#include <common.h>
-#include <cynara-client.h>
-#include <cynara-client-interface.h>
+#include <api/ApiInterface.h>
 
-class CynaraClientBootstrap : public CynaraClientInterface {
+namespace Cynara {
+
+class Logic : public ApiInterface {
 public:
-    CynaraClientBootstrap();
-    virtual ~CynaraClientBootstrap();
+    Logic() = default;
+    virtual ~Logic() = default;
+
     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 */
+} // namespace Cynara
+
+#endif /* SRC_CLIENT_LOGIC_LOGIC_H_ */