signon  8.42
mssf-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 
23 #include <DBusContextAccessManager>
24 #include <QStringList>
25 
27 #include "debug.h"
28 
29 #define SSO_AEGIS_PACKAGE_ID_TOKEN_PREFIX QLatin1String("AID::")
30 
31 static const char keychainAppId[] = "signond::keychain-access";
32 
34  SignOn::AbstractAccessControlManager(parent)
35 {
36 }
37 
39 {
40 }
41 
43 {
44  return QLatin1String(keychainAppId);
45 }
46 
48  const QDBusMessage &peerMessage,
49  const QString &securityContext)
50 {
51  bool hasAccess = false;
52  QStringList Credlist =
53  MssfQt::DBusContextAccessManager::peerCredentials(peerMessage, NULL);
54  foreach(QString cred, Credlist) {
55  if (cred.compare(securityContext) == 0) {
56  hasAccess = true;
57  break;
58  }
59  }
60  TRACE() << "Process ACCESS:" << (hasAccess ? "TRUE" : "FALSE");
61  return hasAccess;
62 }
63 
64 QString MSSFAccessControlManager::appIdOfPeer(const QDBusMessage &peerMessage)
65 {
66  QStringList Credlist =
67  MssfQt::DBusContextAccessManager::peerCredentials(peerMessage, NULL);
68  foreach(QString cred, Credlist) {
69  if (cred.startsWith(SSO_AEGIS_PACKAGE_ID_TOKEN_PREFIX))
70  return cred;
71  }
72 
73  return QString();
74 }
75