]> source.dussan.org Git - gitblit.git/commitdiff
#932 do not trim passwords anywhere in the ui 940/head
authorRainerW <github@inforw.de>
Thu, 8 Oct 2015 10:32:35 +0000 (12:32 +0200)
committerRainerW <github@inforw.de>
Thu, 8 Oct 2015 10:32:35 +0000 (12:32 +0200)
src/main/java/com/gitblit/wicket/NonTrimmedPasswordTextField.java [new file with mode: 0644]
src/main/java/com/gitblit/wicket/pages/ChangePasswordPage.java
src/main/java/com/gitblit/wicket/pages/EditUserPage.java
src/main/java/com/gitblit/wicket/pages/RootPage.java

diff --git a/src/main/java/com/gitblit/wicket/NonTrimmedPasswordTextField.java b/src/main/java/com/gitblit/wicket/NonTrimmedPasswordTextField.java
new file mode 100644 (file)
index 0000000..1bf34e4
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2013 gitblit.com.
+ *
+ * Licensed 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 com.gitblit.wicket;
+
+import org.apache.wicket.markup.html.form.PasswordTextField;
+import org.apache.wicket.model.IModel;
+
+/**
+ * PasswordText field which will not trim spaces from the input field. This 
+ * ensures the password trimming behaviour is everywhere (ui/ssh/git) the same 
+ * (#932).
+ */
+public class NonTrimmedPasswordTextField extends PasswordTextField
+{
+       private static final long serialVersionUID = 1L;
+       
+       public NonTrimmedPasswordTextField(final String id)
+       {
+               super(id);
+       }
+       
+       public NonTrimmedPasswordTextField(final String id, final IModel<String> model)
+       {
+               super(id, model);
+       }
+
+       @Override
+       protected boolean shouldTrimInput()
+       {
+               return false;
+       }
+
+}
index a6aca22d78e2120fd2a62412dc44fcc5e6ed86e5..259a4bf4f600468301bc279c0c0828cb0d4a422b 100644 (file)
@@ -19,7 +19,6 @@ import java.text.MessageFormat;
 \r
 import org.apache.wicket.RestartResponseException;\r
 import org.apache.wicket.markup.html.form.Button;\r
-import org.apache.wicket.markup.html.form.PasswordTextField;\r
 import org.apache.wicket.markup.html.form.StatelessForm;\r
 import org.apache.wicket.model.IModel;\r
 import org.apache.wicket.model.Model;\r
@@ -31,6 +30,7 @@ import com.gitblit.Keys;
 import com.gitblit.models.UserModel;\r
 import com.gitblit.utils.StringUtils;\r
 import com.gitblit.wicket.GitBlitWebSession;\r
+import com.gitblit.wicket.NonTrimmedPasswordTextField;\r
 \r
 public class ChangePasswordPage extends RootSubPage {\r
 \r
@@ -114,10 +114,10 @@ public class ChangePasswordPage extends RootSubPage {
                                setResponsePage(RepositoriesPage.class);\r
                        }\r
                };\r
-               PasswordTextField passwordField = new PasswordTextField("password", password);\r
+               NonTrimmedPasswordTextField passwordField = new NonTrimmedPasswordTextField("password", password);\r
                passwordField.setResetPassword(false);\r
                form.add(passwordField);\r
-               PasswordTextField confirmPasswordField = new PasswordTextField("confirmPassword",\r
+               NonTrimmedPasswordTextField confirmPasswordField = new NonTrimmedPasswordTextField("confirmPassword",\r
                                confirmPassword);\r
                confirmPasswordField.setResetPassword(false);\r
                form.add(confirmPasswordField);\r
index c6b5c3c74d0e055d3bbb5b7f3e0dacdd5c6095bd..220bee3f6ec7391e59bb7aaabe3fb1932fd9fac8 100644 (file)
@@ -27,7 +27,6 @@ import org.apache.wicket.extensions.markup.html.form.palette.Palette;
 import org.apache.wicket.markup.html.form.Button;\r
 import org.apache.wicket.markup.html.form.CheckBox;\r
 import org.apache.wicket.markup.html.form.Form;\r
-import org.apache.wicket.markup.html.form.PasswordTextField;\r
 import org.apache.wicket.markup.html.form.TextField;\r
 import org.apache.wicket.model.CompoundPropertyModel;\r
 import org.apache.wicket.model.Model;\r
@@ -42,6 +41,7 @@ import com.gitblit.models.RegistrantAccessPermission;
 import com.gitblit.models.TeamModel;\r
 import com.gitblit.models.UserModel;\r
 import com.gitblit.utils.StringUtils;\r
+import com.gitblit.wicket.NonTrimmedPasswordTextField;\r
 import com.gitblit.wicket.RequiresAdminRole;\r
 import com.gitblit.wicket.StringChoiceRenderer;\r
 import com.gitblit.wicket.WicketUtils;\r
@@ -242,10 +242,10 @@ public class EditUserPage extends RootSubPage {
 \r
                // field names reflective match UserModel fields\r
                form.add(new TextField<String>("username").setEnabled(editCredentials));\r
-               PasswordTextField passwordField = new PasswordTextField("password");\r
+               NonTrimmedPasswordTextField passwordField = new NonTrimmedPasswordTextField("password");\r
                passwordField.setResetPassword(false);\r
                form.add(passwordField.setEnabled(editCredentials));\r
-               PasswordTextField confirmPasswordField = new PasswordTextField("confirmPassword",\r
+               NonTrimmedPasswordTextField confirmPasswordField = new NonTrimmedPasswordTextField("confirmPassword",\r
                                confirmPassword);\r
                confirmPasswordField.setResetPassword(false);\r
                form.add(confirmPasswordField.setEnabled(editCredentials));\r
index 61d7b7592ed2d48f42a2eb2e4bf4ffb47750d77c..79a4fc679617029b14730eb76d2c9cc186e7fdde 100644 (file)
@@ -40,7 +40,6 @@ import org.apache.wicket.behavior.HeaderContributor;
 import org.apache.wicket.markup.html.IHeaderContributor;
 import org.apache.wicket.markup.html.IHeaderResponse;
 import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.form.PasswordTextField;
 import org.apache.wicket.markup.html.form.TextField;
 import org.apache.wicket.markup.html.link.BookmarkablePageLink;
 import org.apache.wicket.markup.html.panel.Fragment;
@@ -71,6 +70,7 @@ import com.gitblit.models.UserModel;
 import com.gitblit.utils.ModelUtils;
 import com.gitblit.utils.StringUtils;
 import com.gitblit.wicket.GitBlitWebSession;
+import com.gitblit.wicket.NonTrimmedPasswordTextField;
 import com.gitblit.wicket.SessionlessForm;
 import com.gitblit.wicket.WicketUtils;
 import com.gitblit.wicket.panels.AvatarImage;
@@ -581,7 +581,7 @@ public abstract class RootPage extends BasePage {
                        TextField<String> unameField = new TextField<String>("username", username);
                        WicketUtils.setInputPlaceholder(unameField, markupProvider.getString("gb.username"));
                        loginForm.add(unameField);
-                       PasswordTextField pwField = new PasswordTextField("password", password);
+                       NonTrimmedPasswordTextField pwField = new NonTrimmedPasswordTextField("password", password);
                        WicketUtils.setInputPlaceholder(pwField, markupProvider.getString("gb.password"));
                        loginForm.add(pwField);
                        add(loginForm);