2 * Copyright (c) 2014-2020 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <security-manager-types.h>
24 #include <dpl/test/test_runner.h>
35 Privilege(const char* systemPrivilege, Type type = UNSET, std::string license = std::string())
36 : m_name(systemPrivilege)
38 , m_license(std::move(license))
41 Privilege(std::string systemPrivilege, Type type = UNSET, std::string license = std::string())
42 : m_name(std::move(systemPrivilege))
44 , m_license(std::move(license))
47 Privilege(std::string licensedPrivilege, std::string license)
48 : m_name(std::move(licensedPrivilege))
50 , m_license(std::move(license))
53 bool isUnset() const { return m_type == UNSET; }
54 bool isUntrusted() const { return m_type == UNTRUSTED; }
55 bool isLicensed() const { return m_type == LICENSED; }
56 bool isPrivacy() const { return m_type == PRIVACY; }
58 int getType() const { return m_type; }
59 app_defined_privilege_type getSMType () const {
60 RUNNER_ASSERT(m_type != UNSET);
61 if (isLicensed()) return SM_APP_DEFINED_PRIVILEGE_TYPE_LICENSED;
62 return SM_APP_DEFINED_PRIVILEGE_TYPE_UNTRUSTED;
65 const std::string& getName() const { return m_name; }
66 const std::string& getLicense() const { return m_license; }
68 const char *getNameC() const { return m_name.c_str(); }
69 const char *getLicenseC() const { return m_license.c_str(); }
71 operator const char *() const { return m_name.c_str(); }
73 operator std::string() const { return m_name; }
75 bool operator==(const std::string& other) const { return m_name == other; }
80 std::string m_license;
83 typedef std::vector<Privilege> PrivilegeVector;