--- /dev/null
+/*
+ * 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;
+ }
+
+}
\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
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
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
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
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
\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
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;
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;
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);