2 * Copyright (C) 2007 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
26 #include "AuthenticationChallenge.h"
28 #include "ResourceHandle.h"
32 AuthenticationChallengeBase::AuthenticationChallengeBase()
34 , m_previousFailureCount(0)
39 AuthenticationChallengeBase::AuthenticationChallengeBase(const ProtectionSpace& protectionSpace,
40 const Credential& proposedCredential,
41 unsigned previousFailureCount,
42 const ResourceResponse& response,
43 const ResourceError& error)
45 , m_protectionSpace(protectionSpace)
46 , m_proposedCredential(proposedCredential)
47 , m_previousFailureCount(previousFailureCount)
48 , m_failureResponse(response)
54 unsigned AuthenticationChallengeBase::previousFailureCount() const
56 return m_previousFailureCount;
59 const Credential& AuthenticationChallengeBase::proposedCredential() const
61 return m_proposedCredential;
64 const ProtectionSpace& AuthenticationChallengeBase::protectionSpace() const
66 return m_protectionSpace;
69 const ResourceResponse& AuthenticationChallengeBase::failureResponse() const
71 return m_failureResponse;
74 const ResourceError& AuthenticationChallengeBase::error() const
79 bool AuthenticationChallengeBase::isNull() const
84 void AuthenticationChallengeBase::nullify()
89 bool AuthenticationChallengeBase::compare(const AuthenticationChallenge& a, const AuthenticationChallenge& b)
91 if (a.isNull() && b.isNull())
94 if (a.isNull() || b.isNull())
97 if (a.protectionSpace() != b.protectionSpace())
100 if (a.proposedCredential() != b.proposedCredential())
103 if (a.previousFailureCount() != b.previousFailureCount())
106 if (a.failureResponse() != b.failureResponse())
109 if (a.error() != b.error())
112 return AuthenticationChallenge::platformCompare(a, b);