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
33 * @class _PrivilegeInfo
34 * @brief This class provides a basic information of privilege manager.
37 * This class provides a basic information of privilege manager.
41 : public Tizen::Base::Object
46 * This is the default constructor for this class. @n
47 * This method creates an uninitialized instance of _PrivilegeCache.
54 * This is the destructor for this class.
58 virtual ~_PrivilegeInfo(void);
61 * Initializes an instance of _PrivilegeInfo and sets its base information directly.
64 * @return An error code
65 * @param[in] appId The application ID.
66 * @param[in] pBitwisePrivilege The bitwise privilege information.
67 * @exception E_SUCCESS The method is successful.
68 * @exception E_INVALID_ARG A specified input parameter is invalid.
70 result Construct(const Tizen::App::AppId& appId, const byte* pBitwisePrivilege, const Tizen::Base::Collection::ArrayList* pPrivilegeStringList);
73 * Initializes an instance of _PrivilegeInfo and sets its base information using stored privilege information.
76 * @return An error code
77 * @param[in] appId The application ID.
78 * @param[in] encryptedPrivileges A string containing encrypted privilege information.
79 * @param[in] checksum A string containing checksum of privilege information.
80 * @exception E_SUCCESS The method is successful.
81 * @exception E_INVALID_ARG A specified input parameter is invalid.
83 result Construct(const Tizen::App::AppId& appId, const Tizen::Base::String& encryptedPrivileges, const Tizen::Base::String& checksum,
84 const Tizen::Base::Collection::ArrayList* pPrivilegeStringList);
87 * Initializes an instance of _PrivilegeInfo and sets its base information using stored privilege and visibility information.
90 * @return An error code
91 * @param[in] appId The application ID.
92 * @param[in] encryptedPrivileges A string containing encrypted privilege information.
93 * @param[in] checksum A string containing checksum of privilege information.
94 * @exception E_SUCCESS The method is successful.
95 * @exception E_INVALID_ARG A specified input parameter is invalid.
97 result Construct(const Tizen::App::AppId& appId, const Tizen::Base::String& encryptedPrivileges, const Tizen::Base::String& checksum,
98 const Tizen::Base::String& encryptedVisibiliity, const Tizen::Base::String& visibilityChecksum, const Tizen::Base::Collection::ArrayList* pPrivilegeStringList);
101 * Initializes an instance of _PrivilegeInfo and sets its base information using _PrivilegeInfo instance.
104 * @return An error code
105 * @param[in] privilegeInfo An instance of _PrivilegeInfo.
106 * @exception E_SUCCESS The method is successful.
107 * @exception E_AUTHENTICATION The authentication has failed.
108 * @exception E_INVALID_ARG A specified input parameter is invalid.
110 result Construct(const _PrivilegeInfo& privilegeInfo);
113 * CCreates and returns a polymorphic copy of _PrivilegeInfo instance.
115 * @return The clone of this instance
116 * @exception E_OUT_OF_MEMORY The memory is insufficient.
119 _PrivilegeInfo* CloneN(void) const;
122 * Gets the application ID.
125 * @return The application id
127 const Tizen::Base::String GetAppId(void) const;
130 * Gets the bitwise privilege information.
133 * @return An error code
134 * @param[out] pBitwisePrivilege The bitwise privilege information.
135 * @exception E_SUCCESS The method is successful.
136 * @exception E_OUT_OF_MEMORY The memory is insufficient.
138 result GetBitwisePrivilegeN(byte*& pBitwisePrivilege) const;
141 * Gets the encrypted string of bitwise privilege information.
144 * @return An error code
145 * @param[out] encryptedPrivileges A string containing encrypted privilege information.
146 * @exception E_SUCCESS The method is successful.
147 * @exception E_OUT_OF_MEMORY The memory is insufficient.
148 * @exception E_SYSTEM An unexpected system error occurred.
150 result GetEncryptedBitwise(Tizen::Base::String& encryptedPrivileges) const;
153 * Gets the checksum of bitwise privilege information.
156 * @return An error code
157 * @param[out] checksum A string containing checksum of privilege information.
158 * @exception E_SUCCESS The method is successful.
159 * @exception E_SYSTEM An unexpected system error occurred.
161 result GetChecksum(Tizen::Base::String& checksum) const;
164 * Checks whether the application has a privilege to invoke.
167 * @return A boolean value of the result
168 * @param[int] privilege A value of enumerator of the specified privilege.
170 bool HasPrivilege(_Privilege privilege) const;
173 * Checks whether the application has a privilege to invoke. @n
174 * Unlike HasPrivilege, HasPrivilegeEx does not print the log.
177 * @return A boolean value of the result
178 * @param[int] privilege A value of enumerator of the specified privilege.
180 bool HasPrivilegeEx(_Privilege privilege) const;
183 * Checks whether the application has a privilege to invoke.
186 * @return A boolean value of the result
187 * @param[in] privilege A string of the specified privilege.
189 bool HasPrivilege(const Tizen::Base::String& privilege) const;
193 result VerifyIntegrity(const Tizen::App::AppId& appId, const byte* targetBitwisePrivilege, const Tizen::Base::String& storedChecksum, int length);
194 result VerifyIntegrity(const Tizen::App::AppId& appId, const byte* targetBitwisePrivilege, const Tizen::Base::String& storedChecksum, int length, int visibility, const Tizen::Base::String& storedVisibilityChecksum);
195 result VerifyIntegrityEx(const Tizen::App::AppId& appId, const byte* targetBitwisePrivilege, const Tizen::Base::String& storedChecksum, int length);
197 _PrivilegeInfo(const _PrivilegeInfo& rhs);
198 _PrivilegeInfo& operator =(const _PrivilegeInfo& rhs);
201 Tizen::App::AppId __appId;
203 byte __bitwisePrivilege[MAX_BITWISE_PRIV_SIZE];
205 Tizen::Base::Collection::ArrayList __privilegeList;
209 }} // Tizen::Security
211 #endif // _FSEC_INTERNAL_PRIVILEGE_INFO_H_