Index: remoting/protocol/authentication_method.cc |
diff --git a/remoting/protocol/authentication_method.cc b/remoting/protocol/authentication_method.cc |
index ab60f399535289f9e5084b7d646519a85e91fd1d..996390f8d1a2435199d0c2709261f17b81302bcf 100644 |
--- a/remoting/protocol/authentication_method.cc |
+++ b/remoting/protocol/authentication_method.cc |
@@ -19,7 +19,12 @@ AuthenticationMethod AuthenticationMethod::Invalid() { |
// static |
AuthenticationMethod AuthenticationMethod::Spake2(HashFunction hash_function) { |
- return AuthenticationMethod(hash_function); |
+ return AuthenticationMethod(hash_function, false); |
+} |
+ |
+// static |
+AuthenticationMethod AuthenticationMethod::ThirdParty() { |
+ return AuthenticationMethod(NONE, true); |
} |
// static |
@@ -29,6 +34,8 @@ AuthenticationMethod AuthenticationMethod::FromString( |
return Spake2(NONE); |
} else if (value == "spake2_hmac") { |
return Spake2(HMAC_SHA256); |
+ } else if (value == "third_party") { |
+ return ThirdParty(); |
} else { |
return AuthenticationMethod::Invalid(); |
} |
@@ -65,11 +72,14 @@ std::string AuthenticationMethod::ApplyHashFunction( |
AuthenticationMethod::AuthenticationMethod() |
: invalid_(true), |
+ requires_token_(false), |
hash_function_(NONE) { |
} |
-AuthenticationMethod::AuthenticationMethod(HashFunction hash_function) |
+AuthenticationMethod::AuthenticationMethod(HashFunction hash_function, |
+ bool requires_token) |
: invalid_(false), |
+ requires_token_(requires_token), |
hash_function_(hash_function) { |
} |
@@ -81,15 +91,20 @@ AuthenticationMethod::HashFunction AuthenticationMethod::hash_function() const { |
const std::string AuthenticationMethod::ToString() const { |
DCHECK(is_valid()); |
+ if (requires_token_) { |
+ return "third_party"; |
Wez
2013/03/05 22:55:53
nit: No need for {} on single-line if.
|
+ } |
+ |
switch (hash_function_) { |
case NONE: |
return "spake2_plain"; |
case HMAC_SHA256: |
return "spake2_hmac"; |
+ default: |
+ NOTREACHED(); |
} |
- NOTREACHED(); |
- return ""; |
+ return "invalid"; |
} |
bool AuthenticationMethod::operator ==( |
@@ -98,7 +113,7 @@ bool AuthenticationMethod::operator ==( |
return !other.is_valid(); |
if (!other.is_valid()) |
return false; |
- return hash_function_ == other.hash_function_; |
+ return ToString() == other.ToString(); |
Wez
2013/03/05 22:55:53
nit: This creates two std::strings on every compar
|
} |
bool SharedSecretHash::Parse(const std::string& as_string) { |