Index: remoting/base/auth_token_util.cc |
diff --git a/remoting/base/auth_token_util.cc b/remoting/base/auth_token_util.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a789d87a2242b478e67070ab607fa8479a02ede9 |
--- /dev/null |
+++ b/remoting/base/auth_token_util.cc |
@@ -0,0 +1,33 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "remoting/base/auth_token_util.h" |
+#include "remoting/base/constants.h" |
+ |
+namespace remoting { |
+ |
+void ParseAuthTokenWithService(const std::string& auth_token_with_service, |
+ std::string* auth_token, |
+ std::string* auth_service) { |
+ size_t delimiter_pos = auth_token_with_service.find(':'); |
+ if (delimiter_pos == std::string::npos) { |
+ // Legacy case: there is no delimiter. Assume the whole string is the |
+ // auth_token, and that we're using the default service. |
+ // |
+ // TODO(ajwong): Remove this defaulting once all webclients are migrated. |
Wez
2011/05/25 03:57:46
Mark this with a bug-#?
awong
2011/05/25 16:56:56
Done.
|
+ auth_token->assign(auth_token_with_service); |
+ auth_service->assign(kChromotingTokenDefaultServiceName); |
+ } else { |
+ auth_service->assign(auth_token_with_service.substr(0, delimiter_pos)); |
+ |
+ // Make sure there is *something* after the delimiter before doing substr. |
+ if (delimiter_pos < auth_token_with_service.size()) { |
+ auth_token->assign(auth_token_with_service.substr(delimiter_pos + 1)); |
+ } else { |
+ auth_token->clear(); |
+ } |
+ } |
+} |
+ |
+} // namespace remoting |