Search in sources :

Example 16 with JPasswordField

use of javax.swing.JPasswordField in project gitblit by gitblit.

the class EditUserDialog method initialize.

private void initialize(int protocolVersion, UserModel anUser) {
    usernameField = new JTextField(anUser.username == null ? "" : anUser.username, 25);
    passwordField = new JPasswordField(anUser.password == null ? "" : anUser.password, 25);
    confirmPasswordField = new JPasswordField(anUser.password == null ? "" : anUser.password, 25);
    displayNameField = new JTextField(anUser.displayName == null ? "" : anUser.displayName, 25);
    emailAddressField = new JTextField(anUser.emailAddress == null ? "" : anUser.emailAddress, 25);
    canAdminCheckbox = new JCheckBox(Translation.get("gb.canAdminDescription"), anUser.canAdmin);
    canForkCheckbox = new JCheckBox(Translation.get("gb.canForkDescription"), anUser.canFork);
    canCreateCheckbox = new JCheckBox(Translation.get("gb.canCreateDescription"), anUser.canCreate);
    notFederatedCheckbox = new JCheckBox(Translation.get("gb.excludeFromFederationDescription"), anUser.excludeFromFederation);
    disabledCheckbox = new JCheckBox(Translation.get("gb.disableUserDescription"), anUser.disabled);
    organizationalUnitField = new JTextField(anUser.organizationalUnit == null ? "" : anUser.organizationalUnit, 25);
    organizationField = new JTextField(anUser.organization == null ? "" : anUser.organization, 25);
    localityField = new JTextField(anUser.locality == null ? "" : anUser.locality, 25);
    stateProvinceField = new JTextField(anUser.stateProvince == null ? "" : anUser.stateProvince, 25);
    countryCodeField = new JTextField(anUser.countryCode == null ? "" : anUser.countryCode, 15);
    // credentials are optionally controlled by 3rd-party authentication
    usernameField.setEnabled(anUser.isLocalAccount());
    passwordField.setEnabled(anUser.isLocalAccount());
    confirmPasswordField.setEnabled(anUser.isLocalAccount());
    JPanel fieldsPanel = new JPanel(new GridLayout(0, 1));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.username"), usernameField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.password"), passwordField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.confirmPassword"), confirmPasswordField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.displayName"), displayNameField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.emailAddress"), emailAddressField));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.canAdmin"), canAdminCheckbox));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.canFork"), canForkCheckbox));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.canCreate"), canCreateCheckbox));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.excludeFromFederation"), notFederatedCheckbox));
    fieldsPanel.add(newFieldPanel(Translation.get("gb.disableUser"), disabledCheckbox));
    JPanel attributesPanel = new JPanel(new GridLayout(0, 1, 5, 2));
    attributesPanel.add(newFieldPanel(Translation.get("gb.organizationalUnit") + " (OU)", organizationalUnitField));
    attributesPanel.add(newFieldPanel(Translation.get("gb.organization") + " (O)", organizationField));
    attributesPanel.add(newFieldPanel(Translation.get("gb.locality") + " (L)", localityField));
    attributesPanel.add(newFieldPanel(Translation.get("gb.stateProvince") + " (ST)", stateProvinceField));
    attributesPanel.add(newFieldPanel(Translation.get("gb.countryCode") + " (C)", countryCodeField));
    final Insets _insets = new Insets(5, 5, 5, 5);
    repositoryPalette = new RegistrantPermissionsPanel(RegistrantType.REPOSITORY);
    teamsPalette = new JPalette<TeamModel>();
    JPanel fieldsPanelTop = new JPanel(new BorderLayout());
    fieldsPanelTop.add(fieldsPanel, BorderLayout.NORTH);
    JPanel attributesPanelTop = new JPanel(new BorderLayout());
    attributesPanelTop.add(attributesPanel, BorderLayout.NORTH);
    JPanel repositoriesPanel = new JPanel(new BorderLayout()) {

        private static final long serialVersionUID = 1L;

        @Override
        public Insets getInsets() {
            return _insets;
        }
    };
    repositoriesPanel.add(repositoryPalette, BorderLayout.CENTER);
    JPanel teamsPanel = new JPanel(new BorderLayout()) {

        private static final long serialVersionUID = 1L;

        @Override
        public Insets getInsets() {
            return _insets;
        }
    };
    teamsPanel.add(teamsPalette, BorderLayout.CENTER);
    JTabbedPane panel = new JTabbedPane(JTabbedPane.TOP);
    panel.addTab(Translation.get("gb.general"), fieldsPanelTop);
    panel.addTab(Translation.get("gb.attributes"), attributesPanelTop);
    if (protocolVersion > 1) {
        panel.addTab(Translation.get("gb.teamMemberships"), teamsPanel);
    }
    panel.addTab(Translation.get("gb.restrictedRepositories"), repositoriesPanel);
    JButton createButton = new JButton(Translation.get("gb.save"));
    createButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            if (validateFields()) {
                canceled = false;
                setVisible(false);
            }
        }
    });
    JButton cancelButton = new JButton(Translation.get("gb.cancel"));
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            canceled = true;
            setVisible(false);
        }
    });
    JPanel controls = new JPanel();
    controls.add(cancelButton);
    controls.add(createButton);
    JPanel centerPanel = new JPanel(new BorderLayout(5, 5)) {

        private static final long serialVersionUID = 1L;

        @Override
        public Insets getInsets() {
            return _insets;
        }
    };
    centerPanel.add(panel, BorderLayout.CENTER);
    centerPanel.add(controls, BorderLayout.SOUTH);
    getContentPane().setLayout(new BorderLayout(5, 5));
    getContentPane().add(centerPanel, BorderLayout.CENTER);
    pack();
}
Also used : JPanel(javax.swing.JPanel) Insets(java.awt.Insets) ActionEvent(java.awt.event.ActionEvent) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) GridLayout(java.awt.GridLayout) TeamModel(com.gitblit.models.TeamModel) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) JPasswordField(javax.swing.JPasswordField)

