15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2011 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/base/auth.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/base/zap.h"
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace net {
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)AuthChallengeInfo::AuthChallengeInfo() : is_proxy(false) {
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool AuthChallengeInfo::Equals(const AuthChallengeInfo& that) const {
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return (this->is_proxy == that.is_proxy &&
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)          this->challenger.Equals(that.challenger) &&
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)          this->scheme == that.scheme &&
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)          this->realm == that.realm);
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)AuthChallengeInfo::~AuthChallengeInfo() {
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)AuthData::AuthData() : state(AUTH_STATE_NEED_AUTH) {
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)AuthData::~AuthData() {
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)AuthCredentials::AuthCredentials() {
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
32c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)AuthCredentials::AuthCredentials(const base::string16& username,
33c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                                 const base::string16& password)
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    : username_(username),
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      password_(password) {
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)AuthCredentials::~AuthCredentials() {
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
41c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)void AuthCredentials::Set(const base::string16& username,
42c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                          const base::string16& password) {
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  username_ = username;
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  password_ = password;
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool AuthCredentials::Equals(const AuthCredentials& other) const {
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return username_ == other.username_ && password_ == other.password_;
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool AuthCredentials::Empty() const {
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return username_.empty() && password_.empty();
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void AuthCredentials::Zap() {
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ZapString(&password_);
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace net
60