|
signon
8.40
|
00001 /* 00002 * This file is part of signon 00003 * 00004 * Copyright (C) 2011 Intel Corporation. 00005 * 00006 * Contact: Elena Reshetova <elena.reshetova@intel.com> 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public License 00010 * version 2.1 as published by the Free Software Foundation. 00011 * 00012 * This library is distributed in the hope that it will be useful, but 00013 * WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00020 * 02110-1301 USA 00021 */ 00022 00023 #include <DBusContextAccessManager> 00024 #include <QStringList> 00025 00026 #include "mssf-access-control-manager.h" 00027 #include "debug.h" 00028 00029 #define SSO_AEGIS_PACKAGE_ID_TOKEN_PREFIX QLatin1String("AID::") 00030 00031 static const char keychainAppId[] = "signond::keychain-access"; 00032 00033 MSSFAccessControlManager::MSSFAccessControlManager(QObject *parent): 00034 SignOn::AbstractAccessControlManager(parent) 00035 { 00036 } 00037 00038 MSSFAccessControlManager::~MSSFAccessControlManager() 00039 { 00040 } 00041 00042 QString MSSFAccessControlManager::keychainWidgetAppId() 00043 { 00044 return QLatin1String(keychainAppId); 00045 } 00046 00047 bool MSSFAccessControlManager::isPeerAllowedToAccess( 00048 const QDBusMessage &peerMessage, 00049 const QString &securityContext) 00050 { 00051 bool hasAccess = false; 00052 QStringList Credlist = 00053 MssfQt::DBusContextAccessManager::peerCredentials(peerMessage, NULL); 00054 foreach(QString cred, Credlist) { 00055 if (cred.compare(securityContext) == 0) { 00056 hasAccess = true; 00057 break; 00058 } 00059 } 00060 TRACE() << "Process ACCESS:" << (hasAccess ? "TRUE" : "FALSE"); 00061 return hasAccess; 00062 } 00063 00064 QString MSSFAccessControlManager::appIdOfPeer(const QDBusMessage &peerMessage) 00065 { 00066 QStringList Credlist = 00067 MssfQt::DBusContextAccessManager::peerCredentials(peerMessage, NULL); 00068 foreach(QString cred, Credlist) { 00069 if (cred.startsWith(SSO_AEGIS_PACKAGE_ID_TOKEN_PREFIX)) 00070 return cred; 00071 } 00072 00073 return QString(); 00074 } 00075