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

Side by Side Diff: chrome/browser/internal_auth.h

Issue 6683060: Private API for extensions like ssh-client that need access to TCP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed changes to rand_util_unittest 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_INTERNAL_AUTH_H_
6 #define CHROME_BROWSER_INTERNAL_AUTH_H_
7 #pragma once
8
9 #include <map>
10 #include <string>
11
12 #include "base/gtest_prod_util.h"
13
14 class WebSocketProxyPrivateGetPassportForTCPFunction;
15
16 namespace browser {
17
18 // Call InternalAuthVerification methods on any thread.
19 class InternalAuthVerification {
20 public:
21 // Used by consumer of passport in order to verify credentials.
22 static bool VerifyPassport(
23 const std::string& passport,
24 const std::string& domain,
25 const std::map<std::string, std::string>& var_value_map);
26
27 private:
28 // We allow for easy separation of InternalAuthVerification and
29 // InternalAuthGeneration so the only thing they share (besides time) is
30 // a key (regenerated infrequently).
31 static void ChangeKey(const std::string& key);
32
33 #ifdef UNIT_TEST
34 static void set_verification_window_seconds(int seconds) {
35 verification_window_seconds_ = seconds;
36 }
37 #endif
38
39 static int get_verification_window_ticks();
40
41 static int verification_window_seconds_;
42
43 friend class InternalAuthGeneration;
44 friend class InternalAuthVerificationService;
45 friend class InternalAuthGenerationService;
46
47 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, ExpirationAndBruteForce);
48 };
49
50 // Not thread-safe. Make all calls on the same thread (UI thread).
51 class InternalAuthGeneration {
52 private:
53 // Generates passport; do this only after successful check of credentials.
54 static std::string GeneratePassport(
55 const std::string& domain,
56 const std::map<std::string, std::string>& var_value_map);
57
58 // Used only by tests.
59 static void GenerateNewKey();
60
61 friend class ::WebSocketProxyPrivateGetPassportForTCPFunction;
62
63 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, BasicGeneration);
64 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, DoubleGeneration);
65 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, BadGeneration);
66 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, BasicVerification);
67 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, BruteForce);
68 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, ExpirationAndBruteForce);
69 FRIEND_TEST_ALL_PREFIXES(InternalAuthTest, ChangeKey);
70 };
71
72 } // namespace browser
73
74 #endif // CHROME_BROWSER_INTERNAL_AUTH_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_web_socket_proxy_private_apitest.cc ('k') | chrome/browser/internal_auth.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698