sessiondata.h
/*
* This file is part of signon
*
* Copyright (C) 2009-2010 Nokia Corporation.
* Copyright (C) 2012-2016 Canonical Ltd.
*
* Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef SESSIONDATA_H
#define SESSIONDATA_H
#include <QMap>
#include <QString>
#include <QStringList>
#include <QVariant>
#include <SignOn/libsignoncommon.h>
namespace SignOn {
#define SIGNON_SESSION_DECLARE_PROPERTY(type_, name_) \
void set##name_(const type_ &value ) { m_data.insert(QLatin1String(#name_), value); } \
type_ name_() const { return m_data.value(QLatin1String(#name_)).value<type_>(); }
#define SSO_ACCESS_CONTROL_TOKENS QLatin1String("AccessControlTokens")
enum SignonUiPolicy {
DefaultPolicy = 0,
RequestPasswordPolicy,
NoUserInteractionPolicy,
ValidationPolicy,
};
class SIGNON_EXPORT SessionData
{
public:
SessionData(const QVariantMap &data = QVariantMap()) { m_data = data; }
SessionData(const SessionData &other) { m_data = other.m_data; }
SessionData &operator=(const SessionData &other) {
m_data = other.m_data;
return *this;
}
SessionData &operator+=(const SessionData &other) {
for (auto it = other.m_data.constBegin(), itEnd = other.m_data.constEnd(); it != itEnd; ++it) {
m_data[it.key()] = it.value();
}
return *this;
}
const QStringList propertyNames() const {
return m_data.keys();
}
const QVariant getProperty(const QString &propertyName) const {
return m_data.value(propertyName, QVariant());
}
QStringList getAccessControlTokens() const {
return getProperty(SSO_ACCESS_CONTROL_TOKENS).toStringList();
}
template <class T> T data() const {
T dataImpl;
dataImpl.m_data = m_data;
return dataImpl;
}
QVariantMap toMap() const { return m_data; }
SIGNON_SESSION_DECLARE_PROPERTY(QString, Secret)
SIGNON_SESSION_DECLARE_PROPERTY(QString, UserName)
SIGNON_SESSION_DECLARE_PROPERTY(QString, Realm)
SIGNON_SESSION_DECLARE_PROPERTY(QString, NetworkProxy)
SIGNON_SESSION_DECLARE_PROPERTY(int, UiPolicy)
SIGNON_SESSION_DECLARE_PROPERTY(QString, Caption)
SIGNON_SESSION_DECLARE_PROPERTY(quint32, NetworkTimeout)
SIGNON_SESSION_DECLARE_PROPERTY(quint32, WindowId)
SIGNON_SESSION_DECLARE_PROPERTY(bool, RenewToken)
protected:
QVariantMap m_data;
};
} //namespace SignOn
Q_DECLARE_METATYPE(SignOn::SessionData)
#endif // SESSIONDATA_H
SignOn::SessionData
Data container to hold values for authentication session.
Definition: sessiondata.h:92
SignOn::SessionData::data
T data() const
Creates an instance of type T, which must be derived from SessionData.
Definition: sessiondata.h:161
SignOn::SessionData::operator=
SessionData & operator=(const SessionData &other)
Assignment operator.
Definition: sessiondata.h:113
SignOn::SessionData::getProperty
const QVariant getProperty(const QString &propertyName) const
Access the list of runtime existing properties of the SessionData.
Definition: sessiondata.h:144
SignOn::SessionData::getAccessControlTokens
QStringList getAccessControlTokens() const
Gets the access control tokens that the requesting application has.
Definition: sessiondata.h:152
SignOn::SessionData::SessionData
SessionData(const SessionData &other)
Copy constructor.
Definition: sessiondata.h:106
SignOn::SessionData::propertyNames
const QStringList propertyNames() const
Access the list of runtime existing properties of the SessionData.
Definition: sessiondata.h:134
SignOn::SessionData::operator+=
SessionData & operator+=(const SessionData &other)
Addition operator.
Definition: sessiondata.h:123
SignOn::SessionData::m_data
QVariantMap m_data
Declares the property Secret setter and getter.
Definition: sessiondata.h:238
SignOn::SessionData::toMap
QVariantMap toMap() const
Gets the QVariantMap of session parameters.
Definition: sessiondata.h:171
SignOn::SessionData::SessionData
SessionData(const QVariantMap &data=QVariantMap())
Constructor.
Definition: sessiondata.h:100
SignOn
Definition: async-dbus-proxy.cpp:41
SignOn::SignonUiPolicy
SignonUiPolicy
Policy to define how the plugin interacts with the user.
Definition: sessiondata.h:72
SignOn::NoUserInteractionPolicy
@ NoUserInteractionPolicy
Definition: sessiondata.h:75
SignOn::RequestPasswordPolicy
@ RequestPasswordPolicy
Definition: sessiondata.h:74
SignOn::ValidationPolicy
@ ValidationPolicy
Definition: sessiondata.h:76
SignOn::DefaultPolicy
@ DefaultPolicy
Definition: sessiondata.h:73