cda83c88fa6969648aa93c4a5b095b8037543768
[framework/security/security-server.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 WidgetHandleList getHandleList();
105
106     static AppTypes getWidgetType(WidgetHandle handle);
107     static std::string getVersion(WidgetHandle widgetHandle);
108     static std::string getAuthorName(WidgetHandle widgetHandle);
109     static std::string getGUID(WidgetHandle widgetHandle);
110
111     static WidgetCertificateCNList getKeyCommonNameList(
112             WidgetHandle widgetHandle,
113             WidgetCertificateData::Owner owner,
114             WidgetCertificateData::Type type);
115     static FingerPrintList getKeyFingerprints(
116             WidgetHandle widgetHandle,
117             WidgetCertificateData::Owner owner,
118             WidgetCertificateData::Type type);
119
120     static std::string getShareHref(WidgetHandle widgetHandle);
121     static bool isWidgetInstalled(WidgetHandle handle);
122
123   protected:
124     static int promptDecisionToInt(PromptDecision decision);
125     static PromptDecision intToPromptDecision(int decision);
126     static int appTypeToInt(AppTypes app_type);
127     static AppTypes intToAppType(int app_type);
128 };
129
130 }
131
132 #endif