3787fbfa974fa21ba9d30aa01b1c507bf15089d4
[platform/core/security/security-manager.git] / ace / include / ace-dao-ro / AceDAOReadOnly.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /**
17  *
18  *
19  * @file       AceDAOReadOnly.h
20  * @author     Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
21  * @author     Grzegorz Krawczyk (g.krawczyk@samsung.com)
22  * @version    0.1
23  * @brief
24  */
25
26 #ifndef ACE_DAO_READ_ONLY_H_
27 #define ACE_DAO_READ_ONLY_H_
28
29 #include <map>
30
31 #include <openssl/md5.h>
32 #include <dpl/string.h>
33 #include <dpl/exception.h>
34 #include <ace-dao-ro/PreferenceTypes.h>
35 #include <ace-dao-ro/BaseAttribute.h>
36 #include <ace-dao-ro/BasePermission.h>
37 #include <ace-dao-ro/AppTypes.h>
38 #include <ace-dao-ro/IRequest.h>
39 #include <ace/PolicyEffect.h>
40 #include <ace/PolicyResult.h>
41 #include <ace/PromptDecision.h>
42 #include <ace-dao-ro/common_dao_types.h>
43
44 namespace AceDB {
45
46 typedef std::map<DPL::String, bool> RequestedDevCapsMap;
47 typedef DPL::String FeatureName;
48 typedef std::vector<FeatureName> FeatureNameVector;
49
50 class AceDAOReadOnly
51 {
52   public:
53     class Exception
54     {
55       public:
56         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
57         DECLARE_EXCEPTION_TYPE(Base, DatabaseError)
58     };
59
60     AceDAOReadOnly() {}
61
62     static void attachToThreadRO(void);
63     static void attachToThreadRW(void);
64     static void detachFromThread(void);
65
66     // policy effect/decision
67     static OptionalExtendedPolicyResult getPolicyResult(
68             const BaseAttributeSet &attributes);
69
70     static OptionalExtendedPolicyResult getPolicyResult(
71         const DPL::String &attrHash);
72
73     static OptionalCachedPromptDecision getPromptDecision(
74             WidgetHandle widgetHandle,
75             int ruleId);
76
77     // resource settings
78     static PreferenceTypes getDevCapSetting(const std::string &resource);
79     static void getDevCapSettings(PreferenceTypesMap *preferences);
80
81     // user settings
82     static void getWidgetDevCapSettings(BasePermissionList *permissions);
83     static PreferenceTypes getWidgetDevCapSetting(
84             const std::string &resource,
85             WidgetHandle handler);
86
87     static void getAttributes(BaseAttributeSet *attributes);
88
89     // Getter for device capabilities that are requested in widgets config.
90     //
91     // Additional boolean flag means whether widget will always get
92     // (at launch) the SMACK permissions needed to use the device cap).
93     //
94     // 'permissions' is the map of device cap names and smack status for
95     // given widget handle.
96     static void getRequestedDevCaps(
97         WidgetHandle widgetHandle,
98         RequestedDevCapsMap *permissions);
99
100     static void getAcceptedFeature(
101         WidgetHandle widgetHandle,
102         FeatureNameVector *featureVector);
103
104     static AppTypes getWidgetType(WidgetHandle handle);
105     static std::string getVersion(WidgetHandle widgetHandle);
106     static std::string getAuthorName(WidgetHandle widgetHandle);
107     static std::string getGUID(WidgetHandle widgetHandle);
108
109     static WidgetCertificateCNList getKeyCommonNameList(
110             WidgetHandle widgetHandle,
111             WidgetCertificateData::Owner owner,
112             WidgetCertificateData::Type type);
113     static FingerPrintList getKeyFingerprints(
114             WidgetHandle widgetHandle,
115             WidgetCertificateData::Owner owner,
116             WidgetCertificateData::Type type);
117
118     static std::string getShareHref(WidgetHandle widgetHandle);
119
120   protected:
121     static int promptDecisionToInt(PromptDecision decision);
122     static PromptDecision intToPromptDecision(int decision);
123     static int appTypeToInt(AppTypes app_type);
124     static AppTypes intToAppType(int app_type);
125 } __attribute__ ((deprecated));
126
127 }
128
129 #endif