org.apache.wicket.markup.html.form.PasswordTextField Java Examples

The following examples show how to use org.apache.wicket.markup.html.form.PasswordTextField. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChangePasswordPopupPanel.java    From artifact-listener with Apache License 2.0 6 votes vote down vote up
@Override
protected Component createBody(String wicketId) {
	DelegatedMarkupPanel body = new DelegatedMarkupPanel(wicketId, ChangePasswordPopupPanel.class);
	
	passwordForm = new Form<Void>("form");
	body.add(passwordForm);
	
	newPasswordField = new PasswordTextField("newPassword", Model.of(""));
	newPasswordField.setLabel(new ResourceModel("administration.user.field.newPassword"));
	newPasswordField.setRequired(true);
	passwordForm.add(newPasswordField);
	
	confirmPasswordField = new PasswordTextField("confirmPassword", Model.of(""));
	confirmPasswordField.setLabel(new ResourceModel("administration.user.field.confirmPassword"));
	confirmPasswordField.setRequired(true);
	passwordForm.add(confirmPasswordField);
	
	return body;
}
 
Example #2
Source File: SecureStringEditor.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/**
 * Construct simple text editor.
 *
 * @param id         editor id.
 * @param markupProvider markup object.
 * @param model      model.
 * @param labelModel label model
 * @param errorLabelModel error label model
 * @param attrValue  {@link org.yes.cart.domain.entity.AttrValue}
 * @param readOnly  if true this component is read only
 */
public SecureStringEditor(final String id,
                          final MarkupContainer markupProvider,
                          final IModel<String> model,
                          final IModel<String> labelModel,
                          final IModel<String> errorLabelModel,
                          final AttrValueWithAttribute attrValue,
                          final boolean readOnly) {

    super(id, "secureStringEditor", markupProvider);

    final PasswordTextField textField = new PasswordTextField(EDIT, model);

    textField.setLabel(labelModel);
    textField.setRequired(attrValue.getAttribute().isMandatory());
    textField.setEnabled(!readOnly);

    if (StringUtils.isNotBlank(attrValue.getAttribute().getRegexp())) {
        textField.add(new CustomPatternValidator(attrValue.getAttribute().getRegexp(), errorLabelModel));
    }
    textField.add(new AttributeModifier("placeholder", labelModel));
    add(textField);
}
 
Example #3
Source File: InstallWizard.java    From openmeetings with Apache License 2.0 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	add(new CheckBox("allowFrontendRegister"));
	add(new CheckBox("sendEmailAtRegister"));
	add(new CheckBox("sendEmailWithVerficationCode"));
	add(new CheckBox("createDefaultObjects"));
	add(new TextField<String>("mailReferer"));
	add(new TextField<String>("smtpServer"));
	add(new TextField<Integer>("smtpPort").setRequired(true));
	add(new TextField<String>("mailAuthName"));
	add(new PasswordTextField("mailAuthPass").setResetPassword(false).setRequired(false));
	add(new CheckBox("mailUseTls"));
	add(new CheckBox("replyToOrganizer"));
	add(new LangDropDown("defaultLangId"));
}
 
Example #4
Source File: DefaultRestorePasswordPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
protected void onInitialize() {
    super.onInitialize();
    Form<?> form = new Form<>("form");

    TextField<String> passwordField = new PasswordTextField("password", passwordModel);
    TextField<String> confirmPasswordField = new PasswordTextField("confirmPassword", Model.of(""));

    form.add(passwordField);
    form.add(confirmPasswordField);
    form.add(new EqualPasswordInputValidator(passwordField, confirmPasswordField));
    form.add(createRestoreButton("restoreButton"));

    add(createFeedbackPanel("feedback"));
    add(form);

    setOutputMarkupPlaceholderTag(true);
}
 
