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

Unified Diff: remoting/protocol/authentication_method.cc

Issue 12326090: Third Party authentication protocol. (Closed) Base URL: http://git.chromium.org/chromium/src.git@host_key_pair
Patch Set: TokenFetcher/Validator ownership, move parameters to Validator, remove client/host glue Created 7 years, 10 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/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) {

Powered by Google App Engine
This is Rietveld 408576698