2009-09-02 04:21:41 +02:00
|
|
|
/*
|
|
|
|
* Copyright © 2009 Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "serviceprovider_p.h"
|
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
#include "authorizationrule_p.h"
|
|
|
|
#include "authorizationmanager_p.h"
|
|
|
|
#include "joliemessagehelper_p.h"
|
|
|
|
|
2009-09-09 23:54:31 +02:00
|
|
|
#include "config-plasma.h"
|
|
|
|
|
2009-09-03 23:10:33 +02:00
|
|
|
#include <plasma/remote/authorizationinterface.h>
|
|
|
|
#include <plasma/remote/authorizationmanager.h>
|
|
|
|
#include <plasma/remote/authorizationrule.h>
|
|
|
|
#include <plasma/remote/credentials.h>
|
2009-09-02 04:27:16 +02:00
|
|
|
#include <plasma/service.h>
|
|
|
|
#include <plasma/servicejob.h>
|
|
|
|
#include <plasma/private/servicejob_p.h>
|
|
|
|
|
|
|
|
#include <QtCore/QBuffer>
|
|
|
|
#include <QtCore/QFile>
|
|
|
|
|
|
|
|
#include <QtJolie/Server>
|
|
|
|
|
2009-09-09 23:54:31 +02:00
|
|
|
#ifdef ENABLE_REMOTE_WIDGETS
|
|
|
|
#include <QtCrypto>
|
|
|
|
#endif
|
|
|
|
|
2009-09-02 08:28:32 +02:00
|
|
|
#include <kdebug.h>
|
|
|
|
#include <kstandarddirs.h>
|
2009-09-02 04:27:16 +02:00
|
|
|
|
2009-09-02 04:21:41 +02:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
ServiceProvider::ServiceProvider(const QString &name, Service *service)
|
|
|
|
: Jolie::AbstractAdaptor(service),
|
|
|
|
m_service(service)
|
|
|
|
{
|
|
|
|
connect(service, SIGNAL(finished(Plasma::ServiceJob *)),
|
|
|
|
this, SLOT(operationCompleted(Plasma::ServiceJob*)));
|
|
|
|
|
|
|
|
m_providerName = name;
|
|
|
|
AuthorizationManager::self()->d->server->registerAdaptor(m_providerName.toUtf8(), this);
|
|
|
|
kDebug() << "registered service provider " << m_providerName;
|
|
|
|
}
|
|
|
|
|
|
|
|
ServiceProvider::~ServiceProvider()
|
|
|
|
{
|
|
|
|
AuthorizationManager::self()->d->server->unregisterAdaptor(m_providerName.toUtf8());
|
|
|
|
}
|
|
|
|
|
|
|
|
void ServiceProvider::startOperationCall(Jolie::Message message)
|
|
|
|
{
|
|
|
|
kDebug() << "starting operation call";
|
|
|
|
|
|
|
|
KConfigGroup description =
|
|
|
|
m_service->operationDescription(QString(Message::field(Message::Field::OPERATION, message)));
|
|
|
|
|
|
|
|
//deserialize the parameters
|
|
|
|
QByteArray parametersByteArray;
|
|
|
|
parametersByteArray = Message::field(Message::Field::PARAMETERS, message);
|
|
|
|
kDebug() << "parameters byte array: " << parametersByteArray.toBase64();
|
|
|
|
QBuffer buffer(¶metersByteArray);
|
|
|
|
buffer.open(QIODevice::ReadOnly);
|
|
|
|
QDataStream in(&buffer);
|
|
|
|
QMap<QString, QVariant> parameters;
|
|
|
|
in >> parameters;
|
|
|
|
|
|
|
|
if (!description.isValid()) {
|
|
|
|
kDebug() << "invalid description.";
|
|
|
|
}
|
|
|
|
|
|
|
|
kDebug() << "====PARAMETERS====";
|
|
|
|
|
|
|
|
//write the parameters into the operation description
|
|
|
|
foreach (const QString &key, parameters.keys()) {
|
|
|
|
kDebug() << "key = " << key << ", value = " << parameters.value(key);
|
|
|
|
description.writeEntry(key, parameters.value(key));
|
|
|
|
}
|
|
|
|
|
|
|
|
m_service->setDestination(Message::field(Message::Field::DESTINATION, message));
|
|
|
|
ServiceJob *job = m_service->startOperationCall(description);
|
|
|
|
QString identityID = Message::field(Message::Field::IDENTITYID, message);
|
|
|
|
job->d->identity = AuthorizationManager::self()->d->getCredentials(identityID);
|
|
|
|
kDebug() << "adding into messagemap:" << ((QObject*)job);
|
|
|
|
m_messageMap[job] = message;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ServiceProvider::sendOperations(Jolie::Message message)
|
|
|
|
{
|
|
|
|
kDebug() << "send operations.";
|
|
|
|
//kDebug() << printJolieMessage(message);
|
|
|
|
Jolie::Message response(message.resourcePath(), message.operationName(), message.id());
|
|
|
|
|
|
|
|
//FIXME: this is duplicated from Plasma::Service
|
|
|
|
QString path = KStandardDirs::locate("data", "plasma/services/" + m_service->name() +
|
|
|
|
".operations");
|
|
|
|
|
|
|
|
if (path.isEmpty()) {
|
|
|
|
kDebug() << "Cannot find operations description:" << m_service->name() << ".operations";
|
|
|
|
response.setFault(Jolie::Fault("NoOperationsDescription"));
|
|
|
|
} else {
|
|
|
|
kDebug() << "file = " << path;
|
|
|
|
QFile file(path);
|
|
|
|
file.open(QIODevice::ReadOnly);
|
|
|
|
Jolie::Value value;
|
|
|
|
value.children(Message::Field::OPERATIONSDESCRIPTION) << Jolie::Value(file.readAll());
|
|
|
|
file.close();
|
|
|
|
response.setData(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray id = Message::field(Message::Field::IDENTITYID, message);
|
|
|
|
QByteArray uuid = Message::field(Message::Field::UUID, message);
|
|
|
|
response = appendToken(response, id, uuid);
|
|
|
|
kDebug() << "caller = " << id.toBase64();
|
|
|
|
|
|
|
|
//hack around the not yet async service adaptor api in qtjolie
|
|
|
|
if (m_descriptorMap.contains(id + uuid)) {
|
|
|
|
kDebug() << "descriptor found, sending message";
|
2009-09-15 13:12:45 +02:00
|
|
|
AuthorizationManager::self()->d->server->sendReply(
|
2009-09-02 04:27:16 +02:00
|
|
|
m_descriptorMap.value(id + uuid), response);
|
|
|
|
} else {
|
|
|
|
kDebug() << "no valid entry in descriptormap.";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ServiceProvider::sendEnabledOperations(Jolie::Message message)
|
|
|
|
{
|
|
|
|
kDebug() << "send enabled operations.";
|
|
|
|
Jolie::Message response(message.resourcePath(), message.operationName(), message.id());
|
|
|
|
|
|
|
|
QStringList enabledOperationsList;
|
|
|
|
foreach (const QString &operation, m_service->operationNames()) {
|
|
|
|
if (m_service->isOperationEnabled(operation)) {
|
|
|
|
enabledOperationsList << operation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
kDebug() << "enabled operations: " << enabledOperationsList;
|
|
|
|
|
|
|
|
QByteArray enabledOperationsArray;
|
|
|
|
QDataStream out(&enabledOperationsArray, QIODevice::WriteOnly);
|
|
|
|
out << enabledOperationsList;
|
|
|
|
|
|
|
|
Jolie::Value value;
|
|
|
|
value.children(Message::Field::ENABLEDOPERATIONS) << Jolie::Value(enabledOperationsArray);
|
|
|
|
response.setData(value);
|
|
|
|
|
|
|
|
QByteArray id = Message::field(Message::Field::IDENTITYID, message);
|
|
|
|
QByteArray uuid = Message::field(Message::Field::UUID, message);
|
|
|
|
response = appendToken(response, id, uuid);
|
|
|
|
kDebug() << "caller = " << id.toBase64();
|
|
|
|
|
|
|
|
//hack around the not yet async service adaptor api in qtjolie
|
|
|
|
if (m_descriptorMap.contains(id + uuid)) {
|
|
|
|
kDebug() << "descriptor found, sending message";
|
2009-09-15 13:12:45 +02:00
|
|
|
AuthorizationManager::self()->d->server->sendReply(
|
2009-09-02 04:27:16 +02:00
|
|
|
m_descriptorMap.value(id + uuid), response);
|
|
|
|
} else {
|
|
|
|
kDebug() << "no valid entry in descriptormap.";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ServiceProvider::resourceName() const
|
2009-09-02 04:21:41 +02:00
|
|
|
{
|
2009-09-02 04:27:16 +02:00
|
|
|
return m_providerName;
|
2009-09-02 04:21:41 +02:00
|
|
|
}
|
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
void ServiceProvider::relay(Jolie::Server *server, int descriptor,
|
|
|
|
const Jolie::Message &message)
|
2009-09-02 04:21:41 +02:00
|
|
|
{
|
2009-09-02 04:27:16 +02:00
|
|
|
Q_UNUSED(server)
|
|
|
|
|
|
|
|
if (message.operationName() == "startConnection") {
|
|
|
|
kDebug() << "reset token";
|
|
|
|
//add the identity
|
|
|
|
Credentials identity;
|
|
|
|
QByteArray identityByteArray = Message::field(Message::Field::IDENTITY, message);
|
|
|
|
QDataStream stream(&identityByteArray, QIODevice::ReadOnly);
|
|
|
|
stream >> identity;
|
|
|
|
AuthorizationManager::self()->d->addCredentials(identity);
|
|
|
|
|
|
|
|
Jolie::Message response(message.resourcePath(), message.operationName(), message.id());
|
|
|
|
QByteArray uuid = Message::field(Message::Field::UUID, message);
|
|
|
|
response = appendToken(response, identity.id().toAscii(), uuid);
|
2009-09-15 13:12:45 +02:00
|
|
|
AuthorizationManager::self()->d->server->sendReply(descriptor, response);
|
2009-09-02 04:27:16 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Message::field(Message::Field::TOKEN, message).isEmpty()) {
|
|
|
|
Jolie::Message response(message.resourcePath(), message.operationName(), message.id());
|
|
|
|
response.setFault(Jolie::Fault(Message::Error::INVALIDTOKEN));
|
2009-09-15 13:12:45 +02:00
|
|
|
AuthorizationManager::self()->d->server->sendReply(descriptor, response);
|
2009-09-02 04:27:16 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//m_descriptor = descriptor;
|
|
|
|
QByteArray id = Message::field(Message::Field::IDENTITYID, message);
|
|
|
|
QByteArray uuid = Message::field(Message::Field::UUID, message);
|
|
|
|
m_descriptorMap[id + uuid] = descriptor;
|
|
|
|
authorize(message, m_tokens[id + uuid]);
|
2009-09-02 04:21:41 +02:00
|
|
|
}
|
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
void ServiceProvider::operationCompleted(Plasma::ServiceJob *job)
|
2009-09-02 04:21:41 +02:00
|
|
|
{
|
2009-09-02 04:27:16 +02:00
|
|
|
kDebug() << "operation completed.";
|
|
|
|
if (!m_messageMap.contains(job)) {
|
|
|
|
kDebug() << "service not in map!";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
kDebug() << "found message in message map!";
|
|
|
|
|
|
|
|
Jolie::Message message = m_messageMap.take(job);
|
|
|
|
Jolie::Message response(message.resourcePath(), message.operationName(), message.id());
|
|
|
|
|
|
|
|
QVariant variantResult = job->result();
|
|
|
|
kDebug() << "got a result: " << variantResult;
|
|
|
|
QByteArray byteArrayResult;
|
|
|
|
QBuffer buffer(&byteArrayResult);
|
|
|
|
buffer.open(QIODevice::WriteOnly);
|
|
|
|
QDataStream out(&buffer);
|
|
|
|
out << variantResult;
|
|
|
|
|
|
|
|
Jolie::Value data;
|
|
|
|
data.children(Message::Field::RESULT) << Jolie::Value(byteArrayResult);
|
|
|
|
response.setData(data);
|
|
|
|
if (job->error()) {
|
|
|
|
response.setFault(Jolie::Fault(job->errorString().toAscii()));
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray id = Message::field(Message::Field::IDENTITYID, message);
|
|
|
|
QByteArray uuid = Message::field(Message::Field::UUID, message);
|
|
|
|
response = appendToken(response, id, uuid);
|
|
|
|
|
|
|
|
//hack around the not yet async service adaptor api in qtjolie
|
|
|
|
if (m_descriptorMap.contains(id + uuid)) {
|
|
|
|
kDebug() << "descriptor found, sending message";
|
2009-09-15 13:12:45 +02:00
|
|
|
AuthorizationManager::self()->d->server->sendReply(
|
2009-09-02 04:27:16 +02:00
|
|
|
m_descriptorMap.value(id + uuid), response);
|
|
|
|
} else {
|
|
|
|
kDebug() << "no valid entry in descriptormap.";
|
2009-09-02 04:21:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
void ServiceProvider::ruleChanged(Plasma::AuthorizationRule *rule)
|
2009-09-02 04:21:41 +02:00
|
|
|
{
|
2009-09-02 04:27:16 +02:00
|
|
|
int i = 0;
|
|
|
|
foreach (Jolie::Message message, m_messagesPendingAuthorization) {
|
|
|
|
QByteArray id = Message::field(Message::Field::IDENTITYID, message);
|
|
|
|
//Credentials identity = AuthorizationManager::self()->d->getCredentials(id);
|
|
|
|
|
|
|
|
bool matches = rule->d->matches(message.resourcePath(), id);
|
|
|
|
if (matches && rule->policy() == AuthorizationRule::PinRequired &&
|
|
|
|
Message::field(Message::Field::PIN, message) != rule->pin()) {
|
|
|
|
kDebug() << "we need a pin";
|
|
|
|
authorizationFailed(message, Message::Error::REQUIREPIN);
|
|
|
|
m_messagesPendingAuthorization.removeAt(i);
|
|
|
|
return;
|
2009-09-03 01:49:58 +02:00
|
|
|
/**
|
2009-09-02 04:27:16 +02:00
|
|
|
} else if (matches && rule->policy() == AuthorizationRule::PinRequired) {
|
|
|
|
kDebug() << "AUTHORIZATION: Service is freely accessable for verified caller.";
|
|
|
|
rule->setPolicy(AuthorizationRule::Allow);
|
|
|
|
authorizationSuccess(message);
|
|
|
|
//TODO: it might be nicer to do a removeAll once Jolie::Message implements ==
|
|
|
|
m_messagesPendingAuthorization.removeAt(i);
|
|
|
|
return;
|
2009-09-03 01:49:58 +02:00
|
|
|
*/
|
2009-09-02 04:27:16 +02:00
|
|
|
} else if (matches && rule->policy() == AuthorizationRule::Allow) {
|
|
|
|
kDebug() << "AUTHORIZATION: Service is freely accessable for verified caller.";
|
|
|
|
authorizationSuccess(message);
|
|
|
|
//TODO: it might be nicer to do a removeAll once Jolie::Message implements ==
|
|
|
|
m_messagesPendingAuthorization.removeAt(i);
|
|
|
|
return;
|
|
|
|
} else if (matches && rule->policy() == AuthorizationRule::Deny) {
|
|
|
|
kDebug() << "AUTHORIZATION: Service is never accessable for verified caller.";
|
|
|
|
authorizationFailed(message, Message::Error::ACCESSDENIED);
|
|
|
|
m_messagesPendingAuthorization.removeAt(i);
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
2009-09-02 04:21:41 +02:00
|
|
|
}
|
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
Jolie::Message ServiceProvider::appendToken(Jolie::Message message,
|
|
|
|
const QByteArray &caller,
|
|
|
|
const QByteArray &uuid)
|
2009-09-02 04:21:41 +02:00
|
|
|
{
|
2009-09-09 23:54:31 +02:00
|
|
|
#ifdef ENABLE_REMOTE_WIDGETS
|
2009-09-02 04:27:16 +02:00
|
|
|
m_tokens[caller + uuid] = QCA::Random::randomArray(256).toByteArray();
|
2009-09-09 23:54:31 +02:00
|
|
|
#endif
|
2009-09-02 04:27:16 +02:00
|
|
|
//kDebug() << "setting token: " << m_tokens[caller + uuid].toBase64()
|
|
|
|
//<< " for caller: " << caller.toBase64()
|
|
|
|
//<< " with uuid caller: " << uuid.toBase64();
|
|
|
|
|
|
|
|
Jolie::Value data = message.data();
|
|
|
|
data.children(Message::Field::TOKEN) << Jolie::Value(m_tokens[caller + uuid]);
|
|
|
|
message.setData(data);
|
|
|
|
return message;
|
2009-09-02 04:21:41 +02:00
|
|
|
}
|
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
|
|
|
|
void ServiceProvider::authorize(const Jolie::Message &message, const QByteArray &validToken)
|
2009-09-02 04:21:41 +02:00
|
|
|
{
|
2009-09-02 04:27:16 +02:00
|
|
|
kDebug() << "VALIDATING MESSAGE:";
|
|
|
|
//kDebug() << Message::print(message);
|
|
|
|
|
|
|
|
//Authorization step 1: is the service accessable to all callers? In that case we can skip the
|
|
|
|
//verification of the signature
|
|
|
|
kDebug() << "STEP1";
|
|
|
|
AuthorizationRule *rule =
|
|
|
|
AuthorizationManager::self()->d->matchingRule(message.resourcePath(), Credentials());
|
|
|
|
|
|
|
|
if (rule && rule->policy() == AuthorizationRule::Allow) {
|
|
|
|
kDebug() << "AUTHORIZATION: Service is freely accessable.";
|
|
|
|
authorizationSuccess(message);
|
|
|
|
return;
|
|
|
|
} else if (rule && rule->policy() == AuthorizationRule::Deny) {
|
|
|
|
kDebug() << "AUTHORIZATION: Service is never accessable.";
|
|
|
|
authorizationFailed(message, Message::Error::ACCESSDENIED);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Authorization step 2: see if the token matches. If it doesn't we can't safely identify the
|
|
|
|
//caller and are finished.
|
|
|
|
kDebug() << "STEP2";
|
|
|
|
if (Message::field(Message::Field::TOKEN, message) != validToken && !validToken.isEmpty()) {
|
|
|
|
kDebug() << "AUTHORIZATION: Message token doesn't match.";
|
|
|
|
kDebug() << "expected: " << validToken.toBase64();
|
|
|
|
authorizationFailed(message, Message::Error::INVALIDTOKEN);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray payload = Message::payload(message);
|
|
|
|
QByteArray signature = Message::field(Message::Field::SIGNATURE, message);
|
|
|
|
Credentials identity = AuthorizationManager::self()->d->getCredentials(
|
|
|
|
Message::field(Message::Field::IDENTITYID, message));
|
|
|
|
|
|
|
|
if (!identity.isValid()) {
|
|
|
|
kDebug() << "no identity";
|
|
|
|
authorizationFailed(message, Message::Error::INVALIDTOKEN);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
kDebug() << "STEP3";
|
|
|
|
//Authorization step 3: see if we have the key and can validate the signature. If we can't,
|
|
|
|
//either the public key has changed, or somebody is doing something nasty, and we're finished.
|
|
|
|
if ((!identity.isValidSignature(signature, payload))) {
|
|
|
|
kDebug() << "AUTHORIZATION: signature invalid.";
|
|
|
|
authorizationFailed(message, Message::Error::ACCESSDENIED);
|
2009-09-02 04:21:41 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
kDebug() << "STEP4";
|
|
|
|
//Authorization step 4: if we have a valid signature, see if we've got a matching rule
|
|
|
|
rule = AuthorizationManager::self()->d->matchingRule(message.resourcePath(), identity);
|
|
|
|
if (rule && rule->policy() == AuthorizationRule::PinRequired) {
|
|
|
|
kDebug() << "we expect a pin!";
|
|
|
|
QByteArray pin = Message::field(Message::Field::PIN, message);
|
|
|
|
if (rule->pin() == QString(pin)) {
|
|
|
|
authorizationSuccess(message);
|
|
|
|
rule->setPolicy(AuthorizationRule::Allow);
|
|
|
|
} else {
|
|
|
|
authorizationFailed(message, Message::Error::ACCESSDENIED);
|
|
|
|
AuthorizationManager::self()->d->rules.removeAll(rule);
|
|
|
|
delete rule;
|
|
|
|
}
|
|
|
|
} else if (rule && rule->policy() == AuthorizationRule::Allow) {
|
|
|
|
kDebug() << "AUTHORIZATION: Service is freely accessable for validated sender.";
|
|
|
|
authorizationSuccess(message);
|
|
|
|
return;
|
|
|
|
} else if (rule && rule->policy() == AuthorizationRule::Deny) {
|
|
|
|
kDebug() << "AUTHORIZATION: Service is not accessable for validated sender.";
|
|
|
|
authorizationFailed(message, Message::Error::ACCESSDENIED);
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
//- let the shell set the rule matching this request:
|
|
|
|
kDebug() << "STEP6";
|
|
|
|
kDebug() << "leave it up to the authorization interface";
|
|
|
|
m_messagesPendingAuthorization << message;
|
|
|
|
AuthorizationRule *newRule =
|
|
|
|
new AuthorizationRule(QString(message.resourcePath()), identity.id());
|
|
|
|
connect(newRule, SIGNAL(changed(Plasma::AuthorizationRule*)), this,
|
|
|
|
SLOT(ruleChanged(Plasma::AuthorizationRule*)));
|
|
|
|
AuthorizationManager::self()->d->rules.append(newRule);
|
|
|
|
AuthorizationManager::self()->d->authorizationInterface->authorizationRequest(*newRule);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ServiceProvider::authorizationSuccess(const Jolie::Message &message)
|
|
|
|
{
|
|
|
|
kDebug() << "message with operationName " << message.operationName() << " allowed!";
|
|
|
|
|
|
|
|
//would be lovely if this kind of stuff could be autogenerated code from xml like in dbus
|
|
|
|
//adaptors
|
|
|
|
if (message.operationName() == "getOperations") {
|
|
|
|
sendOperations(message);
|
|
|
|
} else if (message.operationName() == "getEnabledOperations") {
|
|
|
|
sendEnabledOperations(message);
|
2009-09-02 04:21:41 +02:00
|
|
|
} else if (message.operationName() == "startOperationCall") {
|
|
|
|
startOperationCall(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
void ServiceProvider::authorizationFailed(const Jolie::Message &message, const QByteArray &error)
|
2009-09-02 04:21:41 +02:00
|
|
|
{
|
2009-09-02 04:27:16 +02:00
|
|
|
kDebug() << "message with operationName " << message.operationName() << " NOT allowed!";
|
|
|
|
Jolie::Message response(message.resourcePath(), message.operationName(), message.id());
|
|
|
|
response.setFault(Jolie::Fault(error));
|
|
|
|
|
|
|
|
QByteArray id = Message::field(Message::Field::IDENTITYID, message);
|
|
|
|
QByteArray uuid = Message::field(Message::Field::UUID, message);
|
2009-09-15 13:12:45 +02:00
|
|
|
AuthorizationManager::self()->d->server->sendReply(
|
2009-09-02 04:27:16 +02:00
|
|
|
m_descriptorMap.value(id + uuid), response);
|
|
|
|
return;
|
2009-09-02 04:21:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} //namespace Plasma
|
|
|
|
|
|
|
|
#include "serviceprovider_p.moc"
|