2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FSec_PrivilegeManagerInfo.h
20 * @brief This is the header file for the FSec_PrivilegeInfo.
21 * This header file contains the declarations of the FSec_PrivilegeInfo.
24 #ifndef _FSEC_INTERNAL_PRIVILEGE_INFO_H_
25 #define _FSEC_INTERNAL_PRIVILEGE_INFO_H_
27 #include <FOspConfig.h>
28 #include "FSec_AccessControlTypes.h"
30 namespace Tizen { namespace Security
34 * @class _PrivilegeInfo
35 * @brief This class provides a basic information of privilege manager.
38 * This class provides a basic information of privilege manager.
42 : public Tizen::Base::Object
47 * This is the default constructor for this class. @n
48 * This method creates an uninitialized instance of _PrivilegeCache.
55 * This is the destructor for this class.
59 virtual ~_PrivilegeInfo(void);
62 * Initializes an instance of _PrivilegeInfo and sets its base information directly.
65 * @return An error code
66 * @param[in] appId The application ID.
67 * @param[in] pBitwisePrivilege The bitwise privilege information.
68 * @exception E_SUCCESS The method is successful.
69 * @exception E_INVALID_ARG A specified input parameter is invalid.
71 result Construct(const Tizen::App::AppId& appId, const byte* pBitwisePrivilege, const Tizen::Base::Collection::ArrayList* pPrivilegeStringList);
74 * Initializes an instance of _PrivilegeInfo and sets its base information using stored privilege information.
77 * @return An error code
78 * @param[in] appId The application ID.
79 * @param[in] encryptedPrivileges A string containing encrypted privilege information.
80 * @param[in] checksum A string containing checksum of privilege information.
81 * @exception E_SUCCESS The method is successful.
82 * @exception E_INVALID_ARG A specified input parameter is invalid.
84 result Construct(const Tizen::App::AppId& appId, const Tizen::Base::String& encryptedPrivileges, const Tizen::Base::String& checksum,
85 const Tizen::Base::Collection::ArrayList* pPrivilegeStringList);
88 * Initializes an instance of _PrivilegeInfo and sets its base information using stored privilege and visibility information.
91 * @return An error code
92 * @param[in] appId The application ID.
93 * @param[in] encryptedPrivileges A string containing encrypted privilege information.
94 * @param[in] checksum A string containing checksum of privilege information.
95 * @exception E_SUCCESS The method is successful.
96 * @exception E_INVALID_ARG A specified input parameter is invalid.
98 result Construct(const Tizen::App::AppId& appId, const Tizen::Base::String& encryptedPrivileges, const Tizen::Base::String& checksum,
99 const Tizen::Base::String& encryptedVisibiliity, const Tizen::Base::String& visibilityChecksum, const Tizen::Base::Collection::ArrayList* pPrivilegeStringList);
102 * Initializes an instance of _PrivilegeInfo and sets its base information using _PrivilegeInfo instance.
105 * @return An error code
106 * @param[in] privilegeInfo An instance of _PrivilegeInfo.
107 * @exception E_SUCCESS The method is successful.
108 * @exception E_AUTHENTICATION The authentication has failed.
109 * @exception E_INVALID_ARG A specified input parameter is invalid.
111 result Construct(const _PrivilegeInfo& privilegeInfo);
114 * CCreates and returns a polymorphic copy of _PrivilegeInfo instance.
116 * @return The clone of this instance
117 * @exception E_OUT_OF_MEMORY The memory is insufficient.
120 _PrivilegeInfo* CloneN(void) const;
123 * Gets the application ID.
126 * @return The application id
128 const Tizen::Base::String GetAppId(void) const;
131 * Gets the bitwise privilege information.
134 * @return An error code
135 * @param[out] pBitwisePrivilege The bitwise privilege information.
136 * @exception E_SUCCESS The method is successful.
137 * @exception E_OUT_OF_MEMORY The memory is insufficient.
139 result GetBitwisePrivilegeN(byte*& pBitwisePrivilege) const;
142 * Gets the encrypted string of bitwise privilege information.
145 * @return An error code
146 * @param[out] encryptedPrivileges A string containing encrypted privilege information.
147 * @exception E_SUCCESS The method is successful.
148 * @exception E_OUT_OF_MEMORY The memory is insufficient.
149 * @exception E_SYSTEM An unexpected system error occurred.
151 result GetEncryptedBitwise(Tizen::Base::String& encryptedPrivileges) const;
154 * Gets the checksum of bitwise privilege information.
157 * @return An error code
158 * @param[out] checksum A string containing checksum of privilege information.
159 * @exception E_SUCCESS The method is successful.
160 * @exception E_SYSTEM An unexpected system error occurred.
162 result GetChecksum(Tizen::Base::String& checksum) const;
165 * Checks whether the application has a privilege to invoke.
168 * @return A boolean value of the result
169 * @param[int] privilege A value of enumerator of the specified privilege.
171 bool HasPrivilege(_Privilege privilege) const;
174 * Checks whether the application has a privilege to invoke. @n
175 * Unlike HasPrivilege, HasPrivilegeEx does not print the log.
178 * @return A boolean value of the result
179 * @param[int] privilege A value of enumerator of the specified privilege.
181 bool HasPrivilegeEx(_Privilege privilege) const;
184 * Checks whether the application has a privilege to invoke.
187 * @return A boolean value of the result
188 * @param[in] privilege A string of the specified privilege.
190 bool HasPrivilege(const Tizen::Base::String& privilege) const;
194 result VerifyIntegrity(const Tizen::App::AppId& appId, const byte* targetBitwisePrivilege, const Tizen::Base::String& storedChecksum, int length);
195 result VerifyIntegrity(const Tizen::App::AppId& appId, const byte* targetBitwisePrivilege, const Tizen::Base::String& storedChecksum, int length, int visibility, const Tizen::Base::String& storedVisibilityChecksum);
196 result VerifyIntegrityEx(const Tizen::App::AppId& appId, const byte* targetBitwisePrivilege, const Tizen::Base::String& storedChecksum, int length);
198 _PrivilegeInfo(const _PrivilegeInfo& rhs);
199 _PrivilegeInfo& operator =(const _PrivilegeInfo& rhs);
202 Tizen::App::AppId __appId;
204 byte __bitwisePrivilege[MAX_BITWISE_PRIV_SIZE];
206 Tizen::Base::Collection::ArrayList __privilegeList;
210 }} // Tizen::Security
212 #endif // _FSEC_INTERNAL_PRIVILEGE_INFO_H_