| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_INTERNAL_AUTH_H_ | 5 #ifndef CHROME_BROWSER_INTERNAL_AUTH_H_ |
| 6 #define CHROME_BROWSER_INTERNAL_AUTH_H_ | 6 #define CHROME_BROWSER_INTERNAL_AUTH_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 | 13 |
| 14 namespace extensions { | |
| 15 class WebSocketProxyPrivateGetPassportForTCPFunction; | |
| 16 class WebSocketProxyPrivateGetURLForTCPFunction; | |
| 17 } | |
| 18 | |
| 19 namespace chrome { | 14 namespace chrome { |
| 20 | 15 |
| 21 // Call InternalAuthVerification methods on any thread. | 16 // Call InternalAuthVerification methods on any thread. |
| 22 class InternalAuthVerification { | 17 class InternalAuthVerification { |
| 23 public: | 18 public: |
| 24 // Used by consumer of passport in order to verify credentials. | 19 // Used by consumer of passport in order to verify credentials. |
| 25 static bool VerifyPassport( | 20 static bool VerifyPassport( |
| 26 const std::string& passport, | 21 const std::string& passport, |
| 27 const std::string& domain, | 22 const std::string& domain, |
| 28 const std::map<std::string, std::string>& var_value_map); | 23 const std::map<std::string, std::string>& var_value_map); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 47 static int get_verification_window_ticks(); | 42 static int get_verification_window_ticks(); |
| 48 | 43 |
| 49 static int verification_window_seconds_; | 44 static int verification_window_seconds_; |
| 50 | 45 |
| 51 DISALLOW_IMPLICIT_CONSTRUCTORS(InternalAuthVerification); | 46 DISALLOW_IMPLICIT_CONSTRUCTORS(InternalAuthVerification); |
| 52 }; | 47 }; |
| 53 | 48 |
| 54 // Not thread-safe. Make all calls on the same thread (UI thread). | 49 // Not thread-safe. Make all calls on the same thread (UI thread). |
| 55 class InternalAuthGeneration { | 50 class InternalAuthGeneration { |
| 56 private: | 51 private: |
| 57 friend class extensions::WebSocketProxyPrivateGetPassportForTCPFunction; | |
| 58 friend class extensions::WebSocketProxyPrivateGetURLForTCPFunction; | |
| 59 | |
| 60 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, BasicGeneration); | 52 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, BasicGeneration); |
| 61 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, DoubleGeneration); | 53 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, DoubleGeneration); |
| 62 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, BadGeneration); | 54 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, BadGeneration); |
| 63 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, BasicVerification); | 55 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, BasicVerification); |
| 64 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, BruteForce); | 56 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, BruteForce); |
| 65 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, ExpirationAndBruteForce); | 57 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, ExpirationAndBruteForce); |
| 66 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, ChangeKey); | 58 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, ChangeKey); |
| 67 | 59 |
| 68 // Generates passport; do this only after successful check of credentials. | 60 // Generates passport; do this only after successful check of credentials. |
| 69 static std::string GeneratePassport( | 61 static std::string GeneratePassport( |
| 70 const std::string& domain, | 62 const std::string& domain, |
| 71 const std::map<std::string, std::string>& var_value_map); | 63 const std::map<std::string, std::string>& var_value_map); |
| 72 | 64 |
| 73 // Used only by tests. | 65 // Used only by tests. |
| 74 static void GenerateNewKey(); | 66 static void GenerateNewKey(); |
| 75 }; | 67 }; |
| 76 | 68 |
| 77 } // namespace chrome | 69 } // namespace chrome |
| 78 | 70 |
| 79 #endif // CHROME_BROWSER_INTERNAL_AUTH_H_ | 71 #endif // CHROME_BROWSER_INTERNAL_AUTH_H_ |
| OLD | NEW |