OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 NET_BASE_AUTH_H__ | 5 #ifndef NET_BASE_AUTH_H__ |
6 #define NET_BASE_AUTH_H__ | 6 #define NET_BASE_AUTH_H__ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 | 15 |
| 16 extern const char kTLSSRPScheme[]; |
| 17 |
| 18 // Protocols that use authentication |
| 19 enum AuthOverProtocol { |
| 20 AUTH_OVER_HTTP, |
| 21 AUTH_OVER_TLS |
| 22 }; |
| 23 |
16 // Holds info about an authentication challenge that we may want to display | 24 // Holds info about an authentication challenge that we may want to display |
17 // to the user. | 25 // to the user. |
18 class AuthChallengeInfo : | 26 class AuthChallengeInfo : |
19 public base::RefCountedThreadSafe<AuthChallengeInfo> { | 27 public base::RefCountedThreadSafe<AuthChallengeInfo> { |
20 public: | 28 public: |
21 AuthChallengeInfo(); | 29 AuthChallengeInfo(); |
22 | 30 |
| 31 void Reset(); |
| 32 |
23 bool operator==(const AuthChallengeInfo& that) const; | 33 bool operator==(const AuthChallengeInfo& that) const; |
24 | 34 |
25 bool operator!=(const AuthChallengeInfo& that) const { | 35 bool operator!=(const AuthChallengeInfo& that) const { |
26 return !(*this == that); | 36 return !(*this == that); |
27 } | 37 } |
28 | 38 |
29 bool is_proxy; // true for Proxy-Authenticate, false for WWW-Authenticate. | 39 bool is_proxy; // true for Proxy-Authenticate, false for WWW-Authenticate. |
30 std::wstring host_and_port; // <host>:<port> of the server asking for auth | 40 std::wstring host_and_port; // <host>:<port> of the server asking for auth |
31 // (could be the proxy). | 41 // (could be the proxy). |
32 std::wstring scheme; // "Basic", "Digest", or whatever other method is used. | 42 std::wstring scheme; // "Basic", "Digest", or whatever other method is used. |
33 std::wstring realm; // the realm provided by the server, if there is one. | 43 std::wstring realm; // the realm provided by the server, if there is one. |
34 | 44 |
| 45 int over_protocol; // the protocol to authenticate over (HTTP or TLS). |
| 46 |
35 private: | 47 private: |
36 friend class base::RefCountedThreadSafe<AuthChallengeInfo>; | 48 friend class base::RefCountedThreadSafe<AuthChallengeInfo>; |
37 ~AuthChallengeInfo(); | 49 ~AuthChallengeInfo(); |
38 }; | 50 }; |
39 | 51 |
40 // Authentication structures | 52 // Authentication structures |
41 enum AuthState { | 53 enum AuthState { |
42 AUTH_STATE_DONT_NEED_AUTH, | 54 AUTH_STATE_DONT_NEED_AUTH, |
43 AUTH_STATE_NEED_AUTH, | 55 AUTH_STATE_NEED_AUTH, |
44 AUTH_STATE_HAVE_AUTH, | 56 AUTH_STATE_HAVE_AUTH, |
45 AUTH_STATE_CANCELED | 57 AUTH_STATE_CANCELED |
46 }; | 58 }; |
47 | 59 |
48 class AuthData : public base::RefCountedThreadSafe<AuthData> { | 60 class AuthData : public base::RefCountedThreadSafe<AuthData> { |
49 public: | 61 public: |
50 AuthState state; // whether we need, have, or gave up on authentication. | 62 AuthState state; // whether we need, have, or gave up on authentication. |
51 std::wstring scheme; // the authentication scheme. | 63 std::wstring scheme; // the authentication scheme. |
52 string16 username; // the username supplied to us for auth. | 64 string16 username; // the username supplied to us for auth. |
53 string16 password; // the password supplied to us for auth. | 65 string16 password; // the password supplied to us for auth. |
| 66 int over_protocol; // the protocol to authenticate over (HTTP or TLS). |
54 | 67 |
55 // We wouldn't instantiate this class if we didn't need authentication. | 68 // We wouldn't instantiate this class if we didn't need authentication. |
56 AuthData(); | 69 AuthData(); |
57 | 70 |
58 private: | 71 private: |
59 friend class base::RefCountedThreadSafe<AuthData>; | 72 friend class base::RefCountedThreadSafe<AuthData>; |
60 ~AuthData(); | 73 ~AuthData(); |
61 }; | 74 }; |
62 | 75 |
63 } // namespace net | 76 } // namespace net |
64 | 77 |
65 #endif // NET_BASE_AUTH_H__ | 78 #endif // NET_BASE_AUTH_H__ |
OLD | NEW |