Example 17 with JPasswordField

use of javax.swing.JPasswordField in project gitblit by gitblit.

the class GitblitAuthority method prepareX509Infrastructure.

private boolean prepareX509Infrastructure() {
    if (caKeystorePassword == null) {
        JPasswordField pass = new JPasswordField(10);
        pass.setText(caKeystorePassword);
        pass.addAncestorListener(new RequestFocusListener());
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(new JLabel(Translation.get("gb.enterKeystorePassword")), BorderLayout.NORTH);
        panel.add(pass, BorderLayout.CENTER);
        int result = JOptionPane.showConfirmDialog(GitblitAuthority.this, panel, Translation.get("gb.password"), JOptionPane.OK_CANCEL_OPTION);
        if (result == JOptionPane.OK_OPTION) {
            caKeystorePassword = new String(pass.getPassword());
        } else {
            return false;
        }
    }
    X509Metadata metadata = new X509Metadata("localhost", caKeystorePassword);
    setMetadataDefaults(metadata);
    metadata.notAfter = new Date(System.currentTimeMillis() + 10 * TimeUtils.ONEYEAR);
    X509Utils.prepareX509Infrastructure(metadata, folder, this);
    return true;
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) JPasswordField(javax.swing.JPasswordField) X509Metadata(com.gitblit.utils.X509Utils.X509Metadata) JLabel(javax.swing.JLabel) Point(java.awt.Point) Date(java.util.Date)

Example 18 with JPasswordField

use of javax.swing.JPasswordField in project gitblit by gitblit.

the class EditRegistrationDialog method initialize.

private void initialize(GitblitRegistration reg, boolean isLogin) {
    setIconImage(new ImageIcon(getClass().getResource("/gitblt-favicon.png")).getImage());
    canceled = true;
    urlField = new JTextField(reg == null ? "" : reg.url, 30);
    nameField = new JTextField(reg == null ? "" : reg.name);
    accountField = new JTextField(reg == null ? "" : reg.account);
    passwordField = new JPasswordField(reg == null ? "" : new String(reg.password));
    savePassword = new JCheckBox("save password (passwords are NOT encrypted!)");
    savePassword.setSelected(reg == null ? false : (reg.password != null && reg.password.length > 0));
    JPanel panel = new JPanel(new GridLayout(0, 1, 5, 5));
    panel.add(newLabelPanel(Translation.get("gb.name"), nameField));
    panel.add(newLabelPanel(Translation.get("gb.url"), urlField));
    panel.add(newLabelPanel(Translation.get("gb.username"), accountField));
    panel.add(newLabelPanel(Translation.get("gb.password"), passwordField));
    panel.add(newLabelPanel("", savePassword));
    JButton cancel = new JButton(Translation.get("gb.cancel"));
    cancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            setVisible(false);
        }
    });
    final JButton save = new JButton(Translation.get(isLogin ? "gb.login" : "gb.save"));
    save.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            if (validateFields()) {
                canceled = false;
                setVisible(false);
            }
        }
    });
    // on enter in password field, save or login
    passwordField.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            save.doClick();
        }
    });
    JPanel controls = new JPanel();
    controls.add(cancel);
    controls.add(save);
    if (reg == null) {
        this.setTitle(Translation.get("gb.create"));
        headerPanel = new HeaderPanel(Translation.get("gb.create"), null);
    } else {
        this.setTitle(Translation.get(isLogin ? "gb.login" : "gb.edit"));
        headerPanel = new HeaderPanel(reg.name, null);
    }
    final Insets insets = new Insets(5, 5, 5, 5);
    JPanel centerPanel = new JPanel(new BorderLayout(5, 5)) {

        private static final long serialVersionUID = 1L;

        @Override
        public Insets getInsets() {
            return insets;
        }
    };
    centerPanel.add(headerPanel, BorderLayout.NORTH);
    centerPanel.add(panel, BorderLayout.CENTER);
    centerPanel.add(controls, BorderLayout.SOUTH);
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(centerPanel, BorderLayout.CENTER);
    pack();
    setModal(true);
    if (isLogin) {
        passwordField.requestFocus();
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) JPanel(javax.swing.JPanel) Insets(java.awt.Insets) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) GridLayout(java.awt.GridLayout) ActionListener(java.awt.event.ActionListener) BorderLayout(java.awt.BorderLayout) JPasswordField(javax.swing.JPasswordField)

