2008-05-11 Sam Weinig <sam@webkit.org>
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 11 May 2008 20:26:28 +0000 (20:26 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 11 May 2008 20:26:28 +0000 (20:26 +0000)
        Reviewed by Dan Bernstein.

        Add scaffolding for the implementation of Access Control for Cross-site Requests.

        * GNUmakefile.am:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * WebCoreSources.bkl:
        * xml/AccessControlList.cpp: Added.
        (WebCore::AccessControlList::AccessControlList):
        (WebCore::AccessControlList::~AccessControlList):
        (WebCore::AccessControlList::parseAccessControlHeader):
        (WebCore::AccessControlList::checkOrigin):
        * xml/AccessControlList.h: Added.
        * xml/AccessItem.cpp: Added.
        (WebCore::AccessItem::AccessItem):
        (WebCore::AccessItem::parseAccessItem):
        (WebCore::AccessItem::matches):
        * xml/AccessItem.h: Added.
        * xml/AccessItemRule.cpp: Added.
        (WebCore::AccessItemRule::AccessItemRule):
        (WebCore::AccessItemRule::parseAccessItemRule):
        * xml/AccessItemRule.h: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@33033 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/WebCoreSources.bkl
WebCore/xml/AccessControlList.cpp [new file with mode: 0644]
WebCore/xml/AccessControlList.h [new file with mode: 0644]
WebCore/xml/AccessItem.cpp [new file with mode: 0644]
WebCore/xml/AccessItem.h [new file with mode: 0644]
WebCore/xml/AccessItemRule.cpp [new file with mode: 0644]
WebCore/xml/AccessItemRule.h [new file with mode: 0644]

index 6ab5575..c6d84cd 100644 (file)
@@ -1,3 +1,30 @@
+2008-05-11  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Dan Bernstein.
+
+        Add scaffolding for the implementation of Access Control for Cross-site Requests. 
+
+        * GNUmakefile.am:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * WebCoreSources.bkl:
+        * xml/AccessControlList.cpp: Added.
+        (WebCore::AccessControlList::AccessControlList):
+        (WebCore::AccessControlList::~AccessControlList):
+        (WebCore::AccessControlList::parseAccessControlHeader):
+        (WebCore::AccessControlList::checkOrigin):
+        * xml/AccessControlList.h: Added.
+        * xml/AccessItem.cpp: Added.
+        (WebCore::AccessItem::AccessItem):
+        (WebCore::AccessItem::parseAccessItem):
+        (WebCore::AccessItem::matches):
+        * xml/AccessItem.h: Added.
+        * xml/AccessItemRule.cpp: Added.
+        (WebCore::AccessItemRule::AccessItemRule):
+        (WebCore::AccessItemRule::parseAccessItemRule):
+        * xml/AccessItemRule.h: Added.
+
 2008-05-11  Julien Chaffraix  <jchaffraix@webkit.org>
 
         Debug build fix.
index 199326a..a1bace1 100644 (file)
@@ -991,6 +991,9 @@ webcore_sources += \
        WebCore/rendering/RenderWidget.cpp \
        WebCore/rendering/RenderWordBreak.cpp \
        WebCore/rendering/RootInlineBox.cpp \
+       WebCore/xml/AccessControlList.cpp \
+       WebCore/xml/AccessItem.cpp \
+       WebCore/xml/AccessItemRule.cpp \
        WebCore/xml/DOMParser.cpp \
        WebCore/xml/XMLHttpRequest.cpp \
        WebCore/xml/XMLHttpRequestProgressEvent.cpp \
index a80cffb..0d69e85 100644 (file)
@@ -927,6 +927,9 @@ SOURCES += \
     rendering/RenderWordBreak.cpp \
     rendering/RootInlineBox.cpp \
     rendering/SVGRenderTreeAsText.cpp \
+    xml/AccessControlList.cpp \
+    xml/AccessItem.cpp \
+    xml/AccessItemRule.cpp \
     xml/DOMParser.cpp \
     xml/NativeXPathNSResolver.cpp \
     xml/XMLHttpRequest.cpp \
index 8e63d3d..8bf6f08 100644 (file)
                        Name="xml"\r
                        >\r
                        <File\r
+                               RelativePath="..\xml\AccessControlList.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\xml\AccessControlList.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\xml\AccessItem.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\xml\AccessItem.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\xml\AccessItemRule.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\xml\AccessItemRule.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\xml\DOMParser.cpp"\r
                                >\r
                        </File>\r
index 7dd5a5b..9ab3556 100644 (file)
                BC348BD40DB7F804004ABAB9 /* JSXMLHttpRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = BC348BD20DB7F804004ABAB9 /* JSXMLHttpRequest.h */; };
                BC348BE90DB80354004ABAB9 /* JSXMLHttpRequestConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC348BE70DB80354004ABAB9 /* JSXMLHttpRequestConstructor.cpp */; };
                BC348BEA0DB80354004ABAB9 /* JSXMLHttpRequestConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC348BE80DB80354004ABAB9 /* JSXMLHttpRequestConstructor.h */; };
+               BC34C33A0DD607DE00090123 /* AccessControlList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC34C3340DD607DE00090123 /* AccessControlList.cpp */; };
+               BC34C33B0DD607DE00090123 /* AccessControlList.h in Headers */ = {isa = PBXBuildFile; fileRef = BC34C3350DD607DE00090123 /* AccessControlList.h */; };
+               BC34C33C0DD607DE00090123 /* AccessItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC34C3360DD607DE00090123 /* AccessItem.cpp */; };
+               BC34C33D0DD607DE00090123 /* AccessItem.h in Headers */ = {isa = PBXBuildFile; fileRef = BC34C3370DD607DE00090123 /* AccessItem.h */; };
+               BC34C33E0DD607DE00090123 /* AccessItemRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC34C3380DD607DE00090123 /* AccessItemRule.cpp */; };
+               BC34C33F0DD607DE00090123 /* AccessItemRule.h in Headers */ = {isa = PBXBuildFile; fileRef = BC34C3390DD607DE00090123 /* AccessItemRule.h */; };
                BC3C39B60C0D3D8D005F4D7A /* JSMediaList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC3C39B40C0D3D8D005F4D7A /* JSMediaList.cpp */; };
                BC3C39B70C0D3D8D005F4D7A /* JSMediaList.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3C39B50C0D3D8D005F4D7A /* JSMediaList.h */; };
                BC3FCAA90AC3DB5800BA54AD /* PlatformScrollBar.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3FCAA80AC3DB5800BA54AD /* PlatformScrollBar.h */; settings = {ATTRIBUTES = (); }; };
                BC348BD20DB7F804004ABAB9 /* JSXMLHttpRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSXMLHttpRequest.h; sourceTree = "<group>"; };
                BC348BE70DB80354004ABAB9 /* JSXMLHttpRequestConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSXMLHttpRequestConstructor.cpp; sourceTree = "<group>"; };
                BC348BE80DB80354004ABAB9 /* JSXMLHttpRequestConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSXMLHttpRequestConstructor.h; sourceTree = "<group>"; };
+               BC34C3340DD607DE00090123 /* AccessControlList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessControlList.cpp; sourceTree = "<group>"; };
+               BC34C3350DD607DE00090123 /* AccessControlList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessControlList.h; sourceTree = "<group>"; };
+               BC34C3360DD607DE00090123 /* AccessItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessItem.cpp; sourceTree = "<group>"; };
+               BC34C3370DD607DE00090123 /* AccessItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessItem.h; sourceTree = "<group>"; };
+               BC34C3380DD607DE00090123 /* AccessItemRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessItemRule.cpp; sourceTree = "<group>"; };
+               BC34C3390DD607DE00090123 /* AccessItemRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessItemRule.h; sourceTree = "<group>"; };
                BC3C39B40C0D3D8D005F4D7A /* JSMediaList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaList.cpp; sourceTree = "<group>"; };
                BC3C39B50C0D3D8D005F4D7A /* JSMediaList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSMediaList.h; sourceTree = "<group>"; };
                BC3FCAA80AC3DB5800BA54AD /* PlatformScrollBar.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PlatformScrollBar.h; sourceTree = "<group>"; };
                E1F0424309839389006694EA /* xml */ = {
                        isa = PBXGroup;
                        children = (
+                               BC34C3340DD607DE00090123 /* AccessControlList.cpp */,
+                               BC34C3350DD607DE00090123 /* AccessControlList.h */,
+                               BC34C3360DD607DE00090123 /* AccessItem.cpp */,
+                               BC34C3370DD607DE00090123 /* AccessItem.h */,
+                               BC34C3380DD607DE00090123 /* AccessItemRule.cpp */,
+                               BC34C3390DD607DE00090123 /* AccessItemRule.h */,
                                1ACE53E10A8D18E70022947D /* DOMParser.cpp */,
                                1ACE53E20A8D18E70022947D /* DOMParser.h */,
                                1ACE53E30A8D18E70022947D /* DOMParser.idl */,
                                BCBFB53D0DCD29CF0019B3E5 /* JSDOMWindowShell.h in Headers */,
                                2999869E0DD0DEEA00F8D261 /* AccessibilityListBoxOption.h in Headers */,
                                299986A00DD0DEEA00F8D261 /* AccessibilityListBox.h in Headers */,
+                               BC34C33B0DD607DE00090123 /* AccessControlList.h in Headers */,
+                               BC34C33D0DD607DE00090123 /* AccessItem.h in Headers */,
+                               BC34C33F0DD607DE00090123 /* AccessItemRule.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                BCBFB53C0DCD29CF0019B3E5 /* JSDOMWindowShell.cpp in Sources */,
                                2999869F0DD0DEEA00F8D261 /* AccessibilityListBoxOption.cpp in Sources */,
                                299986A10DD0DEEA00F8D261 /* AccessibilityListBox.cpp in Sources */,
+                               BC34C33A0DD607DE00090123 /* AccessControlList.cpp in Sources */,
+                               BC34C33C0DD607DE00090123 /* AccessItem.cpp in Sources */,
+                               BC34C33E0DD607DE00090123 /* AccessItemRule.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 94dd84a..3ec2da2 100644 (file)
@@ -835,6 +835,9 @@ This file contains the list of files needed to build WebCore.
     </set>
 
     <set append="1" var="WEBCORE_SOURCES_XML">
+        xml/AccessControlList.cpp
+        xml/AccessItem.cpp
+        xml/AccessItemRule.cpp
         xml/DOMParser.cpp
         xml/NativeXPathNSResolver.cpp
         xml/XMLHttpRequest.cpp
diff --git a/WebCore/xml/AccessControlList.cpp b/WebCore/xml/AccessControlList.cpp
new file mode 100644 (file)
index 0000000..a1b68b9
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "AccessControlList.h"
+
+#include "AccessItemRule.h"
+#include "PlatformString.h"
+#include "SecurityOrigin.h"
+
+namespace WebCore {
+
+AccessControlList::AccessControlList(const String& accessControlHeader)
+{
+    parseAccessControlHeader(accessControlHeader);
+}
+
+AccessControlList::~AccessControlList()
+{
+    deleteAllValues(m_list);
+}
+
+void AccessControlList::parseAccessControlHeader(const String& accessControlHeader)
+{
+}
+
+bool AccessControlList::checkOrigin(const SecurityOrigin* accessControlOrigin)
+{
+    return false;
+}
+
+} // namespace WebCore
diff --git a/WebCore/xml/AccessControlList.h b/WebCore/xml/AccessControlList.h
new file mode 100644 (file)
index 0000000..fc5bc39
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AccessControlList_h
+#define AccessControlList_h
+
+#include <wtf/Noncopyable.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+    class AccessItemRule;
+    class String;
+    class SecurityOrigin;
+
+    class AccessControlList : Noncopyable {
+    public:
+        AccessControlList(const String& accessControlHeader);
+        ~AccessControlList();
+
+        bool checkOrigin(const SecurityOrigin* accessControlOrigin);
+
+    private:
+        void parseAccessControlHeader(const String&);
+
+        Vector<AccessItemRule*> m_list;
+    };
+
+} // namespace WebCore
+
+#endif // AccessControlList_h
diff --git a/WebCore/xml/AccessItem.cpp b/WebCore/xml/AccessItem.cpp
new file mode 100644 (file)
index 0000000..a53ae2d
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "AccessItem.h"
+
+#include "PlatformString.h"
+#include "SecurityOrigin.h"
+
+namespace WebCore {
+
+AccessItem::AccessItem(const String& accessItemString)
+    : m_wildcard(false)
+    , m_domainWildcard(false)
+    , m_portWildcard(false)
+    , m_port(0)
+{
+    parseAccessItem(accessItemString);
+}
+
+void AccessItem::parseAccessItem(const String& accessItemString)
+{
+    // Parse the Access Item according to Section 4.1 (Access Item) of the 
+    // Access Control for Cross-site Requests spec.
+    // W3C Working Draft 14 February 2008
+
+    //   access-item    = [scheme "://"] domain-pattern [":" port-pattern] | "*"
+    //   domain-pattern = domain | "*." domain
+    //   port-pattern   = port | "*"
+
+    // FIXME: Parse the AccessItem.
+}
+
+bool AccessItem::matches(const SecurityOrigin* accessControlOrigin)
+{
+    return false;
+}
+
+} // namespace WebCore
diff --git a/WebCore/xml/AccessItem.h b/WebCore/xml/AccessItem.h
new file mode 100644 (file)
index 0000000..231ea98
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AccessItem_h
+#define AccessItem_h
+
+#include "PlatformString.h"
+#include "SecurityOrigin.h"
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+    class AccessItem {
+    public:
+        AccessItem(const String&);
+
+        bool matches(const SecurityOrigin*);
+
+    private:
+        void parseAccessItem(const String&);
+
+        bool m_wildcard;
+        String m_scheme;
+        bool m_domainWildcard;
+        Vector<String, 4> m_subdomains;
+        bool m_portWildcard;
+        unsigned short m_port;
+    };
+
+} // namespace WebCore
+
+#endif // AccessItem_h
diff --git a/WebCore/xml/AccessItemRule.cpp b/WebCore/xml/AccessItemRule.cpp
new file mode 100644 (file)
index 0000000..e2973cd
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "AccessItemRule.h"
+
+#include "PlatformString.h"
+
+namespace WebCore {
+
+AccessItemRule::AccessItemRule(const String& rule)
+{
+    parseAccessItemRule(rule);
+}
+
+void AccessItemRule::parseAccessItemRule(const String& rule)
+{
+    // Parse the rule according to Section 4.2 (Access-Control HTTP Response Header) of the 
+    // Access Control for Cross-site Requests spec.
+    // W3C Working Draft 14 February 2008
+
+    //   Access-Control = "Access-Control" ":" 1#rule
+    //   rule           = "allow" 1*(LWS pattern) [LWS "exclude" 1*(LWS pattern)]
+    //   pattern        = "<" access item ">"
+
+    // FIXME: Parse the rule.
+}
+
+} // namespace WebCore
diff --git a/WebCore/xml/AccessItemRule.h b/WebCore/xml/AccessItemRule.h
new file mode 100644 (file)
index 0000000..5b7d51a
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AccessItemRule_h
+#define AccessItemRule_h
+
+#include "AccessItem.h"
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+    class String;
+
+    class AccessItemRule {
+    public:
+        AccessItemRule(const String&);
+
+    private:
+        void parseAccessItemRule(const String&);
+
+        Vector<AccessItem> m_allowList;
+        Vector<AccessItem> m_excludeList;
+    };
+
+} // namespace WebCore
+
+#endif // AccessItemRule_h