Example #5
Source File: DefaultRegistrationPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
protected void onInitialize() {
    super.onInitialize();
    IModel<OrienteerUser> model = getModel();

    Form<?> form = new Form<>("form");

    form.add(new TextField<>("firstName", new PropertyModel<>(model, "firstName")).setRequired(true));
    form.add(new TextField<>("lastName", new PropertyModel<>(model, "lastName")).setRequired(true));
    form.add(createEmailField("email", new PropertyModel<>(model, "email")));

    TextField<String> passwordField = new PasswordTextField("password", passwordModel);
    TextField<String> confirmPasswordField = new PasswordTextField("confirmPassword", Model.of(""));

    form.add(passwordField);
    form.add(confirmPasswordField);
    form.add(new EqualPasswordInputValidator(passwordField, confirmPasswordField));
    form.add(createRegisterButton("registerButton"));
    form.add(createSocialNetworksPanel("socialNetworks"));

    add(form);
    add(createFeedbackPanel("feedback"));
    setOutputMarkupPlaceholderTag(true);
}
 
Example #6
Source File: AjaxPasswordFieldPanel.java    From syncope with Apache License 2.0 6 votes vote down vote up
public AjaxPasswordFieldPanel(
        final String id, final String name, final IModel<String> model, final boolean enableOnChange,
        final PasswordStrengthBehavior passwordStrengthBehavior) {
    super(id, name, model);

    field = new PasswordTextField("passwordField", model);
    if (passwordStrengthBehavior != null) {
        field.add(passwordStrengthBehavior);
    }
    add(field.setLabel(new ResourceModel(name, name)).setRequired(false).setOutputMarkupId(true));

    if (enableOnChange && !isReadOnly()) {
        field.add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

            private static final long serialVersionUID = -1107858522700306810L;

            @Override
            protected void onUpdate(final AjaxRequestTarget art) {
                // nothing to do
            }
        });
    }
}
 
Example #7
Source File: PasswordPropertyEditor.java    From onedev with MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	input = new PasswordTextField("input", Model.of(getModelObject()));
	input.setRequired(false);
	input.setResetPassword(false);
	input.setLabel(Model.of(getDescriptor().getDisplayName()));
	add(input);

	Password password = getDescriptor().getPropertyGetter().getAnnotation(Password.class);
	String autoComplete = password.autoComplete();
	if (StringUtils.isNotBlank(autoComplete))
		input.add(AttributeAppender.append("autocomplete", autoComplete));
	input.add(new OnTypingDoneBehavior() {

		@Override
		protected void onTypingDone(AjaxRequestTarget target) {
			onPropertyUpdating(target);
		}
		
	});
}
 
Example #8
Source File: AbstractFieldsetPanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param passwordField
 * @return The created PasswordPanel.
 * @see PasswordPanel#PasswordPanel(String, Component)
 */
public PasswordPanel add(final PasswordTextField passwordField)
{
  final PasswordPanel passwordInput = new PasswordPanel(newChildId(), passwordField);
  add(passwordInput);
  return passwordInput;
}
 
Example #9
Source File: LoginMobileForm.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("serial")
protected void init()
{
  add(new CheckBox("stayLoggedIn", new PropertyModel<Boolean>(this, "stayLoggedIn")));
  add(new TextField<String>("username", new PropertyModel<String>(this, "username")));
  add(new PasswordTextField("password", new PropertyModel<String>(this, "password")).setResetPassword(true).setRequired(true));
  final SubmitLink loginButton = new SubmitLink("login") {
    @Override
    public final void onSubmit()
    {
      parentPage.checkLogin();
    }
  };
  add(loginButton);
}
 
