Author: ilgrosso
Date: Mon Sep 22 14:37:44 2014
New Revision: 1626792

URL: http://svn.apache.org/r1626792
Log:
[SYNCOPE-135] Password reset request from admin console

Added:
    
syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/pages/RequestPasswordResetModalPage.java
   (with props)
    
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage.html
   (with props)
    
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage.properties
   (with props)
    
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage_it.properties
   (with props)
    
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage_pt_BR.properties
   (with props)
Modified:
    
syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/pages/Login.java
    
syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/pages/UserSelfModalPage.java

Modified: 
syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/pages/Login.java
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/pages/Login.java?rev=1626792&r1=1626791&r2=1626792&view=diff
==============================================================================
--- 
syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/pages/Login.java
 (original)
+++ 
syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/pages/Login.java
 Mon Sep 22 14:37:44 2014
@@ -217,7 +217,7 @@ public class Login extends WebPage {
                             // anonymous authentication needed for password 
reset request
                             authenticate(anonymousUser, anonymousKey);
 
-                            return null;
+                            return new 
RequestPasswordResetModalPage(pwdResetModalWin);
                         }
                     });
 

Added: 
syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/pages/RequestPasswordResetModalPage.java
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/pages/RequestPasswordResetModalPage.java?rev=1626792&view=auto
==============================================================================
--- 
syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/pages/RequestPasswordResetModalPage.java
 (added)
+++ 
syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/pages/RequestPasswordResetModalPage.java
 Mon Sep 22 14:37:44 2014
@@ -0,0 +1,124 @@
+/*
+ * 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.console.pages;
+
+import static org.apache.syncope.console.pages.AbstractBasePage.FORM;
+import static org.apache.syncope.console.pages.AbstractBasePage.LOG;
+
+import org.apache.syncope.common.to.SecurityQuestionTO;
+import org.apache.syncope.console.commons.Constants;
+import org.apache.syncope.console.rest.SecurityQuestionRestClient;
+import org.apache.syncope.console.wicket.markup.html.form.AjaxTextFieldPanel;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
+import org.apache.wicket.ajax.markup.html.form.AjaxButton;
+import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton;
+import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.ResourceModel;
+import org.apache.wicket.spring.injection.annot.SpringBean;
+
+public class RequestPasswordResetModalPage extends BaseModalPage {
+
+    private static final long serialVersionUID = -8419445804421211904L;
+
+    @SpringBean
+    private SecurityQuestionRestClient securityQuestionRestClient;
+
+    public RequestPasswordResetModalPage(final ModalWindow window) {
+        super();
+        setOutputMarkupId(true);
+
+        final Form<?> form = new Form<Object>(FORM);
+        form.setOutputMarkupId(true);
+
+        final AjaxTextFieldPanel securityQuestion =
+                new AjaxTextFieldPanel("securityQuestion", "securityQuestion", 
new Model<String>());
+        securityQuestion.setReadOnly(true);
+        securityQuestion.setRequired(true);
+        securityQuestion.getField().setOutputMarkupId(true);
+        form.add(securityQuestion);
+
+        final AjaxTextFieldPanel username =
+                new AjaxTextFieldPanel("username", "username", new 
Model<String>());
+        username.setRequired(true);
+        username.getField().setOutputMarkupId(true);
+        username.getField().add(new 
AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
+
+            private static final long serialVersionUID = -1107858522700306810L;
+
+            @Override
+            protected void onUpdate(final AjaxRequestTarget target) {
+                try {
+                    SecurityQuestionTO read = 
securityQuestionRestClient.readByUser(username.getModelObject());
+                    securityQuestion.setModelObject(read.getContent());
+                    target.add(securityQuestion);
+                } catch (Exception e) {
+                    LOG.error("While fetching security question for {}", 
username.getModelObject(), e);
+                    error(getString(Constants.ERROR) + ": " + e.getMessage());
+                    feedbackPanel.refresh(target);
+                }
+            }
+        });
+        form.add(username);
+
+        final AjaxTextFieldPanel securityAnswer =
+                new AjaxTextFieldPanel("securityAnswer", "securityAnswer", new 
Model<String>());
+        securityAnswer.setRequired(true);
+        form.add(securityAnswer);
+
+        final AjaxButton submit = new IndicatingAjaxButton(APPLY, new 
ResourceModel(SUBMIT, SUBMIT)) {
+
+            private static final long serialVersionUID = -4804368561204623354L;
+
+            @Override
+            protected void onSubmit(final AjaxRequestTarget target, final 
Form<?> form) {
+                try {
+                    
userSelfRestClient.requestPasswordReset(username.getModelObject(), 
securityAnswer.getModelObject());
+                    window.close(target);
+                } catch (Exception e) {
+                    LOG.error("While requesting password reset for {}", 
username.getModelObject(), e);
+                    error(getString(Constants.ERROR) + ": " + e.getMessage());
+                    feedbackPanel.refresh(target);
+                }
+            }
+        };
+        form.add(submit);
+        form.setDefaultButton(submit);
+
+        final AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new 
ResourceModel(CANCEL)) {
+
+            private static final long serialVersionUID = -958724007591692537L;
+
+            @Override
+            protected void onSubmit(final AjaxRequestTarget target, final 
Form<?> form) {
+                window.close(target);
+            }
+
+            @Override
+            protected void onError(final AjaxRequestTarget target, final 
Form<?> form) {
+            }
+        };
+        cancel.setDefaultFormProcessing(false);
+        form.add(cancel);
+
+        add(form);
+    }
+}

Propchange: 
syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/pages/RequestPasswordResetModalPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/pages/RequestPasswordResetModalPage.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: 
syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/pages/RequestPasswordResetModalPage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/pages/UserSelfModalPage.java
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/pages/UserSelfModalPage.java?rev=1626792&r1=1626791&r2=1626792&view=diff
==============================================================================
--- 
syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/pages/UserSelfModalPage.java
 (original)
+++ 
syncope/branches/1_2_X/console/src/main/java/org/apache/syncope/console/pages/UserSelfModalPage.java
 Mon Sep 22 14:37:44 2014
@@ -23,7 +23,6 @@ import org.apache.syncope.common.mod.Use
 import org.apache.syncope.common.to.UserTO;
 import org.apache.syncope.common.util.AttributableOperations;
 import org.apache.syncope.console.rest.UserSelfRestClient;
-import org.apache.syncope.console.wicket.markup.html.form.AjaxCheckBoxPanel;
 import org.apache.wicket.PageReference;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;

Added: 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage.html
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage.html?rev=1626792&view=auto
==============================================================================
--- 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage.html
 (added)
+++ 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage.html
 Mon Sep 22 14:37:44 2014
@@ -0,0 +1,64 @@
+<!--
+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";>
+  <wicket:extend>
+    <div>
+      <p class="ui-widget ui-corner-all ui-widget-header"><wicket:message 
key="title"/></p>
+      <form wicket:id="form">
+        <div id="formtable">
+          <div class="tablerow alt">
+            <div class="tablecolumn_label medium_fixedsize">
+              <label for="username"><wicket:message key="username"/></label>
+            </div>
+            <div class="tablecolumn_field medium_dynamicsize">
+              <span wicket:id="username">[username]</span>
+            </div>
+          </div>
+
+          <div class="tablerow">
+            <div class="tablecolumn_label medium_fixedsize">
+              <label for="securityQuestion"><wicket:message 
key="securityQuestion"/></label>
+            </div>
+            <div class="tablecolumn_field medium_dynamicsize">
+              <span wicket:id="securityQuestion">[securityQuestion]</span>
+            </div>
+          </div>
+
+          <div class="tablerow">
+            <div class="tablecolumn_label medium_fixedsize">
+              <label for="securityAnswer"><wicket:message 
key="securityAnswer"/></label>
+            </div>
+            <div class="tablecolumn_field medium_dynamicsize">
+              <span wicket:id="securityAnswer">[securityAnswer]</span>
+            </div>
+          </div>
+        </div>
+
+        <div style="margin: 20px 10px 0">
+          <input type="submit"
+                 class="ui-button ui-widget ui-state-default ui-corner-all 
ui-button-text-only"
+                 wicket:id="apply"/>
+          <input type="button"
+                 class="ui-button ui-widget ui-state-default ui-corner-all 
ui-button-text-only"
+                 wicket:id="cancel"/>
+        </div>
+      </form>
+    </div>
+  </wicket:extend>
+</html>

Propchange: 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage.html
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Added: 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage.properties
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage.properties?rev=1626792&view=auto
==============================================================================
--- 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage.properties
 (added)
+++ 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage.properties
 Mon Sep 22 14:37:44 2014
@@ -0,0 +1,20 @@
+# 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.
+securityQuestion=Security question
+title=Password reset
+username=User
+securityAnswer=Security answer

Propchange: 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage.properties
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Added: 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage_it.properties
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage_it.properties?rev=1626792&view=auto
==============================================================================
--- 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage_it.properties
 (added)
+++ 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage_it.properties
 Mon Sep 22 14:37:44 2014
@@ -0,0 +1,20 @@
+# 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.
+securityQuestion=Domanda di sicurezza
+title=Password smarrita
+username=Utente
+securityAnswer=Risposta di sicurezza

Propchange: 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage_it.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage_it.properties
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Added: 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage_pt_BR.properties
URL: 
http://svn.apache.org/viewvc/syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage_pt_BR.properties?rev=1626792&view=auto
==============================================================================
--- 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage_pt_BR.properties
 (added)
+++ 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage_pt_BR.properties
 Mon Sep 22 14:37:44 2014
@@ -0,0 +1,20 @@
+# 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.
+securityQuestion=Pergunta de seguran\u00e7a
+title=Redefini\u00e7\u00e3o de senha
+username=Usu\u00e1rio
+securityAnswer=Resposta de seguran\u00e7a

Propchange: 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage_pt_BR.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
syncope/branches/1_2_X/console/src/main/resources/org/apache/syncope/console/pages/RequestPasswordResetModalPage_pt_BR.properties
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id


Reply via email to