Example 19 with JPasswordField

use of javax.swing.JPasswordField in project GNS by MobilityFirst.

the class UserInfoPrompted method promptKeyboardInteractive.

/**
   *
   * @param destination
   * @param name
   * @param instruction
   * @param prompt
   * @param echo
   * @return the array of strings
   */
@Override
public String[] promptKeyboardInteractive(String destination, String name, String instruction, String[] prompt, boolean[] echo) {
    panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    gbc.weightx = 1.0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.gridx = 0;
    panel.add(new JLabel(instruction), gbc);
    gbc.gridy++;
    gbc.gridwidth = GridBagConstraints.RELATIVE;
    JTextField[] texts = new JTextField[prompt.length];
    for (int i = 0; i < prompt.length; i++) {
        gbc.fill = GridBagConstraints.NONE;
        gbc.gridx = 0;
        gbc.weightx = 1;
        panel.add(new JLabel(prompt[i]), gbc);
        gbc.gridx = 1;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.weighty = 1;
        if (echo[i]) {
            texts[i] = new JTextField(20);
        } else {
            texts[i] = new JPasswordField(20);
        }
        panel.add(texts[i], gbc);
        gbc.gridy++;
    }
    if (JOptionPane.showConfirmDialog(null, panel, destination + ": " + name, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) {
        String[] response = new String[prompt.length];
        for (int i = 0; i < prompt.length; i++) {
            response[i] = texts[i].getText();
        }
        return response;
    } else {
        // cancel
        return null;
    }
}
Also used : JPanel(javax.swing.JPanel) GridBagLayout(java.awt.GridBagLayout) JPasswordField(javax.swing.JPasswordField) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField)

Example 20 with JPasswordField

use of javax.swing.JPasswordField in project zaproxy by zaproxy.

the class OptionsConnectionPanel method getTxtProxyChainPassword.

private JPasswordField getTxtProxyChainPassword() {
    if (txtProxyChainPassword == null) {
        txtProxyChainPassword = new JPasswordField();
        txtProxyChainPassword.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                proxyDialog.saveAndClose();
            }
        });
    }
    return txtProxyChainPassword;
}
Also used : JPasswordField(javax.swing.JPasswordField)

Aggregations

JPasswordField (javax.swing.JPasswordField)33 JTextField (javax.swing.JTextField)19 JLabel (javax.swing.JLabel)17 JPanel (javax.swing.JPanel)13 JCheckBox (javax.swing.JCheckBox)10 BorderLayout (java.awt.BorderLayout)9 JButton (javax.swing.JButton)8 JRadioButton (javax.swing.JRadioButton)5 JTextArea (javax.swing.JTextArea)5 Dimension (java.awt.Dimension)4 JComponent (javax.swing.JComponent)4 JTextPane (javax.swing.JTextPane)4 Component (java.awt.Component)3 GridBagLayout (java.awt.GridBagLayout)3 ArrayList (java.util.ArrayList)3 Font (java.awt.Font)2 GridBagConstraints (java.awt.GridBagConstraints)2 GridLayout (java.awt.GridLayout)2 Insets (java.awt.Insets)2 ActionEvent (java.awt.event.ActionEvent)2