OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_LIBJINGLE_XMPP_SASLPLAINMECHANISM_H_ | 11 #ifndef WEBRTC_LIBJINGLE_XMPP_SASLPLAINMECHANISM_H_ |
12 #define WEBRTC_LIBJINGLE_XMPP_SASLPLAINMECHANISM_H_ | 12 #define WEBRTC_LIBJINGLE_XMPP_SASLPLAINMECHANISM_H_ |
13 | 13 |
14 #include "third_party/libjingle_xmpp/xmpp/saslmechanism.h" | 14 #include "third_party/libjingle_xmpp/xmpp/saslmechanism.h" |
15 #include "third_party/webrtc/base/cryptstring.h" | |
16 | 15 |
17 namespace buzz { | 16 namespace buzz { |
18 | 17 |
19 class SaslPlainMechanism : public SaslMechanism { | 18 class SaslPlainMechanism : public SaslMechanism { |
20 | 19 |
21 public: | 20 public: |
22 SaslPlainMechanism(const buzz::Jid user_jid, const rtc::CryptString & password ) : | 21 SaslPlainMechanism(const buzz::Jid user_jid, const std::string & password) : |
23 user_jid_(user_jid), password_(password) {} | 22 user_jid_(user_jid), password_(password) {} |
24 | 23 |
25 virtual std::string GetMechanismName() { return "PLAIN"; } | 24 virtual std::string GetMechanismName() { return "PLAIN"; } |
26 | 25 |
27 virtual XmlElement * StartSaslAuth() { | 26 virtual XmlElement * StartSaslAuth() { |
28 // send initial request | 27 // send initial request |
29 XmlElement * el = new XmlElement(QN_SASL_AUTH, true); | 28 XmlElement * el = new XmlElement(QN_SASL_AUTH, true); |
30 el->AddAttr(QN_MECHANISM, "PLAIN"); | 29 el->AddAttr(QN_MECHANISM, "PLAIN"); |
31 | 30 |
32 rtc::FormatCryptString credential; | 31 std::stringstream ss; |
33 credential.Append("\0", 1); | 32 ss.write("\0", 1); |
34 credential.Append(user_jid_.node()); | 33 ss << user_jid_.node(); |
35 credential.Append("\0", 1); | 34 ss.write("\0", 1); |
36 credential.Append(&password_); | 35 ss << password_; |
37 el->AddText(Base64EncodeFromArray(credential.GetData(), credential.GetLength ())); | 36 el->AddText(Base64EncodeFromArray(ss.str().data(), ss.str().length())); |
nisse-chromium (ooo August 14)
2017/03/09 13:01:57
I think this is where the password is ultimately u
| |
38 return el; | 37 return el; |
39 } | 38 } |
40 | 39 |
41 private: | 40 private: |
42 Jid user_jid_; | 41 Jid user_jid_; |
43 rtc::CryptString password_; | 42 std::string password_; |
44 }; | 43 }; |
45 | 44 |
46 } | 45 } |
47 | 46 |
48 #endif // WEBRTC_LIBJINGLE_XMPP_SASLPLAINMECHANISM_H_ | 47 #endif // WEBRTC_LIBJINGLE_XMPP_SASLPLAINMECHANISM_H_ |
OLD | NEW |