KVIrc  4.9.2
DeveloperAPIs
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 
65 class QUrl;
66 
68 {
69 public:
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 
97 private:
100 };
101 
103 {
104 public:
105  enum Method
106  {
114  };
116 
117  QAtomicInt ref;
118  QString user;
119  QString extractedUser;
120  QString password;
121  QVariantHash options;
123  QString realm;
124  QByteArray challenge;
125  bool hasFailed; //credentials have been tried but rejected by server.
126 
127  enum Phase
128  {
133  };
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
QString password() const
Definition: qhttpauthenticator.cpp:263
static QHash< QByteArray, QByteArray > parseDigestAuthenticationChallenge(const QByteArray &challenge)
Definition: qhttpauthenticator.cpp:504
void setUser(const QString &user)
Definition: qhttpauthenticator.cpp:229
Phase
Definition: qhttpauthenticator_p.h:127
QVariantHash options
Definition: qhttpauthenticator_p.h:121
QAtomicInt ref
Definition: qhttpauthenticator_p.h:117
Method
Definition: qhttpauthenticator_p.h:105
static QHttpAuthenticatorPrivate * getPrivate(QHttpAuthenticator &auth)
Definition: qhttpauthenticator_p.h:146
QVariantHash options() const
Definition: qhttpauthenticator.cpp:324
QString user
Definition: qhttpauthenticator_p.h:118
Definition: qhttpauthenticator_p.h:111
Definition: qhttpauthenticator_p.h:109
QString password
Definition: qhttpauthenticator_p.h:120
QString extractedUser
Definition: qhttpauthenticator_p.h:119
bool isNull() const
Definition: qhttpauthenticator.cpp:346
Definition: qhttpauthenticator_p.h:107
QByteArray challenge
Definition: qhttpauthenticator_p.h:124
void parseHttpResponse(const QHttpResponseHeader &, bool isProxy)
Definition: qhttpauthenticator.cpp:361
static const QHttpAuthenticatorPrivate * getPrivate(const QHttpAuthenticator &auth)
Definition: qhttpauthenticator_p.h:147
Definition: qhttpauthenticator_p.h:102
QString realm
Definition: qhttpauthenticator_p.h:123
QVariant option(const QString &opt) const
Definition: qhttpauthenticator.cpp:311
Definition: qhttpauthenticator_p.h:130
void detach()
Definition: qhttpauthenticator.cpp:282
QAuthenticator toQAuthenticator()
Definition: qhttpauthenticator.cpp:199
Definition: qhttpauthenticator_p.h:112
Definition: qhttpauthenticator_p.h:132
QString realm() const
Definition: qhttpauthenticator.cpp:298
bool operator==(const QHttpAuthenticator &other) const
Definition: qhttpauthenticator.cpp:179
Definition: qhttpauthenticator_p.h:113
Method method
Definition: qhttpauthenticator_p.h:122
QHttpAuthenticator & operator=(const QHttpAuthenticator &other)
Definition: qhttpauthenticator.cpp:161
Definition: qhttpauthenticator_p.h:108
QHttpAuthenticatorPrivate()
Definition: qhttpauthenticator.cpp:351
~QHttpAuthenticator()
Definition: qhttpauthenticator.cpp:142
Definition: qhttpauthenticator_p.h:131
void setOption(const QString &opt, const QVariant &value)
Definition: qhttpauthenticator.cpp:337
QByteArray calculateResponse(const QByteArray &method, const QByteArray &path)
Definition: qhttpauthenticator.cpp:442
The QHttpAuthenticator class provides an authentication object.
Definition: qhttpauthenticator_p.h:67
int nonceCount
Definition: qhttpauthenticator_p.h:138
QHttpAuthenticator()
Definition: qhttpauthenticator.cpp:134
QByteArray cnonce
Definition: qhttpauthenticator_p.h:137
bool hasFailed
Definition: qhttpauthenticator_p.h:125
void setPassword(const QString &password)
Definition: qhttpauthenticator.cpp:273
QString user() const
Definition: qhttpauthenticator.cpp:219
QByteArray digestMd5Response(const QByteArray &challenge, const QByteArray &method, const QByteArray &path)
Definition: qhttpauthenticator.cpp:654
bool operator!=(const QHttpAuthenticator &other) const
Definition: qhttpauthenticator_p.h:77
QString workstation
Definition: qhttpauthenticator_p.h:141
The QHttpResponseHeader class contains response header information for HTTP.
Definition: qhttp.h:114
QString userDomain
Definition: qhttpauthenticator_p.h:142
Phase phase
Definition: qhttpauthenticator_p.h:134
QHttpAuthenticatorPrivate * d
Definition: qhttpauthenticator_p.h:99
Definition: qhttpauthenticator_p.h:129
Definition: qhttpauthenticator_p.h:110