summaryrefslogtreecommitdiffstats
blob: 23dc097145315ac6b07baa1b68ba452f966fa14d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
 * Copyright (c) 2010 Remko Tronçon
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#include "Swiften/SASL/DIGESTMD5Properties.h"

namespace Swift {

DIGESTMD5Properties::DIGESTMD5Properties() {
}

DIGESTMD5Properties DIGESTMD5Properties::parse(const ByteArray&) {
	DIGESTMD5Properties result;
	return result;
}

ByteArray DIGESTMD5Properties::serialize() const {
	ByteArray result;
	for(DIGESTMD5PropertiesMap::const_iterator i = properties.begin(); i != properties.end(); ++i) {
		if (i != properties.begin()) {
			result += ',';
		}
		result += i->first;
		result += '=';
		if (isQuoted(i->first)) {
			result += "\"" + i->second + "\"";
		}
		else {
			result += i->second;
		}
	}
	return result;
}

void DIGESTMD5Properties::setValue(const String& key, const String& value) {
	properties.insert(DIGESTMD5PropertiesMap::value_type(key, ByteArray(value)));
}

bool DIGESTMD5Properties::isQuoted(const String& p) {
	return p == "authzid" || p == "cnonce" || p == "digest-uri" || p == "nonce" || p == "realm" || p == "username";
}

}