You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2015/01/04 20:48:48 UTC
[14/20] isis git commit: ISIS-987 Provide some sort of mechanism to
allow users to self-register for an Isis application.
ISIS-987 Provide some sort of mechanism to allow users to self-register for an Isis application.
Move account management related files to accmngt package.
Extract all i18n stuff to AccountManagementPageAbstract.properties
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/f34e066f
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/f34e066f
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/f34e066f
Branch: refs/heads/master
Commit: f34e066fd9c4e97dd752765d3bbdf85ff9d48433
Parents: 837e1ca
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Sat Jan 3 23:20:03 2015 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Sat Jan 3 23:20:03 2015 +0200
----------------------------------------------------------------------
.../wicket/viewer/IsisWicketApplication.java | 2 +-
.../registries/pages/PageClassListDefault.java | 6 +-
.../ui/pages/AccountManagementPageAbstract.html | 62 --------
.../ui/pages/AccountManagementPageAbstract.java | 126 ---------------
.../pages/accmngt/AccountConfirmationMap.java | 154 +++++++++++++++++++
.../accmngt/AccountManagementPageAbstract.html | 62 ++++++++
.../accmngt/AccountManagementPageAbstract.java | 127 +++++++++++++++
.../AccountManagementPageAbstract.properties | 53 +++++++
.../pages/accmngt/EmailAvailableValidator.java | 40 +++++
.../accmngt/UsernameAvailableValidator.java | 34 ++++
.../password_reset/PasswordResetEmailPanel.html | 32 ++++
.../password_reset/PasswordResetEmailPanel.java | 112 ++++++++++++++
.../password_reset/PasswordResetPage.css | 100 ++++++++++++
.../password_reset/PasswordResetPage.html | 41 +++++
.../password_reset/PasswordResetPage.java | 113 ++++++++++++++
.../password_reset/PasswordResetPanel.html | 37 +++++
.../password_reset/PasswordResetPanel.java | 114 ++++++++++++++
.../ui/pages/accmngt/register/RegisterPage.css | 18 +++
.../ui/pages/accmngt/register/RegisterPage.html | 38 +++++
.../ui/pages/accmngt/register/RegisterPage.java | 80 ++++++++++
.../pages/accmngt/register/RegisterPanel.html | 35 +++++
.../pages/accmngt/register/RegisterPanel.java | 149 ++++++++++++++++++
.../ui/pages/accmngt/register/Registree.java | 49 ++++++
.../accmngt/signup/RegistrationFormPage.css | 100 ++++++++++++
.../accmngt/signup/RegistrationFormPage.html | 35 +++++
.../accmngt/signup/RegistrationFormPage.java | 53 +++++++
.../accmngt/signup/RegistrationFormPanel.html | 34 ++++
.../accmngt/signup/RegistrationFormPanel.java | 114 ++++++++++++++
.../wicket/ui/pages/login/WicketSignInPage.java | 2 +-
.../password_reset/PasswordResetEmailPanel.html | 32 ----
.../password_reset/PasswordResetEmailPanel.java | 112 --------------
.../pages/password_reset/PasswordResetPage.css | 100 ------------
.../pages/password_reset/PasswordResetPage.html | 41 -----
.../pages/password_reset/PasswordResetPage.java | 113 --------------
.../password_reset/PasswordResetPage.properties | 33 ----
.../password_reset/PasswordResetPanel.html | 37 -----
.../password_reset/PasswordResetPanel.java | 114 --------------
.../wicket/ui/pages/register/RegisterPage.css | 18 ---
.../wicket/ui/pages/register/RegisterPage.html | 37 -----
.../wicket/ui/pages/register/RegisterPage.java | 80 ----------
.../ui/pages/register/RegisterPage.properties | 31 ----
.../wicket/ui/pages/register/RegisterPanel.html | 35 -----
.../wicket/ui/pages/register/RegisterPanel.java | 149 ------------------
.../wicket/ui/pages/register/Registree.java | 49 ------
.../ui/pages/signup/AccountConfirmationMap.java | 154 -------------------
.../pages/signup/EmailAvailableValidator.java | 40 -----
.../ui/pages/signup/RegistrationFormPage.css | 100 ------------
.../ui/pages/signup/RegistrationFormPage.html | 35 -----
.../ui/pages/signup/RegistrationFormPage.java | 53 -------
.../signup/RegistrationFormPage.properties | 27 ----
.../ui/pages/signup/RegistrationFormPanel.html | 34 ----
.../ui/pages/signup/RegistrationFormPanel.java | 112 --------------
.../signup/UsernameAvailableValidator.java | 34 ----
53 files changed, 1729 insertions(+), 1763 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication.java b/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication.java
index 3779d13..319d42f 100644
--- a/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication.java
+++ b/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication.java
@@ -99,7 +99,7 @@ import org.apache.isis.viewer.wicket.ui.components.widgets.select2.Select2Bootst
import org.apache.isis.viewer.wicket.ui.components.widgets.select2.Select2JsReference;
import org.apache.isis.viewer.wicket.ui.pages.PageClassRegistry;
import org.apache.isis.viewer.wicket.ui.pages.PageClassRegistryAccessor;
-import org.apache.isis.viewer.wicket.ui.pages.signup.AccountConfirmationMap;
+import org.apache.isis.viewer.wicket.ui.pages.accmngt.AccountConfirmationMap;
import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
import org.apache.isis.viewer.wicket.viewer.integration.isis.DeploymentTypeWicketAbstract;
import org.apache.isis.viewer.wicket.viewer.integration.isis.WicketServer;
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/registries/pages/PageClassListDefault.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/registries/pages/PageClassListDefault.java b/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/registries/pages/PageClassListDefault.java
index e23e8ab..5d15946 100644
--- a/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/registries/pages/PageClassListDefault.java
+++ b/component/viewer/wicket/impl/src/main/java/org/apache/isis/viewer/wicket/viewer/registries/pages/PageClassListDefault.java
@@ -31,9 +31,9 @@ import org.apache.isis.viewer.wicket.ui.pages.actionprompt.ActionPromptPage;
import org.apache.isis.viewer.wicket.ui.pages.entity.EntityPage;
import org.apache.isis.viewer.wicket.ui.pages.home.HomePage;
import org.apache.isis.viewer.wicket.ui.pages.login.WicketSignInPage;
-import org.apache.isis.viewer.wicket.ui.pages.password_reset.PasswordResetPage;
-import org.apache.isis.viewer.wicket.ui.pages.register.RegisterPage;
-import org.apache.isis.viewer.wicket.ui.pages.signup.RegistrationFormPage;
+import org.apache.isis.viewer.wicket.ui.pages.accmngt.password_reset.PasswordResetPage;
+import org.apache.isis.viewer.wicket.ui.pages.accmngt.register.RegisterPage;
+import org.apache.isis.viewer.wicket.ui.pages.accmngt.signup.RegistrationFormPage;
import org.apache.isis.viewer.wicket.ui.pages.standalonecollection.StandaloneCollectionPage;
import org.apache.isis.viewer.wicket.ui.pages.value.ValuePage;
import org.apache.isis.viewer.wicket.ui.pages.voidreturn.VoidReturnPage;
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/AccountManagementPageAbstract.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/AccountManagementPageAbstract.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/AccountManagementPageAbstract.html
deleted file mode 100644
index b59b636..0000000
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/AccountManagementPageAbstract.html
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html>
-<!--
- 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.
--->
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:wicket="http://wicket.apache.org"
- xml:lang="en"
- lang="en">
- <head>
- <wicket:header-items/>
- <title wicket:id="pageTitle"></title>
- </head>
- <body>
- <div class="accountManagementPanel container-fluid">
- <div class="jumbotron" style="background-color: transparent">
-
- <div class="row">
- <div class="col-sm-12"> </div>
- </div>
- <div class="row">
- <div class="col-sm-12"> </div>
- </div>
- <div class="row">
- <div class="col-sm-12"> </div>
- </div>
-
- <div class="row">
- <div class="headerContainer col-sm-offset-4 col-sm-4">
- <h1 wicket:id="applicationName" class="applicationName">[application name]</h1>
- </div>
- </div>
-
- <div class="row">
- <div class="col-sm-12"> </div>
- </div>
- <div class="row">
- <div class="col-sm-12"> </div>
- </div>
-
- <wicket:child/>
-
- </div>
- <div wicket:id="exceptionStackTrace" class="exceptionStackTrace"></div>
- </div>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/AccountManagementPageAbstract.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/AccountManagementPageAbstract.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/AccountManagementPageAbstract.java
deleted file mode 100644
index 2d1ae5b..0000000
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/AccountManagementPageAbstract.java
+++ /dev/null
@@ -1,126 +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.isis.viewer.wicket.ui.pages;
-
-import com.google.inject.Inject;
-import com.google.inject.name.Named;
-import org.apache.wicket.Application;
-import org.apache.wicket.MarkupContainer;
-import org.apache.wicket.markup.head.CssReferenceHeaderItem;
-import org.apache.wicket.markup.head.IHeaderResponse;
-import org.apache.wicket.markup.head.JavaScriptHeaderItem;
-import org.apache.wicket.markup.head.JavaScriptReferenceHeaderItem;
-import org.apache.wicket.markup.head.PriorityHeaderItem;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.wicket.ui.errors.ExceptionModel;
-import org.apache.isis.viewer.wicket.ui.errors.ExceptionStackTracePanel;
-
-/**
- * Boilerplate, pick up our HTML and CSS.
- */
-public class AccountManagementPageAbstract extends WebPage {
-
- private static final long serialVersionUID = 1L;
-
- private static final String ID_PAGE_TITLE = "pageTitle";
- private static final String ID_APPLICATION_NAME = "applicationName";
-
- private static final String ID_EXCEPTION_STACK_TRACE = "exceptionStackTrace";
-
- /**
- * {@link com.google.inject.Inject}ed when {@link #init() initialized}.
- */
- @Inject
- @Named("applicationName")
- private String applicationName;
-
- /**
- * {@link com.google.inject.Inject}ed when {@link #init() initialized}.
- */
- @Inject
- @Named("applicationCss")
- private String applicationCss;
-
- /**
- * {@link com.google.inject.Inject}ed when {@link #init() initialized}.
- */
- @Inject
- @Named("applicationJs")
- private String applicationJs;
-
- /**
- * If set by {@link PageAbstract}.
- */
- protected static ExceptionModel getAndClearExceptionModelIfAny() {
- ExceptionModel exceptionModel = PageAbstract.EXCEPTION.get();
- PageAbstract.EXCEPTION.remove();
- return exceptionModel;
- }
-
- protected AccountManagementPageAbstract(final PageParameters parameters, final ExceptionModel exceptionModel) {
- super(parameters);
-
- addPageTitle();
- addApplicationName();
-
- if(exceptionModel != null) {
- add(new ExceptionStackTracePanel(ID_EXCEPTION_STACK_TRACE, exceptionModel));
- } else {
- add(new WebMarkupContainer(ID_EXCEPTION_STACK_TRACE).setVisible(false));
- }
- }
-
- private MarkupContainer addPageTitle() {
- return add(new Label(ID_PAGE_TITLE, applicationName));
- }
-
- private void addApplicationName() {
- add(new Label(ID_APPLICATION_NAME, applicationName));
- }
-
- @Override
- public void renderHead(IHeaderResponse response) {
- super.renderHead(response);
- response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(Application.get().getJavaScriptLibrarySettings().getJQueryReference())));
-
- if(applicationCss != null) {
- response.render(CssReferenceHeaderItem.forUrl(applicationCss));
- }
- if(applicationJs != null) {
- response.render(JavaScriptReferenceHeaderItem.forUrl(applicationJs));
- }
- }
-
-
-
- // ///////////////////////////////////////////////////
- // System components
- // ///////////////////////////////////////////////////
-
- protected IsisConfiguration getConfiguration() {
- return IsisContext.getConfiguration();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountConfirmationMap.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountConfirmationMap.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountConfirmationMap.java
new file mode 100644
index 0000000..fa7c1b1
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountConfirmationMap.java
@@ -0,0 +1,154 @@
+/*
+ * 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.Map;
+
+import org.apache.wicket.MetaDataKey;
+import org.apache.wicket.util.collections.MostRecentlyUsedMap;
+import org.apache.wicket.util.time.Duration;
+import org.apache.wicket.util.time.Time;
+
+/**
+ * A map that contains the emails to be verified. It has a constraint on the maximum entries that it
+ * can contain, and a constraint on the duration of time an entry is considered valid/non-expired
+ */
+public class AccountConfirmationMap extends MostRecentlyUsedMap<String, Object>
+{
+ private static final long serialVersionUID = 1L;
+
+ public static final MetaDataKey<AccountConfirmationMap> KEY = new MetaDataKey<AccountConfirmationMap>() {
+ };
+
+ /**
+ * The actual object that is stored as a value of the map. It wraps the email and
+ * assigns it a creation time.
+ */
+ private static class Value
+ {
+ /** the original email to store */
+ private String email;
+
+ /** the time when this email is stored */
+ private Time creationTime;
+ }
+
+ /**
+ * The duration of time before a {@link Value} is considered as expired
+ */
+ private final Duration lifetime;
+
+ /**
+ * Construct.
+ *
+ * @param maxEntries
+ * how much entries this map can contain
+ * @param lifetime
+ * the duration of time to keep an entry in the map before considering it expired
+ */
+ public AccountConfirmationMap(int maxEntries, Duration lifetime)
+ {
+ super(maxEntries);
+
+ this.lifetime = lifetime;
+ }
+
+ @Override
+ protected synchronized boolean removeEldestEntry(java.util.Map.Entry<String, Object> eldest)
+ {
+ boolean removed = super.removeEldestEntry(eldest);
+ if (removed == false)
+ {
+ Value value = (Value)eldest.getValue();
+ if (value != null)
+ {
+ Duration elapsedTime = Time.now().subtract(value.creationTime);
+ if (lifetime.lessThanOrEqual(elapsedTime))
+ {
+ removedValue = value.email;
+ removed = true;
+ }
+ }
+ }
+ return removed;
+ }
+
+ @Override
+ public String put(String key, Object email)
+ {
+ if (!(email instanceof String))
+ {
+ throw new IllegalArgumentException(AccountConfirmationMap.class.getSimpleName() +
+ " can store only instances of " + String.class.getSimpleName() + ": " + email);
+ }
+
+ Value value = new Value();
+ value.creationTime = Time.now();
+ value.email = (String)email;
+
+ Value oldValue;
+ synchronized (this)
+ {
+ oldValue = (Value)super.put(key, value);
+ }
+
+ return oldValue != null ? oldValue.email : null;
+ }
+
+ @Override
+ public String get(Object key)
+ {
+ String result = null;
+ Value value;
+ synchronized (this)
+ {
+ value = (Value)super.get(key);
+ }
+ if (value != null)
+ {
+ Duration elapsedTime = Time.now().subtract(value.creationTime);
+ if (lifetime.greaterThan(elapsedTime))
+ {
+ result = value.email;
+ }
+ else
+ {
+ // expired, remove it
+ remove(key);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public String remove(Object key)
+ {
+ Value removedValue;
+ synchronized (this)
+ {
+ removedValue = (Value)super.remove(key);
+ }
+
+ return removedValue != null ? removedValue.email : null;
+ }
+
+ @Override
+ public void putAll(Map<? extends String, ?> m)
+ {
+ throw new UnsupportedOperationException();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.html
new file mode 100644
index 0000000..b59b636
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.html
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<!--
+ 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.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:wicket="http://wicket.apache.org"
+ xml:lang="en"
+ lang="en">
+ <head>
+ <wicket:header-items/>
+ <title wicket:id="pageTitle"></title>
+ </head>
+ <body>
+ <div class="accountManagementPanel container-fluid">
+ <div class="jumbotron" style="background-color: transparent">
+
+ <div class="row">
+ <div class="col-sm-12"> </div>
+ </div>
+ <div class="row">
+ <div class="col-sm-12"> </div>
+ </div>
+ <div class="row">
+ <div class="col-sm-12"> </div>
+ </div>
+
+ <div class="row">
+ <div class="headerContainer col-sm-offset-4 col-sm-4">
+ <h1 wicket:id="applicationName" class="applicationName">[application name]</h1>
+ </div>
+ </div>
+
+ <div class="row">
+ <div class="col-sm-12"> </div>
+ </div>
+ <div class="row">
+ <div class="col-sm-12"> </div>
+ </div>
+
+ <wicket:child/>
+
+ </div>
+ <div wicket:id="exceptionStackTrace" class="exceptionStackTrace"></div>
+ </div>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.java
new file mode 100644
index 0000000..3470886
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.java
@@ -0,0 +1,127 @@
+/*
+ * 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 com.google.inject.Inject;
+import com.google.inject.name.Named;
+import org.apache.wicket.Application;
+import org.apache.wicket.MarkupContainer;
+import org.apache.wicket.markup.head.CssReferenceHeaderItem;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.head.JavaScriptHeaderItem;
+import org.apache.wicket.markup.head.JavaScriptReferenceHeaderItem;
+import org.apache.wicket.markup.head.PriorityHeaderItem;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.wicket.ui.errors.ExceptionModel;
+import org.apache.isis.viewer.wicket.ui.errors.ExceptionStackTracePanel;
+import org.apache.isis.viewer.wicket.ui.pages.PageAbstract;
+
+/**
+ * Boilerplate, pick up our HTML and CSS.
+ */
+public class AccountManagementPageAbstract extends WebPage {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String ID_PAGE_TITLE = "pageTitle";
+ private static final String ID_APPLICATION_NAME = "applicationName";
+
+ private static final String ID_EXCEPTION_STACK_TRACE = "exceptionStackTrace";
+
+ /**
+ * {@link com.google.inject.Inject}ed when {@link #init() initialized}.
+ */
+ @Inject
+ @Named("applicationName")
+ private String applicationName;
+
+ /**
+ * {@link com.google.inject.Inject}ed when {@link #init() initialized}.
+ */
+ @Inject
+ @Named("applicationCss")
+ private String applicationCss;
+
+ /**
+ * {@link com.google.inject.Inject}ed when {@link #init() initialized}.
+ */
+ @Inject
+ @Named("applicationJs")
+ private String applicationJs;
+
+ /**
+ * If set by {@link org.apache.isis.viewer.wicket.ui.pages.PageAbstract}.
+ */
+ protected static ExceptionModel getAndClearExceptionModelIfAny() {
+ ExceptionModel exceptionModel = PageAbstract.EXCEPTION.get();
+ PageAbstract.EXCEPTION.remove();
+ return exceptionModel;
+ }
+
+ protected AccountManagementPageAbstract(final PageParameters parameters, final ExceptionModel exceptionModel) {
+ super(parameters);
+
+ addPageTitle();
+ addApplicationName();
+
+ if(exceptionModel != null) {
+ add(new ExceptionStackTracePanel(ID_EXCEPTION_STACK_TRACE, exceptionModel));
+ } else {
+ add(new WebMarkupContainer(ID_EXCEPTION_STACK_TRACE).setVisible(false));
+ }
+ }
+
+ private MarkupContainer addPageTitle() {
+ return add(new Label(ID_PAGE_TITLE, applicationName));
+ }
+
+ private void addApplicationName() {
+ add(new Label(ID_APPLICATION_NAME, applicationName));
+ }
+
+ @Override
+ public void renderHead(IHeaderResponse response) {
+ super.renderHead(response);
+ response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(Application.get().getJavaScriptLibrarySettings().getJQueryReference())));
+
+ if(applicationCss != null) {
+ response.render(CssReferenceHeaderItem.forUrl(applicationCss));
+ }
+ if(applicationJs != null) {
+ response.render(JavaScriptReferenceHeaderItem.forUrl(applicationJs));
+ }
+ }
+
+
+
+ // ///////////////////////////////////////////////////
+ // System components
+ // ///////////////////////////////////////////////////
+
+ protected IsisConfiguration getConfiguration() {
+ return IsisContext.getConfiguration();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.properties
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.properties b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.properties
new file mode 100644
index 0000000..62ae68d
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/AccountManagementPageAbstract.properties
@@ -0,0 +1,53 @@
+#
+# 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.
+#
+
+signUpHeader=Sign Up
+emailLabel=Email
+emailPlaceholder=Enter an email for the new account
+signUpPasswordLabel=Password
+passwordPlaceholder=Enter password
+emailIsNotAvailable=The given email is already in use
+signUpButtonLabel=Verify email
+emailSentMessage=An automatic email has been sent to '${email}' for verification.
+
+passwordResetHeader=Forgot password
+emailPlaceholder=Enter your email
+passwordLabel=Password
+passwordPlaceholder=Enter your new password
+confirmPasswordLabel=Confirm password
+confirmPasswordPlaceholder=Type the same password again
+passwordResetSubmitLabel=Submit
+emailSentMessage=An automatic email has been sent to '${email}' for verification.
+noSuchUserByEmail=There is no account with this email
+passwordChangeSuccessful=The password has been changed successfully. You can <a href="${signInUrl}">login</a> now.
+passwordChangeUnsuccessful=There was a problem while updating the password. Please try again.
+passwordResetExpiredOrInvalidToken=You are trying to reset the password for an expired or invalid token
+noUserForAnEmailValidToken=The account seems to be either already deleted or has changed its email address. Please try again.
+
+registerHeader=Register
+usernameLabel=Username
+usernamePlaceholder=Username
+emailLabel=Email
+emailPlaceholder=Enter email
+passwordPlaceholder=Enter password
+confirmPasswordLabel=Confirm password
+confirmPasswordPlaceholder=Confirm password
+registerButtonLabel=Register
+resetButtonLabel=Reset
+usernameIsNotAvailable=The provided username is already in use
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/EmailAvailableValidator.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/EmailAvailableValidator.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/EmailAvailableValidator.java
new file mode 100644
index 0000000..92a819b
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/EmailAvailableValidator.java
@@ -0,0 +1,40 @@
+package org.apache.isis.viewer.wicket.ui.pages.accmngt;
+
+import org.apache.wicket.validation.IValidatable;
+import org.apache.wicket.validation.IValidator;
+import org.apache.wicket.validation.ValidationError;
+import org.apache.isis.applib.services.userreg.UserRegistrationService;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+
+/**
+ * Validates that an email is or is not already in use by another user
+ */
+public class EmailAvailableValidator implements IValidator<String> {
+
+ public static final EmailAvailableValidator EXISTS = new EmailAvailableValidator(true, "noSuchUserByEmail");
+ public static final EmailAvailableValidator DOESNT_EXIST = new EmailAvailableValidator(false, "emailIsNotAvailable");
+
+ private final boolean emailExists;
+ private final String resourceKey;
+
+ private EmailAvailableValidator(boolean emailExists, String resourceKey) {
+ this.emailExists = emailExists;
+ this.resourceKey = resourceKey;
+ }
+
+ @Override
+ public void validate(final IValidatable<String> validatable) {
+ IsisContext.doInSession(new Runnable() {
+ @Override
+ public void run() {
+ UserRegistrationService userRegistrationService = IsisContext.getPersistenceSession().getServicesInjector().lookupService(UserRegistrationService.class);
+ String email = validatable.getValue();
+ boolean emailExists1 = userRegistrationService.emailExists(email);
+ if (emailExists1 != emailExists) {
+ validatable.error(new ValidationError().addKey(resourceKey));
+ }
+ }
+ });
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/UsernameAvailableValidator.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/UsernameAvailableValidator.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/UsernameAvailableValidator.java
new file mode 100644
index 0000000..ad0c071
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/UsernameAvailableValidator.java
@@ -0,0 +1,34 @@
+package org.apache.isis.viewer.wicket.ui.pages.accmngt;
+
+import org.apache.wicket.validation.IValidatable;
+import org.apache.wicket.validation.IValidator;
+import org.apache.wicket.validation.ValidationError;
+import org.apache.isis.applib.services.userreg.UserRegistrationService;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+
+/**
+ * Validates that an username is or is not already in use by someone else
+ */
+public class UsernameAvailableValidator implements IValidator<String> {
+
+ public static final UsernameAvailableValidator INSTANCE = new UsernameAvailableValidator();
+
+ private UsernameAvailableValidator() {
+ }
+
+ @Override
+ public void validate(final IValidatable<String> validatable) {
+ IsisContext.doInSession(new Runnable() {
+ @Override
+ public void run() {
+ UserRegistrationService userRegistrationService = IsisContext.getPersistenceSession().getServicesInjector().lookupService(UserRegistrationService.class);
+ String username = validatable.getValue();
+ boolean usernameExists = userRegistrationService.usernameExists(username);
+ if (usernameExists) {
+ validatable.error(new ValidationError().addKey("usernameIsNotAvailable"));
+ }
+ }
+ });
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetEmailPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetEmailPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetEmailPanel.html
new file mode 100644
index 0000000..ca8af7d
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetEmailPanel.html
@@ -0,0 +1,32 @@
+<?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.
+-->
+<html xmlns:wicket="http://wicket.apache.org">
+ <body>
+ <wicket:panel>
+ <form wicket:id="signUpForm" role="form">
+ <div class="form-group" wicket:id="formGroup">
+ <label wicket:for="email" class="control-label"><wicket:message key="emailLabel"/></label>
+ <input type="text" class="form-control" wicket:id="email" wicket:message="placeholder:emailPlaceholder"/>
+ </div>
+
+ <button type="submit" wicket:id="passwordResetSubmit" class="btn btn-primary"><wicket:message key="passwordResetSubmitLabel"/></button>
+ </form>
+
+ </wicket:panel>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetEmailPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetEmailPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetEmailPanel.java
new file mode 100644
index 0000000..804b2df
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetEmailPanel.java
@@ -0,0 +1,112 @@
+/*
+ * 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.password_reset;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+import javax.inject.Inject;
+import org.apache.wicket.markup.html.form.Button;
+import org.apache.wicket.markup.html.form.RequiredTextField;
+import org.apache.wicket.markup.html.form.StatelessForm;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.ResourceModel;
+import org.apache.wicket.request.Url;
+import org.apache.wicket.request.UrlRenderer;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.apache.wicket.validation.validator.EmailAddressValidator;
+import org.apache.isis.applib.services.email.EmailNotificationService;
+import org.apache.isis.applib.services.email.events.PasswordResetEvent;
+import org.apache.isis.viewer.wicket.ui.components.widgets.bootstrap.FormGroup;
+import org.apache.isis.viewer.wicket.ui.pages.accmngt.AccountConfirmationMap;
+import org.apache.isis.viewer.wicket.ui.pages.accmngt.EmailAvailableValidator;
+
+/**
+ * A panel with a form for creation of new users
+ */
+public class PasswordResetEmailPanel extends Panel {
+
+ /**
+ * Constructor
+ *
+ * @param id
+ * the component id
+ */
+ public PasswordResetEmailPanel(final String id) {
+ super(id);
+
+ StatelessForm<Void> form = new StatelessForm<>("signUpForm");
+ addOrReplace(form);
+
+ final RequiredTextField<String> emailField = new RequiredTextField<>("email", Model.of(""));
+ emailField.setLabel(new ResourceModel("emailLabel"));
+ emailField.add(EmailAddressValidator.getInstance());
+ emailField.add(EmailAvailableValidator.EXISTS);
+
+ FormGroup formGroup = new FormGroup("formGroup", emailField);
+ form.add(formGroup);
+
+ formGroup.add(emailField);
+
+ Button signUpButton = new Button("passwordResetSubmit") {
+ @Override
+ public void onSubmit() {
+ super.onSubmit();
+
+ String email = emailField.getModelObject();
+
+ String confirmationUrl = createUrl(email);
+
+ boolean emailSent = emailService.send(new PasswordResetEvent(email, confirmationUrl));
+ if (emailSent) {
+ Map<String, String> map = new HashMap<>();
+ map.put("email", email);
+ IModel<Map<String, String>> model = Model.ofMap(map);
+ String emailSentMessage = getString("emailSentMessage", model);
+ success(emailSentMessage);
+ }
+ }
+ };
+
+ form.add(signUpButton);
+ }
+
+ private String createUrl(String email) {
+ String uuid = UUID.randomUUID().toString();
+ uuid = uuid.replace("-", "");
+
+ // TODO mgrigorov: either improve the API or use a DB table for this
+ AccountConfirmationMap accountConfirmationMap = getApplication().getMetaData(AccountConfirmationMap.KEY);
+ accountConfirmationMap.put(uuid, email);
+
+ PageParameters parameters = new PageParameters();
+ parameters.set(0, uuid);
+ CharSequence relativeUrl = urlFor(PasswordResetPage.class, parameters);
+ UrlRenderer urlRenderer = getRequestCycle().getUrlRenderer();
+ String fullUrl = urlRenderer.renderFullUrl(Url.parse(relativeUrl));
+
+ return fullUrl;
+ }
+
+ @Inject
+ private EmailNotificationService emailService;
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPage.css
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPage.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPage.css
new file mode 100644
index 0000000..3727ba1
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPage.css
@@ -0,0 +1,100 @@
+/*
+ * 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.
+ */
+
+
+#header .applicationName {
+ display:none;
+}
+
+ .loginPanel {
+ width:310px;
+ background-color:#FFFFFF;
+ padding:20px;
+ border-radius:4px;
+ -moz-border-radius:4px;
+ -webkit-border-radius:4px;
+ margin-bottom:1%;
+ position:absolute;
+ clear:both;
+ height:200px;
+ left:50%;
+ top:50%;
+ margin-left:-175px;
+ margin-top:-100px;
+ }
+
+ .loginPanel h2 {
+ color:#423D37;
+ font-size:1.6em;
+ letter-spacing:0px;
+ line-height:150%;
+ margin-bottom:10px;
+ }
+
+ .loginPanel table {
+ width:100%;
+}
+
+.loginPanel table tr td {
+ padding:5px 0px;
+ text-align:left !important;
+}
+
+.loginPanel form input[type=text],
+.loginPanel form input[type=password] {
+ border-radius:4px;
+ -moz-borer-radius:4px;
+ -webkit-border-radius:4px;
+ padding:6px;
+ background-color:#F0EFEA;
+ border:1px solid #F0EFEA;
+ border-top:1px solid #CCCBC7;
+}
+
+
+.loginPanel form input[type=submit] {
+ background-color: #20B5C2;
+ border: 0 none;
+ border-radius: 4px 4px 4px 4px;
+ color: #FFFFFF;
+ cursor: pointer;
+ display: inline-block;
+ font-size: 0.9em;
+ padding: 5px 10px;
+}
+
+.loginPanel form input[type=reset] {
+ background-color: #E4E4DB;
+ border: 0 none;
+ border-radius: 4px 4px 4px 4px;
+ color: #46423C;
+ cursor: pointer;
+ display: inline-block;
+ font-size: 0.9em;
+ padding: 5px 10px;
+ text-transform: uppercase;
+}
+
+.loginPanel table tr td {
+ color:#46423C;
+}
+
+.wicketSignInPanel .mainMessage {
+ margin-top: 550px;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPage.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPage.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPage.html
new file mode 100644
index 0000000..1f8aa1d
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPage.html
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<!--
+ 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.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:wicket="http://wicket.apache.org"
+ xml:lang="en"
+ lang="en">
+ <body>
+ <wicket:extend>
+ <div class="row">
+ <div class="passwordResetPanel col-sm-offset-4 col-sm-4">
+ <div wicket:id="feedback"></div>
+
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <div class="panel-title"><wicket:message key="passwordResetHeader"/></div>
+ </div>
+ <div class="panel-body" wicket:id="passwordResetPanel"></div>
+ </div>
+ </div>
+ </div>
+ </wicket:extend>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPage.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPage.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPage.java
new file mode 100644
index 0000000..8386fa4
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPage.java
@@ -0,0 +1,113 @@
+/*
+ * 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.password_reset;
+
+import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;
+
+import java.util.concurrent.Callable;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.apache.wicket.util.string.StringValue;
+import org.apache.wicket.util.string.Strings;
+import org.apache.isis.applib.services.userreg.UserRegistrationService;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.wicket.ui.errors.ExceptionModel;
+import org.apache.isis.viewer.wicket.ui.pages.accmngt.AccountManagementPageAbstract;
+import org.apache.isis.viewer.wicket.ui.pages.accmngt.AccountConfirmationMap;
+
+/**
+ * A page used for resetting the password of an user.
+ */
+public class PasswordResetPage extends AccountManagementPageAbstract {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String ID_CONTENT_PANEL = "passwordResetPanel";
+
+ public PasswordResetPage(final PageParameters parameters) {
+ this(parameters, getAndClearExceptionModelIfAny());
+ }
+
+ private PasswordResetPage(final PageParameters parameters, ExceptionModel exceptionModel) {
+ super(parameters, exceptionModel);
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ add(new NotificationPanel("feedback"));
+
+ StringValue uuidValue = getPageParameters().get(0);
+ if (uuidValue.isEmpty()) {
+ addPasswordResetEmailPanel(ID_CONTENT_PANEL);
+ } else {
+ String uuid = uuidValue.toString();
+
+ AccountConfirmationMap accountConfirmationMap = getApplication().getMetaData(AccountConfirmationMap.KEY);
+ final String email = accountConfirmationMap.get(uuid);
+ if (Strings.isEmpty(email)) {
+ error(getString("passwordResetExpiredOrInvalidToken"));
+ addOrReplace(addPasswordResetEmailPanel(ID_CONTENT_PANEL));
+ } else {
+ Boolean emailExists = IsisContext.doInSession(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ UserRegistrationService userRegistrationService = IsisContext.getPersistenceSession().getServicesInjector().lookupService(UserRegistrationService.class);
+ return userRegistrationService.emailExists(email);
+ }
+ });
+ if (!emailExists) {
+ error(getString("noUserForAnEmailValidToken"));
+ addOrReplace(addPasswordResetEmailPanel(ID_CONTENT_PANEL));
+ } else {
+ addPasswordResetPanel(ID_CONTENT_PANEL, uuid);
+ }
+ }
+ }
+ }
+
+ /**
+ * Shows a panel with password reset form fields.
+ *
+ * @param id The component id
+ * @param uuid A unique id used to identify the email of the user whose password will be reset
+ * @return A panel with "password reset" form fields
+ */
+ protected PasswordResetPanel addPasswordResetPanel(String id, String uuid) {
+ final PasswordResetPanel passwordResetPanel = new PasswordResetPanel(id, uuid);
+ addOrReplace(passwordResetPanel);
+ return passwordResetPanel;
+ }
+
+ /**
+ * Shows a panel where where the user has to provide her email address.
+ * An email with unique url will be sent to this email address. Once clicked
+ * {@link #addPasswordResetPanel(String, String)} will be used to actually
+ * change the password
+ *
+ * @param id The component id
+ * @return A panel with "send email for password reset" functionality
+ */
+ protected PasswordResetEmailPanel addPasswordResetEmailPanel(String id) {
+ final PasswordResetEmailPanel passwordResetEmailPanel = new PasswordResetEmailPanel(id);
+ addOrReplace(passwordResetEmailPanel);
+ return passwordResetEmailPanel;
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPanel.html
new file mode 100644
index 0000000..8348019
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPanel.html
@@ -0,0 +1,37 @@
+<?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.
+-->
+<html xmlns:wicket="http://wicket.apache.org">
+ <body>
+ <wicket:panel>
+ <form wicket:id="passwordResetForm" role="form">
+ <div class="form-group">
+ <label wicket:for="password" class="control-label"><wicket:message key="passwordLabel"/></label>
+ <input type="password" class="form-control" wicket:id="password" wicket:message="placeholder:passwordPlaceholder"/>
+ </div>
+
+ <div class="form-group">
+ <label wicket:for="confirmPassword" class="control-label"><wicket:message key="confirmPasswordLabel"/></label>
+ <input type="password" class="form-control" wicket:id="confirmPassword" wicket:message="placeholder:confirmPasswordPlaceholder"/>
+ </div>
+
+ <button type="submit" wicket:id="passwordResetSubmit" class="btn btn-primary"><wicket:message key="passwordResetSubmitLabel"/></button>
+ </form>
+
+ </wicket:panel>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPanel.java
new file mode 100644
index 0000000..2373af1
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/password_reset/PasswordResetPanel.java
@@ -0,0 +1,114 @@
+/*
+ * 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.password_reset;
+
+import de.agilecoders.wicket.core.markup.html.bootstrap.common.INotificationMessage;
+import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationMessage;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import javax.inject.Inject;
+import org.apache.wicket.Page;
+import org.apache.wicket.markup.html.form.Button;
+import org.apache.wicket.markup.html.form.PasswordTextField;
+import org.apache.wicket.markup.html.form.StatelessForm;
+import org.apache.wicket.markup.html.form.validation.EqualPasswordInputValidator;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.ResourceModel;
+import org.apache.isis.applib.services.userreg.UserRegistrationService;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.wicket.model.models.PageType;
+import org.apache.isis.viewer.wicket.ui.pages.PageClassRegistry;
+import org.apache.isis.viewer.wicket.ui.pages.accmngt.AccountConfirmationMap;
+
+/**
+ * A panel with a form for creation of new users
+ */
+public class PasswordResetPanel extends Panel {
+
+ /**
+ * Constructor
+ *
+ * @param id The component id
+ * @param uuid The unique id to find the user's email address
+ */
+ public PasswordResetPanel(final String id, final String uuid) {
+ super(id);
+
+ StatelessForm<Void> form = new StatelessForm<>("passwordResetForm");
+ addOrReplace(form);
+
+ final PasswordTextField passwordField = new PasswordTextField("password", Model.of(""));
+ passwordField.setLabel(new ResourceModel("passwordLabel"));
+ form.add(passwordField);
+
+ final PasswordTextField confirmPasswordField = new PasswordTextField("confirmPassword", Model.of(""));
+ confirmPasswordField.setLabel(new ResourceModel("confirmPasswordLabel"));
+ form.add(confirmPasswordField);
+
+ form.add(new EqualPasswordInputValidator(passwordField, confirmPasswordField));
+
+ Button signUpButton = new Button("passwordResetSubmit") {
+ @Override
+ public void onSubmit() {
+ super.onSubmit();
+
+ final String password = confirmPasswordField.getModelObject();
+
+ final AccountConfirmationMap accountConfirmationMap = getApplication().getMetaData(AccountConfirmationMap.KEY);
+
+ Boolean passwordUpdated = IsisContext.doInSession(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ String email = accountConfirmationMap.get(uuid);
+
+ UserRegistrationService userRegistrationService = IsisContext.getPersistenceSession().getServicesInjector().lookupService(UserRegistrationService.class);
+ return userRegistrationService.updatePasswordByEmail(email, password);
+ }
+ });
+
+ if (passwordUpdated) {
+ accountConfirmationMap.remove(uuid);
+ success(createPasswordChangeSuccessfulMessage());
+ } else {
+ error(getString("passwordChangeUnsuccessful"));
+ }
+ }
+ };
+
+ form.add(signUpButton);
+ }
+
+ private INotificationMessage createPasswordChangeSuccessfulMessage() {
+ Class<? extends Page> signInPage = pageClassRegistry.getPageClass(PageType.SIGN_IN);
+ CharSequence signInUrl = urlFor(signInPage, null);
+ Map<String, CharSequence> map = new HashMap<>();
+ map.put("signInUrl", signInUrl);
+ String passwordChangeSuccessful = getString("passwordChangeSuccessful", Model.ofMap(map));
+ NotificationMessage message = new NotificationMessage(Model.of(passwordChangeSuccessful));
+ message.escapeModelStrings(false);
+ return message;
+ }
+
+ @Inject
+ private PageClassRegistry pageClassRegistry;
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPage.css
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPage.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPage.css
new file mode 100644
index 0000000..eaeea17
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPage.css
@@ -0,0 +1,18 @@
+/*
+ * 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.
+ */
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPage.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPage.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPage.html
new file mode 100644
index 0000000..8e7aa84
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPage.html
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<!--
+ 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.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:wicket="http://wicket.apache.org"
+ xml:lang="en"
+ lang="en">
+ <body>
+ <wicket:extend>
+ <div class="row">
+ <div class="registerPanel col-sm-offset-4 col-sm-4">
+ <div wicket:id="feedback"></div>
+
+ <h2><wicket:message key="registerHeader">Register</wicket:message></h2>
+ <div wicket:id="content"></div>
+ </div>
+ </div>
+ </wicket:extend>
+ </body>
+
+</html>
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPage.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPage.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPage.java
new file mode 100644
index 0000000..6afa6d0
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPage.java
@@ -0,0 +1,80 @@
+/*
+ * 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.register;
+
+import de.agilecoders.wicket.core.markup.html.bootstrap.common.NotificationPanel;
+
+import javax.inject.Inject;
+import org.apache.wicket.Page;
+import org.apache.wicket.RestartResponseException;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.apache.wicket.util.string.StringValue;
+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.accmngt.AccountManagementPageAbstract;
+import org.apache.isis.viewer.wicket.ui.pages.PageClassRegistry;
+import org.apache.isis.viewer.wicket.ui.pages.accmngt.AccountConfirmationMap;
+
+/**
+ * Web page representing the about page.
+ */
+public class RegisterPage extends AccountManagementPageAbstract {
+
+ private static final long serialVersionUID = 1L;
+
+ public RegisterPage(final PageParameters parameters) {
+ this(parameters, getAndClearExceptionModelIfAny());
+ }
+
+ private RegisterPage(final PageParameters parameters, final ExceptionModel exceptionModel) {
+ super(parameters, exceptionModel);
+ }
+
+ @Override
+ protected void onInitialize() {
+ super.onInitialize();
+
+ add(new NotificationPanel("feedback"));
+
+ final StringValue uuidValue = getPageParameters().get(0);
+ if (uuidValue.isEmpty()) {
+ goToSignUpPage();
+ } else {
+ String uuid = uuidValue.toString();
+
+ AccountConfirmationMap accountConfirmationMap = getApplication().getMetaData(AccountConfirmationMap.KEY);
+ final String email = accountConfirmationMap.get(uuid);
+ if (Strings.isEmpty(email)) {
+ goToSignUpPage();
+ } else {
+ addOrReplace(new RegisterPanel("content", uuidValue.toString()));
+ }
+ }
+ }
+
+ private void goToSignUpPage() {
+ Class<? extends Page> signUpPageClass = pageClassRegistry.getPageClass(PageType.SIGN_UP);
+ throw new RestartResponseException(signUpPageClass);
+ }
+
+ @Inject
+ private PageClassRegistry pageClassRegistry;
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPanel.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPanel.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPanel.html
new file mode 100644
index 0000000..a6c413b
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPanel.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html xmlns:wicket="http://wicket.apache.org">
+ <head lang="en">
+ <meta charset="UTF-8">
+ <title></title>
+ </head>
+ <body>
+ <wicket:panel>
+ <form wicket:id="registerForm" role="form">
+ <div class="form-group" wicket:id="usernameFormGroup">
+ <label wicket:for="username" class="control-label"><wicket:message key="usernameLabel"/></label>
+ <input type="text" class="form-control" wicket:id="username" wicket:message="placeholder:usernamePlaceholder"/>
+ </div>
+
+ <div class="form-group" wicket:id="passwordFormGroup">
+ <label wicket:for="password" class="control-label"><wicket:message key="passwordLabel"/></label>
+ <input type="password" class="form-control" wicket:id="password" wicket:message="placeholder:passwordPlaceholder"/>
+ </div>
+
+ <div class="form-group" wicket:id="confirmPasswordFormGroup">
+ <label wicket:for="confirmPassword" class="control-label"><wicket:message key="confirmPasswordLabel"/></label>
+ <input type="password" class="form-control" wicket:id="confirmPassword" wicket:message="placeholder:confirmPasswordPlaceholder"/>
+ </div>
+
+ <div class="form-group">
+ <label wicket:for="email"><wicket:message key="emailLabel"/></label>
+ <input type="text" class="form-control" wicket:id="email" readonly tabindex="-1"/>
+ </div>
+
+ <button type="submit" class="btn btn-primary btn-sm"><wicket:message key="registerButtonLabel"/></button>
+ <button type="reset" class="btn btn-default btn-sm"><wicket:message key="resetButtonLabel"/></button>
+ </form>
+ </wicket:panel>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPanel.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPanel.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPanel.java
new file mode 100644
index 0000000..5e06b0f
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPanel.java
@@ -0,0 +1,149 @@
+package org.apache.isis.viewer.wicket.ui.pages.accmngt.register;
+
+import org.apache.wicket.authroles.authentication.AuthenticatedWebSession;
+import org.apache.wicket.markup.html.form.PasswordTextField;
+import org.apache.wicket.markup.html.form.RequiredTextField;
+import org.apache.wicket.markup.html.form.StatelessForm;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.form.validation.EqualPasswordInputValidator;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.CompoundPropertyModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.ResourceModel;
+import org.apache.isis.applib.services.userreg.UserRegistrationService;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.transaction.TransactionalClosureAbstract;
+import org.apache.isis.viewer.wicket.ui.components.widgets.bootstrap.FormGroup;
+import org.apache.isis.viewer.wicket.ui.pages.accmngt.AccountConfirmationMap;
+import org.apache.isis.viewer.wicket.ui.pages.accmngt.UsernameAvailableValidator;
+
+/**
+ * A panel with a form for self-registration of a user
+ */
+public class RegisterPanel extends Panel {
+
+ private static final String ID_REGISTER_FORM = "registerForm";
+
+ public RegisterPanel(String id, String uuid) {
+ super(id);
+
+ add(new RegisterForm(ID_REGISTER_FORM, uuid));
+ }
+
+
+ /**
+ * Register user form.
+ */
+ private static class RegisterForm extends StatelessForm<Registree>
+ {
+ private static final long serialVersionUID = 1L;
+
+ private final String uuid;
+
+ /**
+ * Constructor.
+ *
+ * @param id
+ * id of the form component
+ */
+ public RegisterForm(final String id, final String uuid)
+ {
+ super(id);
+
+ this.uuid = uuid;
+
+ String email = getEmail();
+
+ final Registree registree = new Registree();
+ registree.setEmail(email);
+
+ setModel(new CompoundPropertyModel<>(registree));
+
+ addUsername();
+
+ PasswordTextField password = addPassword();
+ PasswordTextField confirmPassword = addConfirmPassword();
+ add(new EqualPasswordInputValidator(password, confirmPassword));
+
+ addEmail(registree);
+ }
+
+ protected TextField<String> addEmail(final Registree registree) {
+ // use RO-ish model to prevent changing the email with manual form submits
+ TextField<String> emailField = new TextField<>("email", new Model<String>() {
+ @Override
+ public String getObject() {
+ return registree.getEmail();
+ }
+ });
+ addOrReplace(emailField);
+ return emailField;
+ }
+
+ protected PasswordTextField addConfirmPassword() {
+ PasswordTextField confirmPassword = new PasswordTextField("confirmPassword");
+ confirmPassword.setLabel(new ResourceModel("confirmPasswordLabel"));
+ FormGroup confirmPasswordFormGroup = new FormGroup("confirmPasswordFormGroup", confirmPassword);
+ confirmPasswordFormGroup.add(confirmPassword);
+ addOrReplace(confirmPasswordFormGroup);
+ return confirmPassword;
+ }
+
+ protected PasswordTextField addPassword() {
+ PasswordTextField password = new PasswordTextField("password");
+ password.setLabel(new ResourceModel("passwordLabel"));
+ FormGroup passwordFormGroup = new FormGroup("passwordFormGroup", password);
+ passwordFormGroup.add(password);
+ addOrReplace(passwordFormGroup);
+ return password;
+ }
+
+ protected TextField<String> addUsername() {
+ RequiredTextField<String> username = new RequiredTextField<>("username");
+ username.add(UsernameAvailableValidator.INSTANCE);
+ FormGroup usernameFormGroup = new FormGroup("usernameFormGroup", username);
+ usernameFormGroup.add(username);
+ addOrReplace(usernameFormGroup);
+ return username;
+ }
+
+ @Override
+ public final void onSubmit()
+ {
+ final Registree registree = getModelObject();
+
+ IsisContext.doInSession(new Runnable() {
+ @Override
+ public void run() {
+ final UserRegistrationService userRegistrationService = IsisContext.getPersistenceSession().getServicesInjector().lookupService(UserRegistrationService.class);
+
+ IsisContext.getTransactionManager().executeWithinTransaction(new TransactionalClosureAbstract() {
+ @Override
+ public void execute() {
+ userRegistrationService.registerUser(registree.getUsername(), registree.getPassword(), registree.getEmail());
+ removeAccountConfirmation();
+ }
+ });
+ }
+ });
+
+ signIn(registree.getUsername(), registree.getPassword());
+ setResponsePage(getApplication().getHomePage());
+ }
+
+ private boolean signIn(String username, String password)
+ {
+ return AuthenticatedWebSession.get().signIn(username, password);
+ }
+
+ private String getEmail() {
+ AccountConfirmationMap accountConfirmationMap = getApplication().getMetaData(AccountConfirmationMap.KEY);
+ return accountConfirmationMap.get(uuid);
+ }
+
+ private void removeAccountConfirmation() {
+ AccountConfirmationMap accountConfirmationMap = getApplication().getMetaData(AccountConfirmationMap.KEY);
+ accountConfirmationMap.remove(uuid);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/Registree.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/Registree.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/Registree.java
new file mode 100644
index 0000000..9bb476c
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/Registree.java
@@ -0,0 +1,49 @@
+package org.apache.isis.viewer.wicket.ui.pages.accmngt.register;
+
+import java.io.Serializable;
+
+/**
+ * A model object for {@link org.apache.isis.viewer.wicket.ui.pages.accmngt.register.RegisterPanel}
+ */
+public class Registree implements Serializable {
+
+ private String username;
+ private String password;
+ private String confirmPassword;
+ private String email;
+
+ public String getUsername()
+ {
+ return username;
+ }
+
+ public void setUsername(final String username)
+ {
+ this.username = username;
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+ public void setPassword(final String password)
+ {
+ this.password = password;
+ }
+
+ public String getConfirmPassword() {
+ return confirmPassword;
+ }
+
+ public void setConfirmPassword(String confirmPassword) {
+ this.confirmPassword = confirmPassword;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/signup/RegistrationFormPage.css
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/signup/RegistrationFormPage.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/signup/RegistrationFormPage.css
new file mode 100644
index 0000000..3727ba1
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/signup/RegistrationFormPage.css
@@ -0,0 +1,100 @@
+/*
+ * 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.
+ */
+
+
+#header .applicationName {
+ display:none;
+}
+
+ .loginPanel {
+ width:310px;
+ background-color:#FFFFFF;
+ padding:20px;
+ border-radius:4px;
+ -moz-border-radius:4px;
+ -webkit-border-radius:4px;
+ margin-bottom:1%;
+ position:absolute;
+ clear:both;
+ height:200px;
+ left:50%;
+ top:50%;
+ margin-left:-175px;
+ margin-top:-100px;
+ }
+
+ .loginPanel h2 {
+ color:#423D37;
+ font-size:1.6em;
+ letter-spacing:0px;
+ line-height:150%;
+ margin-bottom:10px;
+ }
+
+ .loginPanel table {
+ width:100%;
+}
+
+.loginPanel table tr td {
+ padding:5px 0px;
+ text-align:left !important;
+}
+
+.loginPanel form input[type=text],
+.loginPanel form input[type=password] {
+ border-radius:4px;
+ -moz-borer-radius:4px;
+ -webkit-border-radius:4px;
+ padding:6px;
+ background-color:#F0EFEA;
+ border:1px solid #F0EFEA;
+ border-top:1px solid #CCCBC7;
+}
+
+
+.loginPanel form input[type=submit] {
+ background-color: #20B5C2;
+ border: 0 none;
+ border-radius: 4px 4px 4px 4px;
+ color: #FFFFFF;
+ cursor: pointer;
+ display: inline-block;
+ font-size: 0.9em;
+ padding: 5px 10px;
+}
+
+.loginPanel form input[type=reset] {
+ background-color: #E4E4DB;
+ border: 0 none;
+ border-radius: 4px 4px 4px 4px;
+ color: #46423C;
+ cursor: pointer;
+ display: inline-block;
+ font-size: 0.9em;
+ padding: 5px 10px;
+ text-transform: uppercase;
+}
+
+.loginPanel table tr td {
+ color:#46423C;
+}
+
+.wicketSignInPanel .mainMessage {
+ margin-top: 550px;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/f34e066f/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/signup/RegistrationFormPage.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/signup/RegistrationFormPage.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/signup/RegistrationFormPage.html
new file mode 100644
index 0000000..01d0358
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/signup/RegistrationFormPage.html
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+<!--
+ 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.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:wicket="http://wicket.apache.org"
+ xml:lang="en"
+ lang="en">
+ <body>
+ <wicket:extend>
+ <div class="row">
+ <div class="loginPanel col-sm-offset-4 col-sm-4">
+ <h2><wicket:message key="signUpHeader"/></h2>
+ <div wicket:id="registrationFormPanel"></div>
+ </div>
+ </div>
+ </wicket:extend>
+ </body>
+</html>