1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QNETWORKACCESSAUTHENTICATIONMANAGER_P_H |
5 | #define QNETWORKACCESSAUTHENTICATIONMANAGER_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists for the convenience |
12 | // of the Network Access API. This header file may change from |
13 | // version to version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtNetwork/private/qtnetworkglobal_p.h> |
19 | #include "qnetworkaccessmanager.h" |
20 | #include "qnetworkaccesscache_p.h" |
21 | #include "QtNetwork/qnetworkproxy.h" |
22 | #include "QtCore/QMutex" |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class QAuthenticator; |
27 | class QAbstractNetworkCache; |
28 | class QNetworkAuthenticationCredential; |
29 | class QNetworkCookieJar; |
30 | |
31 | class QNetworkAuthenticationCredential |
32 | { |
33 | public: |
34 | QString domain; |
35 | QString user; |
36 | QString password; |
37 | bool isNull() const { |
38 | return domain.isNull() && user.isNull() && password.isNull(); |
39 | } |
40 | }; |
41 | Q_DECLARE_TYPEINFO(QNetworkAuthenticationCredential, Q_RELOCATABLE_TYPE); |
42 | inline bool operator<(const QNetworkAuthenticationCredential &t1, const QString &t2) |
43 | { return t1.domain < t2; } |
44 | inline bool operator<(const QString &t1, const QNetworkAuthenticationCredential &t2) |
45 | { return t1 < t2.domain; } |
46 | inline bool operator<(const QNetworkAuthenticationCredential &t1, const QNetworkAuthenticationCredential &t2) |
47 | { return t1.domain < t2.domain; } |
48 | |
49 | class QNetworkAccessAuthenticationManager |
50 | { |
51 | public: |
52 | QNetworkAccessAuthenticationManager() {} |
53 | |
54 | void cacheCredentials(const QUrl &url, const QAuthenticator *auth); |
55 | QNetworkAuthenticationCredential fetchCachedCredentials(const QUrl &url, |
56 | const QAuthenticator *auth = nullptr); |
57 | |
58 | #ifndef QT_NO_NETWORKPROXY |
59 | void cacheProxyCredentials(const QNetworkProxy &proxy, const QAuthenticator *auth); |
60 | QNetworkAuthenticationCredential fetchCachedProxyCredentials(const QNetworkProxy &proxy, |
61 | const QAuthenticator *auth = nullptr); |
62 | #endif |
63 | |
64 | void clearCache(); |
65 | |
66 | protected: |
67 | QNetworkAccessCache authenticationCache; |
68 | QMutex mutex; |
69 | }; |
70 | |
71 | QT_END_NAMESPACE |
72 | |
73 | #endif |
74 |