You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2021/07/08 20:00:09 UTC
[isis] branch master updated: ISIS-2796: Use base64 encoding with
o.a.wicket....CookieUtils.save/load.
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new 543acb0 ISIS-2796: Use base64 encoding with o.a.wicket....CookieUtils.save/load.
543acb0 is described below
commit 543acb0719e659397b936f301d7184843e86a7c0
Author: andi-huber <ah...@apache.org>
AuthorDate: Thu Jul 8 21:59:06 2021 +0200
ISIS-2796: Use base64 encoding with o.a.wicket....CookieUtils.save/load.
- also adds a JUnit roundtrip test - though this does not do any RFC6265
verification
---
viewers/wicket/ui/pom.xml | 637 ++++++++++-----------
.../accmngt/AccountManagementPageAbstract.java | 9 +-
.../accmngt/SuccessFeedbackCookieManager.java | 74 +++
.../password_reset/PasswordResetEmailPanel.java | 7 +-
.../accmngt/signup/RegistrationFormPanel.java | 7 +-
.../wicket/ui/pages/login/WicketSignInPage.java | 18 +-
.../accmngt/SuccessFeedbackCookieUtilTest.java | 86 +++
7 files changed, 485 insertions(+), 353 deletions(-)
diff --git a/viewers/wicket/ui/pom.xml b/viewers/wicket/ui/pom.xml
index 9d9d21a..940e726 100644
--- a/viewers/wicket/ui/pom.xml
+++ b/viewers/wicket/ui/pom.xml
@@ -1,341 +1,334 @@
<?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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<!-- 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. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.isis.viewer</groupId>
- <artifactId>isis-viewer-wicket</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
+ <parent>
+ <groupId>org.apache.isis.viewer</groupId>
+ <artifactId>isis-viewer-wicket</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
- <artifactId>isis-viewer-wicket-ui</artifactId>
- <name>Apache Isis Viewer - Wicket (UI Components)</name>
+ <artifactId>isis-viewer-wicket-ui</artifactId>
+ <name>Apache Isis Viewer - Wicket (UI Components)</name>
- <properties>
- <jar-plugin.automaticModuleName>org.apache.isis.viewer.wicket.ui</jar-plugin.automaticModuleName>
- <git-plugin.propertiesDir>org/apache/isis/viewer/wicket/ui</git-plugin.propertiesDir>
- </properties>
+ <properties>
+ <jar-plugin.automaticModuleName>org.apache.isis.viewer.wicket.ui</jar-plugin.automaticModuleName>
+ <git-plugin.propertiesDir>org/apache/isis/viewer/wicket/ui</git-plugin.propertiesDir>
+ </properties>
- <build>
- <resources>
- <resource>
- <filtering>false</filtering>
- <directory>src/main/resources</directory>
- </resource>
- <resource>
- <filtering>false</filtering>
- <directory>src/main/java</directory>
- <includes>
- <include>**</include>
- </includes>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>net.alchim31.maven</groupId>
- <artifactId>yuicompressor-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
+ <build>
+ <resources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>net.alchim31.maven</groupId>
+ <artifactId>yuicompressor-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
- <dependencies>
+ <dependencies>
- <dependency>
- <groupId>org.apache.isis.viewer</groupId>
- <artifactId>isis-viewer-wicket-model</artifactId>
- </dependency>
+ <dependency>
+ <groupId>org.apache.isis.viewer</groupId>
+ <artifactId>isis-viewer-wicket-model</artifactId>
+ </dependency>
- <dependency>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-core</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-core</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
- <dependency>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-devutils</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-devutils</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j-api.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-extensions</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-auth-roles</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-extensions</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-auth-roles</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
- <dependency>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-spring</artifactId>
- <exclusions>
- <!-- already provided by JEE API -->
- <exclusion>
- <groupId>javax.inject</groupId>
- <artifactId>javax.inject</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.ow2.asm</groupId>
- <artifactId>asm</artifactId>
- </exclusion>
- <!-- TODO[2112] exclusions might no longer be relevant -->
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </exclusion>
- <exclusion>
- <!-- for Java7 compatibility (we don't use the proxying capability
- of this component) -->
- <groupId>cglib</groupId>
- <artifactId>cglib</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-spring</artifactId>
+ <exclusions>
+ <!-- already provided by JEE API -->
+ <exclusion>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ </exclusion>
+ <!-- TODO[2112] exclusions might no longer be relevant -->
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <!-- for Java7 compatibility (we don't use the proxying capability of
+ this component) -->
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
- <dependency>
- <groupId>org.wicketstuff</groupId>
- <artifactId>wicketstuff-select2</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-core</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ <dependency>
+ <groupId>org.wicketstuff</groupId>
+ <artifactId>wicketstuff-select2</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-core</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>select2</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.webjars</groupId>
- <artifactId>jquery</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>select2</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.webjars</groupId>
+ <artifactId>jquery</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>jquery-ui</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.webjars</groupId>
- <artifactId>jquery</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>jquery-ui</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.webjars</groupId>
+ <artifactId>jquery</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
- <dependency>
- <groupId>de.agilecoders.wicket.webjars</groupId>
- <artifactId>wicket-webjars</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-request</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.webjars</groupId>
- <artifactId>bootstrap</artifactId>
- </dependency>
-
<dependency>
- <groupId>org.webjars</groupId>
- <artifactId>jquery</artifactId>
+ <groupId>de.agilecoders.wicket.webjars</groupId>
+ <artifactId>wicket-webjars</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-request</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>bootstrap</artifactId>
</dependency>
- <dependency>
- <groupId>de.agilecoders.wicket</groupId>
- <artifactId>wicket-bootstrap-core</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.webjars</groupId>
- <artifactId>popper.js</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-util</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-request</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-extensions</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ <dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>jquery</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>de.agilecoders.wicket</groupId>
+ <artifactId>wicket-bootstrap-core</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.webjars</groupId>
+ <artifactId>popper.js</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-util</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-request</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-extensions</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
- <dependency>
- <groupId>de.agilecoders.wicket</groupId>
- <artifactId>wicket-bootstrap-extensions</artifactId>
- <exclusions>
- <!-- exclude unused extensions -->
- <exclusion>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-util</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-request</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-extensions</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.webjars</groupId>
- <artifactId>bootstrap</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.webjars</groupId>
- <artifactId>font-awesome</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.webjars</groupId>
- <artifactId>jquery</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.webjars</groupId>
- <artifactId>jquerypp</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.webjars</groupId>
- <artifactId>jquery-ui</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.webjars</groupId>
- <artifactId>typeaheadjs</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.webjars</groupId>
- <artifactId>x-editable-bootstrap</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.webjars</groupId>
- <artifactId>spin-js</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.google.javascript</groupId>
- <artifactId>closure-compiler</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.google.javascript</groupId>
- <artifactId>closure-compiler-unshaded</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.webjars.bower</groupId>
- <artifactId>summernote</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.webjars.bower</groupId>
- <artifactId>summernote</artifactId>
- </dependency>
+ <dependency>
+ <groupId>de.agilecoders.wicket</groupId>
+ <artifactId>wicket-bootstrap-extensions</artifactId>
+ <exclusions>
+ <!-- exclude unused extensions -->
+ <exclusion>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-util</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-request</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-extensions</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.webjars</groupId>
+ <artifactId>bootstrap</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.webjars</groupId>
+ <artifactId>font-awesome</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.webjars</groupId>
+ <artifactId>jquery</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.webjars</groupId>
+ <artifactId>jquerypp</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.webjars</groupId>
+ <artifactId>jquery-ui</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.webjars</groupId>
+ <artifactId>typeaheadjs</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.webjars</groupId>
+ <artifactId>x-editable-bootstrap</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.webjars</groupId>
+ <artifactId>spin-js</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.google.javascript</groupId>
+ <artifactId>closure-compiler</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.google.javascript</groupId>
+ <artifactId>closure-compiler-unshaded</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.webjars.bower</groupId>
+ <artifactId>summernote</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.webjars.bower</groupId>
+ <artifactId>summernote</artifactId>
+ </dependency>
- <dependency>
- <groupId>de.agilecoders.wicket</groupId>
- <artifactId>wicket-bootstrap-themes</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-core</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ <dependency>
+ <groupId>de.agilecoders.wicket</groupId>
+ <artifactId>wicket-bootstrap-themes</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-core</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
- <!-- required by de.agilecoders.wicket.themes.markup.html.bootswatch.BootswatchThemeProvider -->
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
+ <!-- required by de.agilecoders.wicket.themes.markup.html.bootswatch.BootswatchThemeProvider -->
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
<!-- JDO API (non transient, provided by plugin) -->
<dependency>
@@ -348,15 +341,21 @@
<scope>provided</scope>
</dependency>
- <!-- TESTING -->
+ <!-- TESTING -->
- <dependency>
- <groupId>org.apache.isis.core</groupId>
- <artifactId>isis-core-internaltestsupport</artifactId>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <groupId>org.apache.isis.core</groupId>
+ <artifactId>isis-core-internaltestsupport</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <scope>test</scope>
+ </dependency>
- </dependencies>
+ </dependencies>
</project>
diff --git a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.java b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.java
index 59998c7..fd837e9 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.java
@@ -42,10 +42,9 @@ import org.apache.isis.viewer.wicket.ui.errors.ExceptionStackTracePanel;
import org.apache.isis.viewer.wicket.ui.pages.PageAbstract;
import org.apache.isis.viewer.wicket.ui.pages.WebPageBase;
-import lombok.val;
-
import de.agilecoders.wicket.core.markup.html.bootstrap.behavior.BootstrapJavascriptBehavior;
import de.agilecoders.wicket.core.markup.html.references.BootstrapJavaScriptReference;
+import lombok.val;
/**
* Boilerplate, pick up our HTML and CSS.
@@ -60,12 +59,6 @@ public class AccountManagementPageAbstract extends WebPageBase {
private static final String ID_EXCEPTION_STACK_TRACE = "exceptionStackTrace";
/**
- * The name of a special cookie that is used as a temporary container for
- * stateless session scoped success feedback messages.
- */
- public static final String FEEDBACK_COOKIE_NAME = "isis.feedback.success";
-
- /**
* If set by {@link org.apache.isis.viewer.wicket.ui.pages.PageAbstract}.
*/
protected static ExceptionModel getAndClearExceptionModelIfAny() {
diff --git a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/SuccessFeedbackCookieManager.java b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/SuccessFeedbackCookieManager.java
new file mode 100644
index 0000000..8b6f8da
--- /dev/null
+++ b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/SuccessFeedbackCookieManager.java
@@ -0,0 +1,74 @@
+/*
+ * 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.isis.viewer.wicket.ui.pages.accmngt;
+
+import java.util.function.Consumer;
+
+import javax.annotation.Nullable;
+
+import org.apache.wicket.util.cookies.CookieUtils;
+
+import org.apache.isis.commons.internal.base._Strings;
+import org.apache.isis.commons.internal.functions._Functions;
+
+import lombok.NonNull;
+import lombok.val;
+import lombok.experimental.UtilityClass;
+
+@UtilityClass
+public class SuccessFeedbackCookieManager {
+
+ /**
+ * The name of a special cookie that is used as a temporary container for
+ * stateless session scoped success feedback messages.
+ */
+ static final String FEEDBACK_COOKIE_NAME = "isis.feedback.success";
+
+
+ /**
+ * Store a cookie with name {@value #FEEDBACK_COOKIE_NAME} that is
+ * used as a temporary container for stateless session scoped success feedback
+ * messages.
+ */
+ public static void storeSuccessFeedback(final @Nullable String successFeedback) {
+ val cookieUtils = new CookieUtils();
+ if (_Strings.isNotEmpty(successFeedback)) {
+ cookieUtils.save(FEEDBACK_COOKIE_NAME, _Strings.base64UrlEncode(successFeedback));
+ } else {
+ // if successFeedback is empty we interpret that as a cookie remove request
+ drainSuccessFeedback(_Functions.noopConsumer());
+ }
+
+ }
+
+ /**
+ * Checks for a cookie with name {@value #FEEDBACK_COOKIE_NAME} that is
+ * used as a temporary container for stateless session scoped success feedback
+ * messages.
+ */
+ public static void drainSuccessFeedback(final @NonNull Consumer<String> onSuccessFeedback) {
+ val cookieUtils = new CookieUtils();
+ final String successFeedback = cookieUtils.load(FEEDBACK_COOKIE_NAME);
+ if (_Strings.isNotEmpty(successFeedback)) {
+ onSuccessFeedback.accept(_Strings.base64UrlDecode(successFeedback));
+ }
+ cookieUtils.remove(FEEDBACK_COOKIE_NAME);
+ }
+
+}
diff --git a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetEmailPanel.java b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetEmailPanel.java
index 6e35ee5..7f974be 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetEmailPanel.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetEmailPanel.java
@@ -28,13 +28,12 @@ import org.apache.wicket.markup.html.form.StatelessForm;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.ResourceModel;
-import org.apache.wicket.util.cookies.CookieUtils;
import org.apache.isis.applib.services.userreg.events.PasswordResetEvent;
import org.apache.isis.viewer.wicket.model.models.PageType;
import org.apache.isis.viewer.wicket.ui.components.widgets.bootstrap.FormGroup;
-import org.apache.isis.viewer.wicket.ui.pages.accmngt.AccountManagementPageAbstract;
import org.apache.isis.viewer.wicket.ui.pages.accmngt.EmailAvailableValidator;
+import org.apache.isis.viewer.wicket.ui.pages.accmngt.SuccessFeedbackCookieManager;
import org.apache.isis.viewer.wicket.ui.panels.PanelBase;
import lombok.val;
@@ -100,9 +99,7 @@ public class PasswordResetEmailPanel extends PanelBase<Void> {
map.put("email", email);
IModel<Map<String, String>> model = Model.ofMap(map);
String emailSentMessage = getString("emailSentMessage", model);
-
- CookieUtils cookieUtils = new CookieUtils();
- cookieUtils.save(AccountManagementPageAbstract.FEEDBACK_COOKIE_NAME, emailSentMessage);
+ SuccessFeedbackCookieManager.storeSuccessFeedback(emailSentMessage);
super.getPageNavigationService().navigateTo(PageType.SIGN_IN);
}
}
diff --git a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/signup/RegistrationFormPanel.java b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/signup/RegistrationFormPanel.java
index 64eeea3..29ab89a 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/signup/RegistrationFormPanel.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/signup/RegistrationFormPanel.java
@@ -29,7 +29,6 @@ import org.apache.wicket.markup.html.form.RequiredTextField;
import org.apache.wicket.markup.html.form.StatelessForm;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.ResourceModel;
-import org.apache.wicket.util.cookies.CookieUtils;
import org.apache.wicket.validation.validator.EmailAddressValidator;
import org.apache.isis.applib.services.userreg.EmailNotificationService;
@@ -38,8 +37,8 @@ import org.apache.isis.viewer.wicket.model.models.PageType;
import org.apache.isis.viewer.wicket.ui.components.widgets.bootstrap.FormGroup;
import org.apache.isis.viewer.wicket.ui.pages.EmailVerificationUrlService;
import org.apache.isis.viewer.wicket.ui.pages.PageNavigationService;
-import org.apache.isis.viewer.wicket.ui.pages.accmngt.AccountManagementPageAbstract;
import org.apache.isis.viewer.wicket.ui.pages.accmngt.EmailAvailableValidator;
+import org.apache.isis.viewer.wicket.ui.pages.accmngt.SuccessFeedbackCookieManager;
import org.apache.isis.viewer.wicket.ui.panels.PanelBase;
import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;
@@ -99,9 +98,7 @@ public class RegistrationFormPanel extends PanelBase<Void> {
Map<String, String> map = new HashMap<>();
map.put("email", email);
String emailSentMessage = getString("emailSentMessage", Model.ofMap(map));
-
- CookieUtils cookieUtils = new CookieUtils();
- cookieUtils.save(AccountManagementPageAbstract.FEEDBACK_COOKIE_NAME, emailSentMessage);
+ SuccessFeedbackCookieManager.storeSuccessFeedback(emailSentMessage);
pageNavigationService.navigateTo(PageType.SIGN_IN);
}
}
diff --git a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/login/WicketSignInPage.java b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/login/WicketSignInPage.java
index 9397595..e5480ab 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/login/WicketSignInPage.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/login/WicketSignInPage.java
@@ -24,13 +24,12 @@ import javax.inject.Inject;
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession;
import org.apache.wicket.authroles.authentication.panel.SignInPanel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.wicket.util.cookies.CookieUtils;
-import org.apache.wicket.util.string.Strings;
import org.apache.isis.viewer.wicket.model.models.PageType;
import org.apache.isis.viewer.wicket.ui.errors.ExceptionModel;
import org.apache.isis.viewer.wicket.ui.pages.PageNavigationService;
import org.apache.isis.viewer.wicket.ui.pages.accmngt.AccountManagementPageAbstract;
+import org.apache.isis.viewer.wicket.ui.pages.accmngt.SuccessFeedbackCookieManager;
/**
* Boilerplate, pick up our HTML and CSS.
@@ -57,22 +56,9 @@ public class WicketSignInPage extends AccountManagementPageAbstract {
addSignInPanel();
- checkForSuccessFeedback();
+ SuccessFeedbackCookieManager.drainSuccessFeedback(this::success);
}
- /**
- * Checks for a cookie with name {@value #FEEDBACK_COOKIE_NAME} that is
- * used as a temporary container for stateless session scoped success feedback
- * messages.
- */
- private void checkForSuccessFeedback() {
- CookieUtils cookieUtils = new CookieUtils();
- String successFeedback = cookieUtils.load(FEEDBACK_COOKIE_NAME);
- if (!Strings.isEmpty(successFeedback)) {
- success(successFeedback);
- cookieUtils.remove(FEEDBACK_COOKIE_NAME);
- }
- }
protected SignInPanel addSignInPanel() {
diff --git a/viewers/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/SuccessFeedbackCookieUtilTest.java b/viewers/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/SuccessFeedbackCookieUtilTest.java
new file mode 100644
index 0000000..6a6593b
--- /dev/null
+++ b/viewers/wicket/ui/src/test/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/SuccessFeedbackCookieUtilTest.java
@@ -0,0 +1,86 @@
+/*
+ * 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.isis.viewer.wicket.ui.pages.accmngt;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.wicket.ThreadContext;
+import org.apache.wicket.mock.MockWebResponse;
+import org.apache.wicket.protocol.http.servlet.ServletWebRequest;
+import org.apache.wicket.request.IExceptionMapper;
+import org.apache.wicket.request.IRequestMapper;
+import org.apache.wicket.request.Url;
+import org.apache.wicket.request.cycle.RequestCycle;
+import org.apache.wicket.request.cycle.RequestCycleContext;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import lombok.val;
+
+class SuccessFeedbackCookieUtilTest {
+
+ private ServletWebRequest servletWebRequest;
+ private MockWebResponse mockWebResponse;
+ private HttpServletRequest mockHttpServletRequest;
+
+ @BeforeEach
+ void setUp() throws Exception {
+
+ mockHttpServletRequest = mock(HttpServletRequest.class);
+ servletWebRequest = new ServletWebRequest(mockHttpServletRequest, "", Url.parse("/"));
+ mockWebResponse = new MockWebResponse();
+
+ ThreadContext.setRequestCycle(new RequestCycle(new RequestCycleContext(
+ servletWebRequest,
+ mockWebResponse,
+ mock(IRequestMapper.class),
+ mock(IExceptionMapper.class))));
+ }
+
+ @Test
+ void roundtrip() {
+
+ val message = "Hallo x@abc.com what`s up 'dear'?!.";
+
+ // store cookie with response
+ SuccessFeedbackCookieManager.storeSuccessFeedback(message);
+
+ // fake request to return cookies that were just written to the response
+ when(mockHttpServletRequest.getCookies())
+ .thenReturn(mockWebResponse.getCookies().toArray(new Cookie[] {}));
+
+
+ // verify that we can read the message from the cookie
+ val resultRef = new AtomicReference<String>();
+
+ SuccessFeedbackCookieManager.drainSuccessFeedback(feedback->{
+ resultRef.set(feedback);
+ });
+
+ assertEquals(message, resultRef.get());
+ }
+
+}