• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 NET_BASE_AUTH_H__
6 #define NET_BASE_AUTH_H__
7 #pragma once
8 
9 #include <string>
10 
11 #include "base/memory/ref_counted.h"
12 #include "base/string16.h"
13 #include "net/base/net_export.h"
14 
15 namespace net {
16 
17 // Holds info about an authentication challenge that we may want to display
18 // to the user.
19 class NET_EXPORT AuthChallengeInfo :
20     public base::RefCountedThreadSafe<AuthChallengeInfo> {
21  public:
22   AuthChallengeInfo();
23 
24   bool operator==(const AuthChallengeInfo& that) const;
25 
26   bool operator!=(const AuthChallengeInfo& that) const {
27     return !(*this == that);
28   }
29 
30   bool is_proxy;  // true for Proxy-Authenticate, false for WWW-Authenticate.
31   std::wstring host_and_port;  // <host>:<port> of the server asking for auth
32                                // (could be the proxy).
33   std::wstring scheme;  // "Basic", "Digest", or whatever other method is used.
34   std::wstring realm;  // the realm provided by the server, if there is one.
35 
36  private:
37   friend class base::RefCountedThreadSafe<AuthChallengeInfo>;
38   ~AuthChallengeInfo();
39 };
40 
41 // Authentication structures
42 enum AuthState {
43   AUTH_STATE_DONT_NEED_AUTH,
44   AUTH_STATE_NEED_AUTH,
45   AUTH_STATE_HAVE_AUTH,
46   AUTH_STATE_CANCELED
47 };
48 
49 class AuthData : public base::RefCountedThreadSafe<AuthData> {
50  public:
51   AuthState state;  // whether we need, have, or gave up on authentication.
52   std::wstring scheme;  // the authentication scheme.
53   string16 username;  // the username supplied to us for auth.
54   string16 password;  // the password supplied to us for auth.
55 
56   // We wouldn't instantiate this class if we didn't need authentication.
57   AuthData();
58 
59  private:
60   friend class base::RefCountedThreadSafe<AuthData>;
61   ~AuthData();
62 };
63 
64 }  // namespace net
65 
66 #endif  // NET_BASE_AUTH_H__
67