OLD | NEW |
---|---|
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 #ifndef CONTENT_COMMON_EXPERIMENTS_API_KEY_H_ | 5 #ifndef CONTENT_COMMON_EXPERIMENTS_API_KEY_H_ |
6 #define CONTENT_COMMON_EXPERIMENTS_API_KEY_H_ | 6 #define CONTENT_COMMON_EXPERIMENTS_API_KEY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 GURL origin() { return origin_; } | 49 GURL origin() { return origin_; } |
50 std::string api_name() { return api_name_; } | 50 std::string api_name() { return api_name_; } |
51 uint64_t expiry_timestamp() { return expiry_timestamp_; } | 51 uint64_t expiry_timestamp() { return expiry_timestamp_; } |
52 | 52 |
53 protected: | 53 protected: |
54 friend class ApiKeyTest; | 54 friend class ApiKeyTest; |
55 | 55 |
56 bool ValidateOrigin(const std::string& origin) const; | 56 bool ValidateOrigin(const std::string& origin) const; |
57 bool ValidateApiName(const std::string& api_name) const; | 57 bool ValidateApiName(const std::string& api_name) const; |
58 bool ValidateDate(const base::Time& now) const; | 58 bool ValidateDate(const base::Time& now) const; |
59 bool ValidateSignature(const uint8_t* public_key) const; | |
davidben
2016/01/11 20:18:57
Passing in a bare pointer without some indication
iclelland
2016/01/12 14:52:49
I can certainly switch to StringPiece if that make
davidben
2016/01/13 20:50:39
I'm fine with whatever. StringPiece or code commen
iclelland
2016/01/13 21:30:11
I'm good with StringPiece (other than all of the r
davidben
2016/01/13 22:18:13
Yeah, having to add those casts drives me crazy. :
| |
60 | |
61 static bool ValidateSignature(const std::string& signature_text, | |
62 const std::string& data, | |
63 const uint8_t* public_key); | |
59 | 64 |
60 private: | 65 private: |
61 ApiKey(const std::string& signature, | 66 ApiKey(const std::string& signature, |
62 const std::string& data, | 67 const std::string& data, |
63 const GURL& origin, | 68 const GURL& origin, |
64 const std::string& api_name, | 69 const std::string& api_name, |
65 uint64_t expiry_timestamp); | 70 uint64_t expiry_timestamp); |
66 | 71 |
67 // The base64-encoded-signature portion of the key. For the key to be valid, | 72 // The base64-encoded-signature portion of the key. For the key to be valid, |
68 // this must be a valid signature for the data portion of the key, as verified | 73 // this must be a valid signature for the data portion of the key, as verified |
(...skipping 11 matching lines...) Expand all Loading... | |
80 std::string api_name_; | 85 std::string api_name_; |
81 | 86 |
82 // The time until which this key should be considered valid, in UTC, as | 87 // The time until which this key should be considered valid, in UTC, as |
83 // seconds since the Unix epoch. | 88 // seconds since the Unix epoch. |
84 uint64_t expiry_timestamp_; | 89 uint64_t expiry_timestamp_; |
85 }; | 90 }; |
86 | 91 |
87 } // namespace content | 92 } // namespace content |
88 | 93 |
89 #endif // CONTENT_COMMON_EXPERIMENTS_API_KEY_H_ | 94 #endif // CONTENT_COMMON_EXPERIMENTS_API_KEY_H_ |
OLD | NEW |