Example #10
Source File: TransferPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
protected void initComponents() {
    add(new Label("host", getString("ActionContributor.Run.destination.host")));
    TextField<String> hostField = new TextField<String>("hostField",
            new PropertyModel<String>(destination, "host"));
    hostField.setLabel(new Model<String>(getString("ActionContributor.Run.destination.host")));
    hostField.setRequired(true);
    hostField.add(new JcrNameValidator());
    add(hostField);

    add(new Label("port", getString("ActionContributor.Run.destination.port")));
    TextField<Integer> portField = new TextField<Integer>("portField",
            new PropertyModel<Integer>(destination, "port"));
    add(portField);

    add(new Label("folder", getString("Folder")));
    TextField<String> folderField = new TextField<String>("folderField",
            new PropertyModel<String>(destination, "folder"));
    add(folderField);

    add(new Label("username", getString("ActionContributor.Run.destination.username")));
    TextField<String> userField = new TextField<String>("userField",
            new PropertyModel<String>(destination, "username"));
    add(userField);

    add(new Label("password", getString("ActionContributor.Run.destination.password")));
    PasswordTextField passwordField = new PasswordTextField("passwordField",
            new PropertyModel<String>(destination, "password"));
    passwordField.setRequired(false);
    passwordField.setResetPassword(false);
    add(passwordField);
    
    add(new Label("changedFileName", getString("ActionContributor.Run.destination.changedFileName")));
    TextField<String> fileNameField = new TextField<String>("changedFileNameField",
            new PropertyModel<String>(destination, "changedFileName"));
    fileNameField.setLabel(new Model<String>(getString("ActionContributor.Run.destination.changedFileName")));
    fileNameField.setRequired(false);
    fileNameField.add(new JcrNameValidator());
    add(fileNameField);       
}
 
Example #11
Source File: LoginPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
protected void onInitialize() {
    super.onInitialize();
    Form<?> form = new Form<>("form");
    form.add(new TextField<>("username", name).setRequired(true));
    form.add(new PasswordTextField("password", passwordModel));
    form.add(new CheckBox("rememberMe", rememberMeModel));
    form.add(createButtonsPanel("loginButtonsPanel"));
    add(form);
    setOutputMarkupPlaceholderTag(true);
}
 
Example #12
Source File: PasswordsPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
public PasswordsPanel(String id, IModel<String> model)
{
	super(id, model);
	password = new PasswordTextField("password", Model.of(""));
	confirmPassword = new PasswordTextField("confirmPassword", Model.of(""));
	add(password, confirmPassword);
}
 
Example #13
Source File: DistributionSettingsPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@Override
protected void addComponents(Form<Settings> form) {

	final TextField<String> mailServerIpField = new TextField<String>("mailServer.ip");
       form.add(mailServerIpField);
       final TextField<Integer> mailServerPortField = new TextField<Integer>("mailServer.port");
       form.add(mailServerPortField);
       final TextField<String> mailServerSenderField = new TextField<String>("mailServer.from");
       form.add(mailServerSenderField);
       final TextField<String> mailServerUsernameField = new TextField<String>("mailServer.username");
       form.add(mailServerUsernameField);
       final PasswordTextField mailServerPasswordField = new PasswordTextField("mailServer.password");
       mailServerPasswordField.setResetPassword(false);
       mailServerPasswordField.setRequired(false);
       form.add(mailServerPasswordField);
       final CheckBox tlsCheckField = new CheckBox("mailServer.enableTls");
       form.add(tlsCheckField);        
       form.add(new MailServerValidator(new FormComponent[] {mailServerIpField, mailServerPortField, mailServerSenderField}));
       
       final TextField<String> distributorDatePatternField = new TextField<String>("distributor.datePattern");
       distributorDatePatternField.add(new JcrNameValidator(getString("Settings.general.distributorDatePattern.error")));
       form.add(distributorDatePatternField);
       final TextField<String> distributorTimePatternField = new TextField<String>("distributor.timePattern");
       distributorTimePatternField.add(new JcrNameValidator(getString("Settings.general.distributorTimePattern.error")));
       form.add(distributorTimePatternField);
       
       Settings settings = storageService.getSettings();
       oldMailPort = settings.getMailServer().getPort();
       oldMailIp = settings.getMailServer().getIp();
       
}
 
