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