[M120][Tizen][Onscreen] Fix build errors for TV profile
[platform/framework/web/chromium-efl.git] / chrome / browser / internal_auth.h
1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_INTERNAL_AUTH_H_
6 #define CHROME_BROWSER_INTERNAL_AUTH_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/gtest_prod_util.h"
12
13 // Call InternalAuthVerification methods on any thread.
14 class InternalAuthVerification {
15  public:
16   InternalAuthVerification() = delete;
17   InternalAuthVerification(const InternalAuthVerification&) = delete;
18   InternalAuthVerification& operator=(const InternalAuthVerification&) = delete;
19
20   // Used by consumer of passport in order to verify credentials.
21   static bool VerifyPassport(
22       const std::string& passport,
23       const std::string& domain,
24       const std::map<std::string, std::string>& var_value_map);
25
26  private:
27   friend class InternalAuthGeneration;
28   friend class InternalAuthVerificationService;
29   friend class InternalAuthGenerationService;
30   FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, ExpirationAndBruteForce);
31
32   // We allow for easy separation of InternalAuthVerification and
33   // InternalAuthGeneration so the only thing they share (besides time) is
34   // a key (regenerated infrequently).
35   static void ChangeKey(const std::string& key);
36
37 #ifdef UNIT_TEST
38   static void set_verification_window_seconds(int seconds) {
39     verification_window_seconds_ = seconds;
40   }
41 #endif
42
43   static int get_verification_window_ticks();
44
45   static int verification_window_seconds_;
46 };
47
48 // Not thread-safe. Make all calls on the same thread (UI thread).
49 class InternalAuthGeneration {
50  private:
51   FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, BasicGeneration);
52   FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, DoubleGeneration);
53   FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, BadGeneration);
54   FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, BasicVerification);
55   FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, BruteForce);
56   FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, ExpirationAndBruteForce);
57   FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, ChangeKey);
58
59   // Generates passport; do this only after successful check of credentials.
60   static std::string GeneratePassport(
61       const std::string& domain,
62       const std::map<std::string, std::string>& var_value_map);
63
64   // Used only by tests.
65   static void GenerateNewKey();
66 };
67
68 #endif  // CHROME_BROWSER_INTERNAL_AUTH_H_