]> vaikene.ee Git - evaf/blob - src/apps/PswGen/Generator/module.h
Merge branch 'master' of ssh://vaikene.net/var/gitpub/evaf
[evaf] / src / apps / PswGen / Generator / module.h
1 /**
2 * @file PswGen/Generator/module.h
3 * @brief Implementation of the iGenerator interface
4 * @author Enar Vaikene
5 *
6 * Copyright (c) 2011 Enar Vaikene
7 *
8 * This file is part of the eVaf C++ cross-platform application development framework.
9 *
10 * This file can be used under the terms of the GNU General Public License
11 * version 3.0 as published by the Free Software Foundation and appearing in
12 * the file LICENSE included in the packaging of this file. Please review the
13 * the following information to ensure the GNU General Public License version
14 * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
15 *
16 * Alternatively, this file may be used in accordance with the Commercial License
17 * Agreement provided with the Software.
18 */
19
20 #ifndef __PSWGEN_GENERATOR_MODULE_H
21 # define __PSWGEN_GENERATOR_MODULE_H
22
23 #include "igenerator.h"
24
25 #include <Plugins/iPlugin>
26
27 #include <QObject>
28 #include <QString>
29
30 namespace eVaf {
31 namespace PswGen {
32
33 /// Module that generates strong passwords using cryptographic methods
34 namespace Generator {
35
36 /// Internal implementation of the Generator module
37 namespace Internal {
38 class GeneratorImpl;
39 } // namespace eVaf::PswGen::Generator::Internal
40
41 /**
42 * Module implementing the iGenerator interface.
43 */
44 class Module : public Plugins::iPlugin
45 {
46 Q_OBJECT
47 Q_INTERFACES(eVaf::Plugins::iPlugin)
48
49 public:
50
51 Module();
52
53 virtual ~Module();
54
55 virtual bool init(QString const & args);
56
57 virtual void done();
58
59 virtual bool isReady() const { return true; }
60
61
62 private: // Members
63
64 /// iGenerator interface instance
65 Internal::GeneratorImpl * mGenerator;
66
67 };
68
69
70 namespace Internal {
71
72 /**
73 * iGenerator interface implementation.
74 *
75 * Implements the iGenerator interface using MD5 cryptographic hashes.
76 */
77
78 class GeneratorImpl : public QObject, public iGenerator
79 {
80 Q_OBJECT
81 Q_INTERFACES(eVaf::PswGen::iGenerator)
82
83 public:
84
85 GeneratorImpl();
86
87 virtual ~GeneratorImpl();
88
89 virtual QString generatePassword(QString const & name, QString const & masterPassword, int length, uint flags = 0) const;
90
91 virtual int maxLength() const { return 24; }
92
93 };
94
95 } // namespace eVaf::PswGen::Generator::Internal
96
97
98 } // namespace eVaf::PswGen::Generator
99 } // namespace eVaf::PswGen
100 } // namespace eVaf
101
102 #endif // module.h