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

Side by Side Diff: net/http/http_auth_multi_round_parse.cc

Issue 1383613002: [net/http auth] Cleanup. Method names, and constness. Base URL: https://chromium.googlesource.com/chromium/src.git@mock-auth-handler-generalization
Patch Set: Created 5 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/base64.h" 5 #include "base/base64.h"
6 #include "base/strings/string_util.h" 6 #include "base/strings/string_util.h"
7 #include "net/http/http_auth_challenge_tokenizer.h" 7 #include "net/http/http_auth_challenge_tokenizer.h"
8 #include "net/http/http_auth_multi_round_parse.h" 8 #include "net/http/http_auth_multi_round_parse.h"
9 9
10 namespace net { 10 namespace net {
11 11
12 HttpAuth::AuthorizationResult ParseFirstRoundChallenge( 12 HttpAuth::AuthorizationResult ParseFirstRoundChallenge(
13 const std::string& scheme, 13 const std::string& scheme,
14 HttpAuthChallengeTokenizer* challenge) { 14 const HttpAuthChallengeTokenizer& challenge) {
15 // Verify the challenge's auth-scheme. 15 // Verify the challenge's auth-scheme.
16 if (!challenge->SchemeIs(scheme)) 16 if (!challenge.SchemeIs(scheme))
17 return HttpAuth::AUTHORIZATION_RESULT_INVALID; 17 return HttpAuth::AUTHORIZATION_RESULT_INVALID;
18 18
19 std::string encoded_auth_token = challenge->base64_param(); 19 std::string encoded_auth_token = challenge.base64_param();
20 if (!encoded_auth_token.empty()) { 20 if (!encoded_auth_token.empty()) {
21 return HttpAuth::AUTHORIZATION_RESULT_INVALID; 21 return HttpAuth::AUTHORIZATION_RESULT_INVALID;
22 } 22 }
23 return HttpAuth::AUTHORIZATION_RESULT_ACCEPT; 23 return HttpAuth::AUTHORIZATION_RESULT_ACCEPT;
24 } 24 }
25 25
26 HttpAuth::AuthorizationResult ParseLaterRoundChallenge( 26 HttpAuth::AuthorizationResult ParseLaterRoundChallenge(
27 const std::string& scheme, 27 const std::string& scheme,
28 HttpAuthChallengeTokenizer* challenge, 28 const HttpAuthChallengeTokenizer& challenge,
29 std::string* encoded_token, 29 std::string* encoded_token,
30 std::string* decoded_token) { 30 std::string* decoded_token) {
31 // Verify the challenge's auth-scheme. 31 // Verify the challenge's auth-scheme.
32 if (!challenge->SchemeIs(scheme)) 32 if (!challenge.SchemeIs(scheme))
33 return HttpAuth::AUTHORIZATION_RESULT_INVALID; 33 return HttpAuth::AUTHORIZATION_RESULT_INVALID;
34 34
35 *encoded_token = challenge->base64_param(); 35 *encoded_token = challenge.base64_param();
36 if (encoded_token->empty()) 36 if (encoded_token->empty())
37 return HttpAuth::AUTHORIZATION_RESULT_REJECT; 37 return HttpAuth::AUTHORIZATION_RESULT_REJECT;
38 38
39 // Make sure the additional token is base64 encoded. 39 // Make sure the additional token is base64 encoded.
40 if (!base::Base64Decode(*encoded_token, decoded_token)) 40 if (!base::Base64Decode(*encoded_token, decoded_token))
41 return HttpAuth::AUTHORIZATION_RESULT_INVALID; 41 return HttpAuth::AUTHORIZATION_RESULT_INVALID;
42 return HttpAuth::AUTHORIZATION_RESULT_ACCEPT; 42 return HttpAuth::AUTHORIZATION_RESULT_ACCEPT;
43 } 43 }
44 44
45 } // namespace net 45 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_multi_round_parse.h ('k') | net/http/http_auth_multi_round_parse_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698