Add IClient::getName() for getting the package id (or the executable path) of a client
[platform/core/context/context-service.git] / src / server / Credential.h
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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 #ifndef __CONTEXT_CREDENTIAL_H__
18 #define __CONTEXT_CREDENTIAL_H__
19
20 #include <string>
21 #include <ContextTypes.h>
22
23 #define ROOT_UID        0
24
25 namespace ctx {
26
27         class Credential {
28         public:
29                 Credential(GDBusConnection* conn, const std::string& busName);
30                 ~Credential();
31
32                 bool valid() const;
33                 bool hasPrivilege(const char* privil) const;
34
35                 uid_t getUid() const;
36                 pid_t getPid() const;
37                 const std::string& getClientId() const;
38                 bool isSystem() const;
39
40                 static bool isSystemUid(uid_t uid);
41
42         private:
43                 pid_t __pid;
44                 uid_t __uid;
45                 std::string __clientId; /* Tizen-Default: Smack label */
46                 char* __session;
47                 char* __user;           /* Tizen-Default: UID */
48                 bool __valid;
49         };
50
51 }
52
53 #endif