|
signon
8.40
|
00001 /* 00002 * This file is part of signon 00003 * 00004 * Copyright (C) 2009-2010 Nokia Corporation. 00005 * Copyright (C) 2011 Intel Corporation. 00006 * 00007 * Contact: Aurel Popirtac <ext-aurel.popirtac@nokia.com> 00008 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> 00009 * Contact: Jussi Laako <jussi.laako@linux.intel.com> 00010 * 00011 * This library is free software; you can redistribute it and/or 00012 * modify it under the terms of the GNU Lesser General Public License 00013 * version 2.1 as published by the Free Software Foundation. 00014 * 00015 * This library is distributed in the hope that it will be useful, but 00016 * WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public 00021 * License along with this library; if not, write to the Free Software 00022 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00023 * 02110-1301 USA 00024 */ 00025 00026 #include "signondaemonadaptor.h" 00027 #include "signondisposable.h" 00028 #include "accesscontrolmanagerhelper.h" 00029 00030 namespace SignonDaemonNS { 00031 00032 SignonDaemonAdaptor::SignonDaemonAdaptor(SignonDaemon *parent): 00033 QDBusAbstractAdaptor(parent), 00034 m_parent(parent) 00035 { 00036 setAutoRelaySignals(false); 00037 } 00038 00039 SignonDaemonAdaptor::~SignonDaemonAdaptor() 00040 { 00041 } 00042 00043 void SignonDaemonAdaptor::registerNewIdentity(QDBusObjectPath &objectPath) 00044 { 00045 m_parent->registerNewIdentity(objectPath); 00046 00047 SignonDisposable::destroyUnused(); 00048 } 00049 00050 void SignonDaemonAdaptor::securityErrorReply(const char *failedMethodName) 00051 { 00052 QString errMsg; 00053 QTextStream(&errMsg) << SIGNOND_PERMISSION_DENIED_ERR_STR 00054 << "Method:" 00055 << failedMethodName; 00056 00057 QDBusMessage msg = parentDBusContext().message(); 00058 msg.setDelayedReply(true); 00059 QDBusMessage errReply = 00060 msg.createErrorReply(SIGNOND_PERMISSION_DENIED_ERR_NAME, 00061 errMsg); 00062 SIGNOND_BUS.send(errReply); 00063 TRACE() << "Method FAILED Access Control check:" << failedMethodName; 00064 } 00065 00066 void SignonDaemonAdaptor::getIdentity(const quint32 id, 00067 QDBusObjectPath &objectPath, 00068 QVariantMap &identityData) 00069 { 00070 if (!AccessControlManagerHelper::instance()->isPeerAllowedToUseIdentity( 00071 parentDBusContext().message(), id)) { 00072 securityErrorReply(__func__); 00073 return; 00074 } 00075 00076 m_parent->getIdentity(id, objectPath, identityData); 00077 00078 SignonDisposable::destroyUnused(); 00079 } 00080 00081 QStringList SignonDaemonAdaptor::queryMethods() 00082 { 00083 return m_parent->queryMethods(); 00084 } 00085 00086 QString SignonDaemonAdaptor::getAuthSessionObjectPath(const quint32 id, 00087 const QString &type) 00088 { 00089 SignonDisposable::destroyUnused(); 00090 00091 /* Access Control */ 00092 if (id != SIGNOND_NEW_IDENTITY) { 00093 if (!AccessControlManagerHelper::instance()->isPeerAllowedToUseAuthSession( 00094 parentDBusContext().message(), id)) { 00095 securityErrorReply(__func__); 00096 return QString(); 00097 } 00098 } 00099 00100 TRACE() << "ACM passed, creating AuthSession object"; 00101 return m_parent->getAuthSessionObjectPath(id, type); 00102 } 00103 00104 QStringList SignonDaemonAdaptor::queryMechanisms(const QString &method) 00105 { 00106 return m_parent->queryMechanisms(method); 00107 } 00108 00109 void SignonDaemonAdaptor::queryIdentities(const QVariantMap &filter) 00110 { 00111 /* Access Control */ 00112 if (!AccessControlManagerHelper::instance()->isPeerKeychainWidget( 00113 parentDBusContext().message())) { 00114 securityErrorReply(__func__); 00115 return; 00116 } 00117 00118 QDBusMessage msg = parentDBusContext().message(); 00119 msg.setDelayedReply(true); 00120 MapList identities = m_parent->queryIdentities(filter); 00121 QDBusMessage reply = msg.createReply(QVariant::fromValue(identities)); 00122 SIGNOND_BUS.send(reply); 00123 } 00124 00125 bool SignonDaemonAdaptor::clear() 00126 { 00127 /* Access Control */ 00128 if (!AccessControlManagerHelper::instance()->isPeerKeychainWidget( 00129 parentDBusContext().message())) { 00130 securityErrorReply(__func__); 00131 return false; 00132 } 00133 00134 return m_parent->clear(); 00135 } 00136 00137 } //namespace SignonDaemonNS