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.
5 #include "remoting/base/auth_token_util.h"
6 #include "remoting/base/constants.h"
10 void ParseAuthTokenWithService(const std::string& auth_service_with_token,
11 std::string* auth_token,
12 std::string* auth_service) {
13 size_t delimiter_pos = auth_service_with_token.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.
18 // TODO(ajwong): Remove this defaulting once all webclients are migrated.
20 auth_token->assign(auth_service_with_token);
21 auth_service->assign(kChromotingTokenDefaultServiceName);
23 auth_service->assign(auth_service_with_token.substr(0, delimiter_pos));
25 // Make sure there is *something* after the delimiter before doing substr.
26 if (delimiter_pos < auth_service_with_token.size()) {
27 auth_token->assign(auth_service_with_token.substr(delimiter_pos + 1));
34 } // namespace remoting