signon  8.40
default-secrets-storage.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) 2011 Canonical Ltd.
00006  *
00007  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public License
00011  * version 2.1 as published by the Free Software Foundation.
00012  *
00013  * This library is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00021  * 02110-1301 USA
00022  */
00023 
00030 #ifndef SIGNON_DEFAULT_SECRETS_STORAGE_H
00031 #define SIGNON_DEFAULT_SECRETS_STORAGE_H
00032 
00033 #include "SignOn/abstract-secrets-storage.h"
00034 #include "credentialsdb.h"
00035 
00036 #include <QObject>
00037 
00038 namespace SignonDaemonNS {
00039 
00040 class SecretsDB: public SqlDatabase
00041 {
00042     friend class ::TestDatabase;
00043 public:
00044     SecretsDB(const QString &name):
00045         SqlDatabase(name, QLatin1String("SSO-secrets"), SSO_SECRETSDB_VERSION) {}
00046 
00047     bool createTables();
00048     bool clear();
00049 
00050     bool updateCredentials(const quint32 id,
00051                            const QString &username,
00052                            const QString &password);
00053     bool removeCredentials(const quint32 id);
00054     bool loadCredentials(const quint32 id,
00055                          QString &username,
00056                          QString &password);
00057 
00058     QVariantMap loadData(quint32 id, quint32 method);
00059     bool storeData(quint32 id, quint32 method, const QVariantMap &data);
00060     bool removeData(quint32 id, quint32 method);
00061 };
00062 
00063 
00072 class DefaultSecretsStorage: public SignOn::AbstractSecretsStorage
00073 {
00074     Q_OBJECT
00075 
00076 public:
00077     explicit DefaultSecretsStorage(QObject *parent = 0);
00078     ~DefaultSecretsStorage();
00079 
00080     /* reimplemented virtual methods */
00081     bool initialize(const QVariantMap &configuration);
00082     bool close();
00083     bool clear();
00084     bool updateCredentials(const quint32 id,
00085                            const QString &username,
00086                            const QString &password);
00087     bool removeCredentials(const quint32 id);
00088     bool loadCredentials(const quint32 id,
00089                          QString &username,
00090                          QString &password);
00091     QVariantMap loadData(quint32 id, quint32 method);
00092     bool storeData(quint32 id, quint32 method, const QVariantMap &data);
00093     bool removeData(quint32 id, quint32 method);
00094 
00095 private:
00096     SecretsDB *m_secretsDB;
00097 };
00098 
00099 } //namespace
00100 
00101 #endif // SIGNON_DEFAULT_SECRETS_STORAGE_H