Search in sources :

Example 96 with JPasswordField

use of javax.swing.JPasswordField in project wiki-java by MER-C.

the class LoginUtils method showLoginScreen.

/**
 * Creates and shows user a login screen, returning user login details in a String array.  Does not check to see if login details are
 * valid.
 *
 * @param title The title of the login window
 * @return An array of length 2, in the form {username, password}.
 */
public static String[] showLoginScreen(String title) {
    JTextField u = new JTextField(20);
    JPasswordField px = new JPasswordField(20);
    if (JOptionPane.showConfirmDialog(null, GUIUtils.buildForm(title, new JLabel("Username:", JLabel.TRAILING), u, new JLabel("Password:", JLabel.TRAILING), px), title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) != JOptionPane.OK_OPTION)
        System.exit(0);
    return new String[] { u.getText().trim(), new String(px.getPassword()) };
}
Also used : JPasswordField(javax.swing.JPasswordField) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField)

Example 97 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)

Example 98 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 99 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 100 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)

Aggregations

JPasswordField (javax.swing.JPasswordField)100 JLabel (javax.swing.JLabel)60 JPanel (javax.swing.JPanel)47 JTextField (javax.swing.JTextField)44 BorderLayout (java.awt.BorderLayout)30 JButton (javax.swing.JButton)24 JCheckBox (javax.swing.JCheckBox)23 GridBagLayout (java.awt.GridBagLayout)22 GridBagConstraints (java.awt.GridBagConstraints)19 ActionEvent (java.awt.event.ActionEvent)19 ActionListener (java.awt.event.ActionListener)19 Insets (java.awt.Insets)18 Dimension (java.awt.Dimension)15 WindowAdapter (java.awt.event.WindowAdapter)12 WindowEvent (java.awt.event.WindowEvent)12 EmptyBorder (javax.swing.border.EmptyBorder)12 EtchedBorder (javax.swing.border.EtchedBorder)12 AbstractAction (javax.swing.AbstractAction)11 CompoundBorder (javax.swing.border.CompoundBorder)11 ItemEvent (java.awt.event.ItemEvent)7