signon  8.42
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 #include "credentialsdb_p.h"
36 
37 #include <QObject>
38 
39 namespace SignonDaemonNS {
40 
41 class SecretsDB: public SqlDatabase
42 {
43  friend class ::TestDatabase;
44 public:
45  SecretsDB(const QString &name):
46  SqlDatabase(name, QLatin1String("SSO-secrets"), SSO_SECRETSDB_VERSION) {}
47 
48  bool createTables();
49  bool clear();
50 
51  bool updateCredentials(const quint32 id,
52  const QString &username,
53  const QString &password);
54  bool removeCredentials(const quint32 id);
55  bool loadCredentials(const quint32 id,
56  QString &username,
57  QString &password);
58 
59  QVariantMap loadData(quint32 id, quint32 method);
60  bool storeData(quint32 id, quint32 method, const QVariantMap &data);
61  bool removeData(quint32 id, quint32 method);
62 };
63 
64 
73 class DefaultSecretsStorage: public SignOn::AbstractSecretsStorage
74 {
75  Q_OBJECT
76 
77 public:
78  explicit DefaultSecretsStorage(QObject *parent = 0);
80 
81  /* reimplemented virtual methods */
82  bool initialize(const QVariantMap &configuration);
83  bool close();
84  bool clear();
85  bool updateCredentials(const quint32 id,
86  const QString &username,
87  const QString &password);
88  bool removeCredentials(const quint32 id);
89  bool loadCredentials(const quint32 id,
90  QString &username,
91  QString &password);
92  QVariantMap loadData(quint32 id, quint32 method);
93  bool storeData(quint32 id, quint32 method, const QVariantMap &data);
94  bool removeData(quint32 id, quint32 method);
95 
96 private:
97  SecretsDB *m_secretsDB;
98 };
99 
100 } //namespace
101 
102 #endif // SIGNON_DEFAULT_SECRETS_STORAGE_H