|
signon
8.40
|
00001 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 00002 /* 00003 * This file is part of signon 00004 * 00005 * Copyright (C) 2009-2010 Nokia Corporation. 00006 * Copyright (C) 2011 Intel Corporation. 00007 * 00008 * Contact: Aurel Popirtac <ext-Aurel.Popirtac@nokia.com> 00009 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> 00010 * Contact: Elena Reshetova <elena.reshetova@intel.com> 00011 * 00012 * This library is free software; you can redistribute it and/or 00013 * modify it under the terms of the GNU Lesser General Public License 00014 * version 2.1 as published by the Free Software Foundation. 00015 * 00016 * This library is distributed in the hope that it will be useful, but 00017 * WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 * Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with this library; if not, write to the Free Software 00023 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00024 * 02110-1301 USA 00025 */ 00026 00033 #ifndef ACCESSCONTROLMANAGERHELPER_H 00034 #define ACCESSCONTROLMANAGERHELPER_H 00035 00036 #include <QIODevice> 00037 #include <QMap> 00038 #include <QDBusConnection> 00039 #include <QDBusContext> 00040 #include <QDBusMessage> 00041 00042 #include "signonauthsession.h" 00043 #include "SignOn/abstract-access-control-manager.h" 00044 00045 namespace SignonDaemonNS { 00046 00052 class AccessControlManagerHelper 00053 { 00054 public: 00061 enum IdentityOwnership { 00062 ApplicationIsOwner = 0, 00063 ApplicationIsNotOwner, 00064 IdentityDoesNotHaveOwner 00065 }; 00066 00067 AccessControlManagerHelper(SignOn::AbstractAccessControlManager *acManager); 00068 ~AccessControlManagerHelper(); 00069 00074 static pid_t pidOfPeer(const QDBusContext &peerContext); 00075 00076 /* creating an instance of a class */ 00077 static AccessControlManagerHelper *instance(); 00078 00085 bool isPeerAllowedToUseIdentity(const QDBusMessage &peerMessage, 00086 const quint32 identityId); 00087 00097 IdentityOwnership isPeerOwnerOfIdentity(const QDBusMessage &peerMessage, 00098 const quint32 identityId); 00099 00108 bool isPeerAllowedToUseAuthSession(const QDBusMessage &peerMessage, 00109 const SignonAuthSession &authSession) 00110 { 00111 return isPeerAllowedToUseIdentity(peerMessage, authSession.id()); 00112 } 00113 00122 bool isPeerAllowedToUseAuthSession(const QDBusMessage &peerMessage, 00123 const quint32 ownerIdentityId) 00124 { 00125 return isPeerAllowedToUseIdentity(peerMessage, ownerIdentityId); 00126 } 00127 00132 bool isPeerKeychainWidget(const QDBusMessage &peerMessage); 00133 00140 QString appIdOfPeer(const QDBusMessage &peerMessage); 00141 00151 bool isPeerAllowedToAccess(const QDBusMessage &peerMessage, 00152 const QString securityContext); 00153 00163 bool peerHasOneOfAccesses(const QDBusMessage &peerMessage, 00164 const QStringList secContexts); 00165 00166 private: 00167 SignOn::AbstractAccessControlManager *m_acManager; 00168 static AccessControlManagerHelper* m_pInstance; 00169 }; 00170 00171 } // namespace SignonDaemonNS 00172 00173 #endif // ACCESSCONTROLMANAGER_H