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

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

Issue 6901121: MAC Cookies (patch 2 of N) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: MAC Cookies (patch 2 of N) Created 9 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 "net/http/http_mac_signature.h" 5 #include "net/http/http_mac_signature.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 request_uri_ = request_uri; 101 request_uri_ = request_uri;
102 host_ = StringToLowerASCII(host); 102 host_ = StringToLowerASCII(host);
103 port_ = base::IntToString(port); 103 port_ = base::IntToString(port);
104 return true; 104 return true;
105 } 105 }
106 106
107 std::string HttpMacSignature::GenerateAuthorizationHeader() { 107 std::string HttpMacSignature::GenerateAuthorizationHeader() {
108 DCHECK(!id_.empty()) << "Call AddStateInfo first."; 108 DCHECK(!id_.empty()) << "Call AddStateInfo first.";
109 DCHECK(!method_.empty()) << "Call AddHttpInfo first."; 109 DCHECK(!method_.empty()) << "Call AddHttpInfo first.";
110 110
111 std::string timestamp = base::IntToString((base::Time::Now() - 111 std::string timestamp = base::Int64ToString((base::Time::Now() -
112 base::Time::UnixEpoch()).InSeconds()); 112 base::Time::UnixEpoch()).InSeconds());
113 std::string nonce = GenerateNonce(); 113 std::string nonce = GenerateNonce();
114 114
115 return GenerateHeaderString(timestamp, nonce); 115 return GenerateHeaderString(timestamp, nonce);
116 } 116 }
117 117
118 std::string HttpMacSignature::GenerateHeaderString( 118 std::string HttpMacSignature::GenerateHeaderString(
119 const std::string& timestamp, 119 const std::string& timestamp,
120 const std::string& nonce) { 120 const std::string& nonce) {
121 std::string mac = GenerateMAC(timestamp, nonce); 121 std::string mac = GenerateMAC(timestamp, nonce);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 length); 163 length);
164 DCHECK(result); 164 DCHECK(result);
165 165
166 std::string encoded_signature; 166 std::string encoded_signature;
167 result = base::Base64Encode(signature, &encoded_signature); 167 result = base::Base64Encode(signature, &encoded_signature);
168 DCHECK(result); 168 DCHECK(result);
169 return encoded_signature; 169 return encoded_signature;
170 } 170 }
171 171
172 } // namespace net 172 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698