signon  8.41
default-secrets-storage.h
Go to the documentation of this file.
1 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of signon
4  *
5  * Copyright (C) 2011 Canonical Ltd.
6  *
7  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * version 2.1 as published by the Free Software Foundation.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  */
23 
30 #ifndef SIGNON_DEFAULT_SECRETS_STORAGE_H
31 #define SIGNON_DEFAULT_SECRETS_STORAGE_H
32 
33 #include "SignOn/abstract-secrets-storage.h"
34 #include "credentialsdb.h"
35 
36 #include <QObject>
37 
38 namespace SignonDaemonNS {
39 
40 class SecretsDB: public SqlDatabase
41 {
42  friend class ::TestDatabase;
43 public:
44  SecretsDB(const QString &name):
45  SqlDatabase(name, QLatin1String("SSO-secrets"), SSO_SECRETSDB_VERSION) {}
46 
47  bool createTables();
48  bool clear();
49 
50  bool updateCredentials(const quint32 id,
51  const QString &username,
52  const QString &password);
53  bool removeCredentials(const quint32 id);
54  bool loadCredentials(const quint32 id,
55  QString &username,
56  QString &password);
57 
58  QVariantMap loadData(quint32 id, quint32 method);
59  bool storeData(quint32 id, quint32 method, const QVariantMap &data);
60  bool removeData(quint32 id, quint32 method);
61 };
62 
63 
72 class DefaultSecretsStorage: public SignOn::AbstractSecretsStorage
73 {
74  Q_OBJECT
75 
76 public:
77  explicit DefaultSecretsStorage(QObject *parent = 0);
79 
80  /* reimplemented virtual methods */
81  bool initialize(const QVariantMap &configuration);
82  bool close();
83  bool clear();
84  bool updateCredentials(const quint32 id,
85  const QString &username,
86  const QString &password);
87  bool removeCredentials(const quint32 id);
88  bool loadCredentials(const quint32 id,
89  QString &username,
90  QString &password);
91  QVariantMap loadData(quint32 id, quint32 method);
92  bool storeData(quint32 id, quint32 method, const QVariantMap &data);
93  bool removeData(quint32 id, quint32 method);
94 
95 private:
96  SecretsDB *m_secretsDB;
97 };
98 
99 } //namespace
100 
101 #endif // SIGNON_DEFAULT_SECRETS_STORAGE_H