C++ Web Framework  3.0
configuration.h
1 /*
2  Copyright 2017 Herik Lima de Castro and Marcelo Medeiros Eler
3  Distributed under MIT license, or public domain if desired and
4  recognized in your jurisdiction.
5  See file LICENSE for detail.
6 */
7 
8 #ifndef CONFIGURATION_H
9 #define CONFIGURATION_H
10 
11 #include <QString>
12 #include <QSettings>
13 #include <QSslSocket>
14 #include <QHostAddress>
15 #include "filemanager.h"
16 #include "cppwebframework_global.h"
20 CWF_BEGIN_NAMESPACE
24 class CPPWEBFRAMEWORKSHARED_EXPORT Configuration
25 {
26  bool valid = false;
27  bool accessCPPWebIni = false;
28  bool accessServerPages = false;
29  int timeOut = 30000;
30  int sessionExpirationTime = 1800000;
31  int cleanupInterval = 86400000;
32  int port = 8080;
33  int maxThread = 100;
34  QString sslKeyFile;
35  QString sslCertFile;
36  QString path;
37  QString logFilePath;
38  QString indexPage;
39  QByteArray sslPassPhrase;
40  QHostAddress host;
41  qint64 maxUploadFile = 2097152;
42  qint64 maxLogFile = 20000000;
43  QSsl::KeyAlgorithm sslKeyAlgorithm = QSsl::Rsa;
44  QSsl::KeyType sslKeyType = QSsl::PrivateKey;
45  QSsl::EncodingFormat sslEncodingFormat = QSsl::Pem;
46  QSsl::SslProtocol sslProtocol = QSsl::TlsV1SslV3;
47  QSslSocket::PeerVerifyMode sslPeerVerifyMode = QSslSocket::VerifyNone;
48  void configure();
49 public:
65  explicit Configuration(const QString &serverFilesPath = "");
72  inline int getTimeOut() const noexcept { return timeOut; }
77  inline int getSessionExpirationTime() const noexcept { return sessionExpirationTime; }
82  inline int getCleanupInterval() const noexcept { return cleanupInterval; }
87  inline int getPort() const noexcept { return port; }
92  inline QHostAddress getHost() const noexcept { return host; }
97  inline int getMaxThread() const noexcept { return maxThread; }
102  inline QString getSslKeyFile() const noexcept { return sslKeyFile; }
107  inline QString getSslCertFile() const noexcept { return sslCertFile; }
112  inline QString getPath() const noexcept { return path; }
117  inline QString getLogFilePath() const noexcept { return logFilePath; }
122  inline qint64 getMaxUploadFile() const noexcept { return maxUploadFile; }
127  inline qint64 getMaxLogFile() const noexcept { return maxLogFile; }
132  inline QString getIndexPage() const noexcept { return indexPage; }
137  inline bool getAccessServerPages() const noexcept { return accessServerPages; }
142  inline QByteArray getSslPassPhrase() const noexcept { return sslPassPhrase; }
147  inline bool isValid() const noexcept { return valid; }
152  inline QSsl::KeyAlgorithm getSslKeyAlgorithm() const noexcept { return sslKeyAlgorithm; }
157  inline QSsl::KeyType getSslKeyType() const noexcept { return sslKeyType; }
162  inline QSsl::EncodingFormat getSslEncodingFormat() const noexcept { return sslEncodingFormat; }
167  inline QSslSocket::PeerVerifyMode getSslPeerVerifyMode() const noexcept { return sslPeerVerifyMode; }
172  inline QSsl::SslProtocol getSslProtocol() const noexcept { return sslProtocol; }
177 };
178 
179 CWF_END_NAMESPACE
180 
181 #endif // CONFIGURATION_H
QByteArray getSslPassPhrase() const noexcept
Returns the ssl pass phrase.
Definition: configuration.h:142
QHostAddress getHost() const noexcept
Returns the address.
Definition: configuration.h:92
QString getSslKeyFile() const noexcept
Returns the ssl key file.
Definition: configuration.h:102
QSsl::SslProtocol getSslProtocol() const noexcept
Returns the SSL Protocol. The TlsV1SslV3 is defined by default.
Definition: configuration.h:172
QString getSslCertFile() const noexcept
Returns the ssl cert file.
Definition: configuration.h:107
QSsl::KeyAlgorithm getSslKeyAlgorithm() const noexcept
Returns the SSL Key Algorithm. The RSA is defined by default.
Definition: configuration.h:152
qint64 getMaxUploadFile() const noexcept
Returns max upload file size supported by the server.
Definition: configuration.h:122
bool getAccessServerPages() const noexcept
Returns the access server page.
Definition: configuration.h:137
QSslSocket::PeerVerifyMode getSslPeerVerifyMode() const noexcept
Returns the SSL Peer Veryfy Mode. The VerifyNone is defined by default.
Definition: configuration.h:167
QSsl::EncodingFormat getSslEncodingFormat() const noexcept
Returns the SSL Encoding Format. The PEM is defined by default.
Definition: configuration.h:162
QString getIndexPage() const noexcept
Returns the index page.
Definition: configuration.h:132
int getMaxThread() const noexcept
Returns the max thread number.
Definition: configuration.h:97
QSsl::KeyType getSslKeyType() const noexcept
Returns the SSL Key Type. The private is defined by default.
Definition: configuration.h:157
QString getLogFilePath() const noexcept
Returns the log file path.
Definition: configuration.h:117
bool isValid() const noexcept
Returns true if the Configuration is ok. Otherwise returns false.
Definition: configuration.h:147
int getTimeOut() const noexcept
Returns the timeOut property that will be used by the server to expire threads that are not in use...
Definition: configuration.h:72
QString getPath() const noexcept
Returns the path to the server&#39;s folder.
Definition: configuration.h:112
int getSessionExpirationTime() const noexcept
Returns the Session Expiration Time.
Definition: configuration.h:77
All classes of C++ Web Framework are contained within the namespace CWF.
Definition: configuration.h:24
qint64 getMaxLogFile() const noexcept
getMaxLogFile the max file log
Definition: configuration.h:127
int getCleanupInterval() const noexcept
Returns the clean up interval Time.
Definition: configuration.h:82
int getPort() const noexcept
Returns the port number.
Definition: configuration.h:87