signon  8.42
smack-access-control-manager.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of signon
3  *
4  * Copyright (C) 2011 Intel Corporation.
5  *
6  * Contact: Elena Reshetova <elena.reshetova@intel.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * version 2.1 as published by the Free Software Foundation.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA
21  */
22 
24 #include "debug.h"
25 
26 #include <DBusSmackContext>
27 #include <SmackQt>
28 
29 static const char keychainAppId[] = "SignondKeychain";
30 
32  SignOn::AbstractAccessControlManager(parent)
33 {
34 }
35 
37 {
38 }
39 
41 {
42  return QLatin1String(keychainAppId);
43 }
44 
46  const QDBusMessage &peerMessage,
47  const QString &securityContext)
48 {
49  QString appId =
50  SmackQt::DBusSmackContext::getCallerSmackContext(peerMessage);
51  TRACE() << appId << ":" << securityContext;
52 
53  if (SmackQt::Smack::hasAccess(appId, securityContext, QLatin1String("r")) ||
54  SmackQt::Smack::hasAccess(appId, securityContext, QLatin1String("x"))) {
55  TRACE() << "Process ACCESS:TRUE";
56  return true;
57  } else {
58  TRACE() << "Process ACCESS:FALSE";
59  return false;
60  }
61 }
62 
63 QString SmackAccessControlManager::appIdOfPeer(const QDBusMessage &peerMessage)
64 {
65  TRACE() << SmackQt::DBusSmackContext::getCallerSmackContext(peerMessage);
66  return SmackQt::DBusSmackContext::getCallerSmackContext(peerMessage);
67 }
68