Merge "Fix GetPrivilegeListN method to retrieve the Privilege string with URI" into...
[platform/framework/native/appfw.git] / src / security / FSecPrivilegeInfo.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file        FSecPrivilegeInfo.cpp
20  * @brief       This is the implementation for the PrivilegeInfo class.
21  */
22
23 #include <new>
24
25 #include <FSecPrivilegeInfo.h>
26
27 #include <FBaseSysLog.h>
28 #include <FSec_AccessController.h>
29 #include "FSec_PrivilegeInfoImpl.h"
30
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Security;
34
35 namespace Tizen { namespace Security
36 {
37
38
39 PrivilegeInfo::PrivilegeInfo(void)
40         : __pImpl(null)
41 {
42
43 }
44
45 PrivilegeInfo::~PrivilegeInfo(void)
46 {
47
48 }
49
50 result
51 PrivilegeInfo::Construct(const Tizen::Base::String& privilegeId)
52 {
53         result r = E_SUCCESS;
54
55         SysAssertf(__pImpl == null,
56                     "Already constructed. Calling Construct() twice or more on a same in stance is not allowed for this class.");
57
58         __pImpl = new (std::nothrow) _PrivilegeInfoImpl;
59     SysTryReturnResult(NID_SEC, __pImpl != null, E_OUT_OF_MEMORY, "");
60
61     r = __pImpl->Construct(privilegeId);
62     SysTryCatch(NID_SEC, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
63
64     return r;
65
66 CATCH:
67     delete __pImpl;
68     __pImpl = null;
69
70     return r;
71
72 }
73
74 String
75 PrivilegeInfo::GetId(void) const
76 {
77         SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
78
79         return __pImpl->GetId();
80 }
81
82
83 String
84 PrivilegeInfo::GetDisplayName(void) const
85 {
86         SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
87
88         return __pImpl->GetDisplayName();
89 }
90
91 String
92 PrivilegeInfo::GetDescription(void) const
93 {
94         SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
95
96         return __pImpl->GetDescription();
97 }
98
99 }} // Tizen::Security