2 // Copyright (c) 2012-2013 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 SecurityService.cpp
19 * @brief This is the implementation file for SecurityService class.
22 #include <FAppAppRegistry.h>
23 #include <FSysBattery.h>
26 #include "SecurityService.h"
27 #include "PrivilegeService.h"
28 #include "CertificateService.h"
29 #include "TrustZoneService.h"
31 using namespace Tizen::System;
32 using namespace Tizen::App;
33 using namespace Tizen::Base::Collection;
36 static SecurityService* __pSecurityService = null;
38 SecurityService::SecurityService(void)
39 : __pPrivilegeService(null)
40 , __pCertificateService(null)
45 SecurityService::~SecurityService(void)
51 SecurityService::CreateInstance(void)
57 if (__pSecurityService == null)
59 __pSecurityService = new (std::nothrow) SecurityService();
60 if (__pSecurityService == null)
62 AppLogException("[E_OUT_OF_MEMORY] The memory is insufficient.");
69 return __pSecurityService;
73 SecurityService::OnAppInitializing(AppRegistry& appRegistry)
80 __pPrivilegeService = new (std::nothrow) PrivilegeService();
81 TryCatchTag(OSP_SECURITY_SERVICE, __pPrivilegeService != null, r = E_OUT_OF_MEMORY; ret = false, "[E_OUT_OF_MEMORY] The memory is insufficient.");
83 r = __pPrivilegeService->Construct();
84 TryCatchTag(OSP_SECURITY_SERVICE, r == E_SUCCESS, r = E_SYSTEM; ret = false, "[E_SYSTEM] An unexpected system error occurred.");
86 __pCertificateService = new (std::nothrow) CertificateService(); //return true even if error occured
87 //because privilege must be running.
88 TryCatchTag(OSP_SECURITY_SERVICE, __pCertificateService != null, r = E_OUT_OF_MEMORY; ret = true, "[E_OUT_OF_MEMORY] The memory is insufficient.");
90 r = __pCertificateService->Construct();
91 TryCatchTag(OSP_SECURITY_SERVICE, r == E_SUCCESS, r = E_SYSTEM; ret = true, "[E_SYSTEM] An unexpected system error occurred.");
93 __pTrustZoneService = new (std::nothrow) TrustZoneService();
94 r = __pTrustZoneService->Construct();
95 TryCatchTag(OSP_SECURITY_SERVICE, r == E_SUCCESS, r = E_SYSTEM; ret = true, "[E_SYSTEM] An unexpected system error occurred.");
110 SecurityService::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
114 delete __pPrivilegeService;
115 delete __pCertificateService;
122 SecurityService::OnLowMemory(void)
128 SecurityService::OnBatteryLevelChanged(BatteryLevel batteryLevel)
134 SecurityService::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList *pArgs)