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