OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "remoting/base/auth_token_util.h" | |
6 #include "remoting/base/constants.h" | |
7 | |
8 namespace remoting { | |
9 | |
10 void ParseAuthTokenWithService(const std::string& auth_token_with_service, | |
11 std::string* auth_token, | |
12 std::string* auth_service) { | |
13 size_t delimiter_pos = auth_token_with_service.find(':'); | |
14 if (delimiter_pos == std::string::npos) { | |
15 // Legacy case: there is no delimiter. Assume the whole string is the | |
16 // auth_token, and that we're using the default service. | |
17 // | |
18 // 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.
| |
19 auth_token->assign(auth_token_with_service); | |
20 auth_service->assign(kChromotingTokenDefaultServiceName); | |
21 } else { | |
22 auth_service->assign(auth_token_with_service.substr(0, delimiter_pos)); | |
23 | |
24 // Make sure there is *something* after the delimiter before doing substr. | |
25 if (delimiter_pos < auth_token_with_service.size()) { | |
26 auth_token->assign(auth_token_with_service.substr(delimiter_pos + 1)); | |
27 } else { | |
28 auth_token->clear(); | |
29 } | |
30 } | |
31 } | |
32 | |
33 } // namespace remoting | |
OLD | NEW |