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 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 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 | |
26 | #ifndef ProtectionSpaceBase_h |
27 | #define ProtectionSpaceBase_h |
28 | |
29 | #include <wtf/text/WTFString.h> |
30 | |
31 | namespace WebCore { |
32 | |
33 | class ProtectionSpace; |
34 | |
35 | enum ProtectionSpaceServerType { |
36 | ProtectionSpaceServerHTTP = 1, |
37 | ProtectionSpaceServerHTTPS = 2, |
38 | ProtectionSpaceServerFTP = 3, |
39 | ProtectionSpaceServerFTPS = 4, |
40 | ProtectionSpaceProxyHTTP = 5, |
41 | ProtectionSpaceProxyHTTPS = 6, |
42 | ProtectionSpaceProxyFTP = 7, |
43 | ProtectionSpaceProxySOCKS = 8 |
44 | }; |
45 | |
46 | enum ProtectionSpaceAuthenticationScheme { |
47 | ProtectionSpaceAuthenticationSchemeDefault = 1, |
48 | ProtectionSpaceAuthenticationSchemeHTTPBasic = 2, |
49 | ProtectionSpaceAuthenticationSchemeHTTPDigest = 3, |
50 | ProtectionSpaceAuthenticationSchemeHTMLForm = 4, |
51 | ProtectionSpaceAuthenticationSchemeNTLM = 5, |
52 | ProtectionSpaceAuthenticationSchemeNegotiate = 6, |
53 | ProtectionSpaceAuthenticationSchemeClientCertificateRequested = 7, |
54 | ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested = 8, |
55 | ProtectionSpaceAuthenticationSchemeOAuth = 9, |
56 | ProtectionSpaceAuthenticationSchemeUnknown = 100 |
57 | }; |
58 | |
59 | class ProtectionSpaceBase { |
60 | |
61 | public: |
62 | bool isHashTableDeletedValue() const { return m_isHashTableDeletedValue; } |
63 | |
64 | WEBCORE_EXPORT const String& host() const; |
65 | WEBCORE_EXPORT int port() const; |
66 | WEBCORE_EXPORT ProtectionSpaceServerType serverType() const; |
67 | WEBCORE_EXPORT bool isProxy() const; |
68 | WEBCORE_EXPORT const String& realm() const; |
69 | WEBCORE_EXPORT ProtectionSpaceAuthenticationScheme authenticationScheme() const; |
70 | |
71 | WEBCORE_EXPORT bool receivesCredentialSecurely() const; |
72 | WEBCORE_EXPORT bool isPasswordBased() const; |
73 | |
74 | bool encodingRequiresPlatformData() const { return false; } |
75 | |
76 | WEBCORE_EXPORT static bool compare(const ProtectionSpace&, const ProtectionSpace&); |
77 | |
78 | protected: |
79 | WEBCORE_EXPORT ProtectionSpaceBase(); |
80 | WEBCORE_EXPORT ProtectionSpaceBase(const String& host, int port, ProtectionSpaceServerType, const String& realm, ProtectionSpaceAuthenticationScheme); |
81 | |
82 | // Hash table deleted values, which are only constructed and never copied or destroyed. |
83 | ProtectionSpaceBase(WTF::HashTableDeletedValueType) : m_isHashTableDeletedValue(true) { } |
84 | |
85 | static bool platformCompare(const ProtectionSpace&, const ProtectionSpace&) { return true; } |
86 | |
87 | private: |
88 | String m_host; |
89 | int m_port; |
90 | ProtectionSpaceServerType m_serverType; |
91 | String m_realm; |
92 | ProtectionSpaceAuthenticationScheme m_authenticationScheme; |
93 | bool m_isHashTableDeletedValue; |
94 | }; |
95 | |
96 | inline bool operator==(const ProtectionSpace& a, const ProtectionSpace& b) { return ProtectionSpaceBase::compare(a, b); } |
97 | inline bool operator!=(const ProtectionSpace& a, const ProtectionSpace& b) { return !(a == b); } |
98 | |
99 | } // namespace WebCore |
100 | |
101 | #endif // ProtectionSpaceBase_h |
102 | |