syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmarte...@apache.org
Subject syncope git commit: [SYNCOPE-156] fix for user password managemnet
Date Wed, 11 Nov 2015 16:05:23 GMT
Repository: syncope
Updated Branches:
  refs/heads/master 3a21e437d -> 93ed788b5


[SYNCOPE-156] fix for user password managemnet


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/93ed788b
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/93ed788b
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/93ed788b

Branch: refs/heads/master
Commit: 93ed788b5aed6761d230b36cf7e8f13301ddccae
Parents: 3a21e43
Author: fmartelli <fabio.martelli@gmail.com>
Authored: Wed Nov 11 17:05:08 2015 +0100
Committer: fmartelli <fabio.martelli@gmail.com>
Committed: Wed Nov 11 17:05:08 2015 +0100

----------------------------------------------------------------------
 .../console/wizards/any/PasswordPanel.java      | 85 ++++++++++++++++++
 .../client/console/wizards/any/UserDetails.java | 92 +++++++++++---------
 .../console/wizards/any/PasswordPanel.html      | 44 ++++++++++
 .../client/console/wizards/any/UserDetails.html | 21 +----
 4 files changed, 180 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/93ed788b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PasswordPanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PasswordPanel.java
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PasswordPanel.java
new file mode 100644
index 0000000..147d5cb
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PasswordPanel.java
@@ -0,0 +1,85 @@
+/*
+ * 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.syncope.client.console.wizards.any;
+
+import org.apache.syncope.client.console.commons.JexlHelpUtils;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxPasswordFieldPanel;
+import org.apache.syncope.client.console.wicket.markup.html.form.FieldPanel;
+import org.apache.syncope.common.lib.to.UserTO;
+import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.PasswordTextField;
+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.PropertyModel;
+
+public class PasswordPanel extends Panel {
+
+    private static final long serialVersionUID = 6592027822510220463L;
+
+    public PasswordPanel(
+            final String id, final UserTO userTO, final boolean resetPassword, final boolean
templateMode) {
+        super(id);
+        
+        setOutputMarkupId(true);
+        
+        final Form<?> form = new Form<>("passwordInnerForm");
+        add(form);
+
+        final WebMarkupContainer pwdJexlHelp = JexlHelpUtils.getJexlHelpWebContainer("pwdJexlHelp");
+
+        final AjaxLink<?> pwdQuestionMarkJexlHelp = JexlHelpUtils.getAjaxLink(pwdJexlHelp,
"pwdQuestionMarkJexlHelp");
+        form.add(pwdQuestionMarkJexlHelp);
+        pwdQuestionMarkJexlHelp.add(pwdJexlHelp);
+
+        FieldPanel<String> passwordField = new AjaxPasswordFieldPanel(
+                "password", "password", new PropertyModel<String>(userTO, "password"),
false);
+        passwordField.setRequired(true);
+        passwordField.setMarkupId("password");
+        passwordField.setPlaceholder("password");
+        ((PasswordTextField) passwordField.getField()).setResetPassword(true);
+        form.add(passwordField);
+
+        FieldPanel<String> confirmPasswordField = new AjaxPasswordFieldPanel(
+                "confirmPassword", "confirmPassword", new Model<String>(), false);
+        passwordField.setRequired(true);
+        confirmPasswordField.setMarkupId("confirmPassword");
+        confirmPasswordField.setPlaceholder("confirmPassword");
+        ((PasswordTextField) confirmPasswordField.getField()).setResetPassword(true);
+        form.add(confirmPasswordField);
+
+        form.add(new EqualPasswordInputValidator(passwordField.getField(), confirmPasswordField.getField()));
+
+        if (templateMode) {
+            confirmPasswordField.setEnabled(false);
+            confirmPasswordField.setVisible(false);
+        } else {
+            pwdQuestionMarkJexlHelp.setVisible(false);
+
+            ((PasswordTextField) passwordField.getField()).setResetPassword(resetPassword);
+
+            if (!resetPassword) {
+                confirmPasswordField.getField().setModelObject(userTO.getPassword());
+            }
+            ((PasswordTextField) confirmPasswordField.getField()).setResetPassword(resetPassword);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/93ed788b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/UserDetails.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/UserDetails.java
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/UserDetails.java
index 1b1fa58..e669464 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/UserDetails.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/UserDetails.java
@@ -18,24 +18,32 @@
  */
 package org.apache.syncope.client.console.wizards.any;
 
+import de.agilecoders.wicket.core.markup.html.bootstrap.tabs.Collapsible;
+import java.util.Collections;
+import org.apache.syncope.client.console.commons.Constants;
 import org.apache.syncope.client.console.commons.JexlHelpUtils;
-import org.apache.syncope.client.console.wicket.markup.html.form.AjaxPasswordFieldPanel;
 import org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel;
 import org.apache.syncope.client.console.wicket.markup.html.form.FieldPanel;
 import org.apache.syncope.common.lib.to.UserTO;
+import org.apache.wicket.Component;
+import org.apache.wicket.ajax.AjaxEventBehavior;
+import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
+import org.apache.wicket.extensions.markup.html.tabs.ITab;
 import org.apache.wicket.extensions.wizard.WizardStep;
 import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.form.PasswordTextField;
-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.PropertyModel;
+import org.apache.wicket.model.ResourceModel;
 
 public class UserDetails extends WizardStep {
 
     private static final long serialVersionUID = 6592027822510220463L;
 
+    private static final String PASSWORD_CONTENT_PATH = "tabs:0:body:content";
+
     public UserDetails(final UserTO userTO, final boolean resetPassword, final boolean templateMode)
{
         // ------------------------
         // Username
@@ -59,46 +67,44 @@ public class UserDetails extends WizardStep {
         // ------------------------
         // Password
         // ------------------------
-        final Form<?> form = new Form<>("passwordInnerForm");
-        add(form);
-
-        final WebMarkupContainer pwdJexlHelp = JexlHelpUtils.getJexlHelpWebContainer("pwdJexlHelp");
-
-        final AjaxLink<?> pwdQuestionMarkJexlHelp = JexlHelpUtils.getAjaxLink(pwdJexlHelp,
"pwdQuestionMarkJexlHelp");
-        form.add(pwdQuestionMarkJexlHelp);
-        pwdQuestionMarkJexlHelp.add(pwdJexlHelp);
-
-        FieldPanel<String> passwordField = new AjaxPasswordFieldPanel(
-                "password", "password", new PropertyModel<String>(userTO, "password"),
false);
-        passwordField.setRequired(true);
-        passwordField.setMarkupId("password");
-        passwordField.setPlaceholder("password");
-        ((PasswordTextField) passwordField.getField()).setResetPassword(true);
-        form.add(passwordField);
-
-        FieldPanel<String> confirmPasswordField = new AjaxPasswordFieldPanel(
-                "confirmPassword", "confirmPassword", new Model<String>(), false);
-        confirmPasswordField.setRequired(true);
-        confirmPasswordField.setMarkupId("confirmPassword");
-        confirmPasswordField.setPlaceholder("confirmPassword");
-        ((PasswordTextField) confirmPasswordField.getField()).setResetPassword(true);
-        form.add(confirmPasswordField);
-
-        form.add(new EqualPasswordInputValidator(passwordField.getField(), confirmPasswordField.getField()));
-
-        if (templateMode) {
-            confirmPasswordField.setEnabled(false);
-            confirmPasswordField.setVisible(false);
-        } else {
-            pwdQuestionMarkJexlHelp.setVisible(false);
-
-            ((PasswordTextField) passwordField.getField()).setResetPassword(resetPassword);
-
-            if (!resetPassword) {
-                confirmPasswordField.getField().setModelObject(userTO.getPassword());
+        final Model<Integer> model = Model.of(-1);
+
+        final Collapsible collapsible = new Collapsible("collapsePanel", Collections.<ITab>singletonList(
+                new AbstractTab(new ResourceModel("password.change", "Change password"))
{
+
+                    private static final long serialVersionUID = 1037272333056449378L;
+
+                    @Override
+                    public Panel getPanel(final String panelId) {
+                        final PasswordPanel panel = new PasswordPanel(panelId, userTO, resetPassword,
templateMode);
+                        panel.setEnabled(model.getObject() >= 0);
+                        return panel;
+                    }
+                }
+        ), model) {
+
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            protected Component newTitle(final String markupId, final ITab tab, final Collapsible.State
state) {
+                return super.newTitle(markupId, tab, state).add(new AjaxEventBehavior(Constants.ON_CLICK)
{
+
+                    private static final long serialVersionUID = 1L;
+
+                    @Override
+                    protected void onEvent(final AjaxRequestTarget target) {
+                        model.setObject(model.getObject() == 0 ? -1 : 0);
+                        final Component passwordPanel = get(PASSWORD_CONTENT_PATH);
+                        passwordPanel.setEnabled(model.getObject() >= 0);
+                        target.add(passwordPanel);
+                    }
+                });
             }
-            ((PasswordTextField) confirmPasswordField.getField()).setResetPassword(resetPassword);
-        }
+
+        };
+
+        collapsible.setOutputMarkupId(true);
+        add(collapsible);
         // ------------------------
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/93ed788b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/PasswordPanel.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/PasswordPanel.html
b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/PasswordPanel.html
new file mode 100644
index 0000000..f08c85b
--- /dev/null
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/PasswordPanel.html
@@ -0,0 +1,44 @@
+<!--
+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">
+  <head><title></title></head>
+  <body>
+    <wicket:panel>
+      <form wicket:id="passwordInnerForm">
+        <div class="form-group">
+          <span wicket:id="password"/>
+          <a class="tooltips" wicket:id="pwdQuestionMarkJexlHelp" href="#" alt="Click
to help" title="Click to help">
+            <img src="img/help.png"/>
+            <span wicket:id="pwdJexlHelp" class="tooltips">
+              <wicket:message key="jexl_info"/>
+              <ul>
+                <li><wicket:message key="jexl_ex1"/></li>
+                <li><wicket:message key="jexl_ex2"/></li>
+              </ul>
+              <a href="#" wicket:id="jexlLink" target="_blank"><wicket:message key="jexl_syntax_url"/></a>
+            </span>
+          </a>
+        </div>
+        <div class="form-group">
+          <span wicket:id="confirmPassword"/>
+        </div>
+      </form>
+    </wicket:panel>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/syncope/blob/93ed788b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails.html
b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails.html
index 45e550c..a676f1e 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails.html
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/UserDetails.html
@@ -35,25 +35,8 @@ under the License.
         </a>
       </div>
 
-      <form wicket:id="passwordInnerForm">
-        <div class="form-group">
-          <span wicket:id="password"/>
-          <a class="tooltips" wicket:id="pwdQuestionMarkJexlHelp" href="#" alt="Click
to help" title="Click to help">
-            <img src="img/help.png"/>
-            <span wicket:id="pwdJexlHelp" class="tooltips">
-              <wicket:message key="jexl_info"/>
-              <ul>
-                <li><wicket:message key="jexl_ex1"/></li>
-                <li><wicket:message key="jexl_ex2"/></li>
-              </ul>
-              <a href="#" wicket:id="jexlLink" target="_blank"><wicket:message key="jexl_syntax_url"/></a>
-            </span>
-          </a>
-        </div>
-        <div class="form-group">
-          <span wicket:id="confirmPassword"/>
-        </div>
-      </form>
+      <div wicket:id="collapsePanel"></div>
+
     </wicket:panel>
   </body>
 </html>


Mime
View raw message