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
25QT_BEGIN_NAMESPACE
26
27class QAuthenticator;
28class QAbstractNetworkCache;
29class QNetworkAuthenticationCredential;
30class QNetworkCookieJar;
31
32class QNetworkAuthenticationCredential
33{
34public:
35 QString domain;
36 QString user;
37 QString password;
38 bool isNull() const {
39 return domain.isNull() && user.isNull() && password.isNull();
40 }
41};
42Q_DECLARE_TYPEINFO(QNetworkAuthenticationCredential, Q_RELOCATABLE_TYPE);
43inline bool operator<(const QNetworkAuthenticationCredential &t1, const QString &t2)
44{ return t1.domain < t2; }
45inline bool operator<(const QString &t1, const QNetworkAuthenticationCredential &t2)
46{ return t1 < t2.domain; }
47inline bool operator<(const QNetworkAuthenticationCredential &t1, const QNetworkAuthenticationCredential &t2)
48{ return t1.domain < t2.domain; }
49
50class QNetworkAccessAuthenticationManager
51{
52public:
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
67protected:
68 QNetworkAccessCache authenticationCache;
69 QMutex mutex;
70};
71
72QT_END_NAMESPACE
73
74#endif
75

source code of qtbase/src/network/access/qnetworkaccessauthenticationmanager_p.h