KVIrc 5.2.6
Developer APIs
qhttpauthenticator_p.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the QtNetwork module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Digia. For licensing terms and
14** conditions see http://qt.digia.com/licensing. For further information
15** use the contact form at http://qt.digia.com/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 2.1 requirements
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24**
25** In addition, as a special exception, Digia gives you certain additional
26** rights. These rights are described in the Digia Qt LGPL Exception
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28**
29** GNU General Public License Usage
30** Alternatively, this file may be used under the terms of the GNU
31** General Public License version 3.0 as published by the Free Software
32** Foundation and appearing in the file LICENSE.GPL included in the
33** packaging of this file. Please review the following information to
34** ensure the GNU General Public License version 3.0 requirements will be
35** met: http://www.gnu.org/copyleft/gpl.html.
36**
37**
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QHTTPAUTHENTICATOR_P_H
43#define QHTTPAUTHENTICATOR_P_H
44
45//
46// W A R N I N G
47// -------------
48//
49// This file is not part of the Qt API. It exists purely as an
50// implementation detail. This header file may change from version to
51// version without notice, or even be removed.
52//
53// We mean it.
54//
55
56#include <qhash.h>
57#include <qbytearray.h>
58#include <qstring.h>
59#include <qvariant.h>
60#include <QAuthenticator>
61
63
65class QUrl;
66
68{
69public:
72
75
76 bool operator==(const QHttpAuthenticator & other) const;
77 inline bool operator!=(const QHttpAuthenticator & other) const { return !operator==(other); }
78
79 QString user() const;
80 void setUser(const QString & user);
81
82 QString password() const;
83 void setPassword(const QString & password);
84
85 QString realm() const;
86
87 QVariant option(const QString & opt) const;
88 QVariantHash options() const;
89 void setOption(const QString & opt, const QVariant & value);
90
91 bool isNull() const;
92 void detach();
93
94 QHttpAuthenticator & operator=(const QAuthenticator & auth);
95 QAuthenticator toQAuthenticator();
96
97private:
100};
101
103{
104public:
116
117 QAtomicInt ref;
118 QString user;
120 QString password;
121 QVariantHash options;
123 QString realm;
124 QByteArray challenge;
125 bool hasFailed; //credentials have been tried but rejected by server.
126
135
136 // digest specific
137 QByteArray cnonce;
139
140 // ntlm specific
141 QString workstation;
142 QString userDomain;
143
144 QByteArray calculateResponse(const QByteArray & method, const QByteArray & path);
145
146 inline static QHttpAuthenticatorPrivate * getPrivate(QHttpAuthenticator & auth) { return auth.d; }
147 inline static const QHttpAuthenticatorPrivate * getPrivate(const QHttpAuthenticator & auth) { return auth.d; }
148
149 QByteArray digestMd5Response(const QByteArray & challenge, const QByteArray & method, const QByteArray & path);
150 static QHash<QByteArray, QByteArray> parseDigestAuthenticationChallenge(const QByteArray & challenge);
151
152#ifndef QT_NO_HTTP
153 void parseHttpResponse(const QHttpResponseHeader &, bool isProxy);
154#endif
155 void parseHttpResponse(const QList<QPair<QByteArray, QByteArray>> &, bool isProxy);
156};
157
158#endif
Definition qhttpauthenticator_p.h:103
QAtomicInt ref
Definition qhttpauthenticator_p.h:117
QString extractedUser
Definition qhttpauthenticator_p.h:119
QString workstation
Definition qhttpauthenticator_p.h:141
static QHash< QByteArray, QByteArray > parseDigestAuthenticationChallenge(const QByteArray &challenge)
Definition qhttpauthenticator.cpp:505
static const QHttpAuthenticatorPrivate * getPrivate(const QHttpAuthenticator &auth)
Definition qhttpauthenticator_p.h:147
QString realm
Definition qhttpauthenticator_p.h:123
void parseHttpResponse(const QHttpResponseHeader &, bool isProxy)
Definition qhttpauthenticator.cpp:362
QByteArray challenge
Definition qhttpauthenticator_p.h:124
Method
Definition qhttpauthenticator_p.h:106
@ Basic
Definition qhttpauthenticator_p.h:108
@ CramMd5
Definition qhttpauthenticator_p.h:112
@ Plain
Definition qhttpauthenticator_p.h:109
@ Login
Definition qhttpauthenticator_p.h:110
@ DigestMd5
Definition qhttpauthenticator_p.h:113
@ Ntlm
Definition qhttpauthenticator_p.h:111
@ None
Definition qhttpauthenticator_p.h:107
static QHttpAuthenticatorPrivate * getPrivate(QHttpAuthenticator &auth)
Definition qhttpauthenticator_p.h:146
QVariantHash options
Definition qhttpauthenticator_p.h:121
QString user
Definition qhttpauthenticator_p.h:118
QString password
Definition qhttpauthenticator_p.h:120
bool hasFailed
Definition qhttpauthenticator_p.h:125
QByteArray calculateResponse(const QByteArray &method, const QByteArray &path)
Definition qhttpauthenticator.cpp:443
Method method
Definition qhttpauthenticator_p.h:122
QByteArray digestMd5Response(const QByteArray &challenge, const QByteArray &method, const QByteArray &path)
Definition qhttpauthenticator.cpp:656
QHttpAuthenticatorPrivate()
Definition qhttpauthenticator.cpp:352
int nonceCount
Definition qhttpauthenticator_p.h:138
QString userDomain
Definition qhttpauthenticator_p.h:142
QByteArray cnonce
Definition qhttpauthenticator_p.h:137
Phase phase
Definition qhttpauthenticator_p.h:134
Phase
Definition qhttpauthenticator_p.h:128
@ Invalid
Definition qhttpauthenticator_p.h:132
@ Done
Definition qhttpauthenticator_p.h:131
@ Start
Definition qhttpauthenticator_p.h:129
@ Phase2
Definition qhttpauthenticator_p.h:130
The QHttpAuthenticator class provides an authentication object.
Definition qhttpauthenticator_p.h:68
QHttpAuthenticator & operator=(const QHttpAuthenticator &other)
Definition qhttpauthenticator.cpp:162
QString password() const
Definition qhttpauthenticator.cpp:264
QVariantHash options() const
Definition qhttpauthenticator.cpp:325
void setPassword(const QString &password)
Definition qhttpauthenticator.cpp:274
QVariant option(const QString &opt) const
Definition qhttpauthenticator.cpp:312
bool operator==(const QHttpAuthenticator &other) const
Definition qhttpauthenticator.cpp:180
void detach()
Definition qhttpauthenticator.cpp:283
QAuthenticator toQAuthenticator()
Definition qhttpauthenticator.cpp:200
QString user() const
Definition qhttpauthenticator.cpp:220
QString realm() const
Definition qhttpauthenticator.cpp:299
void setUser(const QString &user)
Definition qhttpauthenticator.cpp:230
bool isNull() const
Definition qhttpauthenticator.cpp:347
QHttpAuthenticator()
Definition qhttpauthenticator.cpp:135
QHttpAuthenticatorPrivate * d
Definition qhttpauthenticator_p.h:99
void setOption(const QString &opt, const QVariant &value)
Definition qhttpauthenticator.cpp:338
~QHttpAuthenticator()
Definition qhttpauthenticator.cpp:143
bool operator!=(const QHttpAuthenticator &other) const
Definition qhttpauthenticator_p.h:77
The QHttpResponseHeader class contains response header information for HTTP.
Definition qhttp.h:113