|
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 #ifndef AuthenticationChallenge_h |
|
26 #define AuthenticationChallenge_h |
|
27 |
|
28 #include "Credential.h" |
|
29 #include "ProtectionSpace.h" |
|
30 #include "ResourceResponse.h" |
|
31 #include "ResourceError.h" |
|
32 |
|
33 #include <wtf/RefPtr.h> |
|
34 |
|
35 |
|
36 #if PLATFORM(MAC) |
|
37 #include <wtf/RetainPtr.h> |
|
38 #ifndef __OBJC__ |
|
39 typedef struct objc_object *id; |
|
40 class NSURLAuthenticationChallenge; |
|
41 #else |
|
42 @class NSURLAuthenticationChallenge; |
|
43 #endif |
|
44 #endif |
|
45 |
|
46 #if USE(CFNETWORK) |
|
47 typedef struct _CFURLAuthChallenge* CFURLAuthChallengeRef; |
|
48 #endif |
|
49 |
|
50 |
|
51 namespace WebCore { |
|
52 |
|
53 class ResourceHandle; |
|
54 |
|
55 class AuthenticationChallenge { |
|
56 |
|
57 public: |
|
58 AuthenticationChallenge(); |
|
59 AuthenticationChallenge(const ProtectionSpace& protectionSpace, const Credential& proposedCredential, unsigned previousFailureCount, const ResourceResponse& response, const ResourceError& error); |
|
60 #if PLATFORM(MAC) |
|
61 AuthenticationChallenge(NSURLAuthenticationChallenge *); |
|
62 #elif USE(CFNETWORK) |
|
63 AuthenticationChallenge(CFURLAuthChallengeRef, ResourceHandle* sourceHandle); |
|
64 #endif |
|
65 |
|
66 unsigned previousFailureCount() const; |
|
67 const Credential& proposedCredential() const; |
|
68 const ProtectionSpace& protectionSpace() const; |
|
69 const ResourceResponse& failureResponse() const; |
|
70 const ResourceError& error() const; |
|
71 |
|
72 bool isNull() const; |
|
73 void nullify(); |
|
74 |
|
75 #if PLATFORM(MAC) |
|
76 id sender() const { return m_sender.get(); } |
|
77 NSURLAuthenticationChallenge *nsURLAuthenticationChallenge() const { return m_macChallenge.get(); } |
|
78 #elif USE(CFNETWORK) |
|
79 ResourceHandle* sourceHandle() const { return m_sourceHandle.get(); } |
|
80 CFURLAuthChallengeRef cfURLAuthChallengeRef() const { return m_cfChallenge.get(); } |
|
81 #endif |
|
82 private: |
|
83 bool m_isNull; |
|
84 ProtectionSpace m_protectionSpace; |
|
85 Credential m_proposedCredential; |
|
86 unsigned m_previousFailureCount; |
|
87 ResourceResponse m_failureResponse; |
|
88 ResourceError m_error; |
|
89 |
|
90 #if PLATFORM(MAC) |
|
91 RetainPtr<id> m_sender; |
|
92 RetainPtr<NSURLAuthenticationChallenge *> m_macChallenge; |
|
93 #elif USE(CFNETWORK) |
|
94 RefPtr<ResourceHandle> m_sourceHandle; |
|
95 RetainPtr<CFURLAuthChallengeRef> m_cfChallenge; |
|
96 #endif |
|
97 |
|
98 }; |
|
99 |
|
100 bool operator==(const AuthenticationChallenge&, const AuthenticationChallenge&); |
|
101 bool operator!=(const AuthenticationChallenge&, const AuthenticationChallenge&); |
|
102 } |
|
103 #endif |
|
104 |