This is an automated email from the ASF dual-hosted git repository.

svenmeier pushed a commit to branch WICKET-6321-cross-origin-integrity
in repository https://gitbox.apache.org/repos/asf/wicket.git

commit 9c34185602c9aec3db7bcf8498ce85ac56b1043f
Author: Sven Meier <svenme...@apache.org>
AuthorDate: Mon Dec 9 18:19:40 2019 +0100

    WICKET-6321 moved Cors to separate file
---
 .../org/apache/wicket/markup/html/CrossOrigin.java | 54 ++++++++++++++++++++++
 .../wicket/markup/html/image/ExternalImage.java    | 16 +++----
 .../wicket/markup/html/image/ExternalSource.java   |  6 +--
 .../org/apache/wicket/markup/html/image/Image.java | 50 +++-----------------
 .../apache/wicket/markup/html/image/Source.java    |  5 +-
 .../html/image/ImageResourceReferenceTestPage.java |  4 +-
 .../markup/html/image/ResponsiveImageTest.java     |  3 +-
 7 files changed, 79 insertions(+), 59 deletions(-)

diff --git 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/CrossOrigin.java 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/CrossOrigin.java
new file mode 100644
index 0000000..9151eee
--- /dev/null
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/CrossOrigin.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.markup.html;
+
+/**
+ * To be used for the crossOrigin attribute
+ *
+ * @see {@link #setCrossOrigin(CrossOrigin)}
+ */
+public enum CrossOrigin {
+       /**
+        * no authentication required
+        */
+       ANONYMOUS("anonymous"),
+       /**
+        * user credentials required
+        */
+       USE_CREDENTIALS("user-credentials"),
+       /**
+        * no cross origin
+        */
+       NO_CORS("");
+
+       private final String realName;
+
+       private CrossOrigin(String realName)
+       {
+               this.realName = realName;
+       }
+
+       /**
+        * Gets the real name for the cors option
+        * 
+        * @return the real name
+        */
+       public String getRealName()
+       {
+               return realName;
+       }
+}
\ No newline at end of file
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/image/ExternalImage.java
 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/image/ExternalImage.java
index 2a30418..915bb72 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/image/ExternalImage.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/image/ExternalImage.java
@@ -23,8 +23,8 @@ import java.util.Collections;
 import java.util.List;
 
 import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.html.CrossOrigin;
 import org.apache.wicket.markup.html.WebComponent;
-import org.apache.wicket.markup.html.image.Image.Cors;
 import org.apache.wicket.model.IModel;
 import org.apache.wicket.model.Model;
 
@@ -53,7 +53,7 @@ public class ExternalImage extends WebComponent
        /**
         * Cross origin settings
         */
-       private Cors crossOrigin = null;
+       private CrossOrigin crossOrigin = null;
 
        private IModel<List<Serializable>> srcSetModel;
 
@@ -144,8 +144,8 @@ public class ExternalImage extends WebComponent
 
                buildSizesAttribute(tag);
 
-               Cors crossOrigin = getCrossOrigin();
-               if (crossOrigin != null && Cors.NO_CORS != crossOrigin)
+               CrossOrigin crossOrigin = getCrossOrigin();
+               if (crossOrigin != null && CrossOrigin.NO_CORS != crossOrigin)
                {
                        tag.put("crossOrigin", crossOrigin.getRealName());
                }
@@ -282,11 +282,11 @@ public class ExternalImage extends WebComponent
        /**
         * Gets the cross origin settings
         * 
-        * @see {@link 
org.apache.wicket.markup.html.image.Image#setCrossOrigin(Cors)}
+        * @see {@link 
org.apache.wicket.markup.html.image.Image#setCrossOrigin(CrossOrigin)}
         *
         * @return the cross origins settings
         */
-       public Cors getCrossOrigin()
+       public CrossOrigin getCrossOrigin()
        {
                return crossOrigin;
        }
@@ -294,11 +294,11 @@ public class ExternalImage extends WebComponent
        /**
         * Sets the cross origin settings
         * 
-        * @see {@link 
org.apache.wicket.markup.html.image.Image#setCrossOrigin(Cors)}
+        * @see {@link 
org.apache.wicket.markup.html.image.Image#setCrossOrigin(CrossOrigin)}
         * @param crossOrigin
         *            the cross origins settings to set
         */
-       public void setCrossOrigin(Cors crossOrigin)
+       public void setCrossOrigin(CrossOrigin crossOrigin)
        {
                this.crossOrigin = crossOrigin;
        }
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/image/ExternalSource.java
 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/image/ExternalSource.java
index a1bf59a..afd7409 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/image/ExternalSource.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/image/ExternalSource.java
@@ -21,7 +21,7 @@ import java.util.Collections;
 import java.util.List;
 
 import org.apache.wicket.markup.ComponentTag;
-import org.apache.wicket.markup.html.image.Image.Cors;
+import org.apache.wicket.markup.html.CrossOrigin;
 import org.apache.wicket.model.IModel;
 import org.apache.wicket.model.Model;
 
@@ -124,7 +124,7 @@ public class ExternalSource extends ExternalImage
         * Unsupported for source tag
         */
        @Override
-       public void setCrossOrigin(Cors crossorigin)
+       public void setCrossOrigin(CrossOrigin crossorigin)
        {
                throw new UnsupportedOperationException(
                        "It is not allowed to set the crossorigin attribute for 
source tag");
@@ -134,7 +134,7 @@ public class ExternalSource extends ExternalImage
         * Unsupported for source tag
         */
        @Override
-       public final Cors getCrossOrigin()
+       public final CrossOrigin getCrossOrigin()
        {
                return null;
        }
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Image.java 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Image.java
index 60677d1..0b31213 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Image.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Image.java
@@ -25,6 +25,7 @@ import org.apache.wicket.IRequestListener;
 import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
 import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.markup.MarkupStream;
+import org.apache.wicket.markup.html.CrossOrigin;
 import org.apache.wicket.markup.html.WebComponent;
 import org.apache.wicket.markup.html.image.resource.LocalizedImageResource;
 import org.apache.wicket.model.IModel;
@@ -52,43 +53,6 @@ public class Image extends WebComponent implements 
IRequestListener
 {
        private static final long serialVersionUID = 1L;
 
-       /**
-        * To be used for the crossOrigin attribute
-        *
-        * @see {@link #setCrossOrigin(Cors)}
-        */
-       public enum Cors {
-               /**
-                * no authentication required
-                */
-               ANONYMOUS("anonymous"),
-               /**
-                * user credentials required
-                */
-               USE_CREDENTIALS("user-credentials"),
-               /**
-                * no cross origin
-                */
-               NO_CORS("");
-
-               private final String realName;
-
-               private Cors(String realName)
-               {
-                       this.realName = realName;
-               }
-
-               /**
-                * Gets the real name for the cors option
-                * 
-                * @return the real name
-                */
-               public String getRealName()
-               {
-                       return realName;
-               }
-       }
-
        /** The image resource this image component references (src attribute) 
*/
        private final LocalizedImageResource localizedImageResource = new 
LocalizedImageResource(this);
 
@@ -104,7 +68,7 @@ public class Image extends WebComponent implements 
IRequestListener
        /**
         * Cross origin settings
         */
-       private Cors crossOrigin = null;
+       private CrossOrigin crossOrigin = null;
 
        /**
         * This constructor can be used if you override {@link 
#getImageResourceReference()} or
@@ -432,8 +396,8 @@ public class Image extends WebComponent implements 
IRequestListener
                }
                buildSizesAttribute(tag);
 
-               Cors crossOrigin = getCrossOrigin();
-               if (crossOrigin != null && Cors.NO_CORS != crossOrigin)
+               CrossOrigin crossOrigin = getCrossOrigin();
+               if (crossOrigin != null && CrossOrigin.NO_CORS != crossOrigin)
                {
                        tag.put("crossOrigin", crossOrigin.getRealName());
                }
@@ -603,11 +567,11 @@ public class Image extends WebComponent implements 
IRequestListener
        /**
         * Gets the cross origin settings
         *
-        * @see {@link #setCrossOrigin(Cors)}
+        * @see {@link #setCrossOrigin(CrossOrigin)}
         *
         * @return the cross origins settings
         */
-       public Cors getCrossOrigin()
+       public CrossOrigin getCrossOrigin()
        {
                return crossOrigin;
        }
@@ -629,7 +593,7 @@ public class Image extends WebComponent implements 
IRequestListener
         * @param crossOrigin
         *            the cross origins settings to set
         */
-       public void setCrossOrigin(Cors crossOrigin)
+       public void setCrossOrigin(CrossOrigin crossOrigin)
        {
                this.crossOrigin = crossOrigin;
        }
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Source.java 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Source.java
index 713309a..411d0a1 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Source.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Source.java
@@ -17,6 +17,7 @@
 package org.apache.wicket.markup.html.image;
 
 import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.html.CrossOrigin;
 import org.apache.wicket.model.IModel;
 import org.apache.wicket.request.mapper.parameter.PageParameters;
 import org.apache.wicket.request.resource.IResource;
@@ -160,7 +161,7 @@ public class Source extends Image
         * Unsupported for source tag
         */
        @Override
-       public void setCrossOrigin(Cors crossorigin)
+       public void setCrossOrigin(CrossOrigin crossorigin)
        {
                throw new UnsupportedOperationException(
                        "It is not allowed to set the crossorigin attribute for 
source tag");
@@ -170,7 +171,7 @@ public class Source extends Image
         * Unsupported for source tag
         */
        @Override
-       public final Cors getCrossOrigin()
+       public final CrossOrigin getCrossOrigin()
        {
                return null;
        }
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/markup/html/image/ImageResourceReferenceTestPage.java
 
b/wicket-core/src/test/java/org/apache/wicket/markup/html/image/ImageResourceReferenceTestPage.java
index 4181155..934e156 100644
--- 
a/wicket-core/src/test/java/org/apache/wicket/markup/html/image/ImageResourceReferenceTestPage.java
+++ 
b/wicket-core/src/test/java/org/apache/wicket/markup/html/image/ImageResourceReferenceTestPage.java
@@ -16,8 +16,8 @@
  */
 package org.apache.wicket.markup.html.image;
 
+import org.apache.wicket.markup.html.CrossOrigin;
 import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.markup.html.image.Image.Cors;
 import org.apache.wicket.model.Model;
 import org.apache.wicket.request.resource.PackageResourceReference;
 import org.apache.wicket.request.resource.ResourceReference;
@@ -39,7 +39,7 @@ public class ImageResourceReferenceTestPage extends WebPage
                                return new 
PackageResourceReference(this.getClass(), "small.jpg");
                        }
                };
-               image1.setCrossOrigin(Cors.ANONYMOUS);
+               image1.setCrossOrigin(CrossOrigin.ANONYMOUS);
                this.add(image1);
        }
 }
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/markup/html/image/ResponsiveImageTest.java
 
b/wicket-core/src/test/java/org/apache/wicket/markup/html/image/ResponsiveImageTest.java
index a1db8de..a8180d8 100644
--- 
a/wicket-core/src/test/java/org/apache/wicket/markup/html/image/ResponsiveImageTest.java
+++ 
b/wicket-core/src/test/java/org/apache/wicket/markup/html/image/ResponsiveImageTest.java
@@ -20,6 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
+import org.apache.wicket.markup.html.CrossOrigin;
 import org.apache.wicket.protocol.http.WebApplication;
 import org.apache.wicket.util.tester.TagTester;
 import org.apache.wicket.util.tester.WicketTestCase;
@@ -40,7 +41,7 @@ class ResponsiveImageTest extends WicketTestCase
                String lastResponseAsString = 
tester.getLastResponse().getDocument();
                TagTester createTagByAttribute = 
TagTester.createTagByName(lastResponseAsString, "img");
                assertFalse(createTagByAttribute.hasAttribute("srcset"));
-               assertEquals(Image.Cors.ANONYMOUS.getRealName(), 
createTagByAttribute.getAttribute("crossorigin"));
+               assertEquals(CrossOrigin.ANONYMOUS.getRealName(), 
createTagByAttribute.getAttribute("crossorigin"));
        }
 
        @Test

Reply via email to