diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-05-08 08:01:56 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-05-08 08:24:22 (GMT) |
commit | 5616ff49792238b451486f41b187744866d20056 (patch) | |
tree | 6c3a2f56d7aac99db4dbd7317768dfe1949a96e8 /Swiften/SASL/DIGESTMD5Properties.cpp | |
parent | 203ca1c122db89c4a9f9f01bff2cadb3b9daca04 (diff) | |
download | swift-contrib-5616ff49792238b451486f41b187744866d20056.zip swift-contrib-5616ff49792238b451486f41b187744866d20056.tar.bz2 |
Added DIGEST-MD5 properties.
Diffstat (limited to 'Swiften/SASL/DIGESTMD5Properties.cpp')
-rw-r--r-- | Swiften/SASL/DIGESTMD5Properties.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Swiften/SASL/DIGESTMD5Properties.cpp b/Swiften/SASL/DIGESTMD5Properties.cpp new file mode 100644 index 0000000..23dc097 --- /dev/null +++ b/Swiften/SASL/DIGESTMD5Properties.cpp @@ -0,0 +1,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"; +} + +} |