Add CryptAuthApiCallFlow class, the underlying object to handle all CryptAuth API...
[chromium-blink-merge.git] / remoting / base / auth_token_util.cc
blob45caa92cd5d72e401bdd7908a76b527a155db813
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"
8 namespace remoting {
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.
19 // BUG:83897
20 auth_token->assign(auth_service_with_token);
21 auth_service->assign(kChromotingTokenDefaultServiceName);
22 } else {
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));
28 } else {
29 auth_token->clear();
34 } // namespace remoting