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 PrivilegeService.cpp
19 * @brief This is the implementation file for PrivilegeService class.
22 #include <FIo_IpcServer.h>
23 #include <FIo_IIpcServerEventListener.h>
24 #include <FIo_IpcCommonDataTypes.h>
25 #include <FBaseSysLog.h>
26 #include <FSec_PrivilegeManagerServer.h>
27 #include <FSec_PrivilegeManagerMessage.h>
28 #include <FAppPkg_PackageInfoImpl.h>
30 #include "PrivilegeService.h"
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Runtime;
34 using namespace Tizen::App;
35 using namespace Tizen::App::Package;
36 using namespace Tizen::Io;
37 using namespace Tizen::Base::Collection;
38 using namespace Tizen::Security;
40 PrivilegeService::PrivilegeService(void)
46 PrivilegeService::~PrivilegeService(void)
48 AppLogTag(OSP_SECURITY_SERVICE, "Entered.");
53 AppLogTag(OSP_SECURITY_SERVICE, "Leaved.");
57 PrivilegeService::Construct(void)
61 AppLogTag(OSP_SECURITY_SERVICE, "Entered.");
63 __pIpcServer = new (std::nothrow) _IpcServer();
64 TryReturnResultTag(OSP_SECURITY_SERVICE, __pIpcServer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
66 r = __pIpcServer->Construct("osp.security.ipcserver.privilegemanager", *this, false);
67 TryReturnResultTag(OSP_SECURITY_SERVICE, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
69 AppLogTag(OSP_SECURITY_SERVICE, "Leaved.");
74 PrivilegeService::OnIpcServerStarted(const _IpcServer& server)
80 PrivilegeService::OnIpcServerStopped(const _IpcServer& server)
86 PrivilegeService::OnIpcClientConnected(const _IpcServer& server, int clientId)
92 PrivilegeService::OnIpcClientDisconnected(const _IpcServer&server, int clientId)
98 PrivilegeService::RetrievePrivilege(String* pEncryptedBitwise, String* pHmac, ArrayListT < String >* pPrivilegeList, result* pRes)
101 __pIpcServer->GetClientPackageId().SubString(0, MAX_APP_ID_SIZE, appId);
103 *pRes = _PrivilegeManagerServer::RetrievePrivilege(appId, pEncryptedBitwise, pHmac, pPrivilegeList);
109 PrivilegeService::RetrieveVisibility(String* pEncryptedVisibility, String* pHmac, result* pRes)
112 __pIpcServer->GetClientPackageId().SubString(0, MAX_APP_ID_SIZE, appId);
114 *pRes = _PrivilegeManagerServer::GenerateVisibilityString(appId, pEncryptedVisibility, pHmac);
120 PrivilegeService::OnIpcRequestReceived(_IpcServer& server, const IPC::Message& message)
122 IPC_BEGIN_MESSAGE_MAP(PrivilegeService, message)
123 IPC_MESSAGE_HANDLER_EX(PrivilegeManagerMsg_retrieve, &server, RetrievePrivilege)
124 IPC_MESSAGE_HANDLER_EX(PrivilegeManagerMsg_retrieveEx, &server, RetrieveVisibility)
125 IPC_END_MESSAGE_MAP()