2
* Copyright (C) 2003 Justin Karneges
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
#include "xmpp/sasl/digestmd5proplist.h"
24
DIGESTMD5PropList::DIGESTMD5PropList() : QList<DIGESTMD5Prop>()
28
void DIGESTMD5PropList::set(const QByteArray &var, const QByteArray &val) {
35
QByteArray DIGESTMD5PropList::get(const QByteArray &var) const
37
for(ConstIterator it = begin(); it != end(); ++it) {
44
QByteArray DIGESTMD5PropList::toString() const
48
for(ConstIterator it = begin(); it != end(); ++it) {
51
if ((*it).var == "realm" || (*it).var == "nonce" || (*it).var == "username" || (*it).var == "cnonce" || (*it).var == "digest-uri" || (*it).var == "authzid")
52
str += (*it).var + "=\"" + (*it).val + '\"';
54
str += (*it).var + "=" + (*it).val;
60
bool DIGESTMD5PropList::fromString(const QByteArray &str)
62
DIGESTMD5PropList list;
65
while (at < str.length() && (str[at] == ',' || str[at] == ' ' || str[at] == '\t'))
67
int n = str.indexOf('=', at);
71
var = str.mid(at, n-at);
75
n = str.indexOf('\"', at);
78
val = str.mid(at, n-at);
83
while (n < str.length() && str[n] != ',' && str[n] != ' ' && str[n] != '\t')
85
val = str.mid(at, n-at);
90
if (var == "qop" || var == "cipher") {
92
while (a < val.length()) {
93
while (a < val.length() && (val[a] == ',' || val[a] == ' ' || val[a] == '\t'))
95
if (a == val.length())
98
while (n < val.length() && val[n] != ',' && val[n] != ' ' && val[n] != '\t')
100
prop.val = val.mid(a, n-a);
110
if(at >= str.size() - 1 || (str[at] != ',' && str[at] != ' ' && str[at] != '\t'))
115
if(list.varCount("nonce") != 1)
117
if(list.varCount("algorithm") != 1)
123
int DIGESTMD5PropList::varCount(const QByteArray &var) const
126
for(ConstIterator it = begin(); it != end(); ++it) {