You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2021/07/20 08:51:15 UTC
[wicket] branch master updated (a479020 -> 887b4b3)
This is an automated email from the ASF dual-hosted git repository.
svenmeier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git.
from a479020 WICKET-6901 Rename ITagModifier.NoOp to NO_OP
new fa65fd7 WICKET-6902 allow prepend and append
new 887b4b3 WICKET-6906 removed deprecations
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../main/java/org/apache/wicket/Application.java | 23 -
.../wicket/ajax/AbstractAjaxTimerBehavior.java | 14 -
.../org/apache/wicket/ajax/AjaxEventBehavior.java | 9 +-
.../org/apache/wicket/ajax/AjaxRequestHandler.java | 12 +-
.../org/apache/wicket/ajax/AjaxRequestTarget.java | 40 +-
.../wicket/ajax/AjaxSelfUpdatingTimerBehavior.java | 15 +-
.../strategy/DefaultAuthenticationStrategy.java | 46 -
.../wicket/core/util/crypt/AbstractJceCrypt.java | 9 +-
.../util/crypt/KeyInSessionSunJceCryptFactory.java | 11 -
.../html/navigation/paging/PagingNavigation.java | 1 -
.../org/apache/wicket/page/PartialPageUpdate.java | 40 +-
.../apache/wicket/page/XmlPartialPageUpdate.java | 10 -
.../http/CsrfPreventionRequestCycleListener.java | 612 --------
.../wicket/protocol/http/WebApplication.java | 26 +-
.../filter/AjaxServerAndClientTimeFilter.java | 132 --
.../response/filter/ServerAndClientTimeFilter.java | 106 --
.../apache/wicket/settings/SecuritySettings.java | 11 +-
.../apache/wicket/ajax/AjaxRequestHandlerTest.java | 58 +-
.../core/request/mapper/CryptoMapperTest.java | 2 +-
.../markup/html/form/encryption/CryptTest.java | 3 +-
.../CsrfPreventionRequestCycleListenerTest.java | 658 --------
.../CryptedUrlWebRequestCodingStrategyTest.java | 5 -
.../examples/ajax/builtin/AjaxApplication.java | 3 -
.../ajax/builtin/modal/ModalContent1Page.html | 24 -
.../ajax/builtin/modal/ModalContent1Page.java | 101 --
.../ajax/builtin/modal/ModalContent2Page.html | 20 -
.../ajax/builtin/modal/ModalContent2Page.java | 49 -
.../examples/ajax/builtin/modal/ModalPanel1.html | 9 -
.../examples/ajax/builtin/modal/ModalPanel1.java | 53 -
.../ajax/builtin/modal/ModalWindowPage.html | 10 -
.../ajax/builtin/modal/ModalWindowPage.java | 116 --
.../examples/repeater/RepeaterApplication.java | 1 -
.../wicket/examples/tree/TreeApplication.java | 1 -
.../markup/html/form/upload/UploadProgressBar.java | 23 +-
.../ajax/markup/html/modal/ModalWindow.html | 21 -
.../ajax/markup/html/modal/ModalWindow.java | 1184 ---------------
.../markup/html/modal/res/frame-blue-1-alpha.png | Bin 2706 -> 0 bytes
.../ajax/markup/html/modal/res/frame-blue-1-ie.png | Bin 1672 -> 0 bytes
.../markup/html/modal/res/frame-blue-2-alpha.png | Bin 272 -> 0 bytes
.../ajax/markup/html/modal/res/frame-blue-2-ie.png | Bin 245 -> 0 bytes
.../markup/html/modal/res/frame-gray-1-alpha.png | Bin 2568 -> 0 bytes
.../ajax/markup/html/modal/res/frame-gray-1-ie.png | Bin 1578 -> 0 bytes
.../markup/html/modal/res/frame-gray-2-alpha.png | Bin 264 -> 0 bytes
.../ajax/markup/html/modal/res/frame-gray-2-ie.png | Bin 245 -> 0 bytes
.../ajax/markup/html/modal/res/modal.css | 264 ----
.../extensions/ajax/markup/html/modal/res/modal.js | 1594 --------------------
.../ajax/markup/html/modal/res/transparent1.gif | Bin 156 -> 0 bytes
.../ajax/markup/html/modal/res/transparent2.png | Bin 425 -> 0 bytes
.../markup/html/form/select/SelectOptions.java | 40 +-
...ketAwareCsrfPreventionRequestCycleListener.java | 45 -
.../apache/wicket/util/collections/MicroMap.java | 359 -----
.../apache/wicket/util/crypt/AbstractCrypt.java | 1 -
.../util/crypt/CachingSunJceCryptFactory.java | 39 -
.../wicket/util/crypt/ClassCryptFactory.java | 98 --
.../java/org/apache/wicket/util/crypt/ICrypt.java | 13 -
.../java/org/apache/wicket/util/crypt/NoCrypt.java | 11 -
.../org/apache/wicket/util/crypt/SunJceCrypt.java | 36 -
.../org/apache/wicket/util/time/AbstractTime.java | 122 --
.../apache/wicket/util/time/AbstractTimeValue.java | 55 -
.../java/org/apache/wicket/util/time/Duration.java | 565 -------
.../apache/wicket/util/time/ITimeFrameSource.java | 41 -
.../java/org/apache/wicket/util/time/Time.java | 615 --------
.../org/apache/wicket/util/time/TimeFrame.java | 261 ----
.../java/org/apache/wicket/util/time/TimeMap.java | 111 --
.../org/apache/wicket/util/time/TimeOfDay.java | 420 ------
.../wicket/util/collections/MicroMapTest.java | 105 --
.../apache/wicket/util/crypt/SunJceCryptTest.java | 6 +-
67 files changed, 99 insertions(+), 8160 deletions(-)
delete mode 100644 wicket-core/src/main/java/org/apache/wicket/protocol/http/CsrfPreventionRequestCycleListener.java
delete mode 100644 wicket-core/src/main/java/org/apache/wicket/response/filter/AjaxServerAndClientTimeFilter.java
delete mode 100644 wicket-core/src/main/java/org/apache/wicket/response/filter/ServerAndClientTimeFilter.java
delete mode 100644 wicket-core/src/test/java/org/apache/wicket/protocol/http/CsrfPreventionRequestCycleListenerTest.java
delete mode 100644 wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalContent1Page.html
delete mode 100644 wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalContent1Page.java
delete mode 100644 wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalContent2Page.html
delete mode 100644 wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalContent2Page.java
delete mode 100644 wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalPanel1.html
delete mode 100644 wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalPanel1.java
delete mode 100644 wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalWindowPage.html
delete mode 100644 wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalWindowPage.java
delete mode 100644 wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.html
delete mode 100644 wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
delete mode 100644 wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-blue-1-alpha.png
delete mode 100644 wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-blue-1-ie.png
delete mode 100644 wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-blue-2-alpha.png
delete mode 100644 wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-blue-2-ie.png
delete mode 100644 wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-gray-1-alpha.png
delete mode 100644 wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-gray-1-ie.png
delete mode 100644 wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-gray-2-alpha.png
delete mode 100644 wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-gray-2-ie.png
delete mode 100644 wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.css
delete mode 100644 wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.js
delete mode 100644 wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/transparent1.gif
delete mode 100644 wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/transparent2.png
delete mode 100644 wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/WebSocketAwareCsrfPreventionRequestCycleListener.java
delete mode 100644 wicket-util/src/main/java/org/apache/wicket/util/collections/MicroMap.java
delete mode 100644 wicket-util/src/main/java/org/apache/wicket/util/crypt/CachingSunJceCryptFactory.java
delete mode 100644 wicket-util/src/main/java/org/apache/wicket/util/crypt/ClassCryptFactory.java
delete mode 100755 wicket-util/src/main/java/org/apache/wicket/util/time/AbstractTime.java
delete mode 100755 wicket-util/src/main/java/org/apache/wicket/util/time/AbstractTimeValue.java
delete mode 100755 wicket-util/src/main/java/org/apache/wicket/util/time/Duration.java
delete mode 100755 wicket-util/src/main/java/org/apache/wicket/util/time/ITimeFrameSource.java
delete mode 100755 wicket-util/src/main/java/org/apache/wicket/util/time/Time.java
delete mode 100755 wicket-util/src/main/java/org/apache/wicket/util/time/TimeFrame.java
delete mode 100755 wicket-util/src/main/java/org/apache/wicket/util/time/TimeMap.java
delete mode 100755 wicket-util/src/main/java/org/apache/wicket/util/time/TimeOfDay.java
delete mode 100644 wicket-util/src/test/java/org/apache/wicket/util/collections/MicroMapTest.java
[wicket] 01/02: WICKET-6902 allow prepend and append
Posted by sv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
svenmeier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git
commit fa65fd754ca9345dd966d04204521d7edbe645ec
Author: Sven Meier <sv...@apache.org>
AuthorDate: Sat Jul 17 00:18:02 2021 +0200
WICKET-6902 allow prepend and append
up-to including #onAfterRespond()
---
.../org/apache/wicket/ajax/AjaxRequestHandler.java | 12 +----
.../org/apache/wicket/ajax/AjaxRequestTarget.java | 45 +++++++++++++----
.../org/apache/wicket/page/PartialPageUpdate.java | 22 +++++++-
.../apache/wicket/ajax/AjaxRequestHandlerTest.java | 58 ++++++++++++++++------
4 files changed, 98 insertions(+), 39 deletions(-)
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java
index 78699bf..fd54daa 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java
@@ -145,19 +145,9 @@ public class AjaxRequestHandler extends AbstractPartialPageRequestHandler implem
final Map<String, Component> components = Collections
.unmodifiableMap(markupIdToComponent);
- // create response that will be used by listeners to append javascript
- final AjaxRequestTarget.IJavaScriptResponse jsresponse = new AjaxRequestTarget.IJavaScriptResponse()
- {
- @Override
- public void addJavaScript(String script)
- {
- writeEvaluations(response, Collections.<CharSequence> singleton(script));
- }
- };
-
for (AjaxRequestTarget.IListener listener : listeners)
{
- listener.onAfterRespond(components, jsresponse);
+ listener.onAfterRespond(components, AjaxRequestHandler.this);
}
}
}
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
index 6c874dc..2e1efb6 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
@@ -38,35 +38,54 @@ public interface AjaxRequestTarget extends IPartialPageRequestHandler, ILoggable
interface IListener
{
/**
- * Triggered before ajax request target begins its response cycle
+ * Triggered before the target begins writing components.
*
* @param map
* modifiable map (markupId -> component) of components already added to the target
* @param target
* the target itself. Could be used to add components or to append/prepend
- * javascript
+ * JavaScript
*
*/
default void onBeforeRespond(Map<String, Component> map, AjaxRequestTarget target)
{}
/**
- * Triggered after ajax request target is done with its response cycle. At this point only
- * additional javascript can be output to the response using the provided
- * {@link AjaxRequestTarget.IJavaScriptResponse} object
+ * Triggered after the target has written components. At this point only
+ * additional JavaScript can be added to the response.
*
- * NOTE: During this stage of processing any calls to target that manipulate the response
- * (adding components, javascript) will have no effect
+ * NOTE: During this stage of processing any calls that manipulate components will result in
+ * an exception.
*
* @param map
* read-only map:markupId->component of components already added to the target
* @param response
- * response object that can be used to output javascript
+ * response object that can be used to output JavaScript
+ *
+ * @deprecated implement {@link #onAfterRespond(Map, AjaxRequestTarget)} instead
*/
+ @Deprecated
default void onAfterRespond(Map<String, Component> map, AjaxRequestTarget.IJavaScriptResponse response)
{}
/**
+ * Triggered after the target has written components. At this point only
+ * additional JavaScript can be added to the response.
+ *
+ * NOTE: During this stage of processing any calls that manipulate components will result in
+ * an exception. After notification of all listeners no JavaScript can be added any longer.
+ *
+ * @param map
+ * read-only map:markupId->component of components already added to the target
+ * @param target
+ * the target itself. Could be used to append/prepend JavaScript
+ */
+ default void onAfterRespond(Map<String, Component> map, AjaxRequestTarget target)
+ {
+ onAfterRespond(map, script -> target.appendJavaScript(script));
+ }
+
+ /**
* Triggered for every Ajax behavior. Can be used to configure common settings.
*
* @param behavior
@@ -80,19 +99,23 @@ public interface AjaxRequestTarget extends IPartialPageRequestHandler, ILoggable
}
/**
- * An ajax javascript response that allows users to add javascript to be executed on the client
+ * An ajax JavaScript response that allows users to add JavaScript to be executed on the client
* side
*
* @author ivaynberg
+ *
+ * @deprecated use {@link AjaxRequestTargetprependJavaScript(CharSequence)} and
+ * {@link AjaxRequestTarget#appendJavaScript(CharSequence)} instead
*/
+ @Deprecated
@FunctionalInterface
interface IJavaScriptResponse
{
/**
- * Adds more javascript to the ajax response that will be executed on the client side
+ * Adds more JavaScript to the ajax response that will be executed on the client side
*
* @param script
- * javascript
+ * JavaScript
*/
void addJavaScript(String script);
}
diff --git a/wicket-core/src/main/java/org/apache/wicket/page/PartialPageUpdate.java b/wicket-core/src/main/java/org/apache/wicket/page/PartialPageUpdate.java
index 2988956..da9e89b 100644
--- a/wicket-core/src/main/java/org/apache/wicket/page/PartialPageUpdate.java
+++ b/wicket-core/src/main/java/org/apache/wicket/page/PartialPageUpdate.java
@@ -104,6 +104,12 @@ public abstract class PartialPageUpdate
protected transient boolean componentsFrozen;
/**
+ * A flag that indicates that javascripts cannot be added anymore.
+ * See https://issues.apache.org/jira/browse/WICKET-6902
+ */
+ protected transient boolean javascriptsFrozen;
+
+ /**
* Buffer of response body.
*/
protected final ResponseBuffer bodyBuffer;
@@ -161,12 +167,14 @@ public abstract class PartialPageUpdate
// process added components
writeComponents(response, encoding);
+ onAfterRespond(response);
+
+ javascriptsFrozen = true;
+
// queue up prepend javascripts. unlike other steps these are executed out of order so that
// components can contribute them from during rendering.
writePriorityEvaluations(response, prependJavaScripts);
- onAfterRespond(response);
-
// execute the dom ready javascripts as first javascripts
// after component replacement
List<CharSequence> evaluationScripts = new ArrayList<>();
@@ -493,6 +501,11 @@ public abstract class PartialPageUpdate
{
Args.notNull(javascript, "javascript");
+ if (javascriptsFrozen)
+ {
+ throw new IllegalStateException("A partial update of the page is being rendered, JavaScript can no longer be added");
+ }
+
appendJavaScripts.add(javascript);
}
@@ -505,6 +518,11 @@ public abstract class PartialPageUpdate
public final void prependJavaScript(CharSequence javascript)
{
Args.notNull(javascript, "javascript");
+
+ if (javascriptsFrozen)
+ {
+ throw new IllegalStateException("A partial update of the page is being rendered, JavaScript can no longer be added");
+ }
prependJavaScripts.add(javascript);
}
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxRequestHandlerTest.java b/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxRequestHandlerTest.java
index 66cc73d..f2c1236 100644
--- a/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxRequestHandlerTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxRequestHandlerTest.java
@@ -21,14 +21,15 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
+
import java.io.IOException;
import java.lang.reflect.Constructor;
-import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+
import org.apache.wicket.Component;
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.MockPageWithLink;
@@ -38,6 +39,9 @@ import org.apache.wicket.event.IEvent;
import org.apache.wicket.markup.IMarkupResourceStreamProvider;
import org.apache.wicket.markup.html.WebComponent;
import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.request.IRequestHandler;
+import org.apache.wicket.request.cycle.IRequestCycleListener;
+import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.util.encoding.UrlEncoder;
import org.apache.wicket.util.resource.IResourceStream;
import org.apache.wicket.util.resource.StringResourceStream;
@@ -260,20 +264,24 @@ class AjaxRequestHandlerTest extends WicketTestCase
}
/**
- * @see <a href="https://issues.apache.org/jira/browse/WICKET-3263">WICKET-3263</a>
+ * WICKET-3263<br>
+ * WICKET-6902
*/
@Test
void globalAjaxRequestTargetListeners()
{
- final ValidatingAjaxRequestTargetListener listener = new ValidatingAjaxRequestTargetListener();
-
+ JavaScriptPrependerAppender listener = new JavaScriptPrependerAppender();
+
tester.getApplication().getAjaxRequestTargetListeners().add(listener);
+ tester.getApplication().getRequestCycleListeners().add(listener);
tester.startPage(TestEventPage.class);
tester.clickLink(MockPageWithLinkAndComponent.LINK_ID, true);
- assertTrue(listener.onBeforeRespondExecuted);
- assertTrue(listener.onAfterRespondExecuted);
+ tester.assertContains("BEFORE_RESPOND_PREPEND");
+ tester.assertContains("BEFORE_RESPOND_APPEND");
+ tester.assertContains("AFTER_RESPOND_PREPEND");
+ tester.assertContains("AFTER_RESPOND_APPEND");
}
/**
@@ -396,23 +404,43 @@ class AjaxRequestHandlerTest extends WicketTestCase
}
}
- private static class ValidatingAjaxRequestTargetListener implements AjaxRequestTarget.IListener
+ /**
+ * Listener to AjaxRequestTarget and RequestCycle to test prepending and appending of
+ * JavaScript.
+ */
+ private static class JavaScriptPrependerAppender implements AjaxRequestTarget.IListener, IRequestCycleListener
{
- boolean onBeforeRespondExecuted = false;
- boolean onAfterRespondExecuted = false;
-
@Override
public void onBeforeRespond(Map<String, Component> map, AjaxRequestTarget target)
{
- onBeforeRespondExecuted = true;
-
+ target.prependJavaScript("BEFORE_RESPOND_PREPEND");
+ target.appendJavaScript("BEFORE_RESPOND_APPEND");
}
@Override
- public void onAfterRespond(Map<String, Component> map,
- AjaxRequestTarget.IJavaScriptResponse response)
+ public void onAfterRespond(Map<String, Component> map, AjaxRequestTarget target)
{
- onAfterRespondExecuted = true;
+ target.prependJavaScript("AFTER_RESPOND_PREPEND");
+ target.appendJavaScript("AFTER_RESPOND_APPEND");
+ }
+
+ @Override
+ public void onRequestHandlerExecuted(RequestCycle cycle, IRequestHandler handler) {
+ if (handler instanceof AjaxRequestHandler) {
+ try {
+ ((AjaxRequestHandler) handler).appendJavaScript("FAIL");
+
+ fail("appendJavaScript should not be allowed at this state");
+ } catch (IllegalStateException javascriptFrozen) {
+ }
+
+ try {
+ ((AjaxRequestHandler) handler).prependJavaScript("FAIL");
+
+ fail("prependJavaScript should not be allowed at this state");
+ } catch (IllegalStateException javascriptFrozen) {
+ }
+ }
}
}
[wicket] 02/02: WICKET-6906 removed deprecations
Posted by sv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
svenmeier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git
commit 887b4b355b63d977676815fb4b99efc522b97e89
Author: Sven Meier <sv...@apache.org>
AuthorDate: Tue Jul 20 10:23:29 2021 +0200
WICKET-6906 removed deprecations
---
.../main/java/org/apache/wicket/Application.java | 23 -
.../wicket/ajax/AbstractAjaxTimerBehavior.java | 14 -
.../org/apache/wicket/ajax/AjaxEventBehavior.java | 9 +-
.../org/apache/wicket/ajax/AjaxRequestTarget.java | 41 -
.../wicket/ajax/AjaxSelfUpdatingTimerBehavior.java | 15 +-
.../strategy/DefaultAuthenticationStrategy.java | 46 -
.../wicket/core/util/crypt/AbstractJceCrypt.java | 9 +-
.../util/crypt/KeyInSessionSunJceCryptFactory.java | 11 -
.../html/navigation/paging/PagingNavigation.java | 1 -
.../org/apache/wicket/page/PartialPageUpdate.java | 18 +-
.../apache/wicket/page/XmlPartialPageUpdate.java | 10 -
.../http/CsrfPreventionRequestCycleListener.java | 612 --------
.../wicket/protocol/http/WebApplication.java | 26 +-
.../filter/AjaxServerAndClientTimeFilter.java | 132 --
.../response/filter/ServerAndClientTimeFilter.java | 106 --
.../apache/wicket/settings/SecuritySettings.java | 11 +-
.../core/request/mapper/CryptoMapperTest.java | 2 +-
.../markup/html/form/encryption/CryptTest.java | 3 +-
.../CsrfPreventionRequestCycleListenerTest.java | 658 --------
.../CryptedUrlWebRequestCodingStrategyTest.java | 5 -
.../examples/ajax/builtin/AjaxApplication.java | 3 -
.../ajax/builtin/modal/ModalContent1Page.html | 24 -
.../ajax/builtin/modal/ModalContent1Page.java | 101 --
.../ajax/builtin/modal/ModalContent2Page.html | 20 -
.../ajax/builtin/modal/ModalContent2Page.java | 49 -
.../examples/ajax/builtin/modal/ModalPanel1.html | 9 -
.../examples/ajax/builtin/modal/ModalPanel1.java | 53 -
.../ajax/builtin/modal/ModalWindowPage.html | 10 -
.../ajax/builtin/modal/ModalWindowPage.java | 116 --
.../examples/repeater/RepeaterApplication.java | 1 -
.../wicket/examples/tree/TreeApplication.java | 1 -
.../markup/html/form/upload/UploadProgressBar.java | 23 +-
.../ajax/markup/html/modal/ModalWindow.html | 21 -
.../ajax/markup/html/modal/ModalWindow.java | 1184 ---------------
.../markup/html/modal/res/frame-blue-1-alpha.png | Bin 2706 -> 0 bytes
.../ajax/markup/html/modal/res/frame-blue-1-ie.png | Bin 1672 -> 0 bytes
.../markup/html/modal/res/frame-blue-2-alpha.png | Bin 272 -> 0 bytes
.../ajax/markup/html/modal/res/frame-blue-2-ie.png | Bin 245 -> 0 bytes
.../markup/html/modal/res/frame-gray-1-alpha.png | Bin 2568 -> 0 bytes
.../ajax/markup/html/modal/res/frame-gray-1-ie.png | Bin 1578 -> 0 bytes
.../markup/html/modal/res/frame-gray-2-alpha.png | Bin 264 -> 0 bytes
.../ajax/markup/html/modal/res/frame-gray-2-ie.png | Bin 245 -> 0 bytes
.../ajax/markup/html/modal/res/modal.css | 264 ----
.../extensions/ajax/markup/html/modal/res/modal.js | 1594 --------------------
.../ajax/markup/html/modal/res/transparent1.gif | Bin 156 -> 0 bytes
.../ajax/markup/html/modal/res/transparent2.png | Bin 425 -> 0 bytes
.../markup/html/form/select/SelectOptions.java | 40 +-
...ketAwareCsrfPreventionRequestCycleListener.java | 45 -
.../apache/wicket/util/collections/MicroMap.java | 359 -----
.../apache/wicket/util/crypt/AbstractCrypt.java | 1 -
.../util/crypt/CachingSunJceCryptFactory.java | 39 -
.../wicket/util/crypt/ClassCryptFactory.java | 98 --
.../java/org/apache/wicket/util/crypt/ICrypt.java | 13 -
.../java/org/apache/wicket/util/crypt/NoCrypt.java | 11 -
.../org/apache/wicket/util/crypt/SunJceCrypt.java | 36 -
.../org/apache/wicket/util/time/AbstractTime.java | 122 --
.../apache/wicket/util/time/AbstractTimeValue.java | 55 -
.../java/org/apache/wicket/util/time/Duration.java | 565 -------
.../apache/wicket/util/time/ITimeFrameSource.java | 41 -
.../java/org/apache/wicket/util/time/Time.java | 615 --------
.../org/apache/wicket/util/time/TimeFrame.java | 261 ----
.../java/org/apache/wicket/util/time/TimeMap.java | 111 --
.../org/apache/wicket/util/time/TimeOfDay.java | 420 ------
.../wicket/util/collections/MicroMapTest.java | 105 --
.../apache/wicket/util/crypt/SunJceCryptTest.java | 6 +-
65 files changed, 24 insertions(+), 8144 deletions(-)
diff --git a/wicket-core/src/main/java/org/apache/wicket/Application.java b/wicket-core/src/main/java/org/apache/wicket/Application.java
index a450fad..073a2b7 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Application.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Application.java
@@ -1592,29 +1592,6 @@ public abstract class Application implements UnboundListener, IEventSink, IMetad
}
/**
- * Sets an {@link IHeaderResponseDecorator} that you want your application to use to decorate
- * header responses.
- * <p>
- * Calling this method replaces the default decorator, which utilizes a
- * {@link ResourceAggregator}: The given implementation should make sure, that it too wraps
- * responses in a {@link ResourceAggregator}, otherwise no dependencies for {@link HeaderItem}s
- * will be resolved.
- *
- * @param headerResponseDecorator
- * your custom decorator, must not be null
- * @deprecated use {@code add(...)} on {@link #getHeaderResponseDecorators()}. This method
- * removes the {@link ResourceAggregator}, which is needed to resolve resource
- * dependencies.
- */
- @Deprecated
- public final Application
- setHeaderResponseDecorator(final IHeaderResponseDecorator headerResponseDecorator)
- {
- headerResponseDecorators.replaceAll(headerResponseDecorator);
- return this;
- }
-
- /**
* Returns the {@link HeaderResponseDecoratorCollection} used by this application. On this
* collection you can add additional decorators, which will be nested in the order added.
*
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java
index 23d31fc..0e6fafd 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java
@@ -54,20 +54,6 @@ public abstract class AbstractAjaxTimerBehavior extends AbstractDefaultAjaxBehav
* Construct.
*
* @param updateInterval
- * {@link org.apache.wicket.util.time.Duration} between AJAX callbacks
- *
- * @deprecated Since Wicket 9 this constructor is deprecated. It will be removed in Wicket 10. Use {@link AbstractAjaxTimerBehavior#AbstractAjaxTimerBehavior(Duration)} instead
- */
- @Deprecated
- public AbstractAjaxTimerBehavior(final org.apache.wicket.util.time.Duration updateInterval)
- {
- setUpdateInterval(updateInterval.toJavaDuration());
- }
-
- /**
- * Construct.
- *
- * @param updateInterval
* {@link Duration} between AJAX callbacks
*/
public AbstractAjaxTimerBehavior(final Duration updateInterval)
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
index e01b998..71a091a 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
@@ -82,14 +82,7 @@ public abstract class AjaxEventBehavior extends AbstractDefaultAjaxBehavior
{
Args.notEmpty(event, "event");
- if ("inputchange".equals(event))
- {
- // TODO Wicket 10 remove (see WICKET-6667)
- event = "input";
- LOGGER.warn("Since version 9.0.0 Wicket no longer supports 'inputchange' events, please use 'input' instead");
- }
-
- this.event = event;
+ this.event = event;
}
@Override
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
index 2e1efb6..8a75b0b 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
@@ -55,24 +55,6 @@ public interface AjaxRequestTarget extends IPartialPageRequestHandler, ILoggable
* additional JavaScript can be added to the response.
*
* NOTE: During this stage of processing any calls that manipulate components will result in
- * an exception.
- *
- * @param map
- * read-only map:markupId->component of components already added to the target
- * @param response
- * response object that can be used to output JavaScript
- *
- * @deprecated implement {@link #onAfterRespond(Map, AjaxRequestTarget)} instead
- */
- @Deprecated
- default void onAfterRespond(Map<String, Component> map, AjaxRequestTarget.IJavaScriptResponse response)
- {}
-
- /**
- * Triggered after the target has written components. At this point only
- * additional JavaScript can be added to the response.
- *
- * NOTE: During this stage of processing any calls that manipulate components will result in
* an exception. After notification of all listeners no JavaScript can be added any longer.
*
* @param map
@@ -82,7 +64,6 @@ public interface AjaxRequestTarget extends IPartialPageRequestHandler, ILoggable
*/
default void onAfterRespond(Map<String, Component> map, AjaxRequestTarget target)
{
- onAfterRespond(map, script -> target.appendJavaScript(script));
}
/**
@@ -99,28 +80,6 @@ public interface AjaxRequestTarget extends IPartialPageRequestHandler, ILoggable
}
/**
- * An ajax JavaScript response that allows users to add JavaScript to be executed on the client
- * side
- *
- * @author ivaynberg
- *
- * @deprecated use {@link AjaxRequestTargetprependJavaScript(CharSequence)} and
- * {@link AjaxRequestTarget#appendJavaScript(CharSequence)} instead
- */
- @Deprecated
- @FunctionalInterface
- interface IJavaScriptResponse
- {
- /**
- * Adds more JavaScript to the ajax response that will be executed on the client side
- *
- * @param script
- * JavaScript
- */
- void addJavaScript(String script);
- }
-
- /**
* Components can implement this interface to get a notification when AjaxRequestTarget begins
* to respond. This can be used to postpone adding components to AjaxRequestTarget until the
* response begins.
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxSelfUpdatingTimerBehavior.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxSelfUpdatingTimerBehavior.java
index bb2aa0b..0f336a5 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxSelfUpdatingTimerBehavior.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxSelfUpdatingTimerBehavior.java
@@ -17,6 +17,7 @@
package org.apache.wicket.ajax;
import java.time.Duration;
+
import org.apache.wicket.util.lang.Args;
import org.danekja.java.util.function.serializable.SerializableConsumer;
@@ -35,20 +36,6 @@ public class AjaxSelfUpdatingTimerBehavior extends AbstractAjaxTimerBehavior
/**
* Construct.
- *
- * @param updateInterval
- * {@link org.apache.wicket.util.time.Duration} between AJAX callbacks
- *
- * @deprecated Since Wicket 9 this constructor is deprecated. It will be removed in Wicket 10. Use {@link AjaxSelfUpdatingTimerBehavior#AjaxSelfUpdatingTimerBehavior(Duration)} instead
- */
- @Deprecated
- public AjaxSelfUpdatingTimerBehavior(final org.apache.wicket.util.time.Duration updateInterval)
- {
- super(updateInterval);
- }
-
- /**
- * Construct.
*
* @param updateInterval
* {@link Duration} between AJAX callbacks
diff --git a/wicket-core/src/main/java/org/apache/wicket/authentication/strategy/DefaultAuthenticationStrategy.java b/wicket-core/src/main/java/org/apache/wicket/authentication/strategy/DefaultAuthenticationStrategy.java
index 105db6a..b905858 100644
--- a/wicket-core/src/main/java/org/apache/wicket/authentication/strategy/DefaultAuthenticationStrategy.java
+++ b/wicket-core/src/main/java/org/apache/wicket/authentication/strategy/DefaultAuthenticationStrategy.java
@@ -16,13 +16,10 @@
*/
package org.apache.wicket.authentication.strategy;
-import java.util.UUID;
-
import org.apache.wicket.authentication.IAuthenticationStrategy;
import org.apache.wicket.util.cookies.CookieDefaults;
import org.apache.wicket.util.cookies.CookieUtils;
import org.apache.wicket.util.crypt.ICrypt;
-import org.apache.wicket.util.crypt.SunJceCrypt;
import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.string.Strings;
import org.slf4j.Logger;
@@ -44,12 +41,6 @@ public class DefaultAuthenticationStrategy implements IAuthenticationStrategy
/** The cookie name to store the username and password */
protected final String cookieKey;
- /**
- * @deprecated no longer used TODO remove in Wicket 10
- */
- @Deprecated(forRemoval = true)
- protected final String encryptionKey = null;
-
/** The separator used to concatenate the username and password */
protected final String VALUE_SEPARATOR = "-sep-";
@@ -60,43 +51,6 @@ public class DefaultAuthenticationStrategy implements IAuthenticationStrategy
private ICrypt crypt;
/**
- * Constructor
- *
- * @param cookieKey
- * The name of the cookie
- *
- * @deprecated supply a crypt instead TODO remove in Wicket 10
- */
- @Deprecated(forRemoval = true)
- public DefaultAuthenticationStrategy(final String cookieKey)
- {
- this(cookieKey, defaultEncryptionKey());
- }
-
- private static String defaultEncryptionKey()
- {
- return UUID.randomUUID().toString();
- }
-
- /**
- * @deprecated supply a crypt instead TODO remove in Wicket 10
- */
- @Deprecated(forRemoval = true)
- public DefaultAuthenticationStrategy(final String cookieKey, final String encryptionKey)
- {
- this(cookieKey, defaultCrypt(encryptionKey));
- }
-
- private static ICrypt defaultCrypt(String encryptionKey)
- {
- byte[] salt = SunJceCrypt.randomSalt();
-
- SunJceCrypt crypt = new SunJceCrypt(salt, 1000);
- crypt.setKey(encryptionKey);
- return crypt;
- }
-
- /**
* This is the recommended constructor to be used, which allows automatic authentication across
* application restarts.
*
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/crypt/AbstractJceCrypt.java b/wicket-core/src/main/java/org/apache/wicket/core/util/crypt/AbstractJceCrypt.java
index fd1f630..495cea4 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/util/crypt/AbstractJceCrypt.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/util/crypt/AbstractJceCrypt.java
@@ -91,11 +91,4 @@ public abstract class AbstractJceCrypt implements ICrypt
* @throws GeneralSecurityException
*/
abstract protected byte[] encrypt(final byte[] plainBytes);
-
-
- @Override
- public final void setKey(String key)
- {
- throw new UnsupportedOperationException("This method has been deprecated in ICrypt and will be removed.");
- }
-}
+}
\ No newline at end of file
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/crypt/KeyInSessionSunJceCryptFactory.java b/wicket-core/src/main/java/org/apache/wicket/core/util/crypt/KeyInSessionSunJceCryptFactory.java
index 2ad0592..49f69d0 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/util/crypt/KeyInSessionSunJceCryptFactory.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/util/crypt/KeyInSessionSunJceCryptFactory.java
@@ -77,17 +77,6 @@ public class KeyInSessionSunJceCryptFactory extends AbstractKeyInSessionCryptFac
}
}
- /**
- * @return the {@link org.apache.wicket.util.crypt.ICrypt} to use
- *
- * @deprecated this method is no longer called TODO remove in Wicket 10
- */
- @Deprecated(forRemoval = true)
- protected ICrypt createCrypt()
- {
- return null;
- }
-
@Override
protected CryptData generateKey(Session session)
{
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigation.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigation.java
index dd05e8b..5abd724 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigation.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigation.java
@@ -26,7 +26,6 @@ import org.apache.wicket.markup.html.link.AbstractLink;
import org.apache.wicket.markup.html.list.Loop;
import org.apache.wicket.markup.html.list.LoopItem;
import org.apache.wicket.model.Model;
-import org.apache.wicket.util.collections.MicroMap;
/**
* A navigation for a PageableListView that holds links to other pages of the PageableListView.
diff --git a/wicket-core/src/main/java/org/apache/wicket/page/PartialPageUpdate.java b/wicket-core/src/main/java/org/apache/wicket/page/PartialPageUpdate.java
index da9e89b..d9c3ca3 100644
--- a/wicket-core/src/main/java/org/apache/wicket/page/PartialPageUpdate.java
+++ b/wicket-core/src/main/java/org/apache/wicket/page/PartialPageUpdate.java
@@ -433,24 +433,18 @@ public abstract class PartialPageUpdate
/**
* Writes a component to the response.
- * <p>
- * TODO make abstract in Wicket 10
*
* @param response
* the response to write to
* @param contents
* the contents
*/
- protected void writeComponent(Response response, String markupId, CharSequence contents) {
- throw new UnsupportedOperationException();
- }
+ protected abstract void writeComponent(Response response, String markupId, CharSequence contents);
/**
- * TODO make abstract in Wicket 10
+ * Write priority-evaluation.
*/
- protected void writePriorityEvaluation(Response response, CharSequence contents) {
- throw new UnsupportedOperationException();
- }
+ protected abstract void writePriorityEvaluation(Response response, CharSequence contents);
/**
* Writes a header contribution to the response.
@@ -463,11 +457,9 @@ public abstract class PartialPageUpdate
protected abstract void writeHeaderContribution(Response response, CharSequence contents);
/**
- * TODO make abstract in Wicket 10
+ * Write evaluation.
*/
- protected void writeEvaluation(Response response, CharSequence contents) {
- throw new UnsupportedOperationException();
- }
+ protected abstract void writeEvaluation(Response response, CharSequence contents);
@Override
public boolean equals(Object o)
diff --git a/wicket-core/src/main/java/org/apache/wicket/page/XmlPartialPageUpdate.java b/wicket-core/src/main/java/org/apache/wicket/page/XmlPartialPageUpdate.java
index 9800e34..59ac118 100644
--- a/wicket-core/src/main/java/org/apache/wicket/page/XmlPartialPageUpdate.java
+++ b/wicket-core/src/main/java/org/apache/wicket/page/XmlPartialPageUpdate.java
@@ -53,16 +53,6 @@ public class XmlPartialPageUpdate extends PartialPageUpdate
response.write(START_ROOT_ELEMENT);
}
- /**
- * TODO remove in Wicket 10
- */
- @Override
- protected void writeComponent(Response response, String markupId, Component component,
- String encoding)
- {
- super.writeComponent(response, markupId, component, encoding);
- }
-
@Override
protected void writeComponent(Response response, String markupId, CharSequence contents)
{
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/CsrfPreventionRequestCycleListener.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/CsrfPreventionRequestCycleListener.java
deleted file mode 100644
index 294da64..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/CsrfPreventionRequestCycleListener.java
+++ /dev/null
@@ -1,612 +0,0 @@
-/*
- * 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.protocol.http;
-
-import java.util.Locale;
-import jakarta.servlet.http.HttpServletRequest;
-import org.apache.wicket.RestartResponseException;
-import org.apache.wicket.core.request.handler.IPageRequestHandler;
-import org.apache.wicket.core.request.handler.RenderPageRequestHandler;
-import org.apache.wicket.request.IRequestHandler;
-import org.apache.wicket.request.IRequestHandlerDelegate;
-import org.apache.wicket.request.component.IRequestablePage;
-import org.apache.wicket.request.cycle.IRequestCycleListener;
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.request.http.WebRequest;
-import org.apache.wicket.request.http.flow.AbortWithHttpErrorCodeException;
-import org.apache.wicket.util.string.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Prevents CSRF attacks on Wicket components by checking the {@code Origin} and {@code Referer}
- * HTTP headers for cross domain requests. By default only checks requests that try to perform an
- * action on a component, such as a form submit, or link click.
- * <p>
- * <h3>Installation</h3>
- * <p>
- * You can enable this CSRF prevention filter by adding it to the request cycle listeners in your
- * {@link WebApplication#init() application's init method}:
- *
- * <pre>
- * @Override
- * protected void init()
- * {
- * // ...
- * getRequestCycleListeners().add(new CsrfPreventionRequestCycleListener());
- * // ...
- * }
- * </pre>
- * <p>
- * <h3>Configuration</h3>
- * <p>
- * When the {@code Origin} or {@code Referer} HTTP header is present but doesn't match the requested
- * URL this listener will by default throw a HTTP error ( {@code 400 BAD REQUEST}) and abort the
- * request. You can {@link #setConflictingOriginAction(CsrfAction) configure} this specific action.
- * <p>
- * A missing {@code Origin} and {@code Referer} HTTP header is handled as if it were a bad request
- * and rejected. You can {@link #setNoOriginAction(CsrfAction) configure the specific action} to a
- * different value, suppressing or allowing the request when the HTTP headers are missing.
- * <p>
- * When the {@code Origin} HTTP header is present and has the value {@code null} it is considered to
- * be from a "privacy-sensitive" context and will trigger the no origin action. You can customize
- * what happens in those actions by overriding the respective {@code onXXXX} methods.
- * <p>
- * When you want to accept certain cross domain request from a range of hosts, you can
- * {@link #addAcceptedOrigin(String) whitelist those domains}.
- * <p>
- * You can {@link #isEnabled() enable or disable} this listener by overriding {@link #isEnabled()}.
- * <p>
- * You can {@link #isChecked(IRequestablePage) customize} whether a particular page should be
- * checked for CSRF requests. For example you can skip checking pages that have a
- * {@code @NoCsrfCheck} annotation, or only those pages that extend your base secure page class. For
- * example:
- *
- * <pre>
- * @Override
- * protected boolean isChecked(IRequestablePage requestedPage)
- * {
- * return requestedPage instanceof SecurePage;
- * }
- * </pre>
- * <p>
- * You can also tweak the request handlers that are checked. The CSRF prevention request cycle
- * listener checks only action handlers, not render handlers. Override
- * {@link #isChecked(IRequestHandler)} to customize this behavior.
- * </p>
- * <p>
- * You can customize the default actions that are performed by overriding the event handlers for
- * them:
- * <ul>
- * <li>{@link #onWhitelisted(HttpServletRequest, String, IRequestablePage)} when an origin was
- * whitelisted</li>
- * <li>{@link #onMatchingOrigin(HttpServletRequest, String, IRequestablePage)} when an origin was
- * matching</li>
- * <li>{@link #onAborted(HttpServletRequest, String, IRequestablePage)} when an origin was in
- * conflict and the request should be aborted</li>
- * <li>{@link #onAllowed(HttpServletRequest, String, IRequestablePage)} when an origin was in
- * conflict and the request should be allowed</li>
- * <li>{@link #onSuppressed(HttpServletRequest, String, IRequestablePage)} when an origin was in
- * conflict and the request should be suppressed</li>
- * </ul>
- *
- * @deprecated Use {@link FetchMetadataResourceIsolationPolicy} instead
- */
-@Deprecated(since = "9.1.0")
-public class CsrfPreventionRequestCycleListener extends OriginResourceIsolationPolicy implements IRequestCycleListener
-{
- private static final Logger log = LoggerFactory
- .getLogger(CsrfPreventionRequestCycleListener.class);
-
- /**
- * The action to perform when a missing or conflicting source URI is detected.
- */
- public enum CsrfAction {
- /** Aborts the request and throws an exception when a CSRF request is detected. */
- ABORT {
- @Override
- public String toString()
- {
- return "aborted";
- }
- },
-
- /**
- * Ignores the action of a CSRF request, and just renders the page it was targeted against.
- */
- SUPPRESS {
- @Override
- public String toString()
- {
- return "suppressed";
- }
- },
-
- /** Detects a CSRF request, logs it and allows the request to continue. */
- ALLOW {
- @Override
- public String toString()
- {
- return "allowed";
- }
- },
- }
-
- /**
- * Action to perform when no Origin header is present in the request.
- */
- private CsrfAction noOriginAction = CsrfAction.ABORT;
-
- /**
- * Action to perform when a conflicting Origin header is found.
- */
- private CsrfAction conflictingOriginAction = CsrfAction.ABORT;
-
- /**
- * The error code to report when the action to take for a CSRF request is
- * {@link CsrfAction#ABORT}. Default {@code 400 BAD REQUEST}.
- */
- private int errorCode = jakarta.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
-
- /**
- * The error message to report when the action to take for a CSRF request is {@code ERROR}.
- * Default {@code "Origin does not correspond to request"}.
- */
- private String errorMessage = "Origin does not correspond to request";
-
- /**
- * TODO remove in Wicket 10
- */
- @Override
- public CsrfPreventionRequestCycleListener addAcceptedOrigin(String acceptedOrigin)
- {
- super.addAcceptedOrigin(acceptedOrigin);
-
- return this;
- }
-
- /**
- * Sets the action when no Origin header is present in the request. Default {@code ALLOW}.
- *
- * @param action
- * the alternate action
- *
- * @return this (for chaining)
- */
- public CsrfPreventionRequestCycleListener setNoOriginAction(CsrfAction action)
- {
- this.noOriginAction = action;
- return this;
- }
-
- /**
- * Sets the action when a conflicting Origin header is detected. Default is {@code ERROR}.
- *
- * @param action
- * the alternate action
- *
- * @return this
- */
- public CsrfPreventionRequestCycleListener setConflictingOriginAction(CsrfAction action)
- {
- this.conflictingOriginAction = action;
- return this;
- }
-
- /**
- * Modifies the HTTP error code in the exception when a conflicting Origin header is detected.
- *
- * @param errorCode
- * the alternate HTTP error code, default {@code 400 BAD REQUEST}
- *
- * @return this
- */
- public CsrfPreventionRequestCycleListener setErrorCode(int errorCode)
- {
- this.errorCode = errorCode;
- return this;
- }
-
- /**
- * Modifies the HTTP message in the exception when a conflicting Origin header is detected.
- *
- * @param errorMessage
- * the alternate message
- *
- * @return this
- */
- public CsrfPreventionRequestCycleListener setErrorMessage(String errorMessage)
- {
- this.errorMessage = errorMessage;
- return this;
- }
-
- @Override
- public void onBeginRequest(RequestCycle cycle)
- {
- if (log.isDebugEnabled())
- {
- HttpServletRequest containerRequest = (HttpServletRequest)cycle.getRequest()
- .getContainerRequest();
- log.debug("Request Source URI: {}", getSourceUri(containerRequest));
- }
- }
-
- /**
- * Dynamic override for enabling/disabling the CSRF detection. Might be handy for specific
- * tenants in a multi-tenant application. When false, the CSRF detection is not performed for
- * the running request. Default {@code true}
- *
- * @return {@code true} when the CSRF checks need to be performed.
- */
- protected boolean isEnabled()
- {
- return true;
- }
-
- /**
- * Override to limit whether the request to the specific page should be checked for a possible
- * CSRF attack.
- *
- * @param targetedPage
- * the page that is the target for the action
- * @return {@code true} when the request to the page should be checked for CSRF issues.
- */
- protected boolean isChecked(IRequestablePage targetedPage)
- {
- return true;
- }
-
- /**
- * Override to change the request handler types that are checked. Currently only action handlers
- * (form submits, link clicks, AJAX events) are checked for a matching Origin HTTP header.
- *
- * @param handler
- * the handler that is currently processing
- * @return true when the Origin HTTP header should be checked for this {@code handler}
- */
- protected boolean isChecked(IRequestHandler handler)
- {
- return handler instanceof IPageRequestHandler &&
- !(handler instanceof RenderPageRequestHandler);
- }
-
- /**
- * Unwraps the handler if it is a {@code IRequestHandlerDelegate} down to the deepest nested
- * handler.
- *
- * @param handler
- * The handler to unwrap
- * @return the deepest handler that does not implement {@code IRequestHandlerDelegate}
- */
- protected IRequestHandler unwrap(IRequestHandler handler)
- {
- while (handler instanceof IRequestHandlerDelegate)
- handler = ((IRequestHandlerDelegate)handler).getDelegateHandler();
- return handler;
- }
-
- @Override
- public void onRequestHandlerResolved(RequestCycle cycle, IRequestHandler handler)
- {
- if (!isEnabled())
- {
- log.trace("CSRF listener is disabled, no checks performed");
- return;
- }
-
- handler = unwrap(handler);
-
- // check if the request is targeted at a page
- if (isChecked(handler))
- {
- IPageRequestHandler prh = (IPageRequestHandler)handler;
- IRequestablePage targetedPage = prh.getPage();
- HttpServletRequest containerRequest = (HttpServletRequest)cycle.getRequest()
- .getContainerRequest();
- String sourceUri = getSourceUri(containerRequest);
-
- // Check if the page should be CSRF protected
- if (isChecked(targetedPage))
- {
- // if so check the Origin HTTP header
- checkRequest(containerRequest, sourceUri, targetedPage);
- }
- else
- {
- if (log.isDebugEnabled())
- {
- log.debug("Targeted page {} was opted out of the CSRF origin checks, allowed",
- targetedPage.getClass().getName());
- }
- allowHandler(containerRequest, sourceUri, targetedPage);
- }
- }
- else
- {
- if (log.isTraceEnabled())
- log.trace(
- "Resolved handler {} doesn't target an action on a page, no CSRF check performed",
- handler.getClass().getName());
- }
- }
-
- /**
- * Resolves the source URI from the request headers ({@code Origin} or {@code Referer}).
- *
- * @param containerRequest
- * the current container request
- * @return the normalized source URI.
- */
- protected String getSourceUri(HttpServletRequest containerRequest)
- {
- String sourceUri = containerRequest.getHeader(WebRequest.HEADER_ORIGIN);
- if (Strings.isEmpty(sourceUri))
- {
- sourceUri = containerRequest.getHeader(WebRequest.HEADER_REFERER);
- }
- return normalizeUri(sourceUri);
- }
-
- /**
- * Performs the check of the {@code Origin} or {@code Referer} header that is targeted at the
- * {@code page}.
- *
- * @param request
- * the current container request
- * @param sourceUri
- * the source URI
- * @param page
- * the page that is the target of the request
- */
- protected void checkRequest(HttpServletRequest request, String sourceUri, IRequestablePage page)
- {
- if (sourceUri == null || sourceUri.isEmpty())
- {
- log.debug("Source URI not present in request, {}", noOriginAction);
- switch (noOriginAction)
- {
- case ALLOW :
- allowHandler(request, sourceUri, page);
- break;
- case SUPPRESS :
- suppressHandler(request, sourceUri, page);
- break;
- case ABORT :
- abortHandler(request, sourceUri, page);
- break;
- }
- return;
- }
- sourceUri = sourceUri.toLowerCase(Locale.ROOT);
-
- // if the origin is a know and trusted origin, don't check any further but allow the request
- if (isWhitelistedHost(sourceUri))
- {
- whitelistedHandler(request, sourceUri, page);
- return;
- }
-
- // check if the origin HTTP header matches the request URI
- if (!isLocalOrigin(request, sourceUri))
- {
- log.debug("Source URI conflicts with request origin, {}", conflictingOriginAction);
- switch (conflictingOriginAction)
- {
- case ALLOW :
- allowHandler(request, sourceUri, page);
- break;
- case SUPPRESS :
- suppressHandler(request, sourceUri, page);
- break;
- case ABORT :
- abortHandler(request, sourceUri, page);
- break;
- }
- }
- else
- {
- matchingOrigin(request, sourceUri, page);
- }
- }
-
- /**
- * Handles the case where an origin is in the whitelist. Default action is to allow the
- * whitelisted origin.
- *
- * @param request
- * the request
- * @param origin
- * the contents of the {@code Origin} HTTP header
- * @param page
- * the page that is targeted with this request
- */
- protected void whitelistedHandler(HttpServletRequest request, String origin,
- IRequestablePage page)
- {
- onWhitelisted(request, origin, page);
- if (log.isDebugEnabled())
- {
- log.debug("CSRF Origin {} was whitelisted, allowed for page {}", origin,
- page.getClass().getName());
- }
- }
-
- /**
- * Called when the origin was available in the whitelist. Override this method to implement your
- * own custom action.
- *
- * @param request
- * the request
- * @param origin
- * the contents of the {@code Origin} HTTP header
- * @param page
- * the page that is targeted with this request
- */
- protected void onWhitelisted(HttpServletRequest request, String origin, IRequestablePage page)
- {
- }
-
- /**
- * Handles the case where an origin was checked and matched the request origin. Default action
- * is to allow the whitelisted origin.
- *
- * @param request
- * the request
- * @param origin
- * the contents of the {@code Origin} HTTP header
- * @param page
- * the page that is targeted with this request
- */
- protected void matchingOrigin(HttpServletRequest request, String origin,
- IRequestablePage page)
- {
- onMatchingOrigin(request, origin, page);
- if (log.isDebugEnabled())
- {
- log.debug("CSRF Origin {} matched requested resource, allowed for page {}", origin,
- page.getClass().getName());
- }
- }
-
- /**
- * Called when the origin HTTP header matched the request. Override this method to implement
- * your own custom action.
- *
- * @param request
- * the request
- * @param origin
- * the contents of the {@code Origin} HTTP header
- * @param page
- * the page that is targeted with this request
- */
- protected void onMatchingOrigin(HttpServletRequest request, String origin,
- IRequestablePage page)
- {
- }
-
- /**
- * Handles the case where an Origin HTTP header was not present or did not match the request
- * origin, and the corresponding action ({@link #noOriginAction} or
- * {@link #conflictingOriginAction}) is set to {@code ALLOW}.
- *
- * @param request
- * the request
- * @param origin
- * the contents of the {@code Origin} HTTP header, may be {@code null} or empty
- * @param page
- * the page that is targeted with this request
- */
- protected void allowHandler(HttpServletRequest request, String origin,
- IRequestablePage page)
- {
- onAllowed(request, origin, page);
- log.info("Possible CSRF attack, request URL: {}, Origin: {}, action: allowed",
- request.getRequestURL(), origin);
- }
-
- /**
- * Override this method to customize the case where an Origin HTTP header was not present or did
- * not match the request origin, and the corresponding action ({@link #noOriginAction} or
- * {@link #conflictingOriginAction}) is set to {@code ALLOW}.
- *
- * @param request
- * the request
- * @param origin
- * the contents of the {@code Origin} HTTP header, may be {@code null} or empty
- * @param page
- * the page that is targeted with this request
- */
- protected void onAllowed(HttpServletRequest request, String origin, IRequestablePage page)
- {
- }
-
- /**
- * Handles the case where an Origin HTTP header was not present or did not match the request
- * origin, and the corresponding action ({@link #noOriginAction} or
- * {@link #conflictingOriginAction}) is set to {@code SUPPRESS}.
- *
- * @param request
- * the request
- * @param origin
- * the contents of the {@code Origin} HTTP header, may be {@code null} or empty
- * @param page
- * the page that is targeted with this request
- */
- protected void suppressHandler(HttpServletRequest request, String origin,
- IRequestablePage page)
- {
- onSuppressed(request, origin, page);
- log.info("Possible CSRF attack, request URL: {}, Origin: {}, action: suppressed",
- request.getRequestURL(), origin);
- throw new RestartResponseException(page);
- }
-
- /**
- * Override this method to customize the case where an Origin HTTP header was not present or did
- * not match the request origin, and the corresponding action ({@link #noOriginAction} or
- * {@link #conflictingOriginAction}) is set to {@code SUPPRESSED}.
- *
- * @param request
- * the request
- * @param origin
- * the contents of the {@code Origin} HTTP header, may be {@code null} or empty
- * @param page
- * the page that is targeted with this request
- */
- protected void onSuppressed(HttpServletRequest request, String origin, IRequestablePage page)
- {
- }
-
- /**
- * Handles the case where an Origin HTTP header was not present or did not match the request
- * origin, and the corresponding action ({@link #noOriginAction} or
- * {@link #conflictingOriginAction}) is set to {@code ABORT}.
- *
- * @param request
- * the request
- * @param origin
- * the contents of the {@code Origin} HTTP header, may be {@code null} or empty
- * @param page
- * the page that is targeted with this request
- */
- protected void abortHandler(HttpServletRequest request, String origin,
- IRequestablePage page)
- {
- onAborted(request, origin, page);
- log.info(
- "Possible CSRF attack, request URL: {}, Origin: {}, action: aborted with error {} {}",
- request.getRequestURL(), origin, errorCode, errorMessage);
- throw new AbortWithHttpErrorCodeException(errorCode, errorMessage);
- }
-
- /**
- * Override this method to customize the case where an Origin HTTP header was not present or did
- * not match the request origin, and the corresponding action ({@link #noOriginAction} or
- * {@link #conflictingOriginAction}) is set to {@code ABORTED}.
- *
- * @param request
- * the request
- * @param origin
- * the contents of the {@code Origin} HTTP header, may be {@code null} or empty
- * @param page
- * the page that is targeted with this request
- */
- protected void onAborted(HttpServletRequest request, String origin, IRequestablePage page)
- {
- }
-}
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
index 5ec2f52..1f4df9d 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
@@ -24,11 +24,6 @@ import java.util.LinkedList;
import java.util.Locale;
import java.util.function.Function;
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-import jakarta.servlet.http.HttpSession;
-
import org.apache.wicket.Application;
import org.apache.wicket.Page;
import org.apache.wicket.RuntimeConfigurationType;
@@ -90,6 +85,11 @@ import org.apache.wicket.util.watch.IModificationWatcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import jakarta.servlet.ServletContext;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpSession;
+
/**
* A web application is a subclass of Application which associates with an instance of WicketServlet
@@ -1111,16 +1111,6 @@ public abstract class WebApplication extends Application
}
/**
- * TODO remove in Wicket 10
- *
- * @deprecated use {@link #setCspSettings(ContentSecurityPolicySettings)} instead
- */
- protected ContentSecurityPolicySettings newCspSettings()
- {
- return new ContentSecurityPolicySettings(this);
- }
-
- /**
* Returns the {@link ContentSecurityPolicySettings} for this application. See
* {@link ContentSecurityPolicySettings} and {@link CSPHeaderConfiguration} for instructions on
* configuring the CSP for your specific needs.
@@ -1128,16 +1118,14 @@ public abstract class WebApplication extends Application
* @return The {@link ContentSecurityPolicySettings} for this application.
* @see ContentSecurityPolicySettings
* @see CSPHeaderConfiguration
- *
- * TODO make final in Wicket 10
*/
- public ContentSecurityPolicySettings getCspSettings()
+ public final ContentSecurityPolicySettings getCspSettings()
{
checkSettingsAvailable();
if (cspSettings == null)
{
- cspSettings = newCspSettings();
+ cspSettings = new ContentSecurityPolicySettings(this);
}
return cspSettings;
}
diff --git a/wicket-core/src/main/java/org/apache/wicket/response/filter/AjaxServerAndClientTimeFilter.java b/wicket-core/src/main/java/org/apache/wicket/response/filter/AjaxServerAndClientTimeFilter.java
deleted file mode 100644
index 898066e..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/response/filter/AjaxServerAndClientTimeFilter.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * 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.response.filter;
-
-import java.util.HashMap;
-
-import org.apache.wicket.Application;
-import org.apache.wicket.core.util.string.JavaScriptUtils;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.util.string.AppendingStringBuffer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This is a filter that injects javascript code to the top head portion and after the body so that
- * the time can me measured what the client parse time was for this page. It also reports the total
- * server parse/response time in the client and logs the server response time and response size it
- * took for a specific response in the server log.
- *
- * You can specify what the status text should be like this: ServerAndClientTimeFilter.statustext=My
- * Application, Server parsetime: ${servertime}, Client parsetime: ${clienttime} likewise for ajax
- * request use ajax.ServerAndClientTimeFilter.statustext
- *
- * <p>
- * Usage: in YourApplication.java:
- *
- * <pre>
- * @Override
- * public init()
- * {
- * super.init();
- * getRequestCycleSettings().addResponseFilter(new AjaxServerAndClientTimeFilter());
- * }
- * </pre>
- *
- * @author jcompagner
- * @deprecated This class has been deprecated for several reasons. The way it tries to measure
- * server and client times is very inaccurate. Modern browsers provide much better tools
- * to measure Javascript execution times. The measurements were written in a property
- * that has been deprecated for years and removed in modern browsers. Finally, rendering
- * the Javascript directly into the response makes it hard to support a strict CSP with
- * nonces. There is no real replacement for this class. Use the tools provided by the
- * browser. See {@code WicketExampleApplication} for a simple example of passing
- * rendering times to the browser via the {@code Server-Timing} header.
- */
-@Deprecated
-public class AjaxServerAndClientTimeFilter implements IResponseFilter
-{
- private static Logger log = LoggerFactory.getLogger(AjaxServerAndClientTimeFilter.class);
-
- /**
- * @see IResponseFilter#filter(org.apache.wicket.util.string.AppendingStringBuffer)
- */
- @Override
- public AppendingStringBuffer filter(AppendingStringBuffer responseBuffer)
- {
- int headIndex = responseBuffer.indexOf("<head>");
- int bodyIndex = responseBuffer.indexOf("</body>");
- int ajaxStart = responseBuffer.indexOf("<ajax-response>");
- int ajaxEnd = responseBuffer.indexOf("</ajax-response>");
- long timeTaken = System.currentTimeMillis() - RequestCycle.get().getStartTime();
- if (headIndex != -1 && bodyIndex != -1)
- {
- responseBuffer.insert(bodyIndex, scriptTag("window.defaultStatus=" + getStatusString(timeTaken, "ServerAndClientTimeFilter.statustext") + ";"));
- responseBuffer.insert(headIndex + 6, scriptTag("clientTimeVariable = new Date().getTime();"));
- }
- else if (ajaxStart != -1 && ajaxEnd != -1)
- {
- responseBuffer.insert(ajaxEnd, headerContribution("window.defaultStatus=" + getStatusString(timeTaken, "ajax.ServerAndClientTimeFilter.statustext") + ";"));
- responseBuffer.insert(ajaxStart + 15, headerContribution("clientTimeVariable = new Date().getTime();"));
- }
- log.info(timeTaken + "ms server time taken for request " +
- RequestCycle.get().getRequest().getUrl() + " response size: " + responseBuffer.length());
- return responseBuffer;
- }
-
- private String scriptTag(String script)
- {
- AppendingStringBuffer buffer = new AppendingStringBuffer(250);
- buffer.append("\n");
- buffer.append(JavaScriptUtils.SCRIPT_OPEN_TAG);
- buffer.append(script);
- buffer.append(JavaScriptUtils.SCRIPT_CLOSE_TAG).append("\n");
- return buffer.toString();
- }
-
- private String headerContribution(String script)
- {
- AppendingStringBuffer buffer = new AppendingStringBuffer(250);
- buffer.append("<header-contribution><![CDATA[<head xmlns:wicket=\"http://wicket.apache.org\">");
- buffer.append(script);
- buffer.append("</head>]]></header-contribution>");
- return buffer.toString();
- }
-
- /**
- * Returns a locale specific status message about the server and client time.
- *
- * @param timeTaken
- * the server time it took
- * @param resourceKey
- * The key for the locale specific string lookup
- * @return String with the status message
- */
- private String getStatusString(long timeTaken, String resourceKey)
- {
- final HashMap<String, String> map = new HashMap<String, String>(4);
- map.put("servertime", ((double)timeTaken) / 1000 + "s");
- map.put("clienttime", "' + (new Date().getTime() - clientTimeVariable)/1000 + 's");
-
- return Application.get()
- .getResourceSettings()
- .getLocalizer()
- .getString(resourceKey, null, Model.of(map),
- "'Server parsetime: ${servertime}, Client parsetime: ${clienttime}'");
- }
-}
\ No newline at end of file
diff --git a/wicket-core/src/main/java/org/apache/wicket/response/filter/ServerAndClientTimeFilter.java b/wicket-core/src/main/java/org/apache/wicket/response/filter/ServerAndClientTimeFilter.java
deleted file mode 100644
index 51ada47..0000000
--- a/wicket-core/src/main/java/org/apache/wicket/response/filter/ServerAndClientTimeFilter.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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.response.filter;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.wicket.Application;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.util.string.AppendingStringBuffer;
-import org.apache.wicket.core.util.string.JavaScriptUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * This is a filter that injects javascript code to the top head portion and after the body so that
- * the time can me measured what the client parse time was for this page. It also reports the total
- * server parse/response time in the client and logs the server response time and response size it
- * took for a specific response in the server log.
- *
- * You can specify what the status text should be like this: ServerAndClientTimeFilter.statustext=My
- * Application, Server parsetime: ${servertime}, Client parsetime: ${clienttime}
- *
- * <p>
- * Usage: in YourApplication.java:
- *
- * <pre>
- * @Override
- * public init()
- * {
- * super.init();
- * getRequestCycleSettings().addResponseFilter(new ServerAndClientTimeFilter());
- * }
- * </pre>
- *
- * @author jcompagner
- * @deprecated This class has been deprecated for several reasons. The way it tries to measure
- * server and client times is very inaccurate. Modern browsers provide much better tools
- * to measure Javascript execution times. The measurements were written in a property
- * that has been deprecated for years and removed in modern browsers. Finally, rendering
- * the Javascript directly into the response makes it hard to support a strict CSP with
- * nonces. There is no real replacement for this class. Use the tools provided by the
- * browser. See {@code WicketExampleApplication} for a simple example of passing
- * rendering times to the browser via the {@code Server-Timing} header.
- */
-@Deprecated
-public class ServerAndClientTimeFilter implements IResponseFilter
-{
- private static final Logger log = LoggerFactory.getLogger(ServerAndClientTimeFilter.class);
-
- /**
- * @see IResponseFilter#filter(AppendingStringBuffer)
- */
- @Override
- public AppendingStringBuffer filter(AppendingStringBuffer responseBuffer)
- {
- int headIndex = responseBuffer.indexOf("<head>");
- int bodyIndex = responseBuffer.indexOf("</body>");
- long timeTaken = System.currentTimeMillis() - RequestCycle.get().getStartTime();
- if (headIndex != -1 && bodyIndex != -1)
- {
- Map<String, String> map = new HashMap<>(4);
- map.put("clienttime", "' + (new Date().getTime() - clientTimeVariable)/1000 + 's");
- map.put("servertime", ((double)timeTaken) / 1000 + "s");
-
- AppendingStringBuffer defaultValue = new AppendingStringBuffer(128);
- defaultValue.append("Server parsetime: ");
- defaultValue.append(((double)timeTaken) / 1000);
- defaultValue.append("s, Client parsetime: ' + (new Date().getTime() - clientTimeVariable)/1000 + 's");
-
- String txt = Application.get()
- .getResourceSettings()
- .getLocalizer()
- .getString("ServerAndClientTimeFilter.statustext", null, Model.ofMap(map),
- defaultValue.toString());
- AppendingStringBuffer endScript = new AppendingStringBuffer(150);
- endScript.append("\n").append(JavaScriptUtils.SCRIPT_OPEN_TAG);
- endScript.append("\nwindow.defaultStatus='");
- endScript.append(txt);
- endScript.append("';\n").append(JavaScriptUtils.SCRIPT_CLOSE_TAG).append("\n");
- responseBuffer.insert(bodyIndex - 1, endScript);
- responseBuffer.insert(headIndex + 6, "\n" + JavaScriptUtils.SCRIPT_OPEN_TAG +
- "\nvar clientTimeVariable = new Date().getTime();\n" +
- JavaScriptUtils.SCRIPT_CLOSE_TAG + "\n");
- }
- log.info(timeTaken + "ms server time taken for request " +
- RequestCycle.get().getRequest().getUrl() + " response size: " + responseBuffer.length());
- return responseBuffer;
- }
-}
diff --git a/wicket-core/src/main/java/org/apache/wicket/settings/SecuritySettings.java b/wicket-core/src/main/java/org/apache/wicket/settings/SecuritySettings.java
index dbcba20..1c55aad 100644
--- a/wicket-core/src/main/java/org/apache/wicket/settings/SecuritySettings.java
+++ b/wicket-core/src/main/java/org/apache/wicket/settings/SecuritySettings.java
@@ -32,6 +32,7 @@ import org.apache.wicket.core.random.DefaultSecureRandomSupplier;
import org.apache.wicket.core.random.ISecureRandomSupplier;
import org.apache.wicket.core.util.crypt.KeyInSessionSunJceCryptFactory;
import org.apache.wicket.util.crypt.ICryptFactory;
+import org.apache.wicket.util.crypt.SunJceCrypt;
import org.apache.wicket.util.lang.Args;
/**
@@ -48,14 +49,6 @@ import org.apache.wicket.util.lang.Args;
*/
public class SecuritySettings
{
- /**
- * encryption key is no longer used
- *
- * @deprecated
- */
- @Deprecated(forRemoval = true)
- public static final String DEFAULT_ENCRYPTION_KEY = "WiCkEt-FRAMEwork";
-
/** The authorization strategy. */
private IAuthorizationStrategy authorizationStrategy = IAuthorizationStrategy.ALLOW_ALL;
@@ -278,7 +271,7 @@ public class SecuritySettings
{
if (authenticationStrategy == null)
{
- authenticationStrategy = new DefaultAuthenticationStrategy("LoggedIn");
+ authenticationStrategy = new DefaultAuthenticationStrategy("LoggedIn", new SunJceCrypt(SunJceCrypt.randomSalt(), 17));
}
return authenticationStrategy;
}
diff --git a/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/CryptoMapperTest.java b/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/CryptoMapperTest.java
index 3a89b26..41ab1c2 100644
--- a/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/CryptoMapperTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/core/request/mapper/CryptoMapperTest.java
@@ -96,7 +96,7 @@ class CryptoMapperTest extends AbstractMapperTest
WebApplication application = tester.getApplication();
application.mountPage(MOUNTED_URL, Page1.class);
- ICrypt crypt = new SunJceCrypt(new byte[]{ (byte)0x15, (byte)0x8c, (byte)0xa3, (byte)0x4a,
+ SunJceCrypt crypt = new SunJceCrypt(new byte[]{ (byte)0x15, (byte)0x8c, (byte)0xa3, (byte)0x4a,
(byte)0x66, (byte)0x51, (byte)0x2a, (byte)0xbc }, 17);
crypt.setKey("WiCkEt-FRAMEwork");
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/encryption/CryptTest.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/encryption/CryptTest.java
index 8eea58d..1654edf 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/encryption/CryptTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/encryption/CryptTest.java
@@ -33,7 +33,8 @@ class CryptTest extends WicketTestCase
@Test
void crypt()
{
- final ICrypt crypt = new SunJceCrypt();
+ final SunJceCrypt crypt = new SunJceCrypt(new byte[]{ (byte)0x15, (byte)0x8c, (byte)0xa3, (byte)0x4a,
+ (byte)0x66, (byte)0x51, (byte)0x2a, (byte)0xbc }, 17);
crypt.setKey("someStableKey");
try
diff --git a/wicket-core/src/test/java/org/apache/wicket/protocol/http/CsrfPreventionRequestCycleListenerTest.java b/wicket-core/src/test/java/org/apache/wicket/protocol/http/CsrfPreventionRequestCycleListenerTest.java
deleted file mode 100644
index 214faec..0000000
--- a/wicket-core/src/test/java/org/apache/wicket/protocol/http/CsrfPreventionRequestCycleListenerTest.java
+++ /dev/null
@@ -1,658 +0,0 @@
-/*
- * 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.protocol.http;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import jakarta.servlet.http.HttpServletRequest;
-
-import org.apache.wicket.RestartResponseException;
-import org.apache.wicket.protocol.http.CsrfPreventionRequestCycleListener.CsrfAction;
-import org.apache.wicket.request.IRequestHandler;
-import org.apache.wicket.request.component.IRequestablePage;
-import org.apache.wicket.request.http.WebRequest;
-import org.apache.wicket.util.tester.WicketTestCase;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-/**
- * Test cases for the {@link CsrfPreventionRequestCycleListener}. FirstPage has a link that when clicked
- * should render SecondPage.
- */
-class CsrfPreventionRequestCycleListenerTest extends WicketTestCase
-{
- /**
- * Sets up the test cases. Installs the CSRF listener and renders the FirstPage.
- */
- @BeforeEach
- void startWithFirstPageRender()
- {
- WebApplication application = tester.getApplication();
-
- csrfListener = new MockCsrfPreventionRequestCycleListener();
- setErrorCode(errorCode);
- setErrorMessage(errorMessage);
- application.getRequestCycleListeners().add(csrfListener);
-
- // Rendering a page is allowed, regardless of Origin (this allows external links into your
- // website to function)
-
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "https://google.com/");
-
- tester.startPage(FirstPage.class);
- tester.assertRenderedPage(FirstPage.class);
- }
-
- /** Tests that disabling the CSRF listener doesn't check Origin headers. */
- @Test
- void disabledListenerDoesntCheckAnything()
- {
- csrfEnabled = false;
- tester.clickLink("link");
-
- assertOriginsNotChecked();
- tester.assertRenderedPage(SecondPage.class);
- }
-
- /** Tests that disabling the CSRF listener doesn't check Origin headers. */
- @Test
- void disabledListenerDoesntCheckMismatchedOrigin()
- {
- csrfEnabled = false;
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://malicioussite.com/");
- tester.clickLink("link");
- assertOriginsNotChecked();
- tester.assertRenderedPage(SecondPage.class);
- }
-
- /** Tests the default setting of aborting a missing Origin. */
- @Test
- void withoutOriginAllowed()
- {
- csrfListener.setNoOriginAction(CsrfAction.ALLOW);
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, null);
- tester.clickLink("link");
- assertConflictingOriginsRequestAllowed();
- }
-
- /** Tests the alternative action of suppressing a request without Origin header */
- @Test
- void withoutOriginSuppressed()
- {
- csrfListener.setNoOriginAction(CsrfAction.SUPPRESS);
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, null);
- tester.clickLink("link");
- tester.assertRenderedPage(FirstPage.class);
- assertConflictingOriginsRequestSuppressed();
- }
-
- /** Tests the alternative action of aborting a request without Origin header */
- @Test
- void withoutOriginAborted()
- {
- csrfListener.setNoOriginAction(CsrfAction.ABORT);
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, null);
- tester.clickLink("link");
- assertConflictingOriginsRequestAborted();
- }
-
- /** Tests when the Origin header matches the request. */
- @Test
- void matchingOriginsAllowed()
- {
- csrfListener.setConflictingOriginAction(CsrfAction.ALLOW);
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://localhost/");
-
- tester.clickLink("link");
-
- assertOriginsMatched();
- tester.assertRenderedPage(SecondPage.class);
- }
-
- /** Tests when the default action is changed to ALLOW when origins conflict. */
- @Test
- void conflictingOriginsAllowed()
- {
- csrfListener.setConflictingOriginAction(CsrfAction.ALLOW);
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://example.com/");
-
- tester.clickLink("link");
-
- assertConflictingOriginsRequestAllowed();
- tester.assertRenderedPage(SecondPage.class);
- }
-
- /** Tests when the default action is changed to SUPPRESS when origins conflict. */
- @Test
- void conflictingOriginsSuppressed()
- {
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://example.com/");
- csrfListener.setConflictingOriginAction(CsrfAction.SUPPRESS);
-
- tester.clickLink("link");
-
- assertConflictingOriginsRequestSuppressed();
- tester.assertRenderedPage(FirstPage.class);
- }
-
- /** Tests the default action to ABORT when origins conflict. */
- @Test
- void conflictingOriginsAborted()
- {
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://example.com/");
-
- tester.clickLink("link");
-
- assertConflictingOriginsRequestAborted();
- }
-
- /** Tests custom error code/message when the default action is ABORT. */
- @Test
- void conflictingOriginsAbortedWith401Unauhorized()
- {
- setErrorCode(401);
- setErrorMessage("NOT AUTHORIZED");
-
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://example.com/");
- csrfListener.setNoOriginAction(CsrfAction.ABORT);
-
- tester.clickLink("link");
-
- assertConflictingOriginsRequestAborted();
- }
-
- /** Tests whitelisting for conflicting origins. */
- @Test
- void conflictingButWhitelistedOriginAllowed()
- {
- csrfListener.setConflictingOriginAction(CsrfAction.ALLOW);
- csrfListener.addAcceptedOrigin("example.com");
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://example.com/");
-
- tester.clickLink("link");
-
- assertOriginsWhitelisted();
- tester.assertRenderedPage(SecondPage.class);
- }
-
- /** Tests whitelisting with conflicting subdomain origin. */
- @Test
- void conflictingButWhitelistedSubdomainOriginAllowed()
- {
- csrfListener.addAcceptedOrigin("example.com");
- csrfListener.setConflictingOriginAction(CsrfAction.ALLOW);
-
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://foo.example.com/");
-
- tester.clickLink("link");
-
- tester.assertRenderedPage(SecondPage.class);
- assertOriginsWhitelisted();
- }
-
- /**
- * Tests when the listener is disabled for a specific page (by overriding
- * {@link CsrfPreventionRequestCycleListener#isChecked(IRequestablePage)})
- */
- @Test
- void conflictingOriginPageNotCheckedAllowed()
- {
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://example.com/");
- csrfListener.setConflictingOriginAction(CsrfAction.ABORT);
-
- // disable the check for this page
- checkPage = false;
-
- tester.clickLink("link");
-
- assertConflictingOriginsRequestAllowed();
- tester.assertRenderedPage(SecondPage.class);
- }
-
- /** Tests overriding the onSuppressed method for a conflicting origin. */
- @Test
- void conflictingOriginSuppressedCallsCustomHandler()
- {
- // redirect to third page to ensure we are not suppressed to the first page, nor that the
- // request was not suppressed and the second page was rendered erroneously
-
- Runnable thirdPageRedirect = new Runnable()
- {
- @Override
- public void run()
- {
- throw new RestartResponseException(new ThirdPage());
- }
- };
- setSuppressHandler(thirdPageRedirect);
- csrfListener.setConflictingOriginAction(CsrfAction.SUPPRESS);
-
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://example.com/");
-
- tester.clickLink("link");
-
- assertConflictingOriginsRequestSuppressed();
- tester.assertRenderedPage(ThirdPage.class);
- }
-
- /** Tests overriding the onAllowed method for a conflicting origin. */
- @Test
- void conflictingOriginAllowedCallsCustomHandler()
- {
- // redirect to third page to ensure we are not suppressed to the first page, nor that the
- // request was not allowed and the second page was rendered erroneously
-
- Runnable thirdPageRedirect = new Runnable()
- {
- @Override
- public void run()
- {
- throw new RestartResponseException(new ThirdPage());
- }
- };
- setAllowHandler(thirdPageRedirect);
- csrfListener.setConflictingOriginAction(CsrfAction.ALLOW);
-
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://example.com/");
-
- tester.clickLink("link");
-
- assertConflictingOriginsRequestAllowed();
- tester.assertRenderedPage(ThirdPage.class);
- }
-
- /** Tests overriding the onAborted method for a conflicting origin. */
- @Test
- void conflictingOriginAbortedCallsCustomHandler()
- {
- // redirect to third page to ensure we are not suppressed to the first page, nor that the
- // request was not aborted and the second page was rendered erroneously
-
- Runnable thirdPageRedirect = new Runnable()
- {
- @Override
- public void run()
- {
- throw new RestartResponseException(new ThirdPage());
- }
- };
- setAbortHandler(thirdPageRedirect);
-
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://example.com/");
- csrfListener.setConflictingOriginAction(CsrfAction.ABORT);
-
- tester.clickLink("link");
-
- // have to check manually, as the assert checks the error code (which is not set due to our
- // custom handler)
-
- if (!aborted)
- throw new AssertionError("Request was not aborted");
-
- tester.assertRenderedPage(ThirdPage.class);
- }
-
- /** Tests whether a different port, but same scheme and hostname is considered a conflict. */
- @Test
- void differentPortOriginAborted()
- {
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://localhost:8080");
- csrfListener.setConflictingOriginAction(CsrfAction.ABORT);
-
- tester.clickLink("link");
-
- assertConflictingOriginsRequestAborted();
- }
-
- /** Tests whether a different scheme, but same port and hostname is considered a conflict. */
- @Test
- void differentSchemeOriginAborted()
- {
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "https://localhost");
- csrfListener.setConflictingOriginAction(CsrfAction.ABORT);
-
- tester.clickLink("link");
-
- assertConflictingOriginsRequestAborted();
- }
-
- /** Tests whether only the hostname is considered when matching the Origin header. */
- @Test
- void longerOriginAllowed()
- {
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://localhost/supercalifragilisticexpialidocious");
- csrfListener.setConflictingOriginAction(CsrfAction.ABORT);
-
- tester.clickLink("link");
-
- assertOriginsMatched();
- tester.assertRenderedPage(SecondPage.class);
- }
-
- /** Tests whether AJAX Links are checked through the CSRF listener */
- @Test
- void simulatedCsrfAttackThroughAjaxIsPrevented()
- {
- csrfListener.setConflictingOriginAction(CsrfAction.ABORT);
-
- // first render a page in the user's session
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://localhost");
- tester.startPage(ThirdPage.class);
-
- assertOriginsNotChecked();
- tester.assertRenderedPage(ThirdPage.class);
-
- // then click on a link from another external page
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://attacker.com/");
- tester.clickLink("link", true);
-
- assertConflictingOriginsRequestAborted();
- }
-
- /** Tests whether AJAX Links are checked through the CSRF listener */
- @Test
- void simulatedCsrfAttackIsSuppressed()
- {
- csrfListener.setConflictingOriginAction(CsrfAction.SUPPRESS);
-
- // first render a page in the user's session
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://localhost");
- tester.startPage(ThirdPage.class);
-
- assertOriginsNotChecked();
- tester.assertRenderedPage(ThirdPage.class);
-
- // then click on a link from another external page
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://attacker.com/");
- tester.clickLink("link", true);
-
- assertConflictingOriginsRequestSuppressed();
- tester.assertRenderedPage(ThirdPage.class);
- }
-
- /** Tests whether form submits are checked through the CSRF listener */
- @Test
- void simulatedCsrfAttackOnFormIsSuppressed()
- {
- csrfListener.setConflictingOriginAction(CsrfAction.SUPPRESS);
-
- // first render a page in the user's session
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://localhost");
- tester.startPage(ThirdPage.class);
-
- assertOriginsNotChecked();
- tester.assertRenderedPage(ThirdPage.class);
-
- // then click on a link from another external page
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://attacker.com/");
- tester.submitForm("form");
-
- assertConflictingOriginsRequestSuppressed();
- tester.assertRenderedPage(ThirdPage.class);
- }
-
- /** Tests whether a cross origin request by a white listed origin is allowed*/
- @Test
- void crossSiteButWhiteListedAllowed()
- {
- csrfListener.addAcceptedOrigin("example.com");
- tester.addRequestHeader(WebRequest.HEADER_ORIGIN, "http://example.com/");
-
- tester.clickLink("link");
-
- assertOriginsWhitelisted();
- tester.assertRenderedPage(SecondPage.class);
- }
-
- /*
- * Infrastructure code for these test cases starts here.
- */
-
- /** The listener under test */
- private CsrfPreventionRequestCycleListener csrfListener;
-
- /** Flag for enabling/disabling the CSRF listener */
- private boolean csrfEnabled = true;
-
- /** Flag for enabling/disabling the page check of the CSRF listener */
- private boolean checkPage = true;
-
- /** Value for reporting the error code when the request was aborted */
- private int errorCode = 400;
-
- /** Value for reporting the error message when the request was aborted */
- private String errorMessage = "BAD REQUEST";
-
- /** Checks for asserting the functionality of the CSRF listener */
- private boolean matched, whitelisted, aborted, allowed, suppressed;
-
- /**
- * Manner to override the default check whether the current request handler should be checked
- * for CSRF attacks.
- */
- private Predicate<IRequestHandler> customRequestHandlerCheck;
-
- /**
- * Handlers for specific tests (ensures that the listener calls the right handler in the right
- * circumstance.
- */
- private Runnable abortHandler, allowHandler, suppressHandler, matchedHandler, whitelistHandler;
-
- private void setErrorCode(int errorCode)
- {
- this.errorCode = errorCode;
- csrfListener.setErrorCode(errorCode);
- }
-
- void setCustomRequestHandlerCheck(Predicate<IRequestHandler> check)
- {
- this.customRequestHandlerCheck = check;
- }
-
- private void setErrorMessage(String errorMessage)
- {
- this.errorMessage = errorMessage;
- csrfListener.setErrorMessage(errorMessage);
- }
-
- private void setAbortHandler(Runnable abortHandler)
- {
- this.abortHandler = abortHandler;
- }
-
- private void setAllowHandler(Runnable allowHandler)
- {
- this.allowHandler = allowHandler;
- }
-
- private void setSuppressHandler(Runnable suppressHandler)
- {
- this.suppressHandler = suppressHandler;
- }
-
- void setWhitelistHandler(Runnable whitelistHandler)
- {
- this.whitelistHandler = whitelistHandler;
- }
-
- void setMatchedHandler(Runnable matchedHandler)
- {
- this.matchedHandler = matchedHandler;
- }
-
- /**
- * Asserts that the origins were checked, and found matching.
- */
- private void assertOriginsMatched()
- {
- if (!matched)
- throw new AssertionError("Origins were not matched");
- }
-
- /**
- * Asserts that the origins were not checked, because the origin was on the whitelist.
- */
- private void assertOriginsWhitelisted()
- {
- if (!whitelisted)
- throw new AssertionError("Origins were not whitelisted");
- }
-
- /**
- * Asserts that the origins were checked, found conflicting, had an action "ABORTED" and returns
- * a HTTP error.
- */
- private void assertConflictingOriginsRequestAborted()
- {
- if (!aborted)
- throw new AssertionError("Request was not aborted");
-
- assertEquals(errorCode, tester.getLastResponse().getStatus(), "Response error code");
- assertThat("Response error message", tester.getLastResponse().getErrorMessage(),
- is(errorMessage));
- }
-
- /**
- * Asserts that the origins were checked, found conflicting and had an action "SUPPRESS".
- */
- private void assertConflictingOriginsRequestSuppressed()
- {
- if (!suppressed)
- throw new AssertionError("Request was not suppressed");
- }
-
- /**
- * Asserts that the origins were checked, found conflicting and had an action "ALLOWED".
- */
- private void assertConflictingOriginsRequestAllowed()
- {
- if (!allowed)
- throw new AssertionError("Request was not allowed");
- }
-
- /**
- * Asserts that the origins were checked and found non-conflicting.
- */
- void assertOriginsCheckedButNotConflicting()
- {
- if (aborted)
- throw new AssertionError("Origin was checked and aborted");
- if (suppressed)
- throw new AssertionError("Origin was checked and suppressed");
- if (allowed)
- throw new AssertionError("Origin was checked and allowed");
- if (whitelisted)
- throw new AssertionError("Origin was whitelisted");
- if (!matched)
- throw new AssertionError("Origin was not checked");
- }
-
- /**
- * Asserts that no check was performed at all.
- */
- private void assertOriginsNotChecked()
- {
- if (aborted)
- throw new AssertionError("Request was checked and aborted");
- if (suppressed)
- throw new AssertionError("Request was checked and suppressed");
- if (allowed)
- throw new AssertionError("Request was checked and allowed");
- if (whitelisted)
- throw new AssertionError("Origin was whitelisted");
- if (matched)
- throw new AssertionError("Origin was checked and matched");
- }
-
- private final class MockCsrfPreventionRequestCycleListener extends
- CsrfPreventionRequestCycleListener
- {
- @Override
- protected boolean isEnabled()
- {
- return csrfEnabled;
- }
-
- @Override
- protected boolean isChecked(IRequestHandler handler)
- {
- if (customRequestHandlerCheck != null)
- return customRequestHandlerCheck.apply(handler);
-
- return super.isChecked(handler);
- }
-
- @Override
- protected boolean isChecked(IRequestablePage targetedPage)
- {
- return checkPage;
- }
-
- @Override
- protected void onAborted(HttpServletRequest containerRequest, String origin,
- IRequestablePage page)
- {
- aborted = true;
- if (abortHandler != null)
- abortHandler.run();
- }
-
- @Override
- protected void onAllowed(HttpServletRequest containerRequest, String origin,
- IRequestablePage page)
- {
- allowed = true;
- if (allowHandler != null)
- allowHandler.run();
- }
-
- @Override
- protected void onSuppressed(HttpServletRequest containerRequest, String origin,
- IRequestablePage page)
- {
- suppressed = true;
- if (suppressHandler != null)
- suppressHandler.run();
- }
-
- @Override
- protected void onMatchingOrigin(HttpServletRequest containerRequest, String origin,
- IRequestablePage page)
- {
- matched = true;
- if (matchedHandler != null)
- matchedHandler.run();
- }
-
- @Override
- protected void onWhitelisted(HttpServletRequest containerRequest, String origin,
- IRequestablePage page)
- {
- whitelisted = true;
- if (whitelistHandler != null)
- whitelistHandler.run();
- }
- }
-
- // Remove when migration to Java 8 is completed
- private interface Predicate<T>
- {
- boolean apply(T t);
- }
-}
diff --git a/wicket-core/src/test/java/org/apache/wicket/protocol/http/request/CryptedUrlWebRequestCodingStrategyTest.java b/wicket-core/src/test/java/org/apache/wicket/protocol/http/request/CryptedUrlWebRequestCodingStrategyTest.java
index ead2b87..f3c5697 100644
--- a/wicket-core/src/test/java/org/apache/wicket/protocol/http/request/CryptedUrlWebRequestCodingStrategyTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/protocol/http/request/CryptedUrlWebRequestCodingStrategyTest.java
@@ -122,11 +122,6 @@ class CryptedUrlWebRequestCodingStrategyTest extends WicketTestCase
return new String(Base64.getUrlEncoder().encode(plainText.getBytes()));
}
- @Override
- public void setKey(String key)
- {
- }
-
};
}
}
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/AjaxApplication.java b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/AjaxApplication.java
index 77ad598..b60617b 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/AjaxApplication.java
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/AjaxApplication.java
@@ -22,9 +22,7 @@ import org.apache.wicket.ajax.AjaxNewWindowNotifyingBehavior;
import org.apache.wicket.application.IComponentInitializationListener;
import org.apache.wicket.examples.WicketExampleApplication;
import org.apache.wicket.examples.ajax.builtin.modal.ModalDialogPage;
-import org.apache.wicket.examples.ajax.builtin.modal.ModalWindowPage;
import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.response.filter.AjaxServerAndClientTimeFilter;
/**
@@ -61,7 +59,6 @@ public class AjaxApplication extends WicketExampleApplication
mountPage("guest-book", GuestBook.class);
mountPage("lazy-loading", LazyLoadingPage.class);
mountPage("links", LinksPage.class);
- mountPage("modal-window", ModalWindowPage.class);
mountPage("modal-dialog", ModalDialogPage.class);
mountPage("on-change-ajax-behavior", OnChangeAjaxBehaviorPage.class);
mountPage("pageables", PageablesPage.class);
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalContent1Page.html b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalContent1Page.html
deleted file mode 100644
index d8b4dc5..0000000
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalContent1Page.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<html xmlns:wicket="http://wicket.apache.org">
- <head>
- <title>This is modal window</title>
- <style type="text/css">
- body {
- font-family: verdana, sans-serif;
- font-size: 82%;
- background-color: white;
- }
- </style>
- </head>
- <body>
- Modal WINDOW content.
- <p>
- <a wicket:id="closeOK">Close this window with result "OK"</a><br/>
- <a wicket:id="closeCancel">Close this window with result "Cancel"</a><br/>
- </p>
- <p>
- <div wicket:id="modal"></div>
- <a wicket:id="open">Open another modal dialog</a>
- </p>
- </body>
-</html>
\ No newline at end of file
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalContent1Page.java b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalContent1Page.java
deleted file mode 100644
index 5cf8277..0000000
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalContent1Page.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 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.examples.ajax.builtin.modal;
-
-import org.apache.wicket.PageReference;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.markup.html.AjaxLink;
-import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
-import org.apache.wicket.extensions.markup.html.form.datetime.LocalDateTimeField;
-import org.apache.wicket.markup.html.WebPage;
-
-
-/**
- * @author Matej Knopp
- *
- */
-public class ModalContent1Page extends WebPage
-{
- private static final long serialVersionUID = 1L;
-
- /**
- *
- * @param modalWindowPage
- * @param window
- */
- public ModalContent1Page(final PageReference modalWindowPage, final ModalWindow window)
- {
- add(new AjaxLink<Void>("closeOK")
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void onClick(AjaxRequestTarget target)
- {
- if (modalWindowPage != null)
- ((ModalWindowPage)modalWindowPage.getPage()).setResult("Modal window 1 - close link OK");
- window.close(target);
- }
- });
-
- add(new AjaxLink<Void>("closeCancel")
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void onClick(AjaxRequestTarget target)
- {
- if (modalWindowPage != null)
- ((ModalWindowPage)modalWindowPage.getPage()).setResult("Modal window 1 - close link Cancel");
- window.close(target);
- }
- });
-
- final ModalWindow modal;
- add(modal = new ModalWindow("modal"));
-
- modal.setCookieName("modal window 2");
-
- modal.setResizable(false);
- modal.setInitialWidth(30);
- modal.setInitialHeight(15);
- modal.setWidthUnit("em");
- modal.setHeightUnit("em");
-
- modal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
-
- modal.setPageCreator(() -> new ModalContent2Page(modal));
-
- modal.setCloseButtonCallback(target -> {
- target.appendJavaScript("alert('You can\\'t close this modal window using close button."
- + " Use the link inside the window instead.');");
- return false;
- });
-
- add(new AjaxLink<Void>("open")
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void onClick(AjaxRequestTarget target)
- {
- modal.show(target);
- }
- });
-
- }
-}
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalContent2Page.html b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalContent2Page.html
deleted file mode 100644
index 2e151b6..0000000
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalContent2Page.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<html xmlns:wicket="http://wicket.apache.org">
- <head>
- <title>Modal dialog</title>
- <style type="text/css">
- body {
- font-family: verdana, sans-serif;
- font-size: 82%;
- background-color: #FFFEC4;
- }
- </style>
- </head>
- <body>
- This is modal window opened from another modal window. This one is not resizable.
- The window dimensions are specified in relative units (em).
- <p>
- <a wicket:id="close">Close this window</a><br/>
- </p>
- </body>
-</html>
\ No newline at end of file
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalContent2Page.java b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalContent2Page.java
deleted file mode 100644
index 4b668ac..0000000
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalContent2Page.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.examples.ajax.builtin.modal;
-
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.markup.html.AjaxLink;
-import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
-import org.apache.wicket.markup.html.WebPage;
-
-
-/**
- * @author Matej Knopp
- *
- */
-public class ModalContent2Page extends WebPage
-{
- private static final long serialVersionUID = 1L;
-
- /**
- * @param window
- */
- public ModalContent2Page(final ModalWindow window)
- {
- add(new AjaxLink<Void>("close")
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void onClick(AjaxRequestTarget target)
- {
- window.close(target);
- }
- });
- }
-}
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalPanel1.html b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalPanel1.html
deleted file mode 100644
index 6ae319e..0000000
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalPanel1.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<wicket:panel xmlns:wicket="http://wicket.apache.org">
- <div style="margin: 1em">
- This is panel content!
- <p>
- Ajax autocomplete to demonstrate AJAX header contribution -> <input wicket:id="edit" />
- </p>
- </div>
-</wicket:panel>
\ No newline at end of file
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalPanel1.java b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalPanel1.java
deleted file mode 100644
index ba23e97..0000000
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalPanel1.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.examples.ajax.builtin.modal;
-
-import java.util.Arrays;
-import java.util.Iterator;
-
-import org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings;
-import org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField;
-import org.apache.wicket.markup.html.panel.Panel;
-import org.apache.wicket.model.Model;
-
-/**
- * @author Matej Knopp
- */
-public class ModalPanel1 extends Panel
-{
- private static final long serialVersionUID = 1L;
-
- /**
- * @param id
- */
- public ModalPanel1(String id)
- {
- super(id);
-
- AutoCompleteSettings settings = new AutoCompleteSettings();
- settings.setShowListOnEmptyInput(true);
-
- add(new AutoCompleteTextField<String>("edit", new Model<>(), settings)
- {
- @Override
- protected Iterator<String> getChoices(String input)
- {
- return Arrays.asList("A", "B", "C").iterator();
- }
- });
- }
-}
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalWindowPage.html b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalWindowPage.html
deleted file mode 100644
index 4ee457c..0000000
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalWindowPage.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<wicket:extend xmlns:wicket="http://wicket.apache.org">
- Last modal window result: <span wicket:id="result"></span>
-
- <div wicket:id="modal1"></div>
- <a wicket:id="showModal1">Show modal dialog with a page</a>
- <br/>
- <div wicket:id="modal2"></div><br/>
- <a wicket:id="showModal2">Show modal dialog with panel</a>
-</wicket:extend>
\ No newline at end of file
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalWindowPage.java b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalWindowPage.java
deleted file mode 100644
index f8376ff..0000000
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalWindowPage.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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.examples.ajax.builtin.modal;
-
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.markup.html.AjaxLink;
-import org.apache.wicket.examples.ajax.builtin.BasePage;
-import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.model.PropertyModel;
-
-
-/**
- * @author Matej Knopp
- */
-public class ModalWindowPage extends BasePage
-{
- private static final long serialVersionUID = 1L;
-
- public ModalWindowPage()
- {
- final Label result;
- add(result = new Label("result", new PropertyModel<>(this, "result")));
- result.setOutputMarkupId(true);
-
- /*
- * First modal window
- */
-
- final ModalWindow modal1;
- add(modal1 = new ModalWindow("modal1"));
-
- modal1.setCookieName("modal-1");
-
- modal1.setPageCreator(() -> new ModalContent1Page(ModalWindowPage.this.getPageReference(), modal1));
- modal1.setWindowClosedCallback(target -> target.add(result));
- modal1.setCloseButtonCallback(target -> {
- setResult("Modal window 1 - close button");
- return true;
- });
-
- add(new AjaxLink<Void>("showModal1")
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void onClick(AjaxRequestTarget target)
- {
- modal1.show(target);
- }
- });
-
- /*
- * Second modal window
- */
-
- final ModalWindow modal2;
- add(modal2 = new ModalWindow("modal2"));
-
- modal2.setContent(new ModalPanel1(modal2.getContentId()));
- modal2.setTitle("Modal window\n'panel\" content.");
- modal2.setCookieName("modal-2");
-
- modal2.setCloseButtonCallback(target -> {
- setResult("Modal window 2 - close button");
- return true;
- });
-
- modal2.setWindowClosedCallback(target -> target.add(result));
-
- add(new AjaxLink<Void>("showModal2")
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void onClick(AjaxRequestTarget target)
- {
- modal2.show(target);
- }
- });
- }
-
- /**
- * @return the result
- */
- public String getResult()
- {
- return result;
- }
-
- /**
- * @param result
- * the result to set
- */
- public void setResult(String result)
- {
- this.result = result;
- }
-
- private String result;
-
-}
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/RepeaterApplication.java b/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/RepeaterApplication.java
index 5e3f6b4..7a19221 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/RepeaterApplication.java
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/RepeaterApplication.java
@@ -18,7 +18,6 @@ package org.apache.wicket.examples.repeater;
import org.apache.wicket.Page;
import org.apache.wicket.examples.WicketExampleApplication;
-import org.apache.wicket.response.filter.ServerAndClientTimeFilter;
/**
* application class for repeater examples application
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/tree/TreeApplication.java b/wicket-examples/src/main/java/org/apache/wicket/examples/tree/TreeApplication.java
index e58808c..84bd3aa 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/tree/TreeApplication.java
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/tree/TreeApplication.java
@@ -22,7 +22,6 @@ import java.util.List;
import org.apache.wicket.Page;
import org.apache.wicket.examples.WicketExampleApplication;
import org.apache.wicket.protocol.http.WebApplication;
-import org.apache.wicket.response.filter.ServerAndClientTimeFilter;
/**
* Application class for tree examples.
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/UploadProgressBar.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/UploadProgressBar.java
index 04307b8..d938e37 100644
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/UploadProgressBar.java
+++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/UploadProgressBar.java
@@ -21,7 +21,6 @@ import java.util.Formatter;
import org.apache.wicket.Application;
import org.apache.wicket.IInitializer;
import org.apache.wicket.MarkupContainer;
-import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
@@ -38,8 +37,6 @@ import org.apache.wicket.request.resource.ResourceReference;
import org.apache.wicket.request.resource.SharedResourceReference;
import org.apache.wicket.resource.CoreLibrariesContributor;
import org.apache.wicket.util.lang.Args;
-import org.apache.wicket.util.visit.IVisit;
-import org.apache.wicket.util.visit.IVisitor;
/**
* A panel to show the progress of an HTTP upload.
@@ -249,29 +246,11 @@ public class UploadProgressBar extends Panel
/**
* Form on where will be installed the JavaScript callback to present the progress bar.
- * {@link ModalWindow} is designed to hold nested forms and the progress bar callback JavaScript
- * needs to be add at the form inside the {@link ModalWindow} if one is used.
*
* @return form
*/
private Form<?> getCallbackForm()
{
- Boolean insideModal = form.visitParents(ModalWindow.class,
- new IVisitor<ModalWindow, Boolean>()
- {
- @Override
- public void component(final ModalWindow object, final IVisit<Boolean> visit)
- {
- visit.stop(true);
- }
- });
- if ((insideModal != null) && insideModal)
- {
- return form;
- }
- else
- {
- return form.getRootForm();
- }
+ return form.getRootForm();
}
}
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.html b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.html
deleted file mode 100644
index 2aa2cff..0000000
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- 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.
--->
-<wicket:panel xmlns:wicket="http://wicket.apache.org">
- <div wicket:id="content">
- </div>
-</wicket:panel>
\ No newline at end of file
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
deleted file mode 100644
index 7247e45..0000000
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
+++ /dev/null
@@ -1,1184 +0,0 @@
-/*
- * 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.extensions.ajax.markup.html.modal;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.Page;
-import org.apache.wicket.WicketRuntimeException;
-import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.json.JSONFunction;
-import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
-import org.apache.wicket.core.request.handler.PageProvider;
-import org.apache.wicket.core.request.handler.RenderPageRequestHandler;
-import org.apache.wicket.markup.ComponentTag;
-import org.apache.wicket.markup.head.CssHeaderItem;
-import org.apache.wicket.markup.head.IHeaderResponse;
-import org.apache.wicket.markup.head.JavaScriptHeaderItem;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.panel.Panel;
-import org.apache.wicket.markup.repeater.AbstractRepeater;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.request.IRequestHandler;
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.request.resource.CssResourceReference;
-import org.apache.wicket.request.resource.JavaScriptResourceReference;
-import org.apache.wicket.request.resource.ResourceReference;
-import org.apache.wicket.resource.CoreLibrariesContributor;
-import org.apache.wicket.util.io.IClusterable;
-import org.apache.wicket.util.lang.EnumeratedType;
-import org.apache.wicket.util.string.AppendingStringBuffer;
-
-import com.github.openjson.JSONObject;
-
-/**
- * Modal window component.
- * <p>
- * Modal window is a draggable window (with either <div> when used with a Panel or <iframe>
- * when used with a Page content) that prevent user from
- * interacting the rest of page (using a mask) until the window is closed.
- * <p>
- * If you want this to work under IE, don't attach this component to a <span> tag, make sure
- * you use a <div>.
- * <p>
- * The window is draggable and optionally resizable. The content can be either
- * <ul>
- * <li><b>a component</b> - you need to add the component to modal window (with id obtained using
- * <code>{@link #getContentId()}</code>, or
- * <li><b>a page</b> - you need to pass a <code>{@link PageCreator}</code> instance to a
- * <code>{@link #setPageCreator(ModalWindow.PageCreator)}</code> method.
- * </ul>
- * In case the content is a component, it is not rendered until the window is shown (method
- * <code>{@link #show(IPartialPageRequestHandler)})</code>. The window can be made
- * visible from an ajax handler using
- * <code>{@link #show(IPartialPageRequestHandler)}</code>.
- * <p>
- * To close the window there are multiple options. Static method
- * <code>{@link #close(IPartialPageRequestHandler)}</code> can be used to close the
- * window from a handler of ajax link inside the window. By default the close button in the upper
- * right corner of the window closes it. This behavior can be altered using
- * <code>{@link #setCloseButtonCallback(ModalWindow.CloseButtonCallback)}</code>. If you want to be
- * notified when the window is closed (either using the close button or calling
- * <code>{@link #close(IPartialPageRequestHandler)})</code>, you can use
- * <code>{@link #setWindowClosedCallback(ModalWindow.WindowClosedCallback)}</code>.
- * <p>
- * Title is specified using {@link #setTitle(String)}. Pass <code>true</code> to
- * <code>{@link #setEscapeModelStrings(boolean)}</code> to use unencoded markup in the title.
- * <br>
- * If the content is a page (iframe), the title can remain unset, in that case title from the page
- * inside window will be shown.
- * <p>
- * There are several options to specify the visual properties of the window. In all methods where
- * size is expected, width refers to width of entire window (including frame), height refers to the
- * height of window content (without frame).
- * <p>
- * <ul>
- * <li><code>{@link #setResizable(boolean)}</code> specifies, whether the window can be resized.
- * <li><code>{@link #setInitialWidth(int)}</code> and <code>{@link #setInitialHeight(int)}</code>
- * specify the initial width and height of window. If the window is resizable, the unit of these
- * dimensions is always "px". If the window is not resizable, the unit can be specified using
- * <code>{@link #setWidthUnit(String)}</code> and <code>{@link #setHeightUnit(String)}</code>. If
- * the window is not resizable and the content is a component (not a page), the initial height value
- * can be ignored and the actual height can be determined from the height of the content. To enable
- * this behavior use <code>{@link #setUseInitialHeight(boolean)}</code>.
- * <li>The window position (and size if the window is resizable) can be stored in a cookie, so that
- * it is preserved when window is close. The name of the cookie is specified via
- * <code>{@link #setCookieName(String)}</code>. If the name is <code>null</code>, position is not
- * stored (initial width and height are always used). Default cookie name is null (position is not
- * stored).
- * <li><code>{@link #setMinimalWidth(int)}</code> and <code>{@link #setMinimalHeight(int)}</code>
- * set the minimal dimensions of resizable window.
- * <li><code>{@link #setAutoSize(boolean)}</code> sets whether window size will be automatically
- * adjusted on opening to fit content's width and height. Default is false.<span
- * style="text-decoration: underline"> Doesn't work on IE 6.</span></li>
- * <li>Modal window can chose between two colors of frame.
- * <code>{@link #setCssClassName(String)}</code> sets the dialog css class, possible values are
- * <code>{@link #CSS_CLASS_BLUE}</code> for blue frame and <code>{@link #CSS_CLASS_GRAY}</code> for
- * gray frame.
- * <li>Mask (element that prevents user from interacting the rest of the page) can be either
- * transparent or semitransparent. <code>{@link #setMaskType(ModalWindow.MaskType)}</code> alters
- * this.
- * </ul>
- * Also it is recommended to put the modal window component in markup before any component (i.e.
- * AjaxLink or AjaxButton) that shows it.
- * <p>
- * If you want to use form in modal window component make sure that you put the modal window itself
- * in another form (nesting forms is legal in Wicket) and that the form on modal window is submitted
- * before the window get closed.
- *
- * @author Matej Knopp
- *
- * @deprecated use {@link ModalDialog} instead
- */
-public class ModalWindow extends Panel
-{
- private static final long serialVersionUID = 1L;
-
- /** CSS class for window with blue border. */
- public final static String CSS_CLASS_BLUE = "w_blue";
-
- /** CSS class for window with gray border. */
- public final static String CSS_CLASS_GRAY = "w_silver";
-
- private static final ResourceReference JAVASCRIPT = new JavaScriptResourceReference(
- ModalWindow.class, "res/modal.js");
-
- private static final ResourceReference CSS = new CssResourceReference(ModalWindow.class,
- "res/modal.css");
-
- /** the default id of the content component */
- public static final String CONTENT_ID = "content";
-
- /** True while the ModalWindows is showing */
- private boolean shown = false;
-
- /** empty container - used when no component is added */
- private WebMarkupContainer empty;
-
- private int minimalWidth = 200;
- private int minimalHeight = 200;
- private String cssClassName = CSS_CLASS_BLUE;
- private int initialWidth = 600;
- private int initialHeight = 400;
- private boolean useInitialHeight = true;
- private boolean resizable = true;
- private String widthUnit = "px";
- private String heightUnit = "px";
- private String cookieName;
- private IModel<String> title = null;
- private MaskType maskType = MaskType.SEMI_TRANSPARENT;
- private boolean autoSize = false;
- private boolean unloadConfirmation = true;
-
- private PageCreator pageCreator = null;
- private CloseButtonCallback closeButtonCallback = null;
- private WindowClosedCallback windowClosedCallback = null;
-
- /**
- * Interface for lazy page creation. The advantage of creating page using this interface over
- * just passing a page instance is that page created in <code>{@link #createPage()}</code> will
- * have the pagemap automatically set to the pagemap specified for
- * <code>{@link ModalWindow}</code>.
- *
- * @author Matej Knopp
- */
- public interface PageCreator extends IClusterable
- {
- /**
- * Creates a new instance of content page.
- *
- * @return new page instance
- */
- Page createPage();
- }
-
- /**
- * Callback for close button that contains a method that is invoked after the button has been
- * clicked. If no callback instance is specified using
- * <code>{@link ModalWindow#setCloseButtonCallback(ModalWindow.CloseButtonCallback)}</code>, no
- * ajax request will be fired. Clicking the button will just close the window.
- *
- * @author Matej Knopp
- */
- public interface CloseButtonCallback extends IClusterable
- {
- /**
- * Methods invoked after the button has been clicked. The invocation is done using an ajax
- * call, so <code>{@link org.apache.wicket.ajax.AjaxRequestTarget}</code> instance is
- * available.
- *
- * @param target
- * <code>{@link org.apache.wicket.ajax.AjaxRequestTarget}</code> instance bound
- * with the ajax request.
- *
- * @return True if the window can be closed (will close the window), false otherwise
- */
- boolean onCloseButtonClicked(AjaxRequestTarget target);
- }
-
- /**
- * Callback called after the window has been closed. If no callback instance is specified using
- * {@link ModalWindow#setWindowClosedCallback(ModalWindow.WindowClosedCallback)}, no ajax
- * request will be fired.
- *
- * @author Matej Knopp
- */
- public interface WindowClosedCallback extends IClusterable
- {
- /**
- * Called after the window has been closed.
- *
- * @param target
- * <code>{@link org.apache.wicket.ajax.AjaxRequestTarget}</code> instance bound
- * with the ajax request.
- */
- void onClose(AjaxRequestTarget target);
- }
-
- /**
- * Creates a new modal window component.
- *
- * @param id
- * Id of component
- */
- public ModalWindow(final String id)
- {
- super(id);
- init();
- }
-
- /**
- * Creates a new modal window component.
- *
- * @param id
- * Id of component
- * @param model
- * Model
- */
- public ModalWindow(final String id, final IModel<?> model)
- {
- super(id, model);
- init();
- }
-
- /**
- * Initialize
- */
- private void init()
- {
- setVersioned(false);
- cookieName = null;
-
- add(empty = new WebMarkupContainer(getContentId()));
-
- add(newCloseButtonBehavior());
- add(new WindowClosedBehavior());
-
- // install a default callback that will force
- // WindowClosedBehavior to be executed
- setWindowClosedCallback((WindowClosedCallback) target -> {
- // noop
- });
-
- }
-
- @Override
- public void renderHead(final IHeaderResponse response)
- {
- super.renderHead(response);
-
- CoreLibrariesContributor.contributeAjax(getApplication(), response);
- response.render(JavaScriptHeaderItem.forReference(JAVASCRIPT));
-
- ResourceReference cssResource = newCssResource();
- if (cssResource != null)
- {
- response.render(CssHeaderItem.forReference(cssResource));
- }
- }
-
- /**
- * Allows to override CSS contribution. Returning null means the CSS will be contributed via
- * other sources, e.g. a global CSS resource.
- *
- * @return The CSS resource reference or null if CSS is contributed via other means.
- * @see #setCssClassName(String)
- */
- protected ResourceReference newCssResource()
- {
- return CSS;
- }
-
- /**
- * Is this window currently showing.
- *
- * @return the shown
- */
- public boolean isShown()
- {
- return shown;
- }
-
-
- /**
- * Sets the <code>{@link PageCreator}</code> instance. The instance is only used when no custom
- * component has been added to the dialog.
- *
- * @param creator
- * <code>{@link PageCreator}</code> instance
- * @return this
- */
- public ModalWindow setPageCreator(final PageCreator creator)
- {
- setContent(empty);
- pageCreator = creator;
- return this;
- }
-
- /**
- * Sets the <code>{@link CloseButtonCallback}</code> instance.
- *
- * @param callback
- * Callback instance
- * @return this
- */
- public ModalWindow setCloseButtonCallback(final CloseButtonCallback callback)
- {
- closeButtonCallback = callback;
- return this;
- }
-
- /**
- * Sets the <code>@{link {@link WindowClosedCallback}</code> instance.
- *
- * @param callback
- * Callback instance
- * @return this
- */
- public ModalWindow setWindowClosedCallback(final WindowClosedCallback callback)
- {
- windowClosedCallback = callback;
- return this;
- }
-
- /**
- * Shows the modal window.
- *
- * @param target
- * Request target associated with current ajax request.
- */
- public void show(final IPartialPageRequestHandler target)
- {
- if (shown == false)
- {
- getContent().setVisible(true);
- target.add(this);
- target.appendJavaScript(getWindowOpenJavaScript());
- shown = true;
- }
- }
-
- /**
- * Hides the modal window. This can be called from within the modal window, however, the modal
- * window must have configured WindowClosedCallback. Otherwise use the
- * {@link #close(IPartialPageRequestHandler)} method.
- *
- * @param target
- * Request target associated with current ajax request.
- */
- public static void closeCurrent(final IPartialPageRequestHandler target)
- {
- target.appendJavaScript(getCloseJavacriptInternal());
- }
-
- /**
- * Closes the modal window.
- *
- * @param target
- * Request target associated with current ajax request.
- */
- public void close(final IPartialPageRequestHandler target)
- {
- getContent().setVisible(false);
- if (isCustomComponent())
- {
- target.add(getContent());
- }
- target.appendJavaScript(getCloseJavacript());
- shown = false;
- }
-
- /**
- * Method that allows alternate script for showing the window.
- *
- * @return the script that actually shows the window.
- */
- protected CharSequence getShowJavaScript()
- {
- return "window.setTimeout(function(){\n" + " Wicket.Window.create(settings).show();\n"
- + "}, 0);\n";
- }
-
- private static String getCloseJavacriptInternal()
- {
- return "var win;\n" //
- + "try {\n" + " win = window.parent.Wicket.Window;\n"
- + "} catch (ignore) {\n"
- + "}\n"
- + "if (typeof(win) == \"undefined\" || typeof(win.current) == \"undefined\") {\n"
- + " try {\n" + " win = window.Wicket.Window;\n"
- + " } catch (ignore) {\n"
- + " }\n"
- + "}\n"
- + "if (win && win.current) {\n"
- + " var close = function(w) { w.setTimeout(function() {\n"
- + " win.current.close();\n"
- + " }, 0); };\n"
- + " try { close(window.parent); } catch (ignore) { close(window); }\n" + "}";
- }
-
- /**
- * Method that allows alternate script for closing the window.
- *
- * @return the script that actually closes the window.
- */
- protected String getCloseJavacript()
- {
- return getCloseJavacriptInternal();
- }
-
- /**
- * Returns the id of content component.
- *
- * <pre>
- * ModalWindow window = new ModalWindow(parent, "window");
- * new MyPanel(window, window.getContentId());
- * </pre>
- *
- * @return Id of content component.
- */
- public String getContentId()
- {
- return CONTENT_ID;
- }
-
- /**
- * Sets the minimal width of window. This value is only used if the window is resizable. The
- * width is specified in pixels and it is the width of entire window (including frame).
- *
- * @param minimalWidth
- * Minimal window width.
- * @return this
- */
- public ModalWindow setMinimalWidth(final int minimalWidth)
- {
- this.minimalWidth = minimalWidth;
- return this;
- }
-
- /**
- * Returns the minimal width of window (in pixels).
- *
- * @return Minimal width of window
- */
- public int getMinimalWidth()
- {
- return minimalWidth;
- }
-
- /**
- * Sets the minimal height of window. This value is only used if window is resizable. The height
- * is specified in pixels and it is the height of window content (without frame).
- *
- * @param minimalHeight
- * Minimal height
- * @return this
- */
- public ModalWindow setMinimalHeight(final int minimalHeight)
- {
- this.minimalHeight = minimalHeight;
- return this;
- }
-
- /**
- * Returns the minimal height of window (in pixels).
- *
- * @return Minimal height of window
- */
- public int getMinimalHeight()
- {
- return minimalHeight;
- }
-
- /**
- * Sets the CSS class name for this window. This class affects the look of window frame.
- * Possible values (if you don't make your style sheet) are <code>{@link #CSS_CLASS_BLUE}</code>
- * and <code>{@link #CSS_CLASS_GRAY}</code>.
- *
- * @param cssClassName
- * @return this
- * @see #newCssResource()
- */
- public ModalWindow setCssClassName(final String cssClassName)
- {
- this.cssClassName = cssClassName;
- return this;
- }
-
- /**
- * Returns the CSS class name for this window.
- *
- * @return CSS class name
- */
- public String getCssClassName()
- {
- return cssClassName;
- }
-
- /**
- * Sets the initial width of the window. The width refers to the width of entire window
- * (including frame). If the window is resizable, the width unit is always "px". If the window
- * is not resizable, the unit can be specified using {@link #setWidthUnit(String)}. If cookie
- * name is set and window is resizable, the initial width may be ignored in favor of width
- * stored in cookie.
- *
- * @param initialWidth
- * Initial width of the window
- * @return this
- */
- public ModalWindow setInitialWidth(final int initialWidth)
- {
- this.initialWidth = initialWidth;
- return this;
- }
-
- /**
- * Returns the initial width of the window.
- *
- * @return Initial height of the window
- */
- public int getInitialWidth()
- {
- return initialWidth;
- }
-
- /**
- * Sets the initial height of the window. The height refers to the height of window content
- * (without frame). If the window is resizable, the height unit is always "px". If the window is
- * not resizable, the unit can be specified using {@link #setHeightUnit(String)}. If cookie name
- * is set and window is resizable, the initial height may be ignored in favor of height stored
- * in cookie.
- *
- * @param initialHeight
- * Initial height of the window
- * @return this
- */
- public ModalWindow setInitialHeight(final int initialHeight)
- {
- this.initialHeight = initialHeight;
- return this;
- }
-
- /**
- * Returns the initial height of the window.
- *
- * @return Initial height of the window
- */
- public int getInitialHeight()
- {
- return initialHeight;
- }
-
- /**
- * Sets whether to use initial height or preserve the real content height. This can only be used
- * if the content is a component (not a page) and the window is not resizable.
- *
- * @param useInitialHeight
- * Whether to use initial height instead of preserving content height instead of
- * using initial height
- * @return this
- */
- public ModalWindow setUseInitialHeight(final boolean useInitialHeight)
- {
- this.useInitialHeight = useInitialHeight;
- return this;
- }
-
- /**
- * Returns true if the initial height should be used (in favor of preserving real content
- * height).
- *
- * @return True if initial height should be used, false is real content height should be
- * preserved (valid only if the window is not resizable and the content is a component
- * (not a page)
- */
- public boolean isUseInitialHeight()
- {
- return useInitialHeight;
- }
-
- /**
- * Sets whether the user will be able to resize the window.
- *
- * @param resizable
- * Whether the window is resizable
- * @return this
- */
- public ModalWindow setResizable(final boolean resizable)
- {
- this.resizable = resizable;
- return this;
- }
-
- /**
- * Returns whether the window is resizable.
- *
- * @return True if the window is resizable, false otherwise
- */
- public boolean isResizable()
- {
- return resizable;
- }
-
- /**
- * Sets a flag whether to ask the user before leaving the page.
- *
- * @param unloadConfirmation
- * a flag whether to ask the user before leaving the page
- * @return {@code this} instance, for chaining
- */
- public ModalWindow showUnloadConfirmation(final boolean unloadConfirmation)
- {
- this.unloadConfirmation = unloadConfirmation;
- return this;
- }
-
- /**
- * Returns whether the user should be asked before leaving the page.
- *
- * @return {@code true} if the user should be asked if the last action causes leaving the page,
- * {@code false} otherwise
- */
- public boolean showUnloadConfirmation()
- {
- return unloadConfirmation;
- }
-
- /**
- * Sets the CSS unit used for initial window width. This is only applicable when the window is
- * not resizable.
- *
- * @param widthUnit
- * CSS unit for initial window width.
- * @return this
- */
- public ModalWindow setWidthUnit(final String widthUnit)
- {
- this.widthUnit = widthUnit;
- return this;
- }
-
- /**
- * Returns the CSS unit for initial window width.
- *
- * @return CSS unit for initial window width.
- */
- public String getWidthUnit()
- {
- return widthUnit;
- }
-
- /**
- * Sets the CSS unit used for initial window height. This is only applicable when the window is
- * not resizable.
- *
- * @param heightUnit
- * CSS unit for initial window height.
- * @return this
- */
- public ModalWindow setHeightUnit(final String heightUnit)
- {
- this.heightUnit = heightUnit;
- return this;
- }
-
- /**
- * Retrns the CSS unit for initial window height.
- *
- * @return CSS unit for initial window height.
- */
- public String getHeightUnit()
- {
- return heightUnit;
- }
-
- /**
- * Sets the name of the cookie that is used to remember window position (and size if the window
- * is resizable).
- *
- * @param cookieName
- * Name of the cookie
- * @return this
- */
- public ModalWindow setCookieName(final String cookieName)
- {
- if ((cookieName != null) && (cookieName.contains(",") || cookieName.contains("|")))
- {
- throw new IllegalArgumentException("Cookie name may not contain ',' or '|' characters.");
- }
- this.cookieName = cookieName;
- return this;
- }
-
- /**
- * Returns the name of cookie that is used to remember window position (and size if the window
- * is resizable).
- *
- * @return Name of the cookie
- */
- public String getCookieName()
- {
- return cookieName;
- }
-
- /**
- * Sets the title of window. If the window is a page, title can be <code>null</code>. In that
- * case it will display the title document inside the window.
- *
- * @param title
- * Title of the window
- * @return this
- */
- public ModalWindow setTitle(final String title)
- {
- this.title = new Model<>(title);
- return this;
- }
-
- /**
- * Sets the title of window. If the window is a page, title can be <code>null</code>. In that
- * case it will display the title document inside the window.
- *
- * @param title
- * Title of the window
- * @return this
- */
- public ModalWindow setTitle(IModel<String> title)
- {
- title = wrap(title);
- this.title = title;
- return this;
- }
-
- /**
- * Returns the title of the window.
- *
- * @return Title of the window
- */
- public IModel<String> getTitle()
- {
- return title;
- }
-
- /**
- * Mask is the element behind the window, that prevents user from interacting the rest of page.
- * Mask can be either
- * <ul>
- * <li><code>{@link #TRANSPARENT}</code> - the mask is invisible
- * <li><code>{@link #SEMI_TRANSPARENT}</code> - the mask is black with small opacity (10%)
- * </ul>
- *
- * @author Matej Knopp
- */
- public static final class MaskType extends EnumeratedType
- {
- private static final long serialVersionUID = 1L;
-
- /** Transparent mask (not visible). */
- public static final MaskType TRANSPARENT = new MaskType("TRANSPARENT");
-
- /** Visible mask (black with low opacity). */
- public static final MaskType SEMI_TRANSPARENT = new MaskType("SEMI_TRANSPARENT");
-
- /**
- * Constructor.
- *
- * @param name
- */
- public MaskType(final String name)
- {
- super(name);
- }
- }
-
- /**
- * Sets the mask type of the window.
- *
- * @param mask
- * The mask type
- * @return this
- */
- public ModalWindow setMaskType(final MaskType mask)
- {
- maskType = mask;
- return this;
- }
-
- /**
- * Returns the mask type of the window
- *
- * @return The mask type
- */
- public MaskType getMaskType()
- {
- return maskType;
- }
-
- /**
- * Creates the page.
- *
- * @return Page instance or null if page couldn't be created.
- */
- private Page createPage()
- {
- if (pageCreator == null)
- {
- return null;
- }
- else
- {
- return pageCreator.createPage();
- }
- }
-
- /**
- * @see org.apache.wicket.Component#onBeforeRender()
- */
- @Override
- protected void onBeforeRender()
- {
- shown = makeContentVisible();
-
- getContent().setOutputMarkupId(true);
- getContent().setVisible(shown);
-
- super.onBeforeRender();
- }
-
- /**
- * You may subclass this method in case you don't want to show up the window on normal page
- * refresh.
- *
- * @return true, if the window shall be shown
- */
- protected boolean makeContentVisible()
- {
- // if user is refreshing whole page, the window will not be shown
- if (getWebRequest().isAjax() == false)
- {
- return false;
- }
- else
- {
- return shown;
- }
- }
-
- /**
- * @see org.apache.wicket.markup.html.panel.Panel#onComponentTag(org.apache.wicket.markup.ComponentTag)
- */
- @Override
- protected void onComponentTag(final ComponentTag tag)
- {
- super.onComponentTag(tag);
- tag.put("style", "display:none");
- }
-
- /**
- * Returns a content component. In case user haven't specified any content component, it returns
- * an empty WebMarkupContainer.
- *
- * @return Content component
- */
- protected final Component getContent()
- {
- return get(getContentId());
- }
-
- /**
- * Returns true if user has added own component to the window.
- *
- * @return True if user has added own component to the window, false otherwise.
- */
- protected boolean isCustomComponent()
- {
- return getContent() != empty;
- }
-
- /**
- * @see org.apache.wicket.MarkupContainer#remove(org.apache.wicket.Component)
- */
- @Override
- public ModalWindow remove(final Component component)
- {
- super.remove(component);
- if (component.getId().equals(getContentId()))
- {
- add(empty = new WebMarkupContainer(getContentId()));
- }
-
- return this;
- }
-
- /**
- * Sets the content of the modal window.
- *
- * @param component
- * @return this;
- */
- public ModalWindow setContent(final Component component)
- {
- if (component.getId().equals(getContentId()) == false)
- {
- throw new WicketRuntimeException("Modal window content id is wrong. Component ID:" +
- component.getId() + "; content ID: " + getContentId());
- }
- else if (component instanceof AbstractRepeater)
- {
- throw new WicketRuntimeException(
- "A repeater component cannot be used as the content of a modal window, please use repeater's parent");
- }
-
- component.setOutputMarkupPlaceholderTag(true);
- component.setVisible(false);
- replace(component);
- shown = false;
- pageCreator = null;
- return this;
- }
-
- /**
- * @author Matej Knopp
- */
- private class WindowClosedBehavior extends AbstractDefaultAjaxBehavior
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void respond(final AjaxRequestTarget target)
- {
- shown = false;
-
- if (windowClosedCallback != null)
- {
- windowClosedCallback.onClose(target);
- }
- }
- }
-
- /**
- * @author Matej Knopp
- */
- protected class CloseButtonBehavior extends AbstractDefaultAjaxBehavior
- {
- private static final long serialVersionUID = 1L;
-
- public CloseButtonBehavior()
- {
- }
-
- @Override
- protected final void respond(final AjaxRequestTarget target)
- {
- if ((closeButtonCallback == null) ||
- (closeButtonCallback.onCloseButtonClicked(target)))
- {
- close(target);
- }
- }
- }
-
- /**
- * Returns the markup id of the component.
- *
- * @return component id
- */
- private String getContentMarkupId()
- {
- return getContent().getMarkupId();
- }
-
- /**
- * Returns the javascript used to open the window. Subclass
- * {@link #postProcessSettings(JSONObject)} to modify the JavaScript if needed.
- *
- * See WICKET-12
- *
- * @return javascript that opens the window
- */
- protected final String getWindowOpenJavaScript()
- {
- JSONObject settings = new JSONObject();
-
- settings.put("minWidth", getMinimalWidth());
- settings.put("minHeight", getMinimalHeight());
- settings.put("className", getCssClassName());
- settings.put("width", getInitialWidth());
-
- if ((isUseInitialHeight() == true) || (isCustomComponent() == false))
- {
- settings.put("height", getInitialHeight());
- }
- else
- {
- // WICKET-6613 null would remove the key, so use false instead
- settings.put("height", false);
- }
-
- settings.put("resizable", isResizable());
-
- if (isResizable() == false)
- {
- settings.put("widthUnit", getWidthUnit());
- settings.put("heightUnit", getHeightUnit());
- }
-
- if (isCustomComponent() == false)
- {
- Page page = createPage();
- if (page == null)
- {
- throw new WicketRuntimeException("Error creating page for modal dialog.");
- }
- CharSequence pageUrl;
- RequestCycle requestCycle = RequestCycle.get();
-
- page.getSession().getPageManager().touchPage(page);
- if (page.isPageStateless())
- {
- pageUrl = requestCycle.urlFor(page.getClass(), page.getPageParameters());
- }
- else
- {
- IRequestHandler handler = new RenderPageRequestHandler(new PageProvider(page));
- pageUrl = requestCycle.urlFor(handler);
- }
-
- settings.put("src", pageUrl);
- }
- else
- {
- settings.put("element", new JSONFunction("document.getElementById(\"" + getContentMarkupId() + "\")"));
- }
-
- if (getCookieName() != null)
- {
- settings.put("cookieId", getCookieName());
- }
-
- String title = getTitle() != null ? getTitle().getObject() : null;
- if (title != null)
- {
- settings.put("title", getDefaultModelObjectAsString(title));
- }
-
- if (getMaskType() == MaskType.TRANSPARENT)
- {
- settings.put("mask", "transparent");
- }
- else if (getMaskType() == MaskType.SEMI_TRANSPARENT)
- {
- settings.put("mask", "semi-transparent");
- }
-
- settings.put("autoSize", autoSize);
-
- settings.put("unloadConfirmation", showUnloadConfirmation());
-
- // set true if we set a windowclosedcallback
- boolean haveCloseCallback = false;
-
- // in case user is interested in window close callback or we have a pagemap to clean attach
- // notification request
- if (windowClosedCallback != null)
- {
- WindowClosedBehavior behavior = getBehaviors(WindowClosedBehavior.class).get(0);
- settings.put("onClose", new JSONFunction("function() { " + behavior.getCallbackScript() + " }"));
-
- haveCloseCallback = true;
- }
-
- // in case we didn't set windowclosecallback, we need at least callback on close button, to
- // close window property (thus cleaning the shown flag)
- if ((closeButtonCallback != null) || (haveCloseCallback == false))
- {
- CloseButtonBehavior behavior = getBehaviors(CloseButtonBehavior.class).get(0);
- settings.put("onCloseButton", new JSONFunction("function() { " + behavior.getCallbackScript() + "; return false; }"));
- }
-
- postProcessSettings(settings);
-
- AppendingStringBuffer buffer = new AppendingStringBuffer(500);
- buffer.append("var settings = ");
- buffer.append(settings.toString());
- buffer.append(";");
-
- buffer.append(getShowJavaScript());
- return buffer.toString();
- }
-
- /**
- * Method that allows tweaking the settings
- *
- * @param settings
- */
- protected void postProcessSettings(JSONObject settings)
- {
- }
-
- /**
- * Detach the 'title' model
- *
- * @see org.apache.wicket.Component#onDetach()
- */
- @Override
- protected void onDetach()
- {
- super.onDetach();
-
- if (title != null)
- {
- title.detach();
- }
- }
-
- /**
- * Sets whether window size will be automatically adjusted on opening to fit content's width and
- * height. <span style="text-decoration: underline">Doesn't work on IE 6.</span>
- *
- * @param autoSize
- * Whether window size will be automatically adjusted
- * @return this
- */
- public ModalWindow setAutoSize(final boolean autoSize)
- {
- this.autoSize = autoSize;
- return this;
- }
-
- /**
- * Returns whether window will be opened in autosize mode.
- *
- * @return True if the window will be opened open in autosize mode, false otherwise
- */
- public boolean isAutoSize()
- {
- return autoSize;
- }
-
- /**
- * Gives the possibility to provide custom
- * {@link org.apache.wicket.ajax.attributes.IAjaxCallListener}
- *
- * @return the behavior that should be used for the window close button
- */
- protected CloseButtonBehavior newCloseButtonBehavior()
- {
- return new CloseButtonBehavior();
- }
-}
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-blue-1-alpha.png b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-blue-1-alpha.png
deleted file mode 100644
index 232dd2a..0000000
Binary files a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-blue-1-alpha.png and /dev/null differ
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-blue-1-ie.png b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-blue-1-ie.png
deleted file mode 100644
index 524d36f..0000000
Binary files a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-blue-1-ie.png and /dev/null differ
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-blue-2-alpha.png b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-blue-2-alpha.png
deleted file mode 100644
index 719f703..0000000
Binary files a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-blue-2-alpha.png and /dev/null differ
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-blue-2-ie.png b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-blue-2-ie.png
deleted file mode 100644
index 59f0c90..0000000
Binary files a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-blue-2-ie.png and /dev/null differ
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-gray-1-alpha.png b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-gray-1-alpha.png
deleted file mode 100644
index 940dc82..0000000
Binary files a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-gray-1-alpha.png and /dev/null differ
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-gray-1-ie.png b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-gray-1-ie.png
deleted file mode 100644
index e9fe8dd..0000000
Binary files a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-gray-1-ie.png and /dev/null differ
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-gray-2-alpha.png b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-gray-2-alpha.png
deleted file mode 100644
index 2b44b5a..0000000
Binary files a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-gray-2-alpha.png and /dev/null differ
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-gray-2-ie.png b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-gray-2-ie.png
deleted file mode 100644
index a599cd7..0000000
Binary files a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/frame-gray-2-ie.png and /dev/null differ
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.css b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.css
deleted file mode 100644
index 1389e1a..0000000
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.css
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * 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.
- */
-div.wicket-mask-dark {
- position: fixed;
- top: 0px;
- left: 0px;
- width: 100%;
- height: 100%;
- opacity: 0.1;
- background-color: black;
- filter: alpha(opacity=10);
- background-image: url('transparent2.png');
-}
-
-div.wicket-mask-transparent {
- position: fixed;
- top: 0px;
- left: 0px;
- width: 100%;
- height: 100%;
-
- background-image: url('transparent1.gif');
-}
-
-div.wicket-modal {
- position: fixed;
- _position: absolute;
- z-index: 20001;
- visibility: hidden;
-}
-
-
-div.wicket-modal div.w_top_1 {
- width: 100%;
- overflow: hidden;
-}
-
-div.wicket-modal div.w_top {
- height: 11px;
- background-position: 0px -16px;
- overflow: hidden;
- cursor:n-resize;
- padding: 0px; margin: 0px;
-}
-
-div.wicket-modal .w_topLeft {
-/*
- position: absolute;
- top: 0px;
- left: 0px;
- */
- width: 14px;
- height: 11px;
- float: left;
- background-position: 0px 0px;
- overflow: hidden;
- cursor: nw-resize;
-}
-
-div.wicket-modal div.w_topRight {
- /*
- position: absolute;
- top: 0px;
- right: 0px;
- */
- width: 14px;
- height: 11px;
- float: right;
- background-position: -16px 0px;
- overflow: hidden;
- cursor: ne-resize;
-}
-
-div.wicket-modal div.w_left {
- background-position: 0px 0px;
- background-repeat: repeat-y;
- cursor: w-resize;
- width: 100%;
-}
-
-div.wicket-modal div.w_right_1 {
- margin-left:10px;
-}
-
-div.wicket-modal div.w_right {
- background-position: right;
- background-repeat: repeat-y;
- cursor:e-resize;
- width: 100%;
-}
-
-div.wicket-modal div.w_content_1 {
- margin-right: 10px;
- cursor: auto;
-}
-
-
-div.wicket-modal div.w_caption {
- height: 1.4em;
- overflow: hidden;
- cursor: default;
- position: relative;
- background-color: white;
- cursor: default;
- line-height: 1.4em;
- color: #666;
-}
-
-div.wicket-modal a.w_close {
- height: 16px;
- width: 16px;
- overflow: hidden;
- background-position: -64px 0px;
- position: absolute;
- right: 3px;
- padding: 0px;
- margin: 0px;
-}
-
-div.wicket-modal a.w_close:hover {
- float: right;
- height: 16px;
- width: 16px;
- overflow: hidden;
- background-position: -80px 0px;
-
-}
-
-div.wicket-modal h3.w_captionText {
- height: 1.4em;
- position: absolute;
- margin-left: 3px;
- margin-bottom: 0px;
- margin-top: 0px;
- font-weight: bold;
- left: 0em;
-}
-
-div.wicket-modal div.w_content_2 {
- width: 100%;
- background-color: white;
- padding-top: 0.1em;
- _overflow: auto;
- cursor: default;
-}
-
-div.wicket-modal div.w_content_3 {
- border: 1px solid #bbb;
- padding: 0px;
-}
-
-div.wicket-modal div.w_content {
- width: 100%;
- background-color: white;
-}
-
-div.wicket-modal div.w_content_container {
- position: relative;
-}
-
-div.wicket-modal iframe.wicket_modal {
- width: 100%;
- height: 400px;
- padding: 0px;
- margin: 0px;
- border-width: 0px;
- position: relative;
-}
-
-div.wicket-modal div.w_bottom_1 {
- width: 100%;
- overflow: hidden;
- cursor: n-resize;
-}
-
-div.wicket-modal div.w_bottom {
- height: 15px;
- background-position: 0px -32px;
- overflow:hidden;
-
-}
-
-div.wicket-modal div.w_bottomRight {
- /*
- position: absolute;
- bottom: 0px;
- right: 0px;
- */
- width: 14px;
- height: 15px;
- float: right;
- background-position: -48px 0px;
- cursor: nw-resize;
- overflow: hidden;
-}
-
-
-
-div.wicket-modal div.w_bottomLeft {
- /*
- position: absolute;
- bottom: 0px;
- left: 0px;
- */
- width: 14px;
- height: 15px;
- float: left;
- background-position: -32px 0px;
- overflow: hidden;
- cursor: ne-resize;
-}
-
-
-div.wicket-modal div.w_blue div.w_left,
-div.wicket-modal div.w_blue div.w_right {
- background-image: url('frame-blue-2-alpha.png');
- _background-image: url('frame-blue-2-ie.png');
-}
-
-
-div.wicket-modal div.w_blue div.w_top,
-div.wicket-modal div.w_blue div.w_bottom,
-div.wicket-modal div.w_blue div.w_topLeft,
-div.wicket-modal div.w_blue div.w_topRight,
-div.wicket-modal div.w_blue div.w_bottomRight,
-div.wicket-modal div.w_blue div.w_bottomLeft,
-div.wicket-modal div.w_blue a.w_close {
- background-image: url('frame-blue-1-alpha.png');
- _background-image: url('frame-blue-1-ie.png');
-}
-
-
-div.wicket-modal div.w_silver div.w_left,
-div.wicket-modal div.w_silver div.w_right {
- background-image: url('frame-gray-2-alpha.png');
- _background-image: url('frame-gray-2-ie.png');
-}
-
-
-div.wicket-modal div.w_silver div.w_top,
-div.wicket-modal div.w_silver div.w_bottom,
-div.wicket-modal div.w_silver div.w_topLeft,
-div.wicket-modal div.w_silver div.w_topRight,
-div.wicket-modal div.w_silver div.w_bottomRight,
-div.wicket-modal div.w_silver div.w_bottomLeft,
-div.wicket-modal div.w_silver a.w_close {
- background-image: url('frame-gray-1-alpha.png');
- _background-image: url('frame-gray-1-ie.png');
-}
-
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.js b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.js
deleted file mode 100644
index 59431d0..0000000
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.js
+++ /dev/null
@@ -1,1594 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Javascript modal window
- * Licensed under the Apache License, Version 2.0
- * @author Matej Knopp
- */
-
-;(function (undefined) {
- 'use strict';
-
- /**
- * In case wicket-ajax.js is not yet loaded, create
- * Wicket namespace and Wicket.Class.create.
- */
- if (typeof(Wicket) === "undefined") {
- window.Wicket = {};
- }
-
- if (!Wicket.Class) {
- Wicket.Class = {
- create: function() {
- return function() {
- this.initialize.apply(this, arguments);
- };
- }
- };
- }
-
- if (!Wicket.Object) {
- Wicket.Object = { };
- }
-
- if (!Wicket.Object.extend) {
- Wicket.Object.extend = function(destination, source) {
- for (var property in source) {
- destination[property] = source[property];
- }
- return destination;
- };
- }
-
- /**
- * Draggable (and optionally resizable) window that can either hold a div
- * or an iframe.
- */
- Wicket.Window = Wicket.Class.create();
-
- /**
- * Creates a wicket window instance. The advantage of using this is
- * that in case an iframe modal window is opened in an already displayed
- * iframe modal window, the new window is created as a top-level window.
- *
- */
- Wicket.Window.create = function(settings) {
- var Win;
-
- // if it is an iframe window...
- if (typeof(settings.src) !== "undefined") {
- // attempt to get class from parent
- try {
- Win = window.parent.Wicket.Window;
- } catch (ignore) {}
- }
-
- // no parent...
- if (typeof(Win) === "undefined") {
- Win = Wicket.Window;
- }
-
- // create and return instance
- return new Win(settings);
- };
-
- /**
- * Returns the current top level window (null if none).
- */
- Wicket.Window.get = function() {
- var win = null;
-
- if (typeof(Wicket.Window.current) !== "undefined") {
- win = Wicket.Window.current;
- } else {
- try {
- win = window.parent.Wicket.Window.current;
- } catch (ignore) {}
- }
- return win;
- };
-
-
- /**
- * Closes the current open window. This method is supposed to
- * be called from inside the window (therefore it checks window.parent).
- */
- Wicket.Window.close = function() {
-
- var win;
- try {
- win = window.parent.Wicket.Window;
- } catch (ignore) {}
-
- if (win && win.current) {
- // we can't call close directly, because it will delete our window,
- // so we will schedule it as timeout for parent's window
- window.parent.setTimeout(function() {
- win.current.close();
- }, 0);
- }
- };
-
- Wicket.Window.prototype = {
-
- /**
- * Creates a new window instance.
- * Note:
- * Width refers to the width of entire window (including frame).
- * Height refers to the height of user content.
- *
- * @param {Object} settings - map that contains window settings. the default
- * values are below - together with description
- */
- initialize: function(settings) {
-
- // override default settings with user settings
- this.settings = Wicket.Object.extend({
-
- minWidth: 200, /* valid only if resizable */
- minHeight: 150, /* valid only if resizable */
-
- className: "w_blue", /* w_silver */
-
- width: 600, /* initial width */
- height: 300, /* may be null for non-iframe, non-resizable window (automatic height) */
-
- modalSpacing: 10, /* spacing between the modal and viewport border when modal is wider than viewport */
- headerHeight: 40,
-
- overflow: "auto",
-
- resizable: true,
-
- widthUnit: "px", /* valid only if not resizable */
- heightUnit: "px", /* valid only if not resizable */
-
- src: null, /* iframe src - this takes precedence over the "element" property */
- element: null, /* content element (for non-iframe window) */
-
- iframeName: null, /* name of the iframe */
-
- cookieId: null, /* id of position (and size if resizable) cookie */
-
- title: null, /* window title. if null and window content is iframe, title of iframe document will be used. */
-
- onCloseButton: Wicket.bind(function() {
- /* On firefox on Linux, at least, we need to blur() textfields, etc.
- * to get it to update its DOM model. Otherwise you'll lose any changes
- * made to the current form component you're editing.
- */
- this.caption.getElementsByTagName("a")[0].focus();
- this.caption.getElementsByTagName("a")[0].blur();
- this.close();
- return false;
- }, this), /* called when close button is clicked */
-
- afterInit: function() { },
-
- onClose: function() { }, /* called when window is closed */
-
- mask: "semi-transparent", /* or "transparent" */
-
- unloadConfirmation : true /* Display confirmation dialog if the user is about to leave a page (IE and FF) */
-
- }, settings || { });
-
- },
-
- /**
- * Returns true if the window is iframe-based.
- */
- isIframe: function() {
- return this.settings.src != null;
- },
-
- /**
- * Creates the DOM elements of the window.
- */
- createDOM: function() {
- var idWindow = this.newId();
- var idClassElement = this.newId();
- var idCaption = this.newId();
- var idFrame = this.newId();
- var idTop = this.newId();
- var idTopLeft = this.newId();
- var idTopRight = this.newId();
- var idLeft = this.newId();
- var idRight = this.newId();
- var idBottomLeft = this.newId();
- var idBottomRight = this.newId();
- var idBottom = this.newId();
- var idCaptionText = this.newId();
-
- var markup = Wicket.Window.getMarkup(idWindow, idClassElement, idCaption, idFrame,
- idTop, idTopLeft, idTopRight, idLeft, idRight, idBottomLeft, idBottomRight,
- idBottom, idCaptionText, this.isIframe());
-
- var element = document.createElement("div");
- element.id = idWindow;
- document.body.appendChild(element);
- Wicket.DOM.replace(element, markup);
-
- var _ = function(name) { return document.getElementById(name); };
-
- this.window = _(idWindow);
- this.classElement = _(idClassElement);
- this.caption = _(idCaption);
- this.content = _(idFrame);
- this.top = _(idTop);
- this.topLeft = _(idTopLeft);
- this.topRight = _(idTopRight);
- this.left = _(idLeft);
- this.right = _(idRight);
- this.bottomLeft = _(idBottomLeft);
- this.bottomRight = _(idBottomRight);
- this.bottom = _(idBottom);
- this.captionText = _(idCaptionText);
-
- // fix the cursors
- if (this.settings.resizable === false) {
- this.top.style.cursor = this.topLeft.style.cursor = this.topRight.style.cursor =
- this.bottom.style.cursor = this.bottomLeft.style.cursor = this.bottomRight.style.cursor =
- this.left.style.cursor = this.right.style.cursor = "default";
- }
- },
-
- /**
- * Creates the new unique id for window element.
- */
- newId: function() {
- return "_wicket_window_" + Wicket.Window.idCounter++;
- },
-
- /**
- * Binds the handler to the drag event on given element.
- */
- bind: function(element, handler) {
- Wicket.Drag.init(element, Wicket.bind(this.onBegin, this), Wicket.bind(this.onEnd, this), Wicket.bind(handler, this));
- },
-
- /**
- * Unbinds the handler from a drag event on given element.
- */
- unbind: function(element) {
- Wicket.Drag.clean(element);
- },
-
- /**
- * Binds the event handlers to the elements.
- */
- bindInit: function() {
- this.bind(this.caption, this.onMove);
-
- if (this.settings.resizable) {
- this.bind(this.bottomRight, this.onResizeBottomRight);
- this.bind(this.bottomLeft, this.onResizeBottomLeft);
- this.bind(this.bottom, this.onResizeBottom);
- this.bind(this.left, this.onResizeLeft);
- this.bind(this.right, this.onResizeRight);
- this.bind(this.topLeft, this.onResizeTopLeft);
- this.bind(this.topRight, this.onResizeTopRight);
- this.bind(this.top, this.onResizeTop);
- } else {
- this.bind(this.bottomRight, this.onMove);
- this.bind(this.bottomLeft, this.onMove);
- this.bind(this.bottom, this.onMove);
- this.bind(this.left, this.onMove);
- this.bind(this.right, this.onMove);
- this.bind(this.topLeft, this.onMove);
- this.bind(this.topRight, this.onMove);
- this.bind(this.top, this.onMove);
- }
-
- this.caption.getElementsByTagName("a")[0].onclick = Wicket.bind(this.settings.onCloseButton, this);
- },
-
- /**
- * Unbinds the event handlers.
- */
- bindClean: function() {
- this.unbind(this.caption);
- this.unbind(this.bottomRight);
- this.unbind(this.bottomLeft);
- this.unbind(this.bottom);
- this.unbind(this.left);
- this.unbind(this.right);
- this.unbind(this.topLeft);
- this.unbind(this.topRight);
- this.unbind(this.top);
-
- this.caption.getElementsByTagName("a")[0].onclick = null;
- },
-
- /**
- * Returns the content document
- */
- getContentDocument: function() {
- if (this.isIframe() === true) {
- return this.content.contentWindow.document;
- } else {
- return document;
- }
- },
-
- /**
- * Places the window to the center of the viewport.
- */
- center: function() {
- var scTop = 0;
- var scLeft = 0;
-
- var width = Wicket.Window.getViewportWidth();
- var height = Wicket.Window.getViewportHeight();
-
- var modalWidth = this.window.offsetWidth;
- var modalHeight = this.window.offsetHeight;
-
- if (modalWidth > width - this.settings.modalSpacing) {
- this.window.style.width = (width - this.settings.modalSpacing) + "px";
- modalWidth = this.window.offsetWidth;
- }
- if (modalHeight > height - this.settings.headerHeight) {
- this.content.style.height = (height - this.settings.headerHeight) + "px";
- modalHeight = this.window.offsetHeight;
- }
-
- var left = (width / 2) - (modalWidth / 2) + scLeft;
- var top = (height / 2) - (modalHeight / 2) + scTop;
- if (left < 0) {
- left = 0;
- }
- if (top < 0) {
- top = 0;
- }
-
- this.window.style.left = left + "px";
- this.window.style.top = top + "px";
- },
-
- cookieKey: "wicket-modal-window-positions",
- cookieExp: 31,
-
- findPositionString: function(remove) {
- var cookie = Wicket.Cookie.get(this.cookieKey);
-
- var entries = cookie != null ? cookie.split("|") : [];
-
- for (var i = 0; i < entries.length; ++i) {
- if (entries[i].indexOf(this.settings.cookieId + "::") === 0) {
- var string = entries[i];
- if (remove) {
- entries.splice(i, 1);
- Wicket.Cookie.set(this.cookieKey, entries.join("|"), this.cookieExp);
- }
- return string;
- }
- }
- return null;
- },
-
- /**
- * Saves the position (and size if resizable) as a cookie.
- */
- savePosition: function() {
- this.savePositionAs(this.window.style.left, this.window.style.top, this.window.style.width, this.content.style.height);
- },
-
- savePositionAs: function(x, y, width, height) {
- if (this.settings.cookieId) {
-
- this.findPositionString(true);
-
-// if (!cookie || cookie.length === 0) {
-// cookie = "";
-// } else {
-// cookie = cookie + "|";
-// }
- var cookie = this.settings.cookieId;
- cookie += "::";
-
- cookie += x + ",";
- cookie += y + ",";
- cookie += width + ",";
- cookie += height;
-
- var rest = Wicket.Cookie.get(this.cookieKey);
- if (rest != null) {
- cookie += "|" + rest;
- }
- Wicket.Cookie.set(this.cookieKey, cookie, this.cookieExp);
- }
- },
-
- /**
- * Restores the position (and size if resizable) from the cookie.
- */
- loadPosition: function() {
- if (this.settings.cookieId) {
-
- var string = this.findPositionString(false);
-
- if (string != null) {
- var array = string.split("::");
- var positions = array[1].split(",");
- if (positions.length === 4) {
- this.window.style.left = positions[0];
- this.window.style.top = positions[1];
- this.window.style.width = positions[2];
- this.content.style.height = positions[3];
- }
- }
- }
- },
-
- /**
- * Creates the mask accordingly to the settings.
- */
- createMask: function() {
- if (this.settings.mask === "transparent") {
- this.mask = new Wicket.Window.Mask(true);
- } else if (this.settings.mask === "semi-transparent") {
- this.mask = new Wicket.Window.Mask(false);
- }
- if (typeof(this.mask) !== "undefined") {
- this.mask.show();
- }
- },
-
- /**
- * Destroys the mask.
- */
- destroyMask: function() {
- this.mask.hide();
- this.mask = null;
- },
-
- /**
- * Loads the content
- */
- load: function() {
- if (!this.settings.title) {
- this.update = window.setInterval(Wicket.bind(this.updateTitle, this), 100);
- }
-
- this.content.contentWindow.name = this.settings.iframeName;
-
- try
- {
- this.content.contentWindow.location.replace(this.settings.src);
- }
- catch(ignore)
- {
- this.content.src = this.settings.src;
- }
- },
-
- /**
- * Shows the window.
- */
- show: function() {
-
- // create the DOM elements
- this.createDOM();
-
- // set the class of window (blue or silver by default)
- this.classElement.className = this.settings.className;
-
- // is it an iframe window?
- if (this.isIframe()) {
- // load the file
- this.load();
- } else {
- // it's an element content
-
- // is the element specified?
- if (this.settings.element == null) {
- throw "Either src or element must be set.";
- }
-
- // reparent the element
- this.oldParent = this.settings.element.parentNode;
- this.settings.element.parentNode.removeChild(this.settings.element);
- this.content.appendChild(this.settings.element);
-
- // set the overflow style so that scrollbars are shown when the element is bigger than window
- this.content.style.overflow = this.settings.overflow;
- }
-
- // bind the events
- this.bindInit();
-
- // if the title is specified set it
- if (this.settings.title != null) {
- this.captionText.innerHTML = this.settings.title;
- }
-
- // initial width and height
- this.window.style.width = this.settings.width + (this.settings.resizable ? "px" : this.settings.widthUnit);
-
- if (this.settings.height) {
- this.content.style.height = this.settings.height + (this.settings.resizable ? "px" : this.settings.heightUnit);
- }
-
- //if 'auto' flag was set to true call autoresize function
- if (this.settings.autoSize) {
- this.autoSizeWindow();
- }
-
- // center the window
- this.center();
-
- // load position from cookie
- this.loadPosition();
-
- var doShow = Wicket.bind(function() {
- this.adjustOpenWindowZIndexesOnShow();
- this.window.style.visibility="visible";
-
- }, this);
-
- this.adjustOpenWindowsStatusOnShow();
-
- doShow();
-
- // if the content supports focus and blur it, which means
- // that the already focused element will lose it's focus
- if (this.content.focus) {
- this.content.focus();
- this.content.blur();
- }
- // preserve old unload hanler
- this.old_onunload = window.onunload;
-
- // new unload handler - close the window to prevent memory leaks in ie
- window.onunload = Wicket.bind(function() {
- this.close(true);
- if (this.old_onunload) {
- return this.old_onunload();
- }
- }, this);
-
- if (this.settings.unloadConfirmation) {
- Wicket.Event.add(window, 'beforeunload',this.onbeforeunload);
- }
-
- // create the mask that covers the background
- this.createMask();
-
- this.settings.afterInit(this);
- },
-
- onbeforeunload: function() {
- return "Reloading this page will cause the modal window to disappear.";
- },
-
- adjustOpenWindowZIndexesOnShow: function() {
- // if there is a previous window
- if (this.oldWindow) {
- // lower it's z-index so that it's moved under the mask
- this.oldWindow.window.style.zIndex = Wicket.Window.Mask.zIndex - 1;
- }
- },
-
- adjustOpenWindowsStatusOnShow: function() {
- // is there a window displayed already?
- if (Wicket.Window.current) {
- // save the reference to it
- this.oldWindow = Wicket.Window.current;
- }
- // keep reference to this window
- Wicket.Window.current = this;
- },
-
- /**
- * Returns true if the window can be closed.
- */
- canClose: function() {
- return true;
- },
-
- /**
- * Prevent user from closing the window if there's another (nested) modal window in the iframe.
- */
- canCloseInternal: function() {
- try {
- if (this.isIframe() === true) {
- var current = this.content.contentWindow.Wicket.Window.current;
- if (current) {
- window.alert('You can\'t close this modal window. Close the top-level modal window first.');
- return false;
- }
- }
- } catch (ignore) {}
- return true;
- },
-
- /**
- * Closes the window.
- * @param {Boolean} force - internal argument
- */
- close: function(force) {
-
- // can user close the window?
- if (force !== true && (!this.canClose() || !this.canCloseInternal())) {
- return;
- }
-
- // if the update handler was set clean it
- if (typeof(this.update) !== "undefined") {
- window.clearInterval(this.update);
- }
-
- // clean event bindings
- this.bindClean();
-
- // hide elements
- this.window.style.display = "none";
-
- // if the window has a div content, the div is reparented to it's old parent
- if (typeof(this.oldParent) !== "undefined") {
- try {
- this.content.removeChild(this.settings.element);
- this.oldParent.appendChild(this.settings.element);
- this.oldParent = null;
- } catch (ignore) {}
- }
-
- // remove the elements from document
- this.window.parentNode.removeChild(this.window);
-
- // clean references to elements
- this.window = this.classElement = this.caption = this.bottomLeft = this.bottomRight = this.bottom =
- this.left = this.right = this.topLeft = this.topRight = this.top = this.captionText = null;
-
- // restore old unload handler
- window.onunload = this.old_onunload;
- this.old_onunload = null;
-
- Wicket.Event.remove(window, 'beforeunload',this.onbeforeunload);
-
- // hids and cleanup the mask
- this.destroyMask();
-
- if (force !== true) {
- // call onclose handler
- this.settings.onClose();
- }
-
- this.adjustOpenWindowsStatusAndZIndexesOnClose();
- },
-
- adjustOpenWindowsStatusAndZIndexesOnClose: function() {
- // if there was a window shown before this one
- if (this.oldWindow != null) {
- // set the old as current
- Wicket.Window.current = this.oldWindow;
- // increase it's z-index so that it's moved above the mask
- Wicket.Window.current.window.style.zIndex = Wicket.Window.Mask.zIndex + 1;
- this.oldWindow = null;
- } else {
- // remove reference to the window
- Wicket.Window.current = null;
- }
- },
-
- /**
- * Cleans the internal state of the window
- */
- destroy: function() {
- this.settings = null;
- },
-
- /**
- * If the window is Iframe, updates the title with iframe's document title.
- */
- updateTitle: function() {
- try {
- if (this.content.contentWindow.document.title) {
- if (this.captionText.innerHTML !== this.content.contentWindow.document.title) {
- this.captionText.innerHTML = this.content.contentWindow.document.title;
- }
- }
- } catch (ignore) {
- Wicket.Log.info(ignore);
- }
- },
-
- /**
- * Called when dragging has started.
- */
- onBegin: function(element, event) {
- // all resize elements must be clicked directly
- if (jQuery(element).is('.w_caption') === false && element !== event.target) {
- return false;
- }
-
- jQuery(this.window).find('iframe').css('pointer-events', 'none');
-
- return true;
- },
-
- /**
- * Called when dragging has ended.
- */
- onEnd: function(object) {
- jQuery(this.window).find('iframe').css('pointer-events', 'auto');
-
- if (this.content.style.visibility==='hidden') {
- this.content.style.visibility='hidden';
- window.setTimeout(Wicket.bind(function() { this.content.style.visibility='visible'; }, this), 0 );
- }
-
- this.savePosition();
- },
-
- /**
- * Called when window is moving (draggin the caption).
- */
- onMove: function(object, deltaX, deltaY) {
- var w = this.window;
- this.left_ = parseInt(w.style.left, 10) + deltaX;
- this.top_ = parseInt(w.style.top, 10) + deltaY;
-
- if (this.left_ < 0) {
- this.left_ = 0;
- }
-
- if (this.top_ < 0) {
- this.top_ = 0;
- }
-
- w.style.left = this.left_ + "px";
- w.style.top = this.top_ + "px";
-
- this.moving();
- },
-
- /**
- * Called when window is being moved
- */
- moving: function() {
- },
-
- /**
- * Called when window is resizing.
- */
- resizing: function() {
- },
-
- /**
- * Ensures that the size of window is not smaller than minimal size.
- */
- clipSize : function(swapX, swapY) {
- this.res = [0, 0];
-
- if (this.width < this.settings.minWidth) {
- this.left_ -= this.settings.minWidth - this.width;
- this.res[0] = this.settings.minWidth - this.width;
- this.width = this.settings.minWidth;
- }
-
- if (this.height < this.settings.minHeight) {
- this.top_ -= this.settings.minHeight - this.height;
- this.res[1] = this.settings.minHeight - this.height;
- this.height = this.settings.minHeight;
- }
-
- if (swapX === true) {
- this.res[0] = -this.res[0];
- }
- if (swapY === true) {
- this.res[1] = -this.res[1];
- }
- },
-
- //
- // These methods are handlers for parts of window frame
- //
-
- onResizeBottomRight: function(object, deltaX, deltaY) {
- var w = this.window;
- var f = this.content;
-
- this.width = parseInt(w.style.width, 10) + deltaX;
- this.height = parseInt(f.style.height, 10) + deltaY;
-
- this.clipSize();
-
- w.style.width = this.width + "px";
- f.style.height = this.height + "px";
-
- this.moving();
- this.resizing();
-
- return this.res;
- },
-
- onResizeBottomLeft: function(object, deltaX, deltaY) {
- var w = this.window;
- var f = this.content;
-
- this.width = parseInt(w.style.width, 10) - deltaX;
- this.height = parseInt(f.style.height, 10) + deltaY;
- this.left_ = parseInt(w.style.left, 10) + deltaX;
-
- this.clipSize(true);
-
- w.style.width = this.width + "px";
- w.style.left = this.left_ + "px";
- f.style.height = this.height + "px";
-
- this.moving();
- this.resizing();
-
- return this.res;
- },
-
- onResizeBottom: function(object, deltaX, deltaY) {
- var f = this.content;
- this.height = parseInt(f.style.height, 10) + deltaY;
-
- this.clipSize();
-
- f.style.height = this.height + "px";
-
- this.resizing();
-
- return this.res;
- },
-
- onResizeLeft: function(object, deltaX, deltaY) {
- var w = this.window;
-
- this.width = parseInt(w.style.width, 10) - deltaX;
- this.left_ = parseInt(w.style.left, 10) + deltaX;
-
- this.clipSize(true);
-
- w.style.width = this.width + "px";
- w.style.left = this.left_ + "px";
-
- this.moving();
- this.resizing();
-
- return this.res;
- },
-
- onResizeRight: function(object, deltaX, deltaY) {
- var w = this.window;
-
- this.width = parseInt(w.style.width, 10) + deltaX;
-
- this.clipSize();
-
- w.style.width = this.width + "px";
-
- this.resizing();
-
- return this.res;
- },
-
- onResizeTopLeft: function(object, deltaX, deltaY) {
- var w = this.window;
- var f = this.content;
-
- this.width = parseInt(w.style.width, 10) - deltaX;
- this.height = parseInt(f.style.height, 10) - deltaY;
- this.left_ = parseInt(w.style.left, 10) + deltaX;
- this.top_ = parseInt(w.style.top, 10) + deltaY;
-
- this.clipSize(true, true);
-
- w.style.width = this.width + "px";
- w.style.left = this.left_ + "px";
- f.style.height = this.height + "px";
- w.style.top = this.top_ + "px";
-
- this.moving();
- this.resizing();
-
- return this.res;
- },
-
- onResizeTopRight: function(object, deltaX, deltaY) {
- var w = this.window;
- var f = this.content;
-
- this.width = parseInt(w.style.width, 10) + deltaX;
- this.height = parseInt(f.style.height, 10) - deltaY;
- this.top_ = parseInt(w.style.top, 10) + deltaY;
-
- this.clipSize(false, true);
-
- w.style.width = this.width + "px";
- f.style.height = this.height + "px";
- w.style.top = this.top_ + "px";
-
- this.moving();
- this.resizing();
-
- return this.res;
- },
-
- onResizeTop: function(object, deltaX, deltaY) {
- var f = this.content;
- var w = this.window;
-
- this.height = parseInt(f.style.height, 10) - deltaY;
- this.top_ = parseInt(w.style.top, 10) + deltaY;
-
- this.clipSize(false, true);
-
- f.style.height = this.height + "px";
- w.style.top = this.top_ + "px";
-
- this.moving();
- this.resizing();
-
- return this.res;
- },
-
- /**
- * Resize windows in order to fit content's width and heigth
- */
- autoSizeWindow: function(){
- var targetWindow = this.window;
- var targetContent = this.content;
-
- targetContent.style.height = this.settings.minHeight +'px';
- targetWindow.style.width = this.settings.minWidth +'px';
-
- targetContent.style.overflow = 'hidden';
-
- var newHeight = targetContent.scrollHeight +'px';
- var newWidth = (targetContent.scrollWidth + targetWindow.clientWidth - targetContent.clientWidth) + 'px';
-
- targetContent.style.height = newHeight;
-
- targetWindow.style.width = newWidth;
-
- targetContent.style.overflow = this.settings.overflow;
- }
- };
-
- /**
- * Counter for generating unique component ids.
- */
- Wicket.Window.idCounter = 0;
-
- /**
- * Returns the modal window markup with specified element identifiers.
- */
- Wicket.Window.getMarkup = function(idWindow, idClassElement, idCaption, idContent, idTop, idTopLeft, idTopRight, idLeft, idRight, idBottomLeft, idBottomRight, idBottom, idCaptionText, isFrame) {
- var s =
- "<div class=\"wicket-modal\" id=\""+idWindow+"\" role=\"dialog\" aria-labelledby=\""+idCaptionText+"\" style=\"top: 10px; left: 10px; width: 100px;\"><form style='background-color:transparent;padding:0px;margin:0px;border-width:0px;position:static'>"+
- "<div id=\""+idClassElement+"\">"+
-
- "<div class=\"w_top_1\">"+
-
- "<div class=\"w_topLeft\" id=\""+idTopLeft+"\">"+
- "</div>"+
-
- "<div class=\"w_topRight\" id=\""+idTopRight+"\">"+
- "</div>"+
-
- "<div class=\"w_top\" id='"+idTop+"'>"+
- "</div>"+
-
- "</div>"+
-
- "<div class=\"w_left\" id='"+idLeft+"'>"+
- "<div class=\"w_right_1\">"+
- "<div class=\"w_right\" id='"+idRight+"'>"+
- "<div class=\"w_content_1\">"+
- "<div class=\"w_caption\" id=\""+idCaption+"\">"+
- "<a class=\"w_close\" style=\"z-index:1\" href=\"#\"></a>"+
- "<h3 id=\""+idCaptionText+"\" class=\"w_captionText\"></h3>"+
- "</div>"+
-
- "<div class=\"w_content_2\">"+
- "<div class=\"w_content_3\">"+
- "<div class=\"w_content\">";
- if (isFrame) {
- s+= "<iframe frameborder=\"0\" id=\""+idContent+"\" allowtransparency=\"false\" style=\"height: 200px\" class=\"wicket_modal\"></iframe>";
- } else {
- s+= "<div id='"+idContent+"' class='w_content_container'></div>";
- }
- s+=
- "</div>"+
- "</div>"+
- "</div>"+
- "</div>"+
- "</div>"+
- "</div>"+
- "</div>"+
-
-
- "<div class=\"w_bottom_1\" id=\""+idBottom+"_1\">"+
-
- "<div class=\"w_bottomRight\" id=\""+idBottomRight+"\">"+
- "</div>"+
-
- "<div class=\"w_bottomLeft\" id=\""+idBottomLeft+"\">"+
- "</div>"+
-
- "<div class=\"w_bottom\" id=\""+idBottom+"\">"+
- "</div>"+
-
-
- "</div>"+
-
- "</div>"+
- "</form></div>";
-
- return s;
- };
-
- /**
- * Transparent or semi-transparent masks that prevents user from interacting
- * with the portion of page behind a window.
- */
- Wicket.Window.Mask = Wicket.Class.create();
-
- Wicket.Window.Mask.zIndex = 20000;
-
- Wicket.Window.Mask.prototype = {
-
- /**
- * Creates the mask.
- * Created mask is not visible immediately. You have to call <code>show()</code> to
- * make it visible.
- * @param {boolean} transparent - whether the mask should be transparent (true) or
- * semi-transparent (false).
- */
- initialize: function(transparent) {
- this.transparent = transparent;
- },
-
- /**
- * Shows the mask.
- */
- show: function() {
-
- // if the mask is not already shown...
- if (!Wicket.Window.Mask.element) {
-
- // create the mask element and add it to the document
- var e = document.createElement("div");
- document.body.appendChild(e);
-
- // set the proper css class name
- if (this.transparent) {
- e.className = "wicket-mask-transparent";
- } else {
- e.className = "wicket-mask-dark";
- }
-
- e.style.zIndex = Wicket.Window.Mask.zIndex;
-
- // if the mask is not transparent we have to make the background-image invisible (setting it to null)
- if (this.transparent === false) {
- e.style.backgroundImage = "none";
- }
-
- // set the element
- this.element = e;
-
- // preserver old handlers
- this.old_onscroll = window.onscroll;
- this.old_onresize = window.onresize;
-
- // set new handlers
- window.onscroll = Wicket.bind(this.onScrollResize, this);
- window.onresize = Wicket.bind(this.onScrollResize, this);
-
- // fix the mask position
- this.onScrollResize(true);
-
- // set a static reference to mask
- Wicket.Window.Mask.element = e;
- } else {
- // mask is already shown - don't hide it
- this.dontHide = true;
- }
-
- this.shown=true;
- this.focusDisabled=false;
-
- this.disableCoveredContent();
- },
-
- /**
- * Hides the mask.
- */
- hide: function() {
-
- // cancel any pending tasks
- this.cancelPendingTasks();
-
- // if the mask is visible and we can hide it
- if (typeof(Wicket.Window.Mask.element) !== "undefined" && typeof(this.dontHide) === "undefined") {
-
- // remove element from document
- document.body.removeChild(this.element);
- this.element = null;
-
- // restore old handlers
- window.onscroll = this.old_onscroll;
- window.onresize = this.old_onresize;
-
- Wicket.Window.Mask.element = null;
- }
-
- this.shown=false;
-
- this.reenableCoveredContent();
- },
-
- // disable user interaction for content that is covered by the mask
- disableCoveredContent: function() {
- var doc = document;
- var old = Wicket.Window.current.oldWindow;
- if (old) {
- doc = old.getContentDocument();
- }
-
- this.doDisable(doc, Wicket.Window.current);
- },
-
- tasks: [],
- startTask: function (fn, delay) {
- var taskId=setTimeout(Wicket.bind(function() { fn(); this.clearTask(taskId); }, this), delay);
- this.tasks.push(taskId);
- },
- clearTask: function (taskId) {
- var index=-1;
- for (var i=0;i<this.tasks.length;i++) {
- if (this.tasks[i] === taskId) {
- index=i;break;
- }
- }
- if (index>=0) {
- this.tasks.splice(index,1);
- }
- },
- cancelPendingTasks: function() {
- while (this.tasks.length>0) {
- var taskId=this.tasks.shift();
- clearTimeout(taskId);
- }
- },
-
- // disable user interaction for content that is covered by the mask inside the given document, taking into consideration that this modal window is or not in an iframe
- // and has the given content
- doDisable: function(doc, win) {
- this.startTask(Wicket.bind(function() {this.hideSelectBoxes(doc, win);}, this), 300);
- this.startTask(Wicket.bind(function() {this.disableTabs(doc, win);}, this), 400);
- this.startTask(Wicket.bind(function() {this.disableFocus(doc, win);}, this), 1000);
- },
-
- // reenable user interaction for content that was covered by the mask
- reenableCoveredContent: function() {
- // show old select boxes (ie only)
- this.showSelectBoxes();
-
- // restore tab order
- this.restoreTabs();
-
- // revert onfocus handlers
- this.enableFocus();
- },
-
- /**
- * Used to update the position (ie) and size (ie, opera) of the mask.
- */
- onScrollResize: function(dontChangePosition) {
- // if the iframe is not position:fixed fix it's position
- if (this.element.style.position === "absolute") {
-
- var w = Wicket.Window.getViewportWidth();
- var h = Wicket.Window.getViewportHeight();
-
- var scTop = 0;
- var scLeft = 0;
-
- scLeft = Wicket.Window.getScrollX();
- scTop = Wicket.Window.getScrollY();
-
- this.element.style.top = scTop + "px";
- this.element.style.left = scLeft + "px";
-
- if (document.all) { // opera or explorer
- this.element.style.width = w;
- }
- this.element.style.height = h;
- }
- },
-
- /**
- * Returns true if 'element' is a child (anywhere in hierarchy) of 'parent'
- */
- isParent: function(element, parent) {
- if (element.parentNode === parent) {
- return true;
- }
- if (typeof(element.parentNode) === "undefined" || element.parentNode === document.body) {
- return false;
- }
- return this.isParent(element.parentNode, parent);
- },
-
- /**
- * For internet explorer hides the select boxes (because they
- * have always bigger z-order than any other elements).
- */
- hideSelectBoxes : function(doc, win) {
- if (!this.shown) {
- return;
- }
- },
-
- /**
- * Shows the select boxes if they were hidden.
- */
- showSelectBoxes: function() {
- if (typeof (this.boxes) !== "undefined") {
- for (var i = 0; i < this.boxes.length; ++i) {
- var element = this.boxes[i];
- element.style.visibility="visible";
- }
- this.boxes = null;
- }
- },
-
- /**
- * Disable focus on element and all it's children.
- */
- disableFocusElement: function(element, revertList, win) {
-
- if (win && win.window !== element) {
-
- revertList.push([element, element.onfocus]);
- element.onfocus = function() { element.blur(); };
-
- for (var i = 0; i < element.childNodes.length; ++i) {
- this.disableFocusElement(element.childNodes[i], revertList, win);
- }
- }
- },
-
- /**
- * Disable focus on all elements in document
- */
- disableFocus: function(doc, win) {
- if (!this.shown) {
- return;
- }
-
- this.focusRevertList = [];
- var body = doc.getElementsByTagName("body")[0];
- for (var i = 0; i < body.childNodes.length; ++i) {
- this.disableFocusElement(body.childNodes[i], this.focusRevertList, win);
- }
-
- this.focusDisabled=true;
- },
-
- /**
- * Enables focus on all elements where the focus has been disabled.
- */
- enableFocus: function() {
- if (this.focusDisabled === false) {
- return;
- }
-
- if (typeof(this.focusRevertList) !== "undefined") {
- for (var i = 0; i < this.focusRevertList.length; ++i) {
- var item = this.focusRevertList[i];
- item[0].onfocus = item[1];
- }
- }
- this.focusRevertList = null;
- },
-
- /**
- * Disable tab indexes (ie).
- */
- disableTabs: function (doc, win) {
- if (!this.shown) {
- return;
- }
-
- if (typeof (this.tabbableTags) === "undefined") {
- this.tabbableTags = ["A", "BUTTON", "TEXTAREA", "INPUT", "IFRAME", "SELECT"];
- }
- },
-
- /**
- * Restore tab indexes if they were disabled.
- */
- restoreTabs: function() {
- if (typeof (this.disabledTabsRevertList) !== "undefined" && this.disabledTabsRevertList !== null) {
- for (var i = 0; i < this.disabledTabsRevertList.length; ++i) {
- var element = this.disabledTabsRevertList[i];
- if (typeof(element.hiddenTabIndex) !== 'undefined') {
- element.tabIndex = element.hiddenTabIndex;
- try {
- delete element.hiddenTabIndex;
- } catch (e) {
- element.hiddenTabIndex = undefined;
- }
- }
- }
- this.disabledTabsRevertList = null;
- }
- }
- };
-
- /**
- * Returns the height of visible area.
- */
- Wicket.Window.getViewportHeight = function() {
- if (typeof(window.innerHeight) !== "undefined") {
- return window.innerHeight;
- }
-
- if (document.compatMode === 'CSS1Compat') {
- return document.documentElement.clientHeight;
- }
-
- if (document.body) {
- return document.body.clientHeight;
- }
-
- return undefined;
- };
-
- /**
- * Returns the width of visible area.
- */
- Wicket.Window.getViewportWidth = function() {
- if (typeof(window.innerWidth) !== "undefined") {
- return window.innerWidth;
- }
-
- if (document.compatMode === 'CSS1Compat') {
- return document.documentElement.clientWidth;
- }
-
- if (document.body) {
- return document.body.clientWidth;
- }
-
- return undefined;
- };
-
- /**
- * Returns the horizontal scroll offset
- */
- Wicket.Window.getScrollX = function() {
- var iebody = (document.compatMode && document.compatMode !== "BackCompat") ? document.documentElement : document.body;
- return document.all? iebody.scrollLeft : window.pageXOffset;
- };
-
- /**
- * Returns the vertical scroll offset
- */
- Wicket.Window.getScrollY = function() {
- var iebody = (document.compatMode && document.compatMode !== "BackCompat") ? document.documentElement : document.body;
- return document.all? iebody.scrollTop : window.pageYOffset;
- };
-
- /**
- * Convenience methods for getting and setting cookie values.
- */
- Wicket.Cookie = {
-
- /**
- * Returns the value for cookie of given name.
- * @param {String} name - name of cookie
- */
- get: function(name) {
- if (document.cookie.length > 0) {
- var start = document.cookie.indexOf (name + "=");
- if (start !== -1) {
- start = start + name.length + 1;
- var end = document.cookie.indexOf(";", start);
- if (end === -1) {
- end = document.cookie.length;
- }
- return window.unescape(document.cookie.substring(start,end));
- }
- } else {
- return null;
- }
- },
-
- /**
- * Sets the value for cookie of given name.
- * @param {Object} name - name of cookie
- * @param {Object} value - new value
- * @param {Object} expiredays - how long will the cookie be persisted
- */
- set: function(name, value, expiredays) {
- var exdate = new Date();
- exdate.setDate(exdate.getDate() + expiredays);
- var secure = /^https/.test(location.protocol) ? ';secure' : '';
- document.cookie = name + "=" + window.escape(value) +
- ((expiredays === null) ? "" : ";expires="+exdate) +
- secure;
- }
- };
-
- /**
- * Flexible dragging support.
- */
- Wicket.Drag = {
-
- /**
- * Initializes dragging on the specified element.
- *
- * @param element {Element}
- * element clicking on which
- * the drag should begin
- * @param onDragBegin {Function}
- * called at the begin of dragging - passed element and event as parameters,
- * may return false to prevent the start
- * @param onDragEnd {Function}
- * handler called at the end of dragging - passed element as parameter
- * @param onDrag {Function}
- * handler called during dragging - passed element and mouse deltas as parameters
- */
- init: function(element, onDragBegin, onDragEnd, onDrag) {
-
- if (typeof(onDragBegin) === "undefined") {
- onDragBegin = jQuery.noop;
- }
-
- if (typeof(onDragEnd) === "undefined") {
- onDragEnd = jQuery.noop;
- }
-
- if (typeof(onDrag) === "undefined") {
- onDrag = jQuery.noop;
- }
-
- element.wicketOnDragBegin = onDragBegin;
- element.wicketOnDrag = onDrag;
- element.wicketOnDragEnd = onDragEnd;
-
-
- // set the mousedown handler
- Wicket.Event.add(element, "mousedown", Wicket.Drag.mouseDownHandler);
- },
-
- mouseDownHandler: function (e) {
- e = Wicket.Event.fix(e);
-
- var element = this;
-
- if (element.wicketOnDragBegin(element, e) === false) {
- return;
- }
-
- if (e.preventDefault) {
- e.preventDefault();
- }
-
- element.lastMouseX = e.clientX;
- element.lastMouseY = e.clientY;
-
- element.old_onmousemove = document.onmousemove;
- element.old_onmouseup = document.onmouseup;
- element.old_onselectstart = document.onselectstart;
- element.old_onmouseout = document.onmouseout;
-
- document.onselectstart = function () {
- return false;
- };
- document.onmousemove = Wicket.Drag.mouseMove;
- document.onmouseup = Wicket.Drag.mouseUp;
- document.onmouseout = Wicket.Drag.mouseOut;
-
- Wicket.Drag.current = element;
- },
-
- /**
- * Deinitializes the dragging support on given element.
- */
- clean: function (element) {
- element.onmousedown = null;
- },
-
- /**
- * Called when mouse is moved. This method fires the onDrag event
- * with element instance, deltaX and deltaY (the distance
- * between this call and the previous one).
-
- * The onDrag handler can optionally return an array of two integers
- * - the delta correction. This is used, for example, if there is
- * element being resized and the size limit has been reached (but the
- * mouse can still move).
- *
- * @param {Event} e
- */
- mouseMove: function (e) {
- e = Wicket.Event.fix(e);
- var o = Wicket.Drag.current;
-
- // this happens sometimes in Safari
- if (e.clientX < 0 || e.clientY < 0) {
- return;
- }
-
- if (o !== null) {
- var deltaX = e.clientX - o.lastMouseX;
- var deltaY = e.clientY - o.lastMouseY;
-
- var res = o.wicketOnDrag(o, deltaX, deltaY, e);
-
- if (res !== "undefined") {
- res = [0, 0];
- }
-
- o.lastMouseX = e.clientX + res[0];
- o.lastMouseY = e.clientY + res[1];
- }
-
- return false;
- },
-
- /**
- * Called when the mouse button is released.
- * Cleans all temporary variables and callback methods.
- */
- mouseUp: function () {
- var o = Wicket.Drag.current;
-
- if (o) {
- o.wicketOnDragEnd(o);
-
- o.lastMouseX = null;
- o.lastMouseY = null;
-
- document.onmousemove = o.old_onmousemove;
- document.onmouseup = o.old_onmouseup;
- document.onselectstart = o.old_onselectstart;
-
- document.onmouseout = o.old_onmouseout;
-
- o.old_mousemove = null;
- o.old_mouseup = null;
- o.old_onselectstart = null;
- o.old_onmouseout = null;
-
- Wicket.Drag.current = null;
- }
- },
-
- /**
- * Called when mouse leaves an element. We need this for firefox, as otherwise
- * the dragging would continue after mouse leaves the document.
- * Unfortunately this break dragging in firefox immediately after the mouse leaves
- * page.
- */
- mouseOut: function (e) {
- }
- };
-
-})();
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/transparent1.gif b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/transparent1.gif
deleted file mode 100644
index 4df36a3..0000000
Binary files a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/transparent1.gif and /dev/null differ
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/transparent2.png b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/transparent2.png
deleted file mode 100644
index c0e5d70..0000000
Binary files a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/transparent2.png and /dev/null differ
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/select/SelectOptions.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/select/SelectOptions.java
index 18d08c1..5f1d7a4 100644
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/select/SelectOptions.java
+++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/select/SelectOptions.java
@@ -20,7 +20,6 @@ import java.util.Collection;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.MarkupStream;
-import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.parser.XmlTag.TagType;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;
@@ -34,15 +33,6 @@ import org.slf4j.LoggerFactory;
* Component that makes it easy to produce a list of SelectOption components.
* <p>
* Has to be attached to a <option> markup tag.
- * <p>
- * Note: The following pre Wicket 9 markup is deprecated and results in a log warning. Its support
- * will be removed in Wicket 10:
- *
- * <pre>
- * <code>
- * <wicket:container wicket:id="selectOptions"><option wicket:id="option"></option></wicket:container>
- * </code>
- * </pre>
*
* @param <T>
* type of elements contained in the model's collection
@@ -120,47 +110,19 @@ public class SelectOptions<T> extends RepeatingView
Collection<? extends T> modelObject = (Collection<? extends T>)getDefaultModelObject();
if (modelObject != null)
{
- // TODO remove in Wicket 10
- boolean option = "option".equalsIgnoreCase(getMarkupTag().getName());
- if (option == false)
- {
- log.warn("Since version 9.0.0 you should use an option tag");
- }
-
for (T value : modelObject)
{
// we add our actual SelectOption component to the row
String text = renderer.getDisplayValue(value);
IModel<T> model = renderer.getModel(value);
- if (option)
- {
- add(newOption(newChildId(), text, model));
- }
- else
- {
- // pre Wicket 9 a container is used to represent a row in repeater
- WebMarkupContainer row = new WebMarkupContainer(newChildId());
- row.setRenderBodyOnly(true);
- add(row);
-
- // we add our actual SelectOption component to the row
- row.add(newOption(text, model));
- }
+ add(newOption(newChildId(), text, model));
}
}
}
}
/**
- * @deprecated override {@link #newOption(String, String, IModel)} instead.
- */
- protected SelectOption<T> newOption(final String text, final IModel<T> model)
- {
- return newOption("option", text, model);
- }
-
- /**
* Factory method for creating a new <code>SelectOption</code>. Override to add your own
* extensions, such as Ajax behaviors.
*
diff --git a/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/WebSocketAwareCsrfPreventionRequestCycleListener.java b/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/WebSocketAwareCsrfPreventionRequestCycleListener.java
deleted file mode 100644
index ed7a1d0..0000000
--- a/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/WebSocketAwareCsrfPreventionRequestCycleListener.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.protocol.ws;
-
-import org.apache.wicket.protocol.http.CsrfPreventionRequestCycleListener;
-import org.apache.wicket.protocol.ws.api.WebSocketMessageBroadcastHandler;
-import org.apache.wicket.protocol.ws.api.WebSocketRequestHandler;
-import org.apache.wicket.request.IRequestHandler;
-
-/**
- * A specialization of {@link CsrfPreventionRequestCycleListener} that should be used when
- * the application uses Web Sockets.
- *
- * <p>The HTTP upgrade request brings <em>Origin</em> in its headers, but any Web socket frame doesn't
- * bring it so {@link WebSocketRequestHandler} and {@link WebSocketMessageBroadcastHandler}
- * should be ignored.</p>
- *
- * @deprecated Use {@link WebSocketAwareResourceIsolationRequestCycleListener} instead
- */
-@Deprecated(since = "9.3.0")
-public class WebSocketAwareCsrfPreventionRequestCycleListener extends CsrfPreventionRequestCycleListener
-{
- @Override
- protected boolean isChecked(IRequestHandler handler)
- {
- if (handler instanceof WebSocketRequestHandler || handler instanceof WebSocketMessageBroadcastHandler) {
- return false;
- }
- return super.isChecked(handler);
- }
-}
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/collections/MicroMap.java b/wicket-util/src/main/java/org/apache/wicket/util/collections/MicroMap.java
deleted file mode 100644
index f18c664..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/collections/MicroMap.java
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
- * 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.util.collections;
-
-import java.io.Serializable;
-import java.util.AbstractList;
-import java.util.AbstractSet;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-/**
- * An implementation of the java.util.Map interface which can only hold a single object. This is
- * particularly useful to control memory usage in Wicket because many containers hold only a single
- * component.
- *
- * @author Jonathan Locke
- * @param <K>
- * Key type
- * @param <V>
- * Value type
- *
- * @deprecated Please use {@link Map#of(Object, Object)} instead
- */
-@Deprecated(forRemoval = true, since = "9.0.0")
-public final class MicroMap<K, V> implements Map<K, V>, Serializable
-{
- private static final long serialVersionUID = 1L;
-
- /** The maximum number of entries this map supports. */
- public static final int MAX_ENTRIES = 1;
-
- /** The one and only key in this tiny map */
- private K key;
-
- /** The value for the only key in this tiny map */
- private V value;
-
- /**
- * Constructor
- */
- public MicroMap()
- {
- }
-
- /**
- * Constructs map with a single key and value pair.
- *
- * @param key
- * The key
- * @param value
- * The value
- */
- public MicroMap(final K key, final V value)
- {
- put(key, value);
- }
-
- /**
- * @return True if this MicroMap is full
- */
- public boolean isFull()
- {
- return size() == MAX_ENTRIES;
- }
-
- /**
- * @see java.util.Map#size()
- */
- @Override
- public int size()
- {
- return (key != null) ? 1 : 0;
- }
-
- /**
- * @see java.util.Map#isEmpty()
- */
- @Override
- public boolean isEmpty()
- {
- return size() == 0;
- }
-
- /**
- * @see java.util.Map#containsKey(java.lang.Object)
- */
- @Override
- public boolean containsKey(final Object key)
- {
- return key.equals(this.key);
- }
-
- /**
- * @see java.util.Map#containsValue(java.lang.Object)
- */
- @Override
- public boolean containsValue(final Object value)
- {
- return value.equals(this.value);
- }
-
- /**
- * @see java.util.Map#get(java.lang.Object)
- */
- @Override
- public V get(final Object key)
- {
- if (key.equals(this.key))
- {
- return value;
- }
-
- return null;
- }
-
- /**
- * @see java.util.Map#put(java.lang.Object, java.lang.Object)
- */
- @Override
- public V put(final K key, final V value)
- {
- // Replace?
- if (key.equals(this.key))
- {
- final V oldValue = this.value;
-
- this.value = value;
-
- return oldValue;
- }
- else
- {
- // Is there room for a new entry?
- if (size() < MAX_ENTRIES)
- {
- // Store
- this.key = key;
- this.value = value;
-
- return null;
- }
- else
- {
- throw new IllegalStateException("Map full");
- }
- }
- }
-
- /**
- * @see java.util.Map#remove(java.lang.Object)
- */
- @Override
- public V remove(final Object key)
- {
- if (key.equals(this.key))
- {
- final V oldValue = value;
-
- this.key = null;
- value = null;
-
- return oldValue;
- }
-
- return null;
- }
-
- /**
- * @see java.util.Map#putAll(java.util.Map)
- */
- @Override
- public void putAll(final Map<? extends K, ? extends V> map)
- {
- if (map.size() <= MAX_ENTRIES)
- {
- final Entry<? extends K, ? extends V> e = map.entrySet().iterator().next();
-
- put(e.getKey(), e.getValue());
- }
- else
- {
- throw new IllegalStateException("Map full. Cannot add " + map.size() + " entries");
- }
- }
-
- /**
- * @see java.util.Map#clear()
- */
- @Override
- public void clear()
- {
- key = null;
- value = null;
- }
-
- /**
- * @see java.util.Map#keySet()
- */
- @Override
- public Set<K> keySet()
- {
- return new AbstractSet<K>()
- {
- @Override
- public Iterator<K> iterator()
- {
- return new Iterator<K>()
- {
- @Override
- public boolean hasNext()
- {
- return index < MicroMap.this.size();
- }
-
- @Override
- public K next()
- {
- if (!hasNext())
- {
- throw new NoSuchElementException();
- }
- index++;
-
- return key;
- }
-
- @Override
- public void remove()
- {
- MicroMap.this.clear();
- }
-
- int index;
- };
- }
-
- @Override
- public int size()
- {
- return MicroMap.this.size();
- }
- };
- }
-
- /**
- * @see java.util.Map#values()
- */
- @Override
- public Collection<V> values()
- {
- return new AbstractList<V>()
- {
- @Override
- public V get(final int index)
- {
- if (index > size() - 1)
- {
- throw new IndexOutOfBoundsException();
- }
- return value;
- }
-
- @Override
- public int size()
- {
- return MicroMap.this.size();
- }
- };
- }
-
- /**
- * @see java.util.Map#entrySet()
- */
- @Override
- public Set<Entry<K, V>> entrySet()
- {
- return new AbstractSet<Entry<K, V>>()
- {
- @Override
- public Iterator<Entry<K, V>> iterator()
- {
- return new Iterator<Entry<K, V>>()
- {
- @Override
- public boolean hasNext()
- {
- return index < MicroMap.this.size();
- }
-
- @Override
- public Entry<K, V> next()
- {
- if (!hasNext())
- {
- throw new NoSuchElementException();
- }
- index++;
-
- return new Map.Entry<K, V>()
- {
- @Override
- public K getKey()
- {
- return key;
- }
-
- @Override
- public V getValue()
- {
- return value;
- }
-
- @Override
- public V setValue(final V value)
- {
- final V oldValue = MicroMap.this.value;
-
- MicroMap.this.value = value;
-
- return oldValue;
- }
- };
- }
-
- @Override
- public void remove()
- {
- clear();
- }
-
- int index = 0;
- };
- }
-
- @Override
- public int size()
- {
- return MicroMap.this.size();
- }
- };
- }
-}
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/crypt/AbstractCrypt.java b/wicket-util/src/main/java/org/apache/wicket/util/crypt/AbstractCrypt.java
index da8155e..c68f124 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/crypt/AbstractCrypt.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/crypt/AbstractCrypt.java
@@ -118,7 +118,6 @@ public abstract class AbstractCrypt implements ICrypt
* @param key
* private key to make de-/encryption unique
*/
- @Override
public void setKey(final String key)
{
encryptionKey = key;
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/crypt/CachingSunJceCryptFactory.java b/wicket-util/src/main/java/org/apache/wicket/util/crypt/CachingSunJceCryptFactory.java
deleted file mode 100644
index 8edf89e..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/crypt/CachingSunJceCryptFactory.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.util.crypt;
-
-/**
- * Default crypt factory. This factory will instantiate a {@link SunJceCrypt} once and cache it for
- * all further invocations of {@link #newCrypt()}.
- *
- * @author Igor Vaynberg (ivaynberg)
- *
- * @deprecated use a lambda expression instead TODO remove in Wicket 10
- */
-public class CachingSunJceCryptFactory extends CryptFactoryCachingDecorator
-{
- /**
- * Construct.
- *
- * @param encryptionKey
- * encryption key
- */
- public CachingSunJceCryptFactory(final String encryptionKey)
- {
- super(new ClassCryptFactory(SunJceCrypt.class, encryptionKey));
- }
-}
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/crypt/ClassCryptFactory.java b/wicket-util/src/main/java/org/apache/wicket/util/crypt/ClassCryptFactory.java
deleted file mode 100644
index e74d758..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/crypt/ClassCryptFactory.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.util.crypt;
-
-import java.lang.ref.WeakReference;
-
-import org.apache.wicket.util.lang.Args;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- * Crypt factory that creates the {@link ICrypt} object by instantiating a provided class. The class
- * must implement {@link ICrypt}.
- *
- * @author Igor Vaynberg (ivaynberg)
- *
- * @deprecated use a lambda expression instead TODO remove in Wicket 10
- */
-public class ClassCryptFactory implements ICryptFactory
-{
- private static final Logger log = LoggerFactory.getLogger(ClassCryptFactory.class);
-
- private final WeakReference<Class<?>> cryptClass;
- private final String encryptionKey;
-
- /**
- * Construct.
- *
- * @param cryptClass
- * class that will be instantiated to represent the ICrypt object
- * @param encryptionKey
- * encryption key
- */
- public ClassCryptFactory(final Class<?> cryptClass, final String encryptionKey)
- {
- Args.notNull(cryptClass, "cryptClass");
-
- if (!ICrypt.class.isAssignableFrom(cryptClass))
- {
- throw new IllegalArgumentException("cryptClass must implement ICrypt interface");
- }
-
- this.cryptClass = new WeakReference<Class<?>>(cryptClass);
- this.encryptionKey = encryptionKey;
- }
-
- @Override
- public ICrypt newCrypt()
- {
- try
- {
- ICrypt crypt = (ICrypt)(cryptClass.get()).getDeclaredConstructor().newInstance();
- log.info("using encryption/decryption object {}", crypt);
- crypt.setKey(encryptionKey);
- return crypt;
- }
- catch (Exception e)
- {
- log.warn("************************** WARNING **************************");
- log.warn("As the instantiation of encryption/decryption class:");
- log.warn("\t" + cryptClass);
- log.warn("failed, Wicket will fallback on a dummy implementation");
- log.warn("\t(" + NoCrypt.class.getName() + ")");
- log.warn("This is NOT recommended for production systems.");
- log.warn("Please override method org.apache.wicket.util.crypt.ICryptFactory.newCrypt()");
- log.warn("to provide a custom encryption/decryption implementation.");
- log.warn("The cause of the instantiation failure: ");
- log.warn("\t" + e.getMessage());
- if (log.isDebugEnabled())
- {
- log.debug("exception: ", e);
- }
- else
- {
- log.warn("Set log level to DEBUG to display the stack trace.");
- }
- log.warn("*************************************************************");
-
- // assign the dummy crypt implementation
- return new NoCrypt();
- }
- }
-}
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/crypt/ICrypt.java b/wicket-util/src/main/java/org/apache/wicket/util/crypt/ICrypt.java
index cb90a04..079d257 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/crypt/ICrypt.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/crypt/ICrypt.java
@@ -54,17 +54,4 @@ public interface ICrypt
* @since 1.2
*/
String encryptUrlSafe(final String plainText);
-
- /**
- * Sets private encryption key. It depends on the implementation if a default key is applied or
- * an exception is thrown, if no private key has been provided.
- *
- * @param key
- * private key
- *
- *
- * @deprecated TODO remove in Wicket 10
- */
- @Deprecated(forRemoval = true)
- void setKey(final String key);
}
\ No newline at end of file
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/crypt/NoCrypt.java b/wicket-util/src/main/java/org/apache/wicket/util/crypt/NoCrypt.java
index be16986..1e7a800 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/crypt/NoCrypt.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/crypt/NoCrypt.java
@@ -59,15 +59,4 @@ public class NoCrypt implements ICrypt
{
return plainText;
}
-
- /**
- * Set encryption private key
- *
- * @param key
- * private key to make de-/encryption unique
- */
- @Override
- public void setKey(final String key)
- {
- }
}
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java b/wicket-util/src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java
index 09dce34..f4cf621 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/crypt/SunJceCrypt.java
@@ -42,23 +42,9 @@ import org.apache.wicket.util.lang.Args;
*/
public class SunJceCrypt extends AbstractCrypt
{
- /**
- * Iteration count used in combination with the salt to create the encryption key.
- */
- private final static int DEFAULT_ITERATION_COUNT = 17;
-
/** Name of the default encryption method */
public static final String DEFAULT_CRYPT_METHOD = "PBEWithMD5AndDES";
- /**
- * Default salt.
- *
- * @deprecated TODO remove in Wicket 10
- */
- @Deprecated
- public final static byte[] SALT = { (byte)0x15, (byte)0x8c, (byte)0xa3, (byte)0x4a,
- (byte)0x66, (byte)0x51, (byte)0x2a, (byte)0xbc };
-
/** The name of encryption method (cipher) */
private final String cryptMethod;
@@ -67,17 +53,6 @@ public class SunJceCrypt extends AbstractCrypt
private final byte[] salt;
/**
- * Constructor
- *
- * @deprecated TODO remove in Wicket 10
- */
- @Deprecated(forRemoval = true)
- public SunJceCrypt()
- {
- this(DEFAULT_CRYPT_METHOD);
- }
-
- /**
* Constructor.
*
* @param salt
@@ -91,17 +66,6 @@ public class SunJceCrypt extends AbstractCrypt
}
/**
- * Constructor
- *
- * @deprecated TODO remove in Wicket 10
- */
- @Deprecated(forRemoval = true)
- public SunJceCrypt(String cryptMethod)
- {
- this(cryptMethod, SALT, DEFAULT_ITERATION_COUNT);
- }
-
- /**
* Constructor that uses a custom encryption method (cipher).
* You may need to override {@link #createKeySpec()} and/or
* {@link #createParameterSpec()} for the custom cipher.
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/time/AbstractTime.java b/wicket-util/src/main/java/org/apache/wicket/util/time/AbstractTime.java
deleted file mode 100755
index 063d7fe..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/time/AbstractTime.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * 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.util.time;
-
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Locale;
-
-/**
- * Abstract base class for subclasses that represent a point in time (as opposed to a
- * {@link Duration} of time).
- *
- * @author Jonathan Locke
- * @since 1.2.6
- *
- * @deprecated Since Wicket 9 this class is obsolete and no more used. It will be removed in Wicket 10
- */
-@Deprecated
-abstract class AbstractTime extends AbstractTimeValue
-{
- private static final long serialVersionUID = 1L;
-
- /** calendar for the local time zone */
- static final Calendar localtime = Calendar.getInstance();
-
- /** time format */
- static final SimpleDateFormat timeFormat = new SimpleDateFormat("h.mma", Locale.ENGLISH);
-
- /**
- * @param milliseconds
- * @see AbstractTimeValue
- */
- AbstractTime(final long milliseconds)
- {
- super(milliseconds);
- }
-
- /**
- * Returns <code>true</code> if this <code>Time</code> value is after the given
- * <code>Time</code> argument's value.
- *
- * @param that
- * the <code>AbstractTimeValue</code> to compare with
- * @return <code>true</code> if this <code>Time</code> value is after <code>that</code>
- * <code>Time</code> value
- */
- public final boolean after(final AbstractTimeValue that)
- {
- return greaterThan(that);
- }
-
- /**
- * Returns <code>true</code> if this <code>Time</code> value is before the given
- * <code>Time</code> argument's value.
- *
- * @param that
- * the <code>AbstractTimeValue</code> to compare with
- * @return <code>true</code> if this <code>Time</code> value is before <code>that</code>
- * <code>Time</code> value
- */
- public final boolean before(final AbstractTimeValue that)
- {
- return lessThan(that);
- }
-
- /**
- * Converts this <code>Time</code> to a time <code>String</code> using the formatter 'h.mma'.
- *
- * @return the <code>Time</code> <code>String</code>
- */
- public final String toTimeString()
- {
- return toTimeString(localtime);
- }
-
- /**
- * Converts this <code>Time</code> to a <code>Date String</code> using the <code>Date</code>
- * formatter 'h.mma'.
- *
- * @param calendar
- * the <code>Calendar</code> to use in the conversion
- * @return the <code>Date</code> <code>String</code>
- */
- public final String toTimeString(final Calendar calendar)
- {
- synchronized (timeFormat)
- {
- synchronized (calendar)
- {
- timeFormat.setCalendar(calendar);
- return timeFormat.format(new Date(getMilliseconds())).toLowerCase(Locale.ROOT);
- }
- }
- }
-
- /**
- * Converts this <code>Time</code> to a <code>String</code> suitable for use in a file system
- * name.
- *
- * @return this <code>Time</code> as a formatted <code>String</code>
- */
- @Override
- public String toString()
- {
- return toTimeString();
- }
-}
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/time/AbstractTimeValue.java b/wicket-util/src/main/java/org/apache/wicket/util/time/AbstractTimeValue.java
deleted file mode 100755
index 7173812..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/time/AbstractTimeValue.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.util.time;
-
-import org.apache.wicket.util.value.LongValue;
-
-/**
- * Package local class for representing immutable time values in milliseconds and typical operations
- * on such values.
- *
- * @author Jonathan Locke
- * @since 1.2.6
- *
- * @deprecated Since Wicket 9 this class is obsolete and no more used. It will be removed in Wicket 10
- */
-@Deprecated
-abstract class AbstractTimeValue extends LongValue
-{
- private static final long serialVersionUID = 1L;
-
- /**
- * Package local constructor for package subclasses only.
- *
- * @param milliseconds
- * the number of milliseconds in this <code>Time</code> value
- */
- AbstractTimeValue(final long milliseconds)
- {
- super(milliseconds);
- }
-
- /**
- * Retrieves the number of milliseconds in this <code>Time</code> value.
- *
- * @return the number of milliseconds in this <code>Time</code> value
- */
- public final long getMilliseconds()
- {
- return value;
- }
-}
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/time/Duration.java b/wicket-util/src/main/java/org/apache/wicket/util/time/Duration.java
deleted file mode 100755
index 3af16f3..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/time/Duration.java
+++ /dev/null
@@ -1,565 +0,0 @@
-/*
- * 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.util.time;
-
-import java.util.Locale;
-import java.util.Locale.Category;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.apache.wicket.util.string.StringValue;
-import org.apache.wicket.util.string.StringValueConversionException;
-import org.apache.wicket.util.thread.ICode;
-import org.slf4j.Logger;
-
-
-/**
- * A <code>Duration</code> is an immutable length of time stored as a number of milliseconds.
- * Various factory and conversion methods are available for convenience.
- * <p>
- * These static factory methods allow easy construction of value objects using either long values
- * like <code>seconds(2034)</code> or <code>hours(3)</code>:
- * <p>
- * <ul>
- * <li><code>Duration.milliseconds(long)</code>
- * <li><code>Duration.seconds(int)</code>
- * <li><code>Duration.minutes(int)</code>
- * <li><code>Duration.hours(int)</code>
- * <li><code>Duration.days(int)</code>
- * </ul>
- * <p>
- * ...or double-precision floating point values like <code>days(3.2)</code>:
- * <p>
- * <ul>
- * <li><code>Duration.milliseconds(double)</code>
- * <li><code>Duration.seconds(double)</code>
- * <li><code>Duration.minutes(double)</code>
- * <li><code>Duration.hours(double)</code>
- * <li><code>Duration.days(double)</code>
- * </ul>
- * <p>
- * In the case of <code>milliseconds(double)</code>, the value will be rounded off to the nearest
- * integral millisecond using <code>Math.round()</code>.
- * <p>
- * The precise number of milliseconds represented by a <code>Duration</code> object can be retrieved
- * by calling the <code>getMilliseconds</code> method. The value of a <code>Duration</code> object
- * in a given unit like days or hours can be retrieved by calling one of the following unit methods,
- * each of which returns a double-precision floating point number:
- * <p>
- * <ul>
- * <li><code>seconds()</code>
- * <li><code>minutes()</code>
- * <li><code>hours()</code>
- * <li><code>days()</code>
- * </ul>
- * <p>
- * Values can be added and subtracted using the <code>add(Duration)</code> and
- * <code>subtract(Duration)</code> methods, each of which returns a new immutable
- * <code>Duration</code> object.
- * <p>
- * <code>String</code> values can be converted to <code>Duration</code> objects using the static
- * <code>valueOf</code> factory methods. The <code>String</code> format is the opposite of the one
- * created by <code>toString()</code>, which converts a <code>Duration</code> object to a readable
- * form, such as "3.2 hours" or "32.5 minutes". Valid units are: milliseconds, seconds, minutes
- * hours and days. Correct English plural forms are used in creating <code>String</code> values and
- * are parsed as well. The <code>Locale</code> is respected and "," will be used instead of "." in
- * the Eurozone.
- * <p>
- * The benchmark method will "benchmark" a <code>Runnable</code> or an {@link ICode} implementing
- * object, returning a <code>Duration</code> object that represents the amount of time elapsed in
- * running the code.
- * <p>
- * Finally, the <code>sleep</code> method will sleep for the value of a <code>Duration</code>.
- *
- * @author Jonathan Locke
- * @since 1.2.6
- *
- * @deprecated Since Wicket 9 this class is obsolete and no more used. It will be removed in Wicket 10. Use {@link java.time.Duration} instead
- */
-@Deprecated
-public class Duration extends AbstractTimeValue
-{
- private static final long serialVersionUID = 1L;
-
- /** Constant for maximum duration. */
- public static final Duration MAXIMUM = milliseconds(Long.MAX_VALUE);
-
- /** Constant for no duration. */
- public static final Duration NONE = milliseconds(0);
-
- /** Constant for one day. */
- public static final Duration ONE_DAY = days(1);
-
- /** Constant for one hour. */
- public static final Duration ONE_HOUR = hours(1);
-
- /** Constant for on minute. */
- public static final Duration ONE_MINUTE = minutes(1);
-
- /** Constant for one second. */
- public static final Duration ONE_SECOND = seconds(1);
-
- /** Constant for one week. */
- public static final Duration ONE_WEEK = days(7);
-
- /** pattern to match strings */
- private static final Pattern pattern = Pattern.compile(
- "([0-9]+([.,][0-9]+)?)\\s+(millisecond|second|minute|hour|day)s?", Pattern.CASE_INSENSITIVE);
-
- /**
- * Benchmark the given command.
- *
- * @param code
- * an <code>ICode</code>
- * @param log
- * optional logger to use with errors and exceptions
- * @return the <code>Time</code> value it took to run the code
- */
- public static Duration benchmark(final ICode code, final Logger log)
- {
- // Get time before running code
- final Time start = Time.now();
-
- // Run the code
- code.run(log);
-
- // Return the difference
- return Time.now().subtract(start);
- }
-
- /**
- * Benchmark the given command.
- *
- * @param code
- * a <code>Runnable</code>
- * @return the <code>Time</code> value it took to run the code
- */
- public static Duration benchmark(final Runnable code)
- {
- // Get time before running code
- final Time start = Time.now();
-
- // Run code
- code.run();
-
- // Return the difference
- return Time.now().subtract(start);
- }
-
- /**
- * Retrieves the <code>Duration</code> based on days.
- *
- * @param days
- * days <code>double</code> value
- * @return the <code>Duration</code> based on days
- */
- public static Duration days(final double days)
- {
- return hours(24.0 * days);
- }
-
- /**
- * Retrieves the <code>Duration</code> based on days.
- *
- * @param days
- * days <code>int</code> value
- * @return the <code>Duration</code> based on days
- */
- public static Duration days(final int days)
- {
- return hours(24 * days);
- }
-
- /**
- * Calculates the amount of time elapsed since start time.
- *
- * @param start
- * the start <code>Time</code>
- * @return the elapsed period as a <code>Duration</code>
- * @throws IllegalStateException
- * if start <code>Time</code> is in the future
- */
- public static Duration elapsed(final Time start)
- {
- return start.elapsedSince();
- }
-
- /**
- * Retrieves the <code>Duration</code> based on hours.
- *
- * @param hours
- * hours <code>double</code> value
- * @return the <code>Duration</code> based on hours
- */
- public static Duration hours(final double hours)
- {
- return minutes(60.0 * hours);
- }
-
- /**
- * Retrieves the <code>Duration</code> based on hours.
- *
- * @param hours
- * hours <code>int</code> value
- * @return the <code>Duration</code> based on hours
- */
- public static Duration hours(final int hours)
- {
- return minutes(60 * hours);
- }
-
- /**
- * Retrieves the <code>Duration</code> based on milliseconds.
- *
- * @param milliseconds
- * milliseconds <code>double</code> value
- * @return the <code>Duration</code> based on milliseconds
- */
- public static Duration milliseconds(final double milliseconds)
- {
- return milliseconds(Math.round(milliseconds));
- }
-
- /**
- * Retrieves the <code>Duration</code> based on milliseconds.
- *
- * @param milliseconds
- * milliseconds <code>long</code> value
- * @return the <code>Duration</code> based on milliseconds
- */
- public static Duration milliseconds(final long milliseconds)
- {
- return new Duration(milliseconds);
- }
-
- /**
- * Retrieves the <code>Duration</code> based on minutes.
- *
- * @param minutes
- * minutes <code>double</code> value
- * @return the <code>Duration</code> based on minutes
- */
- public static Duration minutes(final double minutes)
- {
- return seconds(60.0 * minutes);
- }
-
- /**
- * Retrieves the <code>Duration</code> based on minutes.
- *
- * @param minutes
- * minutes <code>int</code> value
- * @return the <code>Duration</code> based on minutes
- */
- public static Duration minutes(final int minutes)
- {
- return seconds(60 * minutes);
- }
-
- /**
- * Retrieves the <code>Duration</code> based on seconds.
- *
- * @param seconds
- * seconds <code>double</code> value
- * @return the <code>Duration</code> based on seconds
- */
- public static Duration seconds(final double seconds)
- {
- return milliseconds(seconds * 1000.0);
- }
-
- /**
- * Retrieves the <code>Duration</code> based on seconds.
- *
- * @param seconds
- * seconds <code>int</code> value
- * @return the <code>Duration</code> based on seconds
- */
- public static Duration seconds(final int seconds)
- {
- return milliseconds(seconds * 1000L);
- }
-
- /**
- * Retrieves the given <code>long</code> as a <code>Duration</code>.
- *
- * @param time
- * the duration <code>long</code> value in milliseconds
- * @return the <code>Duration</code> value
- */
- public static Duration valueOf(final long time)
- {
- return new Duration(time);
- }
-
- /**
- * Converts the given <code>String</code> to a new <code>Duration</code> object. The string can
- * take the form of a floating point number followed by a number of milliseconds, seconds,
- * minutes, hours or days. For example "6 hours" or "3.4 days". Parsing is case-insensitive.
- *
- * @param string
- * a <code>String</code> to parse
- * @return the <code>Duration</code> value of the given <code>String</code>
- * @throws StringValueConversionException
- */
- public static Duration valueOf(final String string) throws StringValueConversionException
- {
- return valueOf(string, Locale.getDefault(Locale.Category.FORMAT));
- }
-
- /**
- * Converts the given <code>String</code> to a new <code>Duration</code> object. The string can
- * take the form of a floating point number followed by a number of milliseconds, seconds,
- * minutes, hours or days. For example "6 hours" or "3.4 days". Parsing is case-insensitive.
- *
- * @param string
- * a <code>String</code> to parse
- * @param locale
- * the <code>Locale</code> used for parsing
- * @return the <code>Duration</code> value of the given <code>String</code>
- * @throws StringValueConversionException
- */
- public static Duration valueOf(final String string, final Locale locale)
- throws StringValueConversionException
- {
- final Matcher matcher = pattern.matcher(string);
-
- if (matcher.matches())
- {
- final double value = StringValue.valueOf(matcher.group(1), locale).toDouble();
- final String units = matcher.group(3);
-
- if (units.equalsIgnoreCase("millisecond"))
- {
- return milliseconds(value);
- }
- else if (units.equalsIgnoreCase("second"))
- {
- return seconds(value);
- }
- else if (units.equalsIgnoreCase("minute"))
- {
- return minutes(value);
- }
- else if (units.equalsIgnoreCase("hour"))
- {
- return hours(value);
- }
- else if (units.equalsIgnoreCase("day"))
- {
- return days(value);
- }
- else
- {
- throw new StringValueConversionException("Unrecognized units: " + string);
- }
- }
- else
- {
- throw new StringValueConversionException("Unable to parse duration: " + string);
- }
- }
-
- /**
- * Private constructor forces use of static factory methods.
- *
- * @param milliseconds
- * number of milliseconds in this <code>Duration</code>
- */
- protected Duration(final long milliseconds)
- {
- super(milliseconds);
- }
-
- /**
- * Adds a given <code>Duration</code> to this <code>Duration</code>.
- *
- * @param duration
- * the <code>Duration</code> to add
- * @return the sum of the <code>Duration</code>s
- */
- public Duration add(final Duration duration)
- {
- return valueOf(getMilliseconds() + duration.getMilliseconds());
- }
-
- /**
- * Retrieves the number of days of the current <code>Duration</code>.
- *
- * @return number of days of the current <code>Duration</code>
- */
- public final double days()
- {
- return hours() / 24.0;
- }
-
- /**
- * Retrieves the number of hours of the current <code>Duration</code>.
- *
- * @return number of hours of the current <code>Duration</code>
- */
- public final double hours()
- {
- return minutes() / 60.0;
- }
-
- /**
- * Retrieves the number of minutes of the current <code>Duration</code>.
- *
- * @return number of minutes of the current <code>Duration</code>
- */
- public final double minutes()
- {
- return seconds() / 60.0;
- }
-
- /**
- * Retrieves the number of seconds of the current <code>Duration</code>.
- *
- * @return number of seconds of the current <code>Duration</code>
- */
- public final double seconds()
- {
- return getMilliseconds() / 1000.0;
- }
-
- /**
- * Sleeps for the current <code>Duration</code>.
- */
- public final void sleep()
- {
- if (getMilliseconds() > 0)
- {
- try
- {
- Thread.sleep(getMilliseconds());
- }
- catch (InterruptedException e)
- {
- // Ignored
- }
- }
- }
-
- /**
- * Subtracts a given <code>Duration</code> from this <code>Duration</code>.
- *
- * @param that
- * the <code>Duration</code> to subtract
- * @return this <code>Duration</code> minus that <code>Duration</code>
- */
- public Duration subtract(final Duration that)
- {
- return valueOf(getMilliseconds() - that.getMilliseconds());
- }
-
- /**
- * Wait for this duration on the given monitor
- *
- * @param object
- * The monitor to wait on
- */
- public void wait(final Object object)
- {
- try
- {
- object.wait(getMilliseconds());
- }
- catch (InterruptedException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Retrieves the <code>String</code> representation of this <code>Duration</code> in days,
- * hours, minutes, seconds or milliseconds, as appropriate. Uses the default <code>Locale</code>
- * .
- *
- * @return a <code>String</code> representation
- */
- @Override
- public String toString()
- {
- return toString(Locale.getDefault(Category.FORMAT));
- }
-
- /**
- * Retrieves the <code>String</code> representation of this <code>Duration</code> in days,
- * hours, minutes, seconds or milliseconds, as appropriate.
- *
- * @param locale
- * a <code>Locale</code>
- * @return a <code>String</code> representation
- */
- public String toString(final Locale locale)
- {
- if (getMilliseconds() >= 0)
- {
- if (days() >= 1.0)
- {
- return unitString(days(), "day", locale);
- }
-
- if (hours() >= 1.0)
- {
- return unitString(hours(), "hour", locale);
- }
-
- if (minutes() >= 1.0)
- {
- return unitString(minutes(), "minute", locale);
- }
-
- if (seconds() >= 1.0)
- {
- return unitString(seconds(), "second", locale);
- }
-
- return unitString(getMilliseconds(), "millisecond", locale);
- }
- else
- {
- return "N/A";
- }
- }
-
- /**
- * Builds a {@link java.time.Duration} out of a wicket {@link Duration}.
- *
- * @return returns a {@link java.time.Duration}
- */
- public java.time.Duration toJavaDuration()
- {
- return java.time.Duration.ofMillis(getMilliseconds());
- }
-
- /**
- * Converts a value to a unit-suffixed value, taking care of English singular/plural suffix.
- *
- * @param value
- * a <code>double</code> value to format
- * @param units
- * the units to apply singular or plural suffix to
- * @param locale
- * the <code>Locale</code>
- * @return a <code>String</code> representation
- */
- private String unitString(final double value, final String units, final Locale locale)
- {
- return StringValue.valueOf(value, locale) + " " + units + ((value > 1.0) ? "s" : "");
- }
-}
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/time/ITimeFrameSource.java b/wicket-util/src/main/java/org/apache/wicket/util/time/ITimeFrameSource.java
deleted file mode 100755
index 72b9e60..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/time/ITimeFrameSource.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.util.time;
-
-import java.io.Serializable;
-
-/**
- * An <code>ITimeFrameSource</code> produces <code>TimeFrame</code> values. The value returned by an
- * <code>ITimeFrameSource</code> source may vary over time.
- *
- * @see TimeFrame
- *
- * @author Jonathan Locke
- * @since 1.2.6
- *
- * @deprecated Since Wicket 9 this class is obsolete and no more used. It will be removed in Wicket 10
- */
-@Deprecated
-public interface ITimeFrameSource extends Serializable
-{
- /**
- * Retrieves the current <code>TimeFrame</code> value.
- *
- * @return the current <code>TimeFrame</code> value
- */
- TimeFrame getTimeFrame();
-}
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/time/Time.java b/wicket-util/src/main/java/org/apache/wicket/util/time/Time.java
deleted file mode 100755
index 5124fad..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/time/Time.java
+++ /dev/null
@@ -1,615 +0,0 @@
-/*
- * 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.util.time;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Locale;
-import java.util.TimeZone;
-
-/**
- * An immutable <code>Time</code> class that represents a specific point in time. The underlying
- * representation is a <code>long</code> value which holds a number of milliseconds since January 1,
- * 1970, 0:00 GMT. To represent a duration of time, such as "6 seconds", use the
- * <code>Duration</code> class. To represent a time period with a start and end time, use the
- * <code>TimeFrame</code> class. To represent a time of day, use the <code>TimeOfDay</code> class.
- *
- * @author Jonathan Locke
- * @since 1.2.6
- *
- * @deprecated Since Wicket 9 this class is obsolete and no more used. It will be removed in Wicket 10. Use {@link java.time.Instant} instead
- */
-@Deprecated
-public final class Time extends AbstractTime
-{
- private static final long serialVersionUID = 1L;
-
- /** the beginning of UNIX time: January 1, 1970, 0:00 GMT. */
- public static final Time START_OF_UNIX_TIME = millis(0);
-
- /** parser in 'yyyy.MM.dd' format. */
- private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd",
- Locale.ENGLISH);
-
- /** parser in 'yyyy.MM.dd-h.mma' format. */
- private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy.MM.dd-h.mma",
- Locale.ENGLISH);
-
- /** required for rfc1123 date format */
- private static final String[] DAYS =
- {"Sat", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
-
- /** required for rfc1123 date format */
- private static final String[] MONTHS =
- {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Jan"};
-
- /** time zone for greenwich mean time */
- public static final TimeZone GMT = TimeZone.getTimeZone("GMT");
-
- /**
- * Retrieves a <code>Time</code> instance based on the current time.
- *
- * @return the current <code>Time</code>
- */
- public static Time now()
- {
- return millis(System.currentTimeMillis());
- }
-
- /**
- * Retrieves a <code>Time</code> instance based on the given milliseconds.
- *
- * @param time
- * the <code>Time</code> value in milliseconds since START_OF_UNIX_TIME
- * @return a corresponding immutable <code>Time</code> object
- */
- public static Time millis(final long time)
- {
- return new Time(time);
- }
-
- /**
- * Retrieves a <code>Time</code> instance by parsing 'yyyy.MM.dd' format.
- *
- * @param calendar
- * the <code>Calendar</code> to use when parsing date <code>String</code>
- * @param string
- * the <code>String</code> to parse
- * @return the time
- * @throws ParseException
- */
- public static Time parseDate(final Calendar calendar, final String string)
- throws ParseException
- {
- synchronized (dateFormat)
- {
- synchronized (calendar)
- {
- dateFormat.setCalendar(calendar);
-
- return valueOf(dateFormat.parse(string));
- }
- }
- }
-
- /**
- * Retrieves a <code>Time</code> instance by parsing 'yyyy.MM.dd' format using a local time
- * <code>Calendar</code>.
- *
- * @param string
- * the <code>String</code> to parse
- * @return the time
- * @throws ParseException
- */
- public static Time parseDate(final String string) throws ParseException
- {
- return parseDate(localtime, string);
- }
-
- /**
- * Retrieves a <code>Time</code> instance by parsing 'yyyy.MM.dd-h.mma' format.
- *
- * @param calendar
- * the <code>Calendar</code> to use when parsing the <code>String</code>
- * @param string
- * the <code>String</code> to parse
- * @return an immutable UNIX <code>Time</code> value
- * @throws ParseException
- */
- public static Time valueOf(final Calendar calendar, final String string) throws ParseException
- {
- synchronized (dateTimeFormat)
- {
- synchronized (calendar)
- {
- dateTimeFormat.setCalendar(calendar);
-
- return valueOf(dateTimeFormat.parse(string));
- }
- }
- }
-
- /**
- * Retrieves a <code>Time</code> instance based on the given <code>Calendar</code> and
- * {@link TimeOfDay} objects.
- *
- * @param calendar
- * the <code>Calendar</code> to use
- * @param timeOfDay
- * the time of day
- * @return a <code>Time</code> value for the time of day today
- */
- public static Time valueOf(final Calendar calendar, final TimeOfDay timeOfDay)
- {
- synchronized (calendar)
- {
- // Set time to midnight today
- calendar.setTimeInMillis(System.currentTimeMillis());
- calendar.set(Calendar.HOUR_OF_DAY, 0); // WICKET-2349
- calendar.set(Calendar.MINUTE, 0);
- calendar.set(Calendar.SECOND, 0);
- calendar.set(Calendar.MILLISECOND, 0); // WICKET-1670
-
- // Add time of day milliseconds to midnight
- return millis(calendar.getTimeInMillis() + timeOfDay.getMilliseconds());
- }
- }
-
- /**
- * Retrieves a <code>Time</code> instance based on the given <code>Date</code> object.
- *
- * @param date
- * a <code>java.util.Date</code> object
- * @return a corresponding immutable <code>Time</code> object
- */
- public static Time valueOf(final Date date)
- {
- return new Time(date.getTime());
- }
-
- /**
- * Retrieves a <code>Time</code> instance by parsing 'yyyy.MM.dd-h.mma' format.
- *
- * @param string
- * the <code>String</code> to parse
- * @return the <code>Time</code> instance
- * @throws ParseException
- */
- public static Time valueOf(final String string) throws ParseException
- {
- return valueOf(localtime, string);
- }
-
- /**
- * Retrieves a <code>Time</code> instance by parsing 'pattern' format.
- *
- * @param string
- * input
- * @param pattern
- * the pattern to parse
- * @return a <code>Time</code> instance that resulted from parsing the given <code>String</code>
- * @throws ParseException
- */
- public static Time valueOf(final String string, final String pattern) throws ParseException
- {
- final SimpleDateFormat dateTimeFormat = new SimpleDateFormat(pattern, Locale.ENGLISH);
- dateTimeFormat.setCalendar(localtime);
- return valueOf(dateTimeFormat.parse(string));
- }
-
- /**
- * Retrieves a <code>Time</code> instance based on the given {@link TimeOfDay} object.
- *
- * @param timeOfDay
- * the time of day in local time
- * @return a <code>Time</code> value for the time of day today
- */
- public static Time valueOf(final TimeOfDay timeOfDay)
- {
- return valueOf(localtime, timeOfDay);
- }
-
- /**
- * Private constructor forces use of static factory methods.
- *
- * @param time
- * the <code>Time</code> value in milliseconds since START_OF_UNIX_TIME
- */
- private Time(final long time)
- {
- super(time);
- }
-
- /**
- * Adds the given <code>Duration</code> to this <code>Time</code> object, moving the time into
- * the future.
- *
- * @param duration
- * the <code>Duration</code> to add
- * @return this <code>Time</code> + <code>Duration</code>
- */
- public Time add(final Duration duration)
- {
- return millis(getMilliseconds() + duration.getMilliseconds());
- }
-
- /**
- * Calculates the amount of time that has elapsed since this <code>Time</code> value.
- *
- * @return the amount of time that has elapsed since this <code>Time</code> value
- * @throws IllegalStateException
- * thrown if this <code>Time</code> value is in the future
- */
- public Duration elapsedSince()
- {
- final Time now = now();
- if (this.greaterThan(now))
- {
- throw new IllegalStateException("This time is in the future");
- }
- return now.subtract(this);
- }
-
- /**
- * Retrieves the <code>Duration</code> from now to this <code>Time</code> value. If this
- * <code>Time</code> value is in the past, then the <code>Duration</code> returned will be
- * negative. Otherwise, it will be the number of milliseconds from now to this <code>Time</code>
- * .
- *
- * @return the <code>Duration</code> from now to this <code>Time</code> value
- */
- public Duration fromNow()
- {
- return subtract(now());
- }
-
- /**
- * Retrieves the value of a field from the given <code>Calendar</code>.
- *
- * @param calendar
- * the <code>Calendar</code> to use
- * @param field
- * the <code>Calendar</code> field to get
- * @return the field's value for this point in time on the given <code>Calendar</code>
- */
- public int get(final Calendar calendar, final int field)
- {
- synchronized (calendar)
- {
- calendar.setTimeInMillis(getMilliseconds());
-
- return calendar.get(field);
- }
- }
-
- /**
- * Retrieves the value of a field.
- *
- * @param field
- * the <code>Calendar</code> field to get
- * @return the field's value (in local time)
- */
- public int get(final int field)
- {
- return get(localtime, field);
- }
-
- /**
- * Retrieves the day of month field of the current <code>Calendar</code>.
- *
- * @return the day of month field value
- */
- public int getDayOfMonth()
- {
- return getDayOfMonth(localtime);
- }
-
- /**
- * Retrieves the day of month field of the given <code>Calendar</code>.
- *
- * @param calendar
- * the <code>Calendar</code> to get the field value from
- * @return the day of month field value
- */
- public int getDayOfMonth(final Calendar calendar)
- {
- return get(calendar, Calendar.DAY_OF_MONTH);
- }
-
- /**
- * Retrieves the hour field of the current <code>Calendar</code>.
- *
- * @return the hour field value
- */
- public int getHour()
- {
- return getHour(localtime);
- }
-
- /**
- * Retrieves the hour field of the given <code>Calendar</code>.
- *
- * @param calendar
- * the <code>Calendar</code> to get the field value from
- * @return the hour field value
- */
- public int getHour(final Calendar calendar)
- {
- return get(calendar, Calendar.HOUR_OF_DAY);
- }
-
- /**
- * Retrieves the minute field of the current <code>Calendar</code>.
- *
- * @return the minute field value
- */
- public int getMinute()
- {
- return getMinute(localtime);
- }
-
- /**
- * Retrieves the minute field of the given <code>Calendar</code>.
- *
- * @param calendar
- * the <code>Calendar</code> from which to get the field value
- * @return the minute field value
- */
- public int getMinute(final Calendar calendar)
- {
- return get(calendar, Calendar.MINUTE);
- }
-
- /**
- * Retrieves the month field of the current <code>Calendar</code>.
- *
- * @return the month field value
- */
- public int getMonth()
- {
- return getMonth(localtime);
- }
-
- /**
- * Retrieves the month field of the given <code>Calendar</code>.
- *
- * @param calendar
- * the <code>Calendar</code> from which to get the field value
- * @return the month field value
- */
- public int getMonth(final Calendar calendar)
- {
- return get(calendar, Calendar.MONTH);
- }
-
- /**
- * Retrieves the seconds field of the current <code>Calendar</code>.
- *
- * @return the seconds field value
- */
- public int getSecond()
- {
- return getSecond(localtime);
- }
-
- /**
- * Retrieves the seconds field of the given <code>Calendar</code>.
- *
- * @param calendar
- * the <code>Calendar</code> from which to get the field value
- * @return the seconds field value
- */
- public int getSecond(final Calendar calendar)
- {
- return get(calendar, Calendar.SECOND);
- }
-
- /**
- * Retrieves the year field of the current <code>Calendar</code>.
- *
- * @return the year field value
- */
- public int getYear()
- {
- return getYear(localtime);
- }
-
- /**
- * Retrieves the year field of the given <code>Calendar</code>.
- *
- * @param calendar
- * the <code>Calendar</code> from which to get the field value
- * @return the year field value
- */
- public int getYear(final Calendar calendar)
- {
- return get(calendar, Calendar.YEAR);
- }
-
- /**
- * Subtracts the given <code>Duration</code> from this <code>Time</code> object, moving the time
- * into the past.
- *
- * @param duration
- * the <code>Duration</code> to subtract
- * @return this duration of time
- */
- public Time subtract(final Duration duration)
- {
- return millis(getMilliseconds() - duration.getMilliseconds());
- }
-
- /**
- * Subtract time from this and returns the difference as a <code>Duration</code> object.
- *
- * @param that
- * the time to subtract
- * @return the <code>Duration</code> between this and that time
- */
- public Duration subtract(final Time that)
- {
- return Duration.milliseconds(getMilliseconds() - that.getMilliseconds());
- }
-
- /**
- * Retrieves a <code>Date</code> object for this <code>Time</code> object. A new
- * <code>Date</code> object is always returned rather than attempting to cache a date since
- * <code>Date</code> is mutable.
- *
- * @return this immutable <code>Time</code> object as a mutable <code>java.util.Date</code>
- * object
- */
- public Date toDate()
- {
- return new Date(getMilliseconds());
- }
-
- /**
- * Converts this <code>Time</code> value to a date <code>String</code> using the date formatter
- * 'yyyy.MM.dd'.
- *
- * @return the date string
- */
- public String toDateString()
- {
- return toDateString(localtime);
- }
-
- /**
- * Converts this <code>Time</code> value to a date <code>String</code> using the formatter
- * 'yyyy.MM.dd'.
- *
- * @param calendar
- * the <code>Calendar</code> to use in the conversion
- * @return the date <code>String</code>
- */
- public String toDateString(final Calendar calendar)
- {
- synchronized (dateFormat)
- {
- synchronized (calendar)
- {
- dateFormat.setCalendar(calendar);
-
- return dateFormat.format(new Date(getMilliseconds())).toLowerCase(Locale.ROOT);
- }
- }
- }
-
- /**
- * Converts this <code>Time</code> value to a <code>String</code> suitable for use in a file
- * system name.
- *
- * @return this <code>Time</code> value as a formatted <code>String</code>
- */
- @Override
- public String toString()
- {
- return toDateString() + "-" + toTimeString();
- }
-
- /**
- * Converts this <code>Time</code> object to a <code>String</code> using the given
- * <code>Calendar</code> and format.
- *
- * @param calendar
- * the <code>Calendar</code> to use in the conversion
- * @param format
- * the format to use
- * @return this <code>Time</code> value as a formatted <code>String</code>
- */
- public String toString(final Calendar calendar, final String format)
- {
- final SimpleDateFormat dateTimeFormat = new SimpleDateFormat(format, Locale.ENGLISH);
- dateTimeFormat.setCalendar(calendar == null ? localtime : calendar);
- return dateTimeFormat.format(new Date(getMilliseconds()));
- }
-
- /**
- * Converts this <code>Time</code> value to a <code>String</code> using the given format.
- *
- * @param format
- * the format to use
- * @return this <code>Time</code> value as a formatted string
- */
- public String toString(final String format)
- {
- return toString(null, format);
- }
-
- /**
- * Returns this time stamp in RFC1123 string format. Contrary to
- * {@link java.text.SimpleDateFormat} this is thread-safe. Taken from the source code of jetty
- * 7.3.0, credits + thanks to Greg Wilkins!
- *
- * @return timestamp string in RFC1123 format
- */
- public String toRfc1123TimestampString()
- {
- final Calendar cal = GregorianCalendar.getInstance(GMT);
- final StringBuilder buf = new StringBuilder(32);
-
- cal.setTimeInMillis(getMilliseconds());
-
- int day_of_week = cal.get(Calendar.DAY_OF_WEEK);
- int day_of_month = cal.get(Calendar.DAY_OF_MONTH);
- int month = cal.get(Calendar.MONTH);
- int year = cal.get(Calendar.YEAR);
- int century = year / 100;
- year = year % 100;
-
- int hours = cal.get(Calendar.HOUR_OF_DAY);
- int minutes = cal.get(Calendar.MINUTE);
- int seconds = cal.get(Calendar.SECOND);
-
- buf.append(DAYS[day_of_week]);
- buf.append(',');
- buf.append(' ');
- appendTwoDigits(buf, day_of_month);
-
- buf.append(' ');
- buf.append(MONTHS[month]);
- buf.append(' ');
- appendTwoDigits(buf, century);
- appendTwoDigits(buf, year);
-
- buf.append(' ');
- appendTwoDigits(buf, hours);
- buf.append(':');
- appendTwoDigits(buf, minutes);
- buf.append(':');
- appendTwoDigits(buf, seconds);
- buf.append(" GMT");
-
- return buf.toString();
- }
-
- /**
- * helper method for {@link #toRfc1123TimestampString()}
- *
- * @param str
- * @param number
- */
- private static void appendTwoDigits(StringBuilder str, int number)
- {
- str.append((char)(number / 10 + '0'));
- str.append((char)(number % 10 + '0'));
- }
-}
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/time/TimeFrame.java b/wicket-util/src/main/java/org/apache/wicket/util/time/TimeFrame.java
deleted file mode 100755
index 07502c7..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/time/TimeFrame.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * 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.util.time;
-
-import org.apache.wicket.util.lang.Objects;
-
-/**
- * Immutable class which represents an interval of time with a beginning and an end. The beginning
- * value is inclusive and the end value is exclusive. In other words, the time frame of 1pm to 2pm
- * includes 1pm, but not 2pm. 1:59:59 is the last value in the <code>TimeFrame</code>.
- * <p>
- * <code>TimeFrame</code>s can be constructed by calling the <code>valueOf</code> static factory
- * methods <code>valueOf(Time, Time)</code> (yielding a <code>TimeFrame</code> between two absolute
- * times) and <code>valueOf(Time, Duration)</code> yielding a <code>TimeFrame</code> starting at an
- * absolute time and having a given length.
- * <p>
- * The start and end of a <code>TimeFrame</code> can be retrieved by calling <code>getStart</code>
- * and <code>getEnd</code>. Its duration can be retrieved by calling <code>getDuration</code>.
- * <p>
- * The <code>contains(Time)</code> method can be called to determine if a <code>TimeFrame</code>
- * contains a given point in time. The <code>overlaps(TimeFrame)</code> method can be called to
- * determine if two <code>TimeFrames</code> overlap.
- * <p>
- * The <code>eachDay(TimeOfDay, TimeOfDay)</code> will return a <code>TimeFrameSource</code> which
- * generates a <code>TimeFrame</code> using the two times of day. In other words, if the start is
- * 3pm and the end is 4pm, the <code>TimeFrameSource</code> returned will yield 3-4pm on the day it
- * is called (each day).
- *
- * @author Jonathan Locke
- * @since 1.2.6
- *
- * @deprecated Since Wicket 9 this class is obsolete and no more used. It will be removed in Wicket 10
- */
-@Deprecated
-public final class TimeFrame implements ITimeFrameSource
-{
- private static final long serialVersionUID = 1L;
-
- /** end of this <code>TimeFrame</code> */
- private final Time end;
-
- /** beginning of this <code>TimeFrame</code> */
- private final Time start;
-
- /**
- * Creates an <code>ITimeFrameSource</code> source for start and end <code>TimeOfDay</code>s.
- * For example, called with 3pm and 5pm as parameters, the <code>TimeFrame</code> source
- * returned would produce <code>TimeFrame</code> objects representing 3pm-5pm on whatever day it
- * is when the caller calls the <code>TimeFrameSource</code> interface.
- *
- * @param startTimeOfDay
- * the start <code>TimeOfDay</code> for this <code>TimeFrame</code> each day
- * @param endTimeOfDay
- * the end <code>TimeOfDay</code> for this <code>TimeFrame</code> each day
- * @return a <code>TimeFrameSource</code> which will return the specified <code>TimeFrame</code>
- * each day
- */
- public static ITimeFrameSource eachDay(final TimeOfDay startTimeOfDay,
- final TimeOfDay endTimeOfDay)
- {
- check(startTimeOfDay, endTimeOfDay);
-
- return new ITimeFrameSource()
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- public TimeFrame getTimeFrame()
- {
- return new TimeFrame(Time.valueOf(startTimeOfDay), Time.valueOf(endTimeOfDay));
- }
- };
- }
-
- /**
- * Creates a <code>TimeFrame</code> for a start <code>Time</code> and <code>Duration</code>.
- *
- * @param start
- * the start <code>Time</code>
- * @param duration
- * the <code>Duration</code>
- * @return the <code>TimeFrame</code>
- * @throws IllegalArgumentException
- * thrown if start <code>Time</code> value is before end <code>Time</code> value
- */
- public static TimeFrame valueOf(final Time start, final Duration duration)
- {
- return new TimeFrame(start, start.add(duration));
- }
-
- /**
- * Creates a <code>TimeFrame</code> for given start and end <code>Time</code>s.
- *
- * @param start
- * the start <code>Time</code>
- * @param end
- * the end <code>Time</code>
- * @return the <code>TimeFrame</code>
- * @throws IllegalArgumentException
- * thrown if start <code>Time</code> value is before end <code>Time</code> value
- */
- public static TimeFrame valueOf(final Time start, final Time end)
- {
- return new TimeFrame(start, end);
- }
-
- /**
- * Checks consistency of start and end <code>AbstractTimeValue</code> values, ensuring that the
- * end value is less than the start value.
- *
- * @param start
- * start <code>AbstractTimeValue</code> value
- * @param end
- * end <code>AbstractTimeValue</code> value
- * @throws IllegalArgumentException
- * thrown if end is less than start
- */
- private static void check(final AbstractTimeValue start, final AbstractTimeValue end)
- {
- // Throw illegal argument exception if end is less than start
- if (end.lessThan(start))
- {
- throw new IllegalArgumentException("Start time of time frame " + start +
- " was after end time " + end);
- }
- }
-
- /**
- * Private constructor to force use of static factory methods.
- *
- * @param start
- * the start <code>Time</code>
- * @param end
- * the end <code>Time</code>
- * @throws IllegalArgumentException
- * thrown if start <code>Time</code> value is before end <code>Time</code> value
- */
- private TimeFrame(final Time start, final Time end)
- {
- check(start, end);
- this.start = start;
- this.end = end;
- }
-
- /**
- * Determines if this <code>TimeFrame</code> contains a given point in time.
- *
- * @param time
- * the <code>Time</code> to check
- * @return <code>true</code> if this <code>TimeFrame</code> contains the given time
- */
- public boolean contains(final Time time)
- {
- return (start.equals(time) || start.before(time)) && end.after(time);
- }
-
- /**
- * Retrieves the <code>Duration</code> of this <code>TimeFrame</code>.
- *
- * @return the <code>Duration</code> of this <code>TimeFrame</code>
- */
- public Duration getDuration()
- {
- return end.subtract(start);
- }
-
- /**
- * Retrieves the end <code>Time</code> of this <code>TimeFrame</code>.
- *
- * @return the end of this <code>TimeFrame</code>
- */
- public Time getEnd()
- {
- return end;
- }
-
- /**
- * Retrieves the start <code>Time</code> of this <code>TimeFrame</code>.
- *
- * @return the start of this <code>TimeFrame</code>
- */
- public Time getStart()
- {
- return start;
- }
-
- /**
- * Implementation of <code>ITimeFrameSource</code> that simply returns this
- * <code>TimeFrame</code>.
- *
- * @return this <code>TimeFrame</code>
- */
- @Override
- public TimeFrame getTimeFrame()
- {
- return this;
- }
-
- /**
- * Determines if two <code>TimeFrame</code>s overlap.
- *
- * @param timeframe
- * the <code>TimeFrame</code> to test
- * @return <code>true</code> if the given <code>TimeFrame</code> overlaps this one
- */
- public boolean overlaps(final TimeFrame timeframe)
- {
- return contains(timeframe.start) || contains(timeframe.end) || timeframe.contains(start) ||
- timeframe.contains(end);
- }
-
- @Override
- public int hashCode()
- {
- return Objects.hashCode(start, end);
- }
-
- @Override
- public boolean equals(final Object obj)
- {
- if (this == obj)
- {
- return true;
- }
- if (obj == null)
- {
- return false;
- }
- if (getClass() != obj.getClass())
- {
- return false;
- }
- TimeFrame other = (TimeFrame)obj;
- return Objects.equal(start, other.start) && Objects.equal(end, other.end);
- }
-
- /**
- * Converts this <code>TimeFrame</code> to a <code>String</code> representation.
- *
- * @return a <code>String</code> representation of this object
- */
- @Override
- public String toString()
- {
- return "[start=" + start + ", end=" + end + "]";
- }
-}
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/time/TimeMap.java b/wicket-util/src/main/java/org/apache/wicket/util/time/TimeMap.java
deleted file mode 100755
index 2280e37..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/time/TimeMap.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.util.time;
-
-import java.io.Serializable;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * This class maps <code>ITimeFrame</code>s to <code>Object</code>s. Since values are stored using
- * <code>ITimeFrameSource</code> implementing objects, the value returned by the source may vary
- * over time. For example, one implementation of <code>ITimeFrameSource</code> might return the
- * start and end time of lunch on any given day.
- * <p>
- * To associate an object with a dynamic <code>TimeFrame</code> (via <code>ITimeFrameSource</code>),
- * call <code>put(ITimeFrameSource, Object)</code>. You can later retrieve the first object for a
- * point in time with <code>get(Time)</code>. The <code>get</code> method is provided for
- * convenience and is equivalent to <code>get(Time.now())</code>.
- * <p>
- * This class is not thread-safe.
- *
- * @author Jonathan Locke
- * @since 1.2.6
- *
- * @deprecated Since Wicket 9 this class is obsolete and no more used. It will be removed in Wicket 10
- */
-@Deprecated
-public final class TimeMap implements Serializable
-{
- private static final long serialVersionUID = 1L;
-
- /**
- * <code>Map</code> from <code>ITimeFrameSource</code> implementing objects to
- * <code>Object</code> values.
- */
- private final Map<ITimeFrameSource, Object> sources = new ConcurrentHashMap<>();
-
- /**
- * Retrieves an <code>Object</code> for the current <code>Time</code> value.
- *
- * @return <code>Object</code> for the current <code>Time</code> value
- */
- public Object get()
- {
- return get(Time.now());
- }
-
- /**
- * Retrieves an <code>Object</code> for the given <code>Time</code> value.
- *
- * @param time
- * the <code>Time</code> value
- * @return gets an <code>Object</code> for the given <code>Time</code> value or
- * <code>null</code> if none exists
- */
- public Object get(final Time time)
- {
- for (ITimeFrameSource source : sources.keySet())
- {
- final TimeFrame current = source.getTimeFrame();
- if (current.contains(time))
- {
- return sources.get(current);
- }
- }
-
- return null;
- }
-
- /**
- * Associates an <code>Object</code> with a dynamic <code>TimeFrame</code>.
- *
- * @param source
- * a source that can produce a <code>TimeFrame</code> with which to compare a
- * <code>Time</code> value
- * @param o
- * the <code>Object</code> to be returned for the given dynamic
- * <code>TimeFrame</code>
- */
- public void put(final ITimeFrameSource source, final Object o)
- {
- final TimeFrame timeframe = source.getTimeFrame();
-
- for (ITimeFrameSource tfs : sources.keySet())
- {
- final TimeFrame current = tfs.getTimeFrame();
-
- if (timeframe.overlaps(current))
- {
- throw new IllegalArgumentException("Timeframe " + timeframe +
- " overlaps timeframe " + current);
- }
- }
-
- sources.put(source, o);
- }
-}
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/time/TimeOfDay.java b/wicket-util/src/main/java/org/apache/wicket/util/time/TimeOfDay.java
deleted file mode 100755
index 69dd50d..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/time/TimeOfDay.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * 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.util.time;
-
-import java.text.ParseException;
-import java.util.Calendar;
-import org.apache.wicket.util.lang.EnumeratedType;
-
-
-/**
- * An immutable time of day value represented as milliseconds since the most recent midnight.
- * <p>
- * Values can be constructed using various factory methods:
- * <ul>
- * <li><code>valueOf(long)</code> where <code>long</code> is milliseconds since midnight
- * <li><code>valueOf(String)</code> where the <code>String</code> is in 'h.mma' format
- * <li><code>valueOf(Calendar, String)</code> where the <code>String</code> is in 'h.mma' format
- * <li><code>valueOf(Duration)</code> where <code>Duration</code> is time since midnight
- * <li><code>valueOf(Time)</code> where <code>Time</code> is some point in time today
- * <li><code>valueOf(Calendar, Time)</code> where <code>Time</code> is some point in time today
- * <li><code>militaryTime(int hour, int minute, int second)</code> for 24-hour time
- * <li><code>time(int hour, int minute, Meridian)</code> where <code>Meridian</code> is AM or PM
- * <li><code>time(int hour, int minute, int second, Meridian)</code> where <code>Meridian</code> is
- * AM or PM
- * <li><code>now()</code> to construct the current time of day
- * <li><code>now(Calendar)</code> to construct the current time of day using a given
- * <code>Calendar</code>
- * </ul>
- * <p>
- * If an attempt is made to construct an illegal time of day value (one that is greater than 24
- * hours worth of milliseconds), an <code>IllegalArgumentException</code> will be thrown.
- * <p>
- * Military hours, minutes and seconds of the time of day can be retrieved by calling the
- * <code>hour</code>, <code>minute</code>, and <code>second</code> methods.
- * <p>
- * The next occurrence of a given <code>TimeOfDay</code> can be retrieved by calling
- * <code>next()</code> or <code>next(Calendar)</code>.
- *
- * @author Jonathan Locke
- * @since 1.2.6
- *
- * @deprecated Since Wicket 9 this class is obsolete and no more used. It will be removed in Wicket 10
- */
-@Deprecated
-public final class TimeOfDay extends AbstractTime
-{
- private static final long serialVersionUID = 1L;
-
- /** Constant for AM time. */
- public static final Meridian AM = new Meridian("AM");
-
- /** Constant for midnight. */
- public static final TimeOfDay MIDNIGHT = time(12, 0, AM);
-
- /** Constant for PM time. */
- public static final Meridian PM = new Meridian("PM");
-
- /** Constant for noon. */
- public static final TimeOfDay NOON = time(12, 0, PM);
-
- /** Typesafe AM/PM enumeration. */
- public static final class Meridian extends EnumeratedType
- {
- private static final long serialVersionUID = 1L;
-
- /**
- * Constructor.
- *
- * @param name
- * the meridian name (value)
- */
- Meridian(final String name)
- {
- super(name);
- }
- }
-
- /**
- * Retrieves a <code>TimeOfDay</code> value on a 24-hour clock.
- *
- * @param hour
- * the hour (0-23)
- * @param minute
- * the minute (0-59)
- * @param second
- * the second (0-59)
- * @return the time of day
- */
- public static TimeOfDay militaryTime(final int hour, final int minute, final int second)
- {
- if ((hour > 23) || (hour < 0))
- {
- throw new IllegalArgumentException("Hour " + hour + " is not valid");
- }
-
- if ((minute > 59) || (minute < 0))
- {
- throw new IllegalArgumentException("Minute " + minute + " is not valid");
- }
-
- if ((second > 59) || (second < 0))
- {
- throw new IllegalArgumentException("Second " + second + " is not valid");
- }
-
- return valueOf(Duration.hours(hour)
- .add(Duration.minutes(minute))
- .add(Duration.seconds(second)));
- }
-
- /**
- * Retrieves the <code>TimeOfDay</code> representing 'now'.
- *
- * @return the time of day it is now
- */
- public static TimeOfDay now()
- {
- return valueOf(Time.now());
- }
-
- /**
- * Retrieves the <code>TimeOfDay</code> representing 'now' on the given <code>Calendar</code>.
- *
- * @param calendar
- * the <code>Calendar</code> to use
- * @return the time of day it is now on the given <code>Calendar</code>
- */
- public static TimeOfDay now(final Calendar calendar)
- {
- return valueOf(calendar, Time.now());
- }
-
- /**
- * Retrieves a <code>TimeOfDay</code> on a 12-hour clock.
- *
- * @param hour
- * the hour (1-12)
- * @param minute
- * the minute (0-59)
- * @param second
- * the second (0-59)
- * @param meridian
- * AM or PM
- * @return the <code>TimeOfDay</code> value
- */
- public static TimeOfDay time(final int hour, final int minute, final int second,
- final Meridian meridian)
- {
- if (meridian == PM)
- {
- if (hour == 12)
- {
- return militaryTime(12, minute, second);
- }
- else
- {
- return militaryTime(hour + 12, minute, second);
- }
- }
- else
- {
- if (hour == 12)
- {
- return militaryTime(0, minute, second);
- }
- else
- {
- return militaryTime(hour, minute, second);
- }
- }
- }
-
- /**
- * Retrieves a <code>TimeOfDay</code> on a 12-hour clock.
- *
- * @param hour
- * the hour (1-12)
- * @param minute
- * the minute (0-59)
- * @param meridian
- * AM of PM
- * @return the <code>TimeOfDay</code> value
- */
- public static TimeOfDay time(final int hour, final int minute, final Meridian meridian)
- {
- return time(hour, minute, 0, meridian);
- }
-
- /**
- * Converts a time <code>String</code> and <code>Calendar</code> to a <code>TimeOfDay</code>
- * instance.
- *
- * @param calendar
- * the <code>Calendar</code> to use when parsing time <code>String</code>
- * @param time
- * a <code>String</code> in 'h.mma' format
- * @return the <code>TimeOfDay</code> on the given <code>Calendar</code>
- * @throws ParseException
- */
- public static TimeOfDay valueOf(final Calendar calendar, final String time)
- throws ParseException
- {
- synchronized (timeFormat)
- {
- synchronized (calendar)
- {
- timeFormat.setCalendar(calendar);
- return new TimeOfDay(timeFormat.parse(time).getTime());
- }
- }
- }
-
- /**
- * Converts a <code>Time</code> instance and <code>Calendar</code> to a <code>TimeOfDay</code>
- * instance.
- *
- * @param calendar
- * the <code>Calendar</code> to use
- * @param time
- * a <code>Time</code> instance
- * @return the <code>TimeOfDay</code> on the given <code>Calendar</code>
- */
- public static TimeOfDay valueOf(final Calendar calendar, final Time time)
- {
- return militaryTime(time.getHour(calendar), time.getMinute(calendar),
- time.getSecond(calendar));
- }
-
- /**
- * Converts a <code>Duration</code> instance to a <code>TimeOfDay</code> instance.
- *
- * @param duration
- * the <code>Duration</code> to use
- * @return the <code>TimeOfDay</code> of the given <code>Duration</code>
- */
- public static TimeOfDay valueOf(final Duration duration)
- {
- return new TimeOfDay(duration.getMilliseconds());
- }
-
- /**
- * Converts a <code>long</code> value to a <code>TimeOfDay</code> instance.
- *
- * @param time
- * the time in milliseconds today
- * @return the <code>TimeOfDay</code>
- */
- public static TimeOfDay valueOf(final long time)
- {
- return new TimeOfDay(time);
- }
-
- /**
- * Converts a <code>String</code> value to a <code>TimeOfDay</code> instance.
- *
- * @param time
- * a <code>String</code> in 'h.mma' format
- * @return the <code>TimeOfDay</code>
- * @throws ParseException
- */
- public static TimeOfDay valueOf(final String time) throws ParseException
- {
- return valueOf(localtime, time);
- }
-
- /**
- * Converts a <code>String</code> value to a <code>TimeOfDay</code> instance.
- *
- * @param time
- * a <code>Time</code> to convert to <code>TimeOfDay</code>
- * @return the <code>TimeOfDay</code> in the current time zone
- */
- public static TimeOfDay valueOf(final Time time)
- {
- return valueOf(AbstractTime.localtime, time);
- }
-
- /**
- * Private utility constructor forces use of static factory methods.
- *
- * @param time
- * the time today in milliseconds
- */
- private TimeOfDay(final long time)
- {
- super(time);
-
- // A time of day value must be less than 1 day of milliseconds
- if (Duration.valueOf(time).greaterThan(Duration.ONE_DAY))
- {
- throw new IllegalArgumentException("Time " + this + " is not a time of day value");
- }
- }
-
- /**
- * Retrieves the hour of the day.
- *
- * @return the hour (0-23) of this <code>TimeOfDay</code>
- */
- public int hour()
- {
- return toHours(getMilliseconds());
- }
-
- /**
- * Retrieves the minute.
- *
- * @return the minute (0-59) of this <code>TimeOfDay</code>
- */
- public int minute()
- {
- return toMinutes(getMilliseconds()) % 60;
- }
-
- /**
- * Retrieves the next occurrence of this <code>TimeOfDay</code> in local time.
- *
- * @return the next occurrence of this <code>TimeOfDay</code> in local time
- */
- public Time next()
- {
- return next(AbstractTime.localtime);
- }
-
- /**
- * Retrieves the next occurrence of this <code>TimeOfDay</code> on the given
- * <code>Calendar</code>.
- *
- * @param calendar
- * the <code>Calendar</code> to use
- * @return the next occurrence of this <code>TimeOfDay</code> on the given <code>Calendar</code>
- */
- public Time next(final Calendar calendar)
- {
- // Get this time of day today
- final Time timeToday = Time.valueOf(calendar, this);
-
- // If it has already passed
- if (timeToday.before(Time.now()))
- {
- // Return the time tomorrow
- return Time.valueOf(calendar, this).add(Duration.ONE_DAY);
- }
- else
- {
- // Time hasn't happened yet today
- return timeToday;
- }
- }
-
- /**
- * Retrieves the second.
- *
- * @return the second (0-59)
- */
- public int second()
- {
- return toSeconds(getMilliseconds()) % 60;
- }
-
- /**
- * @see Object#toString()
- */
- @Override
- public String toString()
- {
- final int second = second();
- return "" + hour() + ":" + minute() + (second != 0 ? ":" + second : "");
- }
-
- /**
- * Retrieves milliseconds as hours.
- *
- * @param milliseconds
- * milliseconds to convert
- * @return converted input
- */
- private int toHours(final long milliseconds)
- {
- return toMinutes(milliseconds) / 60;
- }
-
- /**
- * Retrieves milliseconds as minutes.
- *
- * @param milliseconds
- * milliseconds to convert
- * @return converted input
- */
- private int toMinutes(final long milliseconds)
- {
- return toSeconds(milliseconds) / 60;
- }
-
- /**
- * Retrieves milliseconds as seconds.
- *
- * @param milliseconds
- * milliseconds to convert
- * @return converted input
- */
- private int toSeconds(final long milliseconds)
- {
- return (int)(milliseconds / 1000);
- }
-}
diff --git a/wicket-util/src/test/java/org/apache/wicket/util/collections/MicroMapTest.java b/wicket-util/src/test/java/org/apache/wicket/util/collections/MicroMapTest.java
deleted file mode 100644
index ba7234a..0000000
--- a/wicket-util/src/test/java/org/apache/wicket/util/collections/MicroMapTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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.util.collections;
-
-import org.junit.jupiter.api.Test;
-
-import java.util.*;
-import java.util.Map.Entry;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-/**
- * @author almaw
- */
-public class MicroMapTest
-{
- private static final Object FOO = new Object();
- private static final Object BAR = new Object();
-
- /**
- * Basic test for keySet(), entrySet() and values().
- */
- @Test
- public void microMap()
- {
- MicroMap<Object, Object> m = new MicroMap<>();
- m.put(FOO, BAR);
-
- // Test .keySet();
- Set<Object> s = m.keySet();
- assertEquals(1, m.size());
- assertEquals(1, s.size());
-
- Iterator<?> i = s.iterator();
- assertTrue(i.hasNext());
- Object key = i.next();
- assertEquals(FOO, key);
- assertFalse(i.hasNext());
- try
- {
- i.next();
- fail("Expected i.next() to fail with NoSuchElementException");
- }
- catch (NoSuchElementException e)
- {
- // Swallow this.
- }
-
- // Do approx the same again with the .entrySet()
- Set<Entry<Object, Object>> entrySet = m.entrySet();
- assertEquals(1, m.size());
- assertEquals(1, entrySet.size());
-
- i = entrySet.iterator();
- assertTrue(i.hasNext());
- @SuppressWarnings("unchecked")
- Map.Entry<Object, Object> entry = (Map.Entry<Object, Object>)i.next();
- assertEquals(FOO, entry.getKey());
- assertEquals(BAR, entry.getValue());
- assertFalse(i.hasNext());
- try
- {
- i.next();
- fail("Expected i.next() to fail with NoSuchElementException");
- }
- catch (NoSuchElementException e)
- {
- // Swallow this.
- }
-
- // Do approx the same again with the .values()
- Collection<Object> v = m.values();
- assertEquals(1, m.size());
- assertEquals(1, v.size());
-
- i = v.iterator();
- assertTrue(i.hasNext());
- Object value = i.next();
- assertEquals(BAR, value);
- assertFalse(i.hasNext());
- try
- {
- i.next();
- fail("Expected i.next() to fail with NoSuchElementException");
- }
- catch (NoSuchElementException e)
- {
- // Swallow this.
- }
- }
-}
diff --git a/wicket-util/src/test/java/org/apache/wicket/util/crypt/SunJceCryptTest.java b/wicket-util/src/test/java/org/apache/wicket/util/crypt/SunJceCryptTest.java
index a4b0c39..4d529da 100644
--- a/wicket-util/src/test/java/org/apache/wicket/util/crypt/SunJceCryptTest.java
+++ b/wicket-util/src/test/java/org/apache/wicket/util/crypt/SunJceCryptTest.java
@@ -35,8 +35,7 @@ public class SunJceCryptTest
@Test
public void defaultEncryption() throws GeneralSecurityException
{
- @SuppressWarnings("deprecation")
- SunJceCrypt crypt = new SunJceCrypt();
+ SunJceCrypt crypt = new SunJceCrypt(SunJceCrypt.randomSalt(), 1);
String input = "input";
byte[] encrypted = crypt.crypt(input.getBytes(), Cipher.ENCRYPT_MODE);
@@ -53,8 +52,7 @@ public class SunJceCryptTest
boolean unlimitedStrengthJurisdictionPolicyInstalled = isUnlimitedStrengthJurisdictionPolicyInstalled();
Assumptions.assumeTrue(unlimitedStrengthJurisdictionPolicyInstalled);
- @SuppressWarnings("deprecation")
- SunJceCrypt crypt = new SunJceCrypt("PBEWithMD5AndTripleDES");
+ SunJceCrypt crypt = new SunJceCrypt("PBEWithMD5AndTripleDES", SunJceCrypt.randomSalt(), 1);
String input = "input";
byte[] encrypted = crypt.crypt(input.getBytes(), Cipher.ENCRYPT_MODE);