Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1199)

Unified Diff: remoting/protocol/negotiating_authenticator_base.cc

Issue 1768383004: Cleanup AuthenticatorMethod usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/protocol/negotiating_authenticator_base.cc
diff --git a/remoting/protocol/negotiating_authenticator_base.cc b/remoting/protocol/negotiating_authenticator_base.cc
index dbb3aac7609a6367e66773f771beb1da448e25cd..5fe81293caa67023ebb65a19172aa925150466db 100644
--- a/remoting/protocol/negotiating_authenticator_base.cc
+++ b/remoting/protocol/negotiating_authenticator_base.cc
@@ -13,11 +13,26 @@
#include "base/strings/string_split.h"
#include "remoting/base/rsa_key_pair.h"
#include "remoting/protocol/channel_authenticator.h"
+#include "remoting/protocol/name_value_map.h"
#include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
namespace remoting {
namespace protocol {
+namespace {
+
+const NameMapElement<NegotiatingAuthenticatorBase::Method>
+ kAuthenticationMethodStrings[] = {
+ {NegotiatingAuthenticatorBase::Method::SPAKE2_SHARED_SECRET_PLAIN,
+ "spake2_plain"},
+ {NegotiatingAuthenticatorBase::Method::SPAKE2_SHARED_SECRET_HMAC,
+ "spake2_hmac"},
+ {NegotiatingAuthenticatorBase::Method::SPAKE2_PAIR, "spake2_pair"},
+ {NegotiatingAuthenticatorBase::Method::THIRD_PARTY, "third_party"},
+};
+
+} // namespace
+
const buzz::StaticQName NegotiatingAuthenticatorBase::kMethodAttributeQName =
{ "", "method" };
const buzz::StaticQName
@@ -47,6 +62,20 @@ NegotiatingAuthenticatorBase::rejection_reason() const {
return rejection_reason_;
}
+// static
+NegotiatingAuthenticatorBase::Method
+NegotiatingAuthenticatorBase::ParseMethodString(const std::string& value) {
+ Method result;
+ if (!NameToValue(kAuthenticationMethodStrings, value, &result))
+ return Method::INVALID;
+ return result;
+}
+
+// static
+std::string NegotiatingAuthenticatorBase::MethodToString(Method method) {
+ return ValueToName(kAuthenticationMethodStrings, method);
+}
+
void NegotiatingAuthenticatorBase::ProcessMessageInternal(
const buzz::XmlElement* message,
const base::Closure& resume_callback) {
@@ -78,7 +107,7 @@ void NegotiatingAuthenticatorBase::UpdateState(
scoped_ptr<buzz::XmlElement>
NegotiatingAuthenticatorBase::GetNextMessageInternal() {
DCHECK_EQ(state(), MESSAGE_READY);
- DCHECK(current_method_ != AuthenticationMethod::INVALID);
+ DCHECK(current_method_ != Method::INVALID);
scoped_ptr<buzz::XmlElement> result;
if (current_authenticator_->state() == MESSAGE_READY) {
@@ -88,13 +117,12 @@ NegotiatingAuthenticatorBase::GetNextMessageInternal() {
}
state_ = current_authenticator_->state();
DCHECK(state_ == ACCEPTED || state_ == WAITING_MESSAGE);
- result->AddAttr(kMethodAttributeQName,
- AuthenticationMethodToString(current_method_));
+ result->AddAttr(kMethodAttributeQName, MethodToString(current_method_));
return result;
}
-void NegotiatingAuthenticatorBase::AddMethod(AuthenticationMethod method) {
- DCHECK(method != AuthenticationMethod::INVALID);
+void NegotiatingAuthenticatorBase::AddMethod(Method method) {
+ DCHECK(method != Method::INVALID);
methods_.push_back(method);
}
« no previous file with comments | « remoting/protocol/negotiating_authenticator_base.h ('k') | remoting/protocol/negotiating_authenticator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698