CKMI: Implementation of ckm-policy. 57/48057/3
authorBartlomiej Grzelewski <b.grzelewski@samsung.com>
Fri, 11 Sep 2015 12:45:02 +0000 (14:45 +0200)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Tue, 15 Sep 2015 12:43:57 +0000 (14:43 +0200)
Change-Id: I60da89cf4aeff7818f7ebd92a1e20eb7f6ac4d96

src/ckm-integration/ckm-policy.cpp [new file with mode: 0644]
src/ckm-integration/ckm-policy.h [new file with mode: 0644]

diff --git a/src/ckm-integration/ckm-policy.cpp b/src/ckm-integration/ckm-policy.cpp
new file mode 100644 (file)
index 0000000..9f33c3e
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ *  Copyright (c) 2015 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       ckm-policy.cpp
+ * @author     Bartlomiej Grzelewski (b.grzelewski@samsung.com)
+ * @version    1.0
+ */
+#include <sstream>
+
+#include <ckm-policy.h>
+
+CKMPolicy::CKMPolicy(
+    std::string pkgId,
+    std::string userName,
+    ProcessSettings::PrivilegeVector priv)
+  : m_userName(std::move(userName))
+  , m_pkgId(pkgId)
+  , m_appId(std::move(pkgId))
+  , m_privileges(std::move(priv))
+{
+    std::stringstream ss;
+    ss << "User::App::" << m_pkgId;
+    m_smackLabel = ss.str();
+}
+
+std::string CKMPolicy::GetUserName() const {
+    return m_userName;
+}
+
+void CKMPolicy::SetUserName(std::string userName) {
+    m_userName = std::move(userName);
+}
+
+gid_t CKMPolicy::GetGid() const {
+    return m_gid;
+}
+
+void CKMPolicy::SetGid(gid_t gid) {
+    m_gid = gid;
+}
+
+uid_t CKMPolicy::GetUid() const {
+    return m_uid;
+}
+
+void CKMPolicy::SetUid(uid_t uid) {
+    m_uid = uid;
+}
+
+std::string CKMPolicy::GetSmackLabel() const {
+    return m_smackLabel;
+}
+
+void CKMPolicy::SetSmackLabel(std::string label) {
+    m_smackLabel = std::move(label);
+}
+
+std::string CKMPolicy::GetAppId() const {
+    return m_appId;
+}
+
+void CKMPolicy::SetAppId(std::string appId) {
+    m_appId = std::move(appId);
+}
+
+std::string CKMPolicy::GetPkgId() const {
+    return m_pkgId;
+}
+
+void CKMPolicy::SetPkgId(std::string pkgId) {
+    m_pkgId = std::move(pkgId);
+}
+
+ProcessSettings::PrivilegeVector CKMPolicy::GetPrivileges() const {
+    return m_privileges;
+}
+
+void CKMPolicy::SetPrivileges(ProcessSettings::PrivilegeVector priv) {
+    m_privileges = std::move(priv);
+}
+
+const ProcessSettings::PrivilegeVector PrivNone;
+const ProcessSettings::PrivilegeVector PrivCKMBoth {
+    "http://tizen.org/privilege/keymanager",
+    "http://tizen.org/privilege/keymanager.admin"};
+const ProcessSettings::PrivilegeVector PrivCKMControl {
+    "http://tizen.org/privilege/keymanager.admin"};
+const ProcessSettings::PrivilegeVector PrivCKMStore {
+    "http://tizen.org/privilege/keymanager"};
+
+
diff --git a/src/ckm-integration/ckm-policy.h b/src/ckm-integration/ckm-policy.h
new file mode 100644 (file)
index 0000000..1051141
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ *  Copyright (c) 2015 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       ckm-policy.h
+ * @author     Bartlomiej Grzelewski (b.grzelewski@samsung.com)
+ * @version    1.0
+ */
+#pragma once
+
+#include <process-settings/policy.h>
+#include <process-settings/executor.h>
+#include <process-settings/change-uid.h>
+#include <process-settings/change-smack.h>
+#include <process-settings/install-app.h>
+#include <process-settings/create-user.h>
+
+class CKMPolicy : public ProcessSettings::Policy {
+public:
+    CKMPolicy(
+        std::string pkgId,
+        std::string userName,
+        ProcessSettings::PrivilegeVector priv);
+    virtual std::string GetUserName() const;
+    virtual void SetUserName(std::string);
+    virtual gid_t GetGid() const;
+    virtual void SetGid(gid_t);
+    virtual uid_t GetUid() const;
+    virtual void SetUid(uid_t);
+    virtual std::string GetSmackLabel() const;
+    virtual void SetSmackLabel(std::string);
+    virtual std::string GetAppId() const;
+    virtual void SetAppId(std::string);
+    virtual std::string GetPkgId() const;
+    virtual void SetPkgId(std::string);
+    virtual ProcessSettings::PrivilegeVector GetPrivileges() const;
+    virtual void SetPrivileges(ProcessSettings::PrivilegeVector);
+    virtual ~CKMPolicy() {}
+private:
+    uid_t m_uid;
+    gid_t m_gid;
+    std::string m_userName;
+    std::string m_smackLabel;
+    std::string m_pkgId;
+    std::string m_appId;
+    ProcessSettings::PrivilegeVector m_privileges;
+};
+
+extern const ProcessSettings::PrivilegeVector PrivNone;
+extern const ProcessSettings::PrivilegeVector PrivCKMBoth;
+extern const ProcessSettings::PrivilegeVector PrivCKMControl;
+extern const ProcessSettings::PrivilegeVector PrivCKMStore;
+