signon  8.58
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 #include "credentialsdb_p.h"
00036 
00037 #include <QObject>
00038 
00039 namespace SignonDaemonNS {
00040 
00041 class SecretsDB: public SqlDatabase
00042 {
00043     friend class ::TestDatabase;
00044 public:
00045     SecretsDB(const QString &name):
00046         SqlDatabase(name, QLatin1String("SSO-secrets"), SSO_SECRETSDB_VERSION) {}
00047 
00048     bool createTables();
00049     bool clear();
00050 
00051     bool updateCredentials(const quint32 id,
00052                            const QString &username,
00053                            const QString &password);
00054     bool removeCredentials(const quint32 id);
00055     bool loadCredentials(const quint32 id,
00056                          QString &username,
00057                          QString &password);
00058 
00059     QVariantMap loadData(quint32 id, quint32 method);
00060     bool storeData(quint32 id, quint32 method, const QVariantMap &data);
00061     bool removeData(quint32 id, quint32 method);
00062 };
00063 
00064 
00073 class DefaultSecretsStorage: public SignOn::AbstractSecretsStorage
00074 {
00075     Q_OBJECT
00076 
00077 public:
00078     explicit DefaultSecretsStorage(QObject *parent = 0);
00079     ~DefaultSecretsStorage();
00080 
00081     /* reimplemented virtual methods */
00082     bool initialize(const QVariantMap &configuration);
00083     bool close();
00084     bool clear();
00085     bool updateCredentials(const quint32 id,
00086                            const QString &username,
00087                            const QString &password);
00088     bool removeCredentials(const quint32 id);
00089     bool loadCredentials(const quint32 id,
00090                          QString &username,
00091                          QString &password);
00092     QVariantMap loadData(quint32 id, quint32 method);
00093     bool storeData(quint32 id, quint32 method, const QVariantMap &data);
00094     bool removeData(quint32 id, quint32 method);
00095 
00096 private:
00097     SecretsDB *m_secretsDB;
00098     QString m_secretsDBConnectionName;
00099 };
00100 
00101 } //namespace
00102 
00103 #endif // SIGNON_DEFAULT_SECRETS_STORAGE_H