/src/3rdparty/webkit/Source/WebCore/platform/network/AuthenticationChallengeBase.cpp

https://bitbucket.org/ultra_iter/qt-vtl · C++ · 113 lines · 69 code · 20 blank · 24 comment · 14 complexity · 0c88ec77b80ca1884b2aed8a21a5ca90 MD5 · raw file

  1. /*
  2. * Copyright (C) 2007 Apple Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * 1. Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * 2. Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
  14. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
  17. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  18. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  20. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  21. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #include "config.h"
  26. #include "AuthenticationChallenge.h"
  27. #include "ResourceHandle.h"
  28. namespace WebCore {
  29. AuthenticationChallengeBase::AuthenticationChallengeBase()
  30. : m_isNull(true)
  31. , m_previousFailureCount(0)
  32. {
  33. }
  34. AuthenticationChallengeBase::AuthenticationChallengeBase(const ProtectionSpace& protectionSpace,
  35. const Credential& proposedCredential,
  36. unsigned previousFailureCount,
  37. const ResourceResponse& response,
  38. const ResourceError& error)
  39. : m_isNull(false)
  40. , m_protectionSpace(protectionSpace)
  41. , m_proposedCredential(proposedCredential)
  42. , m_previousFailureCount(previousFailureCount)
  43. , m_failureResponse(response)
  44. , m_error(error)
  45. {
  46. }
  47. unsigned AuthenticationChallengeBase::previousFailureCount() const
  48. {
  49. return m_previousFailureCount;
  50. }
  51. const Credential& AuthenticationChallengeBase::proposedCredential() const
  52. {
  53. return m_proposedCredential;
  54. }
  55. const ProtectionSpace& AuthenticationChallengeBase::protectionSpace() const
  56. {
  57. return m_protectionSpace;
  58. }
  59. const ResourceResponse& AuthenticationChallengeBase::failureResponse() const
  60. {
  61. return m_failureResponse;
  62. }
  63. const ResourceError& AuthenticationChallengeBase::error() const
  64. {
  65. return m_error;
  66. }
  67. bool AuthenticationChallengeBase::isNull() const
  68. {
  69. return m_isNull;
  70. }
  71. void AuthenticationChallengeBase::nullify()
  72. {
  73. m_isNull = true;
  74. }
  75. bool AuthenticationChallengeBase::compare(const AuthenticationChallenge& a, const AuthenticationChallenge& b)
  76. {
  77. if (a.isNull() && b.isNull())
  78. return true;
  79. if (a.isNull() || b.isNull())
  80. return false;
  81. if (a.protectionSpace() != b.protectionSpace())
  82. return false;
  83. if (a.proposedCredential() != b.proposedCredential())
  84. return false;
  85. if (a.previousFailureCount() != b.previousFailureCount())
  86. return false;
  87. if (a.failureResponse() != b.failureResponse())
  88. return false;
  89. if (a.error() != b.error())
  90. return false;
  91. return AuthenticationChallenge::platformCompare(a, b);
  92. }
  93. }