signon  8.58
accesscontrolmanagerhelper.h
Go to the documentation of this file.
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  * Copyright (C) 2013 Canonical Ltd.
00008  *
00009  * Contact: Aurel Popirtac <ext-Aurel.Popirtac@nokia.com>
00010  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
00011  * Contact: Elena Reshetova <elena.reshetova@intel.com>
00012  *
00013  * This library is free software; you can redistribute it and/or
00014  * modify it under the terms of the GNU Lesser General Public License
00015  * version 2.1 as published by the Free Software Foundation.
00016  *
00017  * This library is distributed in the hope that it will be useful, but
00018  * WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00020  * Lesser General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU Lesser General Public
00023  * License along with this library; if not, write to the Free Software
00024  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00025  * 02110-1301 USA
00026  */
00027 
00034 #ifndef ACCESSCONTROLMANAGERHELPER_H
00035 #define ACCESSCONTROLMANAGERHELPER_H
00036 
00037 #include <QDBusConnection>
00038 #include <QDBusContext>
00039 #include <QDBusMessage>
00040 
00041 #include "signonauthsession.h"
00042 #include "SignOn/abstract-access-control-manager.h"
00043 
00044 namespace SignonDaemonNS {
00045 
00051 class AccessControlManagerHelper
00052 {
00053 public:
00060     enum IdentityOwnership {
00061         ApplicationIsOwner = 0,
00062         ApplicationIsNotOwner,
00063         IdentityDoesNotHaveOwner
00064     };
00065 
00066     AccessControlManagerHelper(SignOn::AbstractAccessControlManager *acManager);
00067     ~AccessControlManagerHelper();
00068 
00073     static pid_t pidOfPeer(const QDBusContext &peerContext);
00074     static pid_t pidOfPeer(const QDBusConnection &peerConnection,
00075                            const QDBusMessage &peerMessage);
00076 
00077     /* creating an instance of a class */
00078     static AccessControlManagerHelper *instance();
00079 
00087     bool isPeerAllowedToUseIdentity(const QDBusConnection &peerConnection,
00088                                     const QDBusMessage &peerMessage,
00089                                     const quint32 identityId);
00090 
00101     IdentityOwnership isPeerOwnerOfIdentity(const QDBusConnection &peerConnection,
00102                                             const QDBusMessage &peerMessage,
00103                                             const quint32 identityId);
00104 
00114     bool isPeerAllowedToUseAuthSession(const QDBusConnection &peerConnection,
00115                                        const QDBusMessage &peerMessage,
00116                                        const SignonAuthSession &authSession)
00117     {
00118         return isPeerAllowedToUseIdentity(peerConnection, peerMessage,
00119                                           authSession.id());
00120     }
00121 
00131     bool isPeerAllowedToUseAuthSession(const QDBusConnection &peerConnection,
00132                                        const QDBusMessage &peerMessage,
00133                                        const quint32 ownerIdentityId)
00134     {
00135         return isPeerAllowedToUseIdentity(peerConnection, peerMessage,
00136                                           ownerIdentityId);
00137     }
00138 
00144     bool isPeerKeychainWidget(const QDBusConnection &peerConnection,
00145                               const QDBusMessage &peerMessage);
00146 
00154     QString appIdOfPeer(const QDBusConnection &peerConnection,
00155                         const QDBusMessage &peerMessage);
00156 
00167     bool isPeerAllowedToAccess(const QDBusConnection &peerConnection,
00168                                const QDBusMessage &peerMessage,
00169                                const QString securityContext);
00170 
00181     bool peerHasOneOfAccesses(const QDBusConnection &peerConnection,
00182                               const QDBusMessage &peerMessage,
00183                               const QStringList secContexts);
00184 
00185     SignOn::AccessReply *
00186         requestAccessToIdentity(const QDBusConnection &peerConnection,
00187                                 const QDBusMessage &peerMessage,
00188                                 quint32 id);
00189 
00190 private:
00191     SignOn::AbstractAccessControlManager *m_acManager;
00192     static AccessControlManagerHelper* m_pInstance;
00193 };
00194 
00195 } // namespace SignonDaemonNS
00196 
00197 #endif // ACCESSCONTROLMANAGER_H