| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 friend class base::RefCountedThreadSafe<AuthChallengeInfo>; | 42 friend class base::RefCountedThreadSafe<AuthChallengeInfo>; |
| 43 ~AuthChallengeInfo(); | 43 ~AuthChallengeInfo(); |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 // Authentication Credentials for an authentication credentials. | 46 // Authentication Credentials for an authentication credentials. |
| 47 class NET_EXPORT AuthCredentials { | 47 class NET_EXPORT AuthCredentials { |
| 48 public: | 48 public: |
| 49 AuthCredentials(); | 49 AuthCredentials(); |
| 50 AuthCredentials(const string16& username, const string16& password); |
| 50 ~AuthCredentials(); | 51 ~AuthCredentials(); |
| 51 | 52 |
| 53 // Set the |username| and |password|. |
| 54 void Set(const string16& username, const string16& password); |
| 55 |
| 56 // Determines if |this| is equivalent to |other|. |
| 57 bool Equals(const AuthCredentials& other) const; |
| 58 |
| 59 // Returns true if all credentials are empty. |
| 60 bool Empty() const; |
| 61 |
| 62 // Overwrites the password memory to prevent it from being read if |
| 63 // it's paged out to disk. |
| 64 void Zap(); |
| 65 |
| 66 const string16& username() const { return username_; } |
| 67 const string16& password() const { return password_; } |
| 68 |
| 69 private: |
| 52 // The username to provide, possibly empty. This should be ASCII only to | 70 // The username to provide, possibly empty. This should be ASCII only to |
| 53 // minimize compatibility problems, but arbitrary UTF-16 strings are allowed | 71 // minimize compatibility problems, but arbitrary UTF-16 strings are allowed |
| 54 // and will be attempted. | 72 // and will be attempted. |
| 55 string16 username; | 73 string16 username_; |
| 56 | 74 |
| 57 // The password to provide, possibly empty. This should be ASCII only to | 75 // The password to provide, possibly empty. This should be ASCII only to |
| 58 // minimize compatibility problems, but arbitrary UTF-16 strings are allowed | 76 // minimize compatibility problems, but arbitrary UTF-16 strings are allowed |
| 59 // and will be attempted. | 77 // and will be attempted. |
| 60 string16 password; | 78 string16 password_; |
| 61 | 79 |
| 62 // Intentionally allowing the implicit copy constructor and assignment | 80 // Intentionally allowing the implicit copy constructor and assignment |
| 63 // operators. | 81 // operators. |
| 64 }; | 82 }; |
| 65 | 83 |
| 66 // Authentication structures | 84 // Authentication structures |
| 67 enum AuthState { | 85 enum AuthState { |
| 68 AUTH_STATE_DONT_NEED_AUTH, | 86 AUTH_STATE_DONT_NEED_AUTH, |
| 69 AUTH_STATE_NEED_AUTH, | 87 AUTH_STATE_NEED_AUTH, |
| 70 AUTH_STATE_HAVE_AUTH, | 88 AUTH_STATE_HAVE_AUTH, |
| 71 AUTH_STATE_CANCELED | 89 AUTH_STATE_CANCELED |
| 72 }; | 90 }; |
| 73 | 91 |
| 74 class AuthData : public base::RefCountedThreadSafe<AuthData> { | 92 class AuthData : public base::RefCountedThreadSafe<AuthData> { |
| 75 public: | 93 public: |
| 76 AuthState state; // whether we need, have, or gave up on authentication. | 94 AuthState state; // whether we need, have, or gave up on authentication. |
| 77 AuthCredentials credentials; // The credentials to use for auth. | 95 AuthCredentials credentials; // The credentials to use for auth. |
| 78 | 96 |
| 79 // We wouldn't instantiate this class if we didn't need authentication. | 97 // We wouldn't instantiate this class if we didn't need authentication. |
| 80 AuthData(); | 98 AuthData(); |
| 81 | 99 |
| 82 private: | 100 private: |
| 83 friend class base::RefCountedThreadSafe<AuthData>; | 101 friend class base::RefCountedThreadSafe<AuthData>; |
| 84 ~AuthData(); | 102 ~AuthData(); |
| 85 }; | 103 }; |
| 86 | 104 |
| 87 } // namespace net | 105 } // namespace net |
| 88 | 106 |
| 89 #endif // NET_BASE_AUTH_H__ | 107 #endif // NET_BASE_AUTH_H__ |
| OLD | NEW |