2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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.
18 * @file FSec_PrivilegeManagerInfo.h
19 * @brief This is the header file for the FSec_PrivilegeInfo.
20 * This header file contains the declarations of the FSec_PrivilegeInfo.
23 #ifndef _FSEC_INTERNAL_PRIVILEGE_INFO_H_
24 #define _FSEC_INTERNAL_PRIVILEGE_INFO_H_
26 #include <FOspConfig.h>
27 #include "FSec_AccessControlTypes.h"
29 namespace Tizen { namespace Security
35 * @class _PrivilegeInfo
36 * @brief This class provides a basic information of privilege manager.
39 * This class provides a basic information of privilege manager.
43 : public Tizen::Base::Object
48 * This is the default constructor for this class. @n
49 * This method creates an uninitialized instance of _PrivilegeCache.
56 * This is the destructor for this class.
60 virtual ~_PrivilegeInfo(void);
63 * Initializes an instance of _PrivilegeInfo and sets its base information directly.
66 * @return An error code
67 * @param[in] appId The application ID.
68 * @param[in] pBitwisePrivilege The bitwise privilege information.
69 * @exception E_SUCCESS The method is successful.
70 * @exception E_INVALID_ARG A specified input parameter is invalid.
72 result Construct(const Tizen::App::AppId& appId, const byte* pBitwisePrivilege, const Tizen::Base::Collection::ArrayList* pPrivilegeStringList);
75 * Initializes an instance of _PrivilegeInfo and sets its base information using stored privilege information.
78 * @return An error code
79 * @param[in] appId The application ID.
80 * @param[in] encryptedPrivileges A string containing encrypted privilege information.
81 * @param[in] checksum A string containing checksum of privilege information.
82 * @exception E_SUCCESS The method is successful.
83 * @exception E_INVALID_ARG A specified input parameter is invalid.
85 result Construct(const Tizen::App::AppId& appId, const Tizen::Base::String& encryptedPrivileges, const Tizen::Base::String& checksum,
86 const Tizen::Base::Collection::ArrayList* pPrivilegeStringList);
89 * Initializes an instance of _PrivilegeInfo and sets its base information using stored privilege and visibility information.
92 * @return An error code
93 * @param[in] appId The application ID.
94 * @param[in] encryptedPrivileges A string containing encrypted privilege information.
95 * @param[in] checksum A string containing checksum of privilege information.
96 * @exception E_SUCCESS The method is successful.
97 * @exception E_INVALID_ARG A specified input parameter is invalid.
99 result Construct(const Tizen::App::AppId& appId, const Tizen::Base::String& encryptedPrivileges, const Tizen::Base::String& checksum,
100 const Tizen::Base::String& encryptedVisibiliity, const Tizen::Base::String& visibilityChecksum, const Tizen::Base::Collection::ArrayList* pPrivilegeStringList);
103 * Initializes an instance of _PrivilegeInfo and sets its base information using _PrivilegeInfo instance.
106 * @return An error code
107 * @param[in] privilegeInfo An instance of _PrivilegeInfo.
108 * @exception E_SUCCESS The method is successful.
109 * @exception E_AUTHENTICATION The authentication has failed.
110 * @exception E_INVALID_ARG A specified input parameter is invalid.
112 result Construct(const _PrivilegeInfo& privilegeInfo);
115 * CCreates and returns a polymorphic copy of _PrivilegeInfo instance.
117 * @return The clone of this instance
118 * @exception E_OUT_OF_MEMORY The memory is insufficient.
121 _PrivilegeInfo* CloneN(void) const;
124 * Gets the application ID.
127 * @return The application id
129 const Tizen::Base::String GetAppId(void) const;
132 * Gets the bitwise privilege information.
135 * @return An error code
136 * @param[out] pBitwisePrivilege The bitwise privilege information.
137 * @exception E_SUCCESS The method is successful.
138 * @exception E_OUT_OF_MEMORY The memory is insufficient.
140 result GetBitwisePrivilegeN(byte*& pBitwisePrivilege) const;
143 * Gets the encrypted string of bitwise privilege information.
146 * @return An error code
147 * @param[out] encryptedPrivileges A string containing encrypted privilege information.
148 * @exception E_SUCCESS The method is successful.
149 * @exception E_OUT_OF_MEMORY The memory is insufficient.
150 * @exception E_SYSTEM An unexpected system error occurred.
152 result GetEncryptedBitwise(Tizen::Base::String& encryptedPrivileges) const;
155 * Gets the checksum of bitwise privilege information.
158 * @return An error code
159 * @param[out] checksum A string containing checksum of privilege information.
160 * @exception E_SUCCESS The method is successful.
161 * @exception E_SYSTEM An unexpected system error occurred.
163 result GetChecksum(Tizen::Base::String& checksum) const;
166 * Checks whether the application has a privilege to invoke.
169 * @return A boolean value of the result
170 * @param[int] privilege A value of enumerator of the specified privilege.
172 bool HasPrivilege(_Privilege privilege) const;
175 * Checks whether the application has a privilege to invoke. @n
176 * Unlike HasPrivilege, HasPrivilegeEx does not print the log.
179 * @return A boolean value of the result
180 * @param[int] privilege A value of enumerator of the specified privilege.
182 bool HasPrivilegeEx(_Privilege privilege) const;
185 * Checks whether the application has a privilege to invoke.
188 * @return A boolean value of the result
189 * @param[in] privilege A string of the specified privilege.
191 bool HasPrivilege(const Tizen::Base::String& privilege) const;
195 result VerifyIntegrity(const Tizen::App::AppId& appId, const byte* targetBitwisePrivilege, const Tizen::Base::String& storedChecksum, int length);
196 result VerifyIntegrity(const Tizen::App::AppId& appId, const byte* targetBitwisePrivilege, const Tizen::Base::String& storedChecksum, int length, int visibility, const Tizen::Base::String& storedVisibilityChecksum);
197 result VerifyIntegrityEx(const Tizen::App::AppId& appId, const byte* targetBitwisePrivilege, const Tizen::Base::String& storedChecksum, int length);
199 static int GetPrivilegeLevel(const Tizen::Base::String& privilegeLevel);
200 static ISecretKey* GetDeviceUniqueKeyN(void);
202 _PrivilegeInfo(const _PrivilegeInfo& rhs);
203 _PrivilegeInfo& operator =(const _PrivilegeInfo& rhs);
206 Tizen::App::AppId __appId;
208 byte __bitwisePrivilege[MAX_BITWISE_PRIV_SIZE];
210 Tizen::Base::Collection::HashMap __privilegeList;
214 }} // Tizen::Security
216 #endif // _FSEC_INTERNAL_PRIVILEGE_INFO_H_