2
This file is part of libqobex.
4
Copyright (c) 2003 Mathias Froehlich <Mathias.Froehlich@web.de>
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Library General Public
8
License as published by the Free Software Foundation; either
9
version 2 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Library General Public License for more details.
16
You should have received a copy of the GNU Library General Public License
17
along with this library; see the file COPYING.LIB. If not, write to
18
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
19
Boston, MA 02110-1301, USA.
27
#include "qobexlengthvaluebase.h"
29
class QObexAuthDigestBase
30
: public QObexLengthValueBase {
46
QObexAuthDigestBase( const QByteArray& d ) : QObexLengthValueBase( d ) {}
47
QObexAuthDigestBase() {}
49
void appendStringValue( Q_UINT8 tag, const QString& s );
50
QString getStringTag( Q_UINT8 tag ) const;
52
static QByteArray computeDigest( const QByteArray&, const QByteArray& );
53
// returns a random bytearray
54
static QByteArray randomNonce();
55
static QString toString( const QByteArray& );
57
struct text_encoding {
61
static text_encoding encoding_list[];
64
class QObexAuthDigestChallenge
65
: public QObexAuthDigestBase {
79
AuthInfo() : options( 0 ) {}
80
AuthInfo( const QString& r ) : realm( r ), options( 0 ) {}
81
AuthInfo( Q_UINT8 o ) : options( o ) {}
82
AuthInfo( const QString& r, Q_UINT8 o ) : realm( r ), options( o ) {}
85
// Constructor to create data for a new AuthChallenge header.
86
QObexAuthDigestChallenge( const AuthInfo& );
87
// Constructor used to parse the data given here.
88
QObexAuthDigestChallenge( const QByteArray& );
89
// Needed for list handling.
90
QObexAuthDigestChallenge();
92
// Read access to the fields of the header data.
93
QByteArray nonce() const;
94
QString realm() const;
95
bool hasRealm() const;
97
bool readOnly() const;
98
bool userIdRequired() const;
99
bool hasOptions() const;
103
QString toString( int indent ) const;
106
class QObexAuthDigestResponse
107
: public QObexAuthDigestBase {
110
RequestDigestTag = 0,
122
AuthInfo( const QByteArray& s ) : secret( s ) {}
123
AuthInfo( const QString& u ) : userId( u ) {}
124
AuthInfo( const QByteArray& s, const QString& u ) : secret( s ), userId( u ) {}
127
// Constructor to create data for a new AuthResponse header.
128
QObexAuthDigestResponse( const QByteArray&, const AuthInfo& );
129
// Constructor used to parse the data given here.
130
QObexAuthDigestResponse( const QByteArray& );
131
// Needed for list handling.
132
QObexAuthDigestResponse();
134
// Read access to the fields of the header data.
135
QByteArray requestDigest() const;
136
QByteArray nonce() const;
137
bool hasNonce() const;
138
QString userId() const;
139
bool hasUserId() const;
141
bool authenticate( const QByteArray& secret, const QByteArray& nonce ) const;
145
QString toString( int indent ) const;