Example #14
Source File: EnduserITCase.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Test
public void mustChangePassword() {
    UserTO mustchangepassword = userService.read("mustchangepassword");
    userService.update(new UserUR.Builder(mustchangepassword.getKey()).
            mustChangePassword(new BooleanReplacePatchItem.Builder().value(Boolean.TRUE).build()).build());

    TESTER.startPage(Login.class);
    doLogin("mustchangepassword", "password123");

    TESTER.assertRenderedPage(MustChangePassword.class);

    final String changePwdForm = "changePassword";
    TESTER.assertComponent(changePwdForm + ":username", TextField.class);
    TESTER.assertComponent(changePwdForm + ":password:passwordField", PasswordTextField.class);
    TESTER.
            assertComponent(changePwdForm + ":confirmPassword:passwordField", PasswordTextField.class);
    TESTER.assertModelValue(changePwdForm + ":username", "mustchangepassword");

    FormTester formTester = TESTER.newFormTester(changePwdForm);

    assertNotNull(formTester);
    // 1. set new password
    formTester.setValue(findComponentById(changePwdForm + ":password", "passwordField"), "password124");
    // 2. confirm password
    formTester.setValue(findComponentById(changePwdForm + ":confirmPassword", "passwordField"),
            "password124");
    // 3. submit form
    TESTER.executeAjaxEvent(changePwdForm + ":submit", Constants.ON_CLICK);

    TESTER.assertRenderedPage(Login.class);
    TESTER.assertComponent("login:username", TextField.class);

    TESTER.cleanupFeedbackMessages();

    doLogin("mustchangepassword", "password124");
    TESTER.assertComponent(WIZARD_FORM + ":view:username:textField", TextField.class);
}
 
Example #15
Source File: SignInPage.java    From ontopia with Apache License 2.0 5 votes vote down vote up
public SignInForm(String id) { 
  super(id); 
  setDefaultModel(new CompoundPropertyModel<SignInForm>(this)); 
  
  add(new FeedbackPanel("feedback", new ContainerFeedbackMessageFilter(this)));
  
  add(new TextField<String>("username")); 
  add(new PasswordTextField("password"));   
}
 
Example #16
Source File: CustomerCreatePage.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
private LabeledFormBorder<String> passwordField() {
	PasswordTextField passwordTextField = new PasswordTextField("password");
	//TODO its not recommended to disable the password reset. But without my tests are failing cause the password is not submitted. https://issues.apache.org/jira/browse/WICKET-6221 
	passwordTextField.setResetPassword(false);
	LabeledFormBorder<String> labeledPasswordTextField = new LabeledFormBorder<String>(getString("password"), passwordTextField){

		@Override
		public boolean isVisible() {
			return isCreatePage();
		}
		
	};
	return labeledPasswordTextField;
}
 
Example #17
Source File: LoginPage.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
public LoginForm(String id) {
	super(id);
	setModel(new CompoundPropertyModel<>(this));
	add(new FeedbackPanel("feedback"));
	add(new RequiredTextField<String>("username"));
	add(new PasswordTextField("password"));
}
 
Example #18
Source File: ManageUsersPage.java    From webanno with Apache License 2.0 5 votes vote down vote up
public DetailForm(String id, IModel<User> aModel)
{
    super(id, new CompoundPropertyModel<>(aModel));

    setOutputMarkupId(true);
    setOutputMarkupPlaceholderTag(true);
    
    add(new TextField<String>("username")
            .setRequired(true)
            .add(this::validateUsername)
            .add(enabledWhen(() -> isCreate)));
    add(new Label("lastLogin"));
    add(new EmailTextField("email"));
    
    passwordField = new PasswordTextField("password");
    passwordField.setModel(PropertyModel.of(DetailForm.this, "password"));
    passwordField.setRequired(false);
    add(passwordField);
    
    repeatPasswordField = new PasswordTextField("repeatPassword");
    repeatPasswordField.setModel(PropertyModel.of(DetailForm.this, "repeatPassword"));
    repeatPasswordField.setRequired(false);
    add(repeatPasswordField);
    
    add(new EqualPasswordInputValidator(passwordField, repeatPasswordField));
    
    add(new ListMultipleChoice<>("roles", getRoles())
            .add(this::validateRoles)
            .add(visibleWhen(ManageUsersPage.this::isAdmin)));
    
    add(new CheckBox("enabled")
            .add(this::validateEnabled)
            .add(visibleWhen(ManageUsersPage.this::isAdmin))
            .setOutputMarkupPlaceholderTag(true));

    add(new LambdaAjaxButton<>("save", ManageUsersPage.this::actionSave));
    
    add(new LambdaAjaxLink("cancel", ManageUsersPage.this::actionCancel));
}
 
Example #19
Source File: LoginPage.java    From webanno with Apache License 2.0 5 votes vote down vote up
public LoginForm(String id)
{
    super(id);
    setModel(new CompoundPropertyModel<>(this));
    add(new RequiredTextField<String>("username"));
    add(new PasswordTextField("password"));
    add(new HiddenField<>("urlfragment"));
    Properties settings = SettingsUtil.getSettings();
    String loginMessage = settings.getProperty(SettingsUtil.CFG_LOGIN_MESSAGE);
    add(new Label("loginMessage", loginMessage)
            .setEscapeModelStrings(false)
            .add(visibleWhen(() -> isNotBlank(loginMessage))));
}
 
Example #20
Source File: InstallWizard.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	add(tzDropDown);
	add(new RequiredTextField<String>("username").setLabel(new ResourceModel("install.wizard.params.step1.username")).add(minimumLength(USER_LOGIN_MINIMUM_LENGTH)));
	add(new PasswordTextField("password")
			.setResetPassword(false).setLabel(new ResourceModel("install.wizard.params.step1.password"))
			.add(new StrongPasswordValidator(new User())));
	add(new RequiredTextField<String>("email").setLabel(new ResourceModel("lbl.email")).add(RfcCompliantEmailAddressValidator.getInstance()));
	add(new RequiredTextField<String>("group").setLabel(new ResourceModel("install.wizard.params.step1.group")));
}
 
Example #21
Source File: RegisterDialog.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	add(feedback.setOutputMarkupId(true));
	add(firstNameField = new RequiredTextField<>("firstName", new PropertyModel<String>(RegisterDialog.this, "firstName")));
	add(lastNameField = new RequiredTextField<>("lastName", new PropertyModel<String>(RegisterDialog.this, "lastName")));
	add(loginField = new RequiredTextField<>("login", new PropertyModel<String>(RegisterDialog.this, "login")));
	add(passwordField = new PasswordTextField("password", new PropertyModel<String>(RegisterDialog.this, "password")));
	add(confirmPassword = new PasswordTextField("confirmPassword", new Model<String>()).setResetPassword(true));
	add(emailField = new RequiredTextField<>("email", new PropertyModel<String>(RegisterDialog.this, "email")) {
		private static final long serialVersionUID = 1L;

		@Override
		protected String[] getInputTypes() {
			return new String[] {"email"};
		}
	});
	add(captcha = new Captcha("captcha"));
	firstNameField.setLabel(new ResourceModel("117"));
	lastNameField.setLabel(new ResourceModel("136"));
	loginField.add(minimumLength(getMinLoginLength())).setLabel(new ResourceModel("114"));
	passwordField.setResetPassword(true).add(new StrongPasswordValidator(new User()) {
		private static final long serialVersionUID = 1L;

		@Override
		public void validate(IValidatable<String> pass) {
			User u = new User();
			u.setLogin(loginField.getRawInput());
			u.setAddress(new Address());
			u.getAddress().setEmail(emailField.getRawInput());
			setUser(u);
			super.validate(pass);
		}
	}).setLabel(new ResourceModel("110"));
	confirmPassword.setLabel(new ResourceModel("116"));
	emailField.add(RfcCompliantEmailAddressValidator.getInstance()).setLabel(new ResourceModel("119"));
	AjaxButton ab = new AjaxButton("submit") { // FAKE button so "submit-on-enter" works as expected
		private static final long serialVersionUID = 1L;
	};
	add(ab);
	setDefaultButton(ab);
}
 
Example #22
Source File: ResetPanel.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
/**
 * Get the particular editor for given attribute value. Type of editor depends from type of attribute value.
 *
 * @param attrValue give {@link org.yes.cart.domain.entity.AttrValue}
 * @param id  field id
 *
 * @return editor
 */
protected Component getEditor(final AttrValueWithAttribute attrValue, final String id) {

    if (attrValue == null) {
        return new PasswordTextField(id);
    }

    return editorFactory.getEditor(id, this, getLocale().getLanguage(), attrValue, false);
}
 
Example #23
Source File: UserFormPopupPanel.java    From artifact-listener with Apache License 2.0 4 votes vote down vote up
@Override
protected Component createBody(String wicketId) {
	DelegatedMarkupPanel body = new DelegatedMarkupPanel(wicketId, UserFormPopupPanel.class);
	
	userForm = new Form<User>("form", getModel());
	body.add(userForm);
	
	TextField<String> emailField = new EmailTextField("email", BindingModel.of(userForm.getModel(),
			Binding.user().email())) {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onConfigure() {
			super.onConfigure();
			setVisible(UserFormPopupPanel.this.isAddMode());
		}
	};
	emailField.setLabel(new ResourceModel("administration.user.field.email"));
	emailField.setRequired(isAddMode());
	userForm.add(emailField);
	
	TextField<String> fullNameField = new TextField<String>("fullName", BindingModel.of(userForm.getModel(),
			Binding.user().fullName()));
	fullNameField.setLabel(new ResourceModel("administration.user.field.fullName"));
	userForm.add(fullNameField);
	
	WebMarkupContainer passwordContainer = new WebMarkupContainer("passwordContainer") {
		private static final long serialVersionUID = 2727669661139358058L;
		
		@Override
		protected void onConfigure() {
			super.onConfigure();
			setVisible(UserFormPopupPanel.this.isAddMode());
		}
	};
	userForm.add(passwordContainer);
	
	CheckBox activeField = new CheckBox("active", BindingModel.of(userForm.getModel(), Binding.user().active()));
	activeField.setLabel(new ResourceModel("administration.user.field.active"));
	passwordContainer.add(activeField);
	
	newPasswordField = new PasswordTextField("newPassword", Model.of(""));
	newPasswordField.setLabel(new ResourceModel("administration.user.field.password"));
	newPasswordField.setRequired(true);
	passwordContainer.add(newPasswordField);
	
	confirmPasswordField = new PasswordTextField("confirmPassword", Model.of(""));
	confirmPasswordField.setLabel(new ResourceModel("administration.user.field.confirmPassword"));
	confirmPasswordField.setRequired(true);
	passwordContainer.add(confirmPasswordField);
	
	LocaleDropDownChoice localeField = new LocaleDropDownChoice("locale", BindingModel.of(userForm.getModel(), Binding.user().locale()));
	localeField.setLabel(new ResourceModel("administration.user.field.locale"));
	userForm.add(localeField);
	
	return body;
}
 
Example #24
Source File: LinkedAccountCredentialsPanel.java    From syncope with Apache License 2.0 4 votes vote down vote up
public LinkedAccountCredentialsPanel(
        final EntityWrapper<LinkedAccountTO> modelObject, final List<String> whichCredentials) {
    super();
    setOutputMarkupId(true);

    linkedAccountTO = modelObject.getInnerObject();

    boolean isUsernameManagementEnabled = whichCredentials.contains("username");
    AjaxTextFieldPanel usernameField = new AjaxTextFieldPanel(
            "username",
            "username",
            new PropertyModel<>(linkedAccountTO, "username"));
    FieldPanel.class.cast(usernameField).setReadOnly(StringUtils.isBlank(linkedAccountTO.getUsername()));
    LinkedAccountPlainAttrProperty usernameProperty = new LinkedAccountPlainAttrProperty();
    usernameProperty.setOverridable(StringUtils.isNotBlank(linkedAccountTO.getUsername()));
    usernameProperty.setSchema("username");
    usernameProperty.getValues().add(linkedAccountTO.getUsername());
    usernameField.showExternAction(
            checkboxToggle(usernameProperty, usernameField).setEnabled(isUsernameManagementEnabled));
    add(usernameField.setOutputMarkupId(true));
    usernameField.setEnabled(isUsernameManagementEnabled);

    boolean isPasswordManagementEnabled = whichCredentials.contains("password");
    AjaxPasswordFieldPanel passwordField = new AjaxPasswordFieldPanel(
            "password",
            "password",
            new PropertyModel<>(linkedAccountTO, "password"),
            false);
    passwordField.setMarkupId("password");
    passwordField.setRequired(true);
    FieldPanel.class.cast(passwordField).setReadOnly(StringUtils.isBlank(linkedAccountTO.getPassword()));
    LinkedAccountPlainAttrProperty passwordProperty = new LinkedAccountPlainAttrProperty();
    passwordProperty.setOverridable(StringUtils.isNotBlank(linkedAccountTO.getPassword()));
    passwordProperty.setSchema("password");
    passwordProperty.getValues().add(linkedAccountTO.getPassword());
    passwordField.showExternAction(
            checkboxToggle(passwordProperty, passwordField).setEnabled(isPasswordManagementEnabled));
    ((PasswordTextField) passwordField.getField()).setResetPassword(false);
    add(passwordField.setOutputMarkupId(true));
    passwordField.setEnabled(isPasswordManagementEnabled);
}
 
Example #25
Source File: LoginPage.java    From oodt with Apache License 2.0 4 votes vote down vote up
public LoginPage(PageParameters parameters) {
  super();
  final CurationApp app = (CurationApp)Application.get();
  final CurationSession session = (CurationSession)getSession();
  String ssoClass = app.getSSOImplClass();
  final AbstractWebBasedSingleSignOn sso = SingleSignOnFactory
      .getWebBasedSingleSignOn(ssoClass);
  sso.setReq(((WebRequest) RequestCycle.get().getRequest())
      .getHttpServletRequest());
  sso.setRes(((WebResponse) RequestCycle.get().getResponse())
      .getHttpServletResponse());
  
  String action = parameters.getString("action");
  String appNameString = app.getProjectName()+" CAS Curation Interface";
  add(new Label("login_project_name", appNameString));
  replace(new Label("crumb_name", "Login"));
  final WebMarkupContainer creds = new WebMarkupContainer("invalid_creds");
  final WebMarkupContainer connect = new WebMarkupContainer("connect_error");
  creds.setVisible(false);
  connect.setVisible(false);
  final TextField<String> loginUser = new TextField<String>("login_username", new Model<String>(""));
  final PasswordTextField pass = new PasswordTextField("password", new Model<String>(""));
  
  
  Form<?> form = new Form<Void>("login_form"){

    private static final long serialVersionUID = 1L;
    
    @Override
    protected void onSubmit() {
      String username = loginUser.getModelObject();
      String password = pass.getModelObject();
      
      if(sso.login(username, password)){
        session.setLoggedIn(true);
        session.setLoginUsername(username);
        setResponsePage(WorkbenchPage.class);
      }
      else{
        session.setLoggedIn(false);
        if (session.getLoginUsername() == null){
          connect.setVisible(true);
        }
        else{
          creds.setVisible(true);
        }
      }
      
    }
    
  };
  
  form.add(loginUser);
  form.add(pass);
  form.add(creds);
  form.add(connect);
  add(form);
  
  if(action.equals("logout")){
    sso.logout();
    session.setLoginUsername(null);
    session.setLoggedIn(false);
    PageParameters params = new PageParameters();
    params.add("action", "login");
    setResponsePage(LoginPage.class, params);
  }

}
 
Example #26
Source File: ConnConfPropertyListView.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void populateItem(final ListItem<ConnConfProperty> item) {
    final ConnConfProperty property = item.getModelObject();

    final String label = StringUtils.isBlank(property.getSchema().getDisplayName())
            ? property.getSchema().getName() : property.getSchema().getDisplayName();

    final FieldPanel<? extends Serializable> field;
    boolean required = false;
    boolean isArray = false;

    if (property.getSchema().isConfidential()
            || IdMConstants.GUARDED_STRING.equalsIgnoreCase(property.getSchema().getType())
            || IdMConstants.GUARDED_BYTE_ARRAY.equalsIgnoreCase(property.getSchema().getType())) {

        field = new AjaxPasswordFieldPanel("panel", label, new Model<>(), false);
        ((PasswordTextField) field.getField()).setResetPassword(false);

        required = property.getSchema().isRequired();
    } else {
        Class<?> propertySchemaClass;
        try {
            propertySchemaClass = ClassUtils.getClass(property.getSchema().getType());
            if (ClassUtils.isPrimitiveOrWrapper(propertySchemaClass)) {
                propertySchemaClass = ClassUtils.primitiveToWrapper(propertySchemaClass);
            }
        } catch (ClassNotFoundException e) {
            LOG.error("Error parsing attribute type", e);
            propertySchemaClass = String.class;
        }

        if (ClassUtils.isAssignable(Number.class, propertySchemaClass)) {
            @SuppressWarnings("unchecked")
            Class<Number> numberClass = (Class<Number>) propertySchemaClass;
            field = new AjaxSpinnerFieldPanel.Builder<>().build("panel", label, numberClass, new Model<>());
            required = property.getSchema().isRequired();
        } else if (ClassUtils.isAssignable(Boolean.class, propertySchemaClass)) {
            field = new AjaxCheckBoxPanel("panel", label, new Model<>());
        } else {
            field = new AjaxTextFieldPanel("panel", label, new Model<>());
            required = property.getSchema().isRequired();
        }

        if (propertySchemaClass.isArray()) {
            isArray = true;
        }
    }

    field.setIndex(item.getIndex());
    field.setTitle(property.getSchema().getHelpMessage(), true);

    final AbstractFieldPanel<? extends Serializable> fieldPanel;
    if (isArray) {
        final MultiFieldPanel multiFieldPanel = new MultiFieldPanel.Builder(
                new PropertyModel<>(property, "values")).setEventTemplate(true).build("panel", label, field);
        item.add(multiFieldPanel);
        fieldPanel = multiFieldPanel;
    } else {
        setNewFieldModel(field, property.getValues());
        item.add(field);
        fieldPanel = field;
    }

    if (required) {
        fieldPanel.addRequiredLabel();
    }

    if (withOverridable) {
        fieldPanel.showExternAction(addCheckboxToggle(property));
    }
}
 
Example #27
Source File: SignInPanel.java    From etcd-viewer with Apache License 2.0 3 votes vote down vote up
public AuthForm(String id) {
    super(id);

    setModel(new CompoundPropertyModel<SignInPanel>(SignInPanel.this));

    add(new TextField<String>("username").setRequired(true));
    add(new PasswordTextField("password").setRequired(true));

}
 
Example #28
Source File: DeletePanel.java    From yes-cart with Apache License 2.0 2 votes vote down vote up
/**
 * Construct login form.
 *
 * @param id              form id
 * @param token           auth token
 */
public DeleteForm(final String id,
                  final String token) {

    super(id);

    setModel(new CompoundPropertyModel<>(DeleteForm.this));

    add(new PasswordTextField(PASSWORD_INPUT));


    add(
            new Button(DELETE_BUTTON) {

                @Override
                public void onSubmit() {

                    try {
                        final Map<String, Object> deleteAccount = new HashMap<>();
                        deleteAccount.put(ShoppingCartCommand.CMD_DELETE_ACCOUNT, token);
                        deleteAccount.put(ShoppingCartCommand.CMD_DELETE_ACCOUNT_PW, password);
                        ((AbstractWebPage) getPage()).executeCommands(deleteAccount);

                        final Map<String, Object> logout = new HashMap<>();
                        logout.put(ShoppingCartCommand.CMD_LOGOUT, ShoppingCartCommand.CMD_LOGOUT);
                        ((AbstractWebPage) getPage()).executeCommands(logout);

                        getPage().setResponsePage(wicketPagesMounter.getLoginPageProvider().get());

                    } catch (BadCredentialsException bce) {

                        error(getLocalizer().getString("newPasswordInvalidToken", this));

                    }

                }

            }
    );

    add(new Label(CONTENT, ""));

}