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

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