Adjust admin API policy type codes 71/27971/5
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Tue, 23 Sep 2014 15:50:27 +0000 (17:50 +0200)
committerLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Wed, 22 Oct 2014 12:12:53 +0000 (14:12 +0200)
External admin API policy types should match inner cynara values
used in storage and protocols. That would make plugins work easier
and allows correct work of cynara_admin_check function.

New header cynara-policy-types.h is provided by libcynara-common.
It defines policy type values and is included by external admin API.
Predefined policies variables use same values for initialization.

Change-Id: If1b158dcd5abbe9ee3af692e706a2d2e886f8631

packaging/cynara.spec
src/common/CMakeLists.txt
src/common/types/PolicyType.h
src/include/CMakeLists.txt
src/include/cynara-admin-types.h
src/include/cynara-admin.h
src/include/cynara-offline-admin.h
src/include/cynara-policy-types.h [new file with mode: 0644]

index 8212f7e..4d067c3 100644 (file)
@@ -458,6 +458,7 @@ fi
 %{_libdir}/libcynara-commons.so.*
 
 %files -n libcynara-commons-devel
+%{_includedir}/cynara/cynara-policy-types.h
 %{_includedir}/cynara/types/PolicyResult.h
 %{_includedir}/cynara/types/PolicyType.h
 %{_libdir}/libcynara-commons.so
index 77c7d56..6cd0005 100644 (file)
@@ -21,6 +21,10 @@ SET(CYNARA_COMMON_VERSION ${CYNARA_COMMON_VERSION_MAJOR}.3.0)
 
 SET(COMMON_PATH ${CYNARA_PATH}/common)
 
+INCLUDE_DIRECTORIES(
+    ${CYNARA_PATH}/include
+    )
+
 SET(COMMON_SOURCES
     ${COMMON_PATH}/containers/BinaryQueue.cpp
     ${COMMON_PATH}/log/log.cpp
index 5bef612..36c84e6 100644 (file)
 #include <cstdint>
 #include <string>
 
+#include <cynara-policy-types.h>
+
 namespace Cynara {
 
 typedef std::uint16_t PolicyType;
 
 namespace PredefinedPolicyType  {
-    const PolicyType DENY = 0;
-    const PolicyType NONE = 1;
-    const PolicyType BUCKET = 0xFFFE;
-    const PolicyType ALLOW = 0xFFFF;
+    const PolicyType DENY = CYNARA_ADMIN_DENY;
+    const PolicyType NONE = CYNARA_ADMIN_NONE;
+    const PolicyType BUCKET = CYNARA_ADMIN_BUCKET;
+    const PolicyType ALLOW = CYNARA_ADMIN_ALLOW;
 };
 
 class PolicyResult;
index 245962d..1d672a8 100644 (file)
@@ -26,6 +26,7 @@ INSTALL(FILES
     ${CYNARA_PATH}/include/cynara-creds-socket.h
     ${CYNARA_PATH}/include/cynara-error.h
     ${CYNARA_PATH}/include/cynara-plugin.h
+    ${CYNARA_PATH}/include/cynara-policy-types.h
     ${CYNARA_PATH}/include/cynara-session.h
     DESTINATION ${INCLUDE_INSTALL_DIR}/cynara
     )
index 073881a..8dd3c66 100644 (file)
@@ -63,29 +63,6 @@ struct cynara_admin_policy {
  */
 #define CYNARA_ADMIN_DEFAULT_BUCKET ""
 
-/**
- * \name Operation Codes
- * operation codes that define action type to be taken in below defined functions
- * they are used mostly to define policy result
- * @{
- */
-
-/*! \brief   a policy or bucket should be removed */
-#define CYNARA_ADMIN_DELETE -1
-
-/*! \brief   set policy result or bucket's default policy to DENY */
-#define CYNARA_ADMIN_DENY 0
-
-/*! \brief   set bucket's default policy to NONE */
-#define CYNARA_ADMIN_NONE 1
-
-/*! \brief   set policy result or bucket's default policy to ALLOW */
-#define CYNARA_ADMIN_ALLOW 2
-
-/*! \brief   set policy to point into another bucket */
-#define CYNARA_ADMIN_BUCKET 3
-/** @}*/
-
 #ifdef __cplusplus
 }
 #endif
index 0e92b18..cd51465 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <cynara-admin-types.h>
 #include <cynara-error.h>
+#include <cynara-policy-types.h>
 
 #ifdef __cplusplus
 extern "C" {
index dbecc78..ce711f7 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <cynara-admin-types.h>
 #include <cynara-error.h>
+#include <cynara-policy-types.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/src/include/cynara-policy-types.h b/src/include/cynara-policy-types.h
new file mode 100644 (file)
index 0000000..398c267
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *  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/include/cynara-policy-types.h
+ * \author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * \version     1.0
+ * \brief       This file contains policy types / operations definitions.
+ */
+
+#ifndef CYNARA_POLICY_TYPES_H
+#define CYNARA_POLICY_TYPES_H
+
+/**
+ * \name Operation Codes
+ * operation codes that define action type to be taken in below defined functions
+ * they are used mostly to define policy result
+ * @{
+ */
+
+/*! \brief   a policy or bucket should be removed */
+#define CYNARA_ADMIN_DELETE -1
+
+/*! \brief   set policy result or bucket's default policy to DENY */
+#define CYNARA_ADMIN_DENY 0
+
+/*! \brief   set bucket's default policy to NONE */
+#define CYNARA_ADMIN_NONE 1
+
+/*! \brief   set policy to point into another bucket */
+#define CYNARA_ADMIN_BUCKET 0xFFFE
+
+/*! \brief   set policy result or bucket's default policy to ALLOW */
+#define CYNARA_ADMIN_ALLOW 0xFFFF
+/** @}*/
+
+#endif /* CYNARA_POLICY_TYPES_H */