Add the check routine of certificate
[platform/framework/native/channel-service.git] / inc / FIo_MessagePortService.h
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        FIo_MessagePortService.h
20  * @brief       This is the header file for the _MessagePortService class.
21  *
22  * This file contains the declarations of _MessagePortService.
23  */
24
25 #ifndef _FIO_INTERNAL_MESSAGE_PORT_SERVICE_H_
26 #define _FIO_INTERNAL_MESSAGE_PORT_SERVICE_H_
27
28 #include <message-port-data-types.h>
29
30 #include <FBaseResult.h>
31 #include <FBaseString.h>
32 #include <FBaseColHashMap.h>
33 #include <FBaseColHashMapT.h>
34 #include <FAppTypes.h>
35
36 namespace IPC
37 {
38 class Message;
39 }
40
41 class _MessagePortStub;
42
43 class _MessagePortService
44 {
45 public:
46         _MessagePortService(void);
47
48         virtual ~_MessagePortService(void);
49
50         virtual result Construct(_MessagePortStub& stub);
51
52         virtual int RegisterMessagePort(int clientId, const BundleBuffer& buffer);
53
54         virtual int CheckRemotePort(const BundleBuffer& buffer);
55
56         result UnregisterMessagePort(int clientId);
57
58         virtual int SendMessage(const BundleBuffer& buffer);
59
60 private:
61         Tizen::Base::String GetKey(const BundleBuffer& buffer, bool local = true) const;
62
63         bool IsPreloaded(const Tizen::Base::String& localAppId, const Tizen::Base::String& remoteAppId) const;
64
65         int CheckCertificate(const Tizen::Base::String& localAppId, const Tizen::Base::String& remoteAppId) const;
66
67         class _StringHashProvider
68                 : public Tizen::Base::Collection::IHashCodeProviderT<Tizen::Base::String>
69         {
70         public:
71                 virtual int GetHashCode(const Tizen::Base::String& value) const
72                 {
73                         return value.GetHashCode();
74                 }
75         };
76
77         class _StringComparer
78                 : public Tizen::Base::Collection::IComparerT<Tizen::Base::String>
79         {
80         public:
81                 virtual result Compare(const Tizen::Base::String& string1, const Tizen::Base::String& string2, int& cmp) const
82                 {
83                         cmp = string1.CompareTo(string2);
84                         return E_SUCCESS;
85                 }
86         };
87
88 private:
89         _MessagePortStub* __pStub;
90
91         Tizen::Base::Collection::HashMapT <Tizen::Base::String, int>* __pPorts;
92         Tizen::Base::Collection::HashMapT <Tizen::Base::String, int>* __pTrustedPorts;
93 }; // _MessagePortService
94
95 #endif // _FIO_INTERNAL_MESSAGE_PORT_SERVICE_H_