use of javax.swing.JPasswordField in project keystore-explorer by kaikramer.
the class DGetNewPassword method initComponents.
private void initComponents() {
getContentPane().setLayout(new BorderLayout());
jlFirst = new JLabel(res.getString("DGetNewPassword.jlFirst.text"));
GridBagConstraints gbc_jlFirst = new GridBagConstraints();
gbc_jlFirst.gridx = 0;
gbc_jlFirst.gridy = 0;
gbc_jlFirst.anchor = GridBagConstraints.EAST;
gbc_jlFirst.insets = new Insets(5, 5, 5, 5);
jlConfirm = new JLabel(res.getString("DGetNewPassword.jlConfirm.text"));
GridBagConstraints gbc_jpfFirst = new GridBagConstraints();
gbc_jpfFirst.gridx = 1;
gbc_jpfFirst.gridy = 0;
gbc_jpfFirst.anchor = GridBagConstraints.WEST;
gbc_jpfFirst.insets = new Insets(5, 5, 5, 5);
if (passwordQualityConfig.getEnabled()) {
if (passwordQualityConfig.getEnforced()) {
jpfFirst = new JPasswordQualityField(15, passwordQualityConfig.getMinimumQuality());
} else {
jpfFirst = new JPasswordQualityField(15);
}
} else {
jpfFirst = new JPasswordField(15);
}
GridBagConstraints gbc_jlConfirm = new GridBagConstraints();
gbc_jlConfirm.gridx = 0;
gbc_jlConfirm.gridy = 1;
gbc_jlConfirm.anchor = GridBagConstraints.EAST;
gbc_jlConfirm.insets = new Insets(5, 5, 5, 5);
jpfConfirm = new JPasswordField(15);
GridBagConstraints gbc_jpfConfirm = new GridBagConstraints();
gbc_jpfConfirm.gridx = 1;
gbc_jpfConfirm.gridy = 1;
gbc_jpfConfirm.anchor = GridBagConstraints.WEST;
gbc_jpfConfirm.insets = new Insets(5, 5, 5, 5);
jpPassword = new JPanel(new GridBagLayout());
jpPassword.add(jlFirst, gbc_jlFirst);
jpPassword.add(jpfFirst, gbc_jpfFirst);
jpPassword.add(jlConfirm, gbc_jlConfirm);
jpPassword.add(jpfConfirm, gbc_jpfConfirm);
jpPassword.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5))));
jbOK = new JButton(res.getString("DGetNewPassword.jbOK.text"));
jbOK.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
okPressed();
}
});
jbCancel = new JButton(res.getString("DGetNewPassword.jbCancel.text"));
jbCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
cancelPressed();
}
});
jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY);
jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent evt) {
cancelPressed();
}
});
jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel, false);
getContentPane().add(jpPassword, BorderLayout.CENTER);
getContentPane().add(jpButtons, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
closeDialog();
}
});
setResizable(false);
getRootPane().setDefaultButton(jbOK);
pack();
// fix for focus issues: request focus after dialog was made visible
jpfFirst.addAncestorListener(new AncestorListener() {
@Override
public void ancestorRemoved(AncestorEvent event) {
}
@Override
public void ancestorMoved(AncestorEvent event) {
}
@Override
public void ancestorAdded(AncestorEvent event) {
JComponent component = event.getComponent();
component.requestFocusInWindow();
}
});
}
use of javax.swing.JPasswordField in project keystore-explorer by kaikramer.
the class DExportKeyPair method initComponents.
private void initComponents() {
GridBagConstraints gbcLbl = new GridBagConstraints();
gbcLbl.gridx = 0;
gbcLbl.gridwidth = 3;
gbcLbl.gridheight = 1;
gbcLbl.insets = new Insets(5, 5, 5, 5);
gbcLbl.anchor = GridBagConstraints.EAST;
GridBagConstraints gbcEdCtrl = new GridBagConstraints();
gbcEdCtrl.gridx = 3;
gbcEdCtrl.gridwidth = 3;
gbcEdCtrl.gridheight = 1;
gbcEdCtrl.insets = new Insets(5, 5, 5, 5);
gbcEdCtrl.anchor = GridBagConstraints.WEST;
jlPassword = new JLabel(res.getString("DExportKeyPair.jlPassword.text"));
GridBagConstraints gbc_jlPassword = (GridBagConstraints) gbcLbl.clone();
gbc_jlPassword.gridy = 0;
if (passwordQualityConfig.getEnabled()) {
if (passwordQualityConfig.getEnforced()) {
jpfPassword = new JPasswordQualityField(15, passwordQualityConfig.getMinimumQuality());
} else {
jpfPassword = new JPasswordQualityField(15);
}
} else {
jpfPassword = new JPasswordField(15);
}
jpfPassword.setToolTipText(res.getString("DExportKeyPair.jpqfPassword.tooltip"));
GridBagConstraints gbc_jpfPassword = (GridBagConstraints) gbcEdCtrl.clone();
gbc_jpfPassword.gridy = 0;
jlConfirmPassword = new JLabel(res.getString("DExportKeyPair.jlConfirmPassword.text"));
GridBagConstraints gbc_jlConfirmPassword = (GridBagConstraints) gbcLbl.clone();
gbc_jlConfirmPassword.gridy = 1;
jpfConfirmPassword = new JPasswordField(15);
jpfConfirmPassword.setToolTipText(res.getString("DExportKeyPair.jpfConfirmPassword.tooltip"));
GridBagConstraints gbc_jpfConfirmPassword = (GridBagConstraints) gbcEdCtrl.clone();
gbc_jpfConfirmPassword.gridy = 1;
jlExportFile = new JLabel(res.getString("DExportKeyPair.jlExportFile.text"));
GridBagConstraints gbc_jlExportFile = (GridBagConstraints) gbcLbl.clone();
gbc_jlExportFile.gridy = 2;
jtfExportFile = new JTextField(30);
jtfExportFile.setToolTipText(res.getString("DExportKeyPair.jtfExportFile.tooltip"));
GridBagConstraints gbc_jtfExportFile = (GridBagConstraints) gbcEdCtrl.clone();
gbc_jtfExportFile.gridy = 2;
gbc_jtfExportFile.gridwidth = 6;
jbBrowse = new JButton(res.getString("DExportKeyPair.jbBrowse.text"));
jbBrowse.setToolTipText(res.getString("DExportKeyPair.jbBrowse.tooltip"));
PlatformUtil.setMnemonic(jbBrowse, res.getString("DExportKeyPair.jbBrowse.mnemonic").charAt(0));
GridBagConstraints gbc_jbBrowse = (GridBagConstraints) gbcEdCtrl.clone();
gbc_jbBrowse.gridy = 2;
gbc_jbBrowse.gridx = 9;
jbBrowse.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(DExportKeyPair.this);
browsePressed();
} finally {
CursorUtil.setCursorFree(DExportKeyPair.this);
}
}
});
jpOptions = new JPanel(new GridBagLayout());
jpOptions.setBorder(new CompoundBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new EtchedBorder()), new EmptyBorder(5, 5, 5, 5)));
jpOptions.add(jlPassword, gbc_jlPassword);
jpOptions.add(jpfPassword, gbc_jpfPassword);
jpOptions.add(jlConfirmPassword, gbc_jlConfirmPassword);
jpOptions.add(jpfConfirmPassword, gbc_jpfConfirmPassword);
jpOptions.add(jlExportFile, gbc_jlExportFile);
jpOptions.add(jtfExportFile, gbc_jtfExportFile);
jpOptions.add(jbBrowse, gbc_jbBrowse);
jbExport = new JButton(res.getString("DExportKeyPair.jbExport.text"));
PlatformUtil.setMnemonic(jbExport, res.getString("DExportKeyPair.jbExport.mnemonic").charAt(0));
jbExport.setToolTipText(res.getString("DExportKeyPair.jbExport.tooltip"));
jbExport.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
try {
CursorUtil.setCursorBusy(DExportKeyPair.this);
exportPressed();
} finally {
CursorUtil.setCursorFree(DExportKeyPair.this);
}
}
});
jbCancel = new JButton(res.getString("DExportKeyPair.jbCancel.text"));
jbCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
cancelPressed();
}
});
jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY);
jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent evt) {
cancelPressed();
}
});
jpButtons = PlatformUtil.createDialogButtonPanel(jbExport, jbCancel, false);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(jpOptions, BorderLayout.CENTER);
getContentPane().add(jpButtons, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
closeDialog();
}
});
setTitle(MessageFormat.format(res.getString("DExportKeyPair.Title"), entryAlias));
setResizable(false);
getRootPane().setDefaultButton(jbExport);
populateExportFileName();
pack();
}
use of javax.swing.JPasswordField in project keystore-explorer by kaikramer.
the class DExportPrivateKeyPvk method exportPressed.
private void exportPressed() {
if (jrbExchange.isSelected()) {
keyType = MsPvkUtil.PVK_KEY_EXCHANGE;
} else {
keyType = MsPvkUtil.PVK_KEY_SIGNATURE;
}
encrypt = jcbEncrypt.isSelected();
if (encrypt) {
strongEncryption = jrbStrong.isSelected();
Password firstPassword;
if (jpfPassword instanceof JPasswordQualityField) {
char[] firstPasswordChars = ((JPasswordQualityField) jpfPassword).getPassword();
if (firstPasswordChars == null) {
JOptionPane.showMessageDialog(this, res.getString("DExportPrivateKeyPvk.MinimumPasswordQualityNotMet.message"), res.getString("DExportPrivateKeyPvk.Simple.Title"), JOptionPane.WARNING_MESSAGE);
return;
}
firstPassword = new Password(firstPasswordChars);
} else {
firstPassword = new Password(((JPasswordField) jpfPassword).getPassword());
}
Password confirmPassword = new Password(jpfConfirmPassword.getPassword());
if (firstPassword.equals(confirmPassword)) {
exportPassword = firstPassword;
} else {
JOptionPane.showMessageDialog(this, res.getString("DExportPrivateKeyPvk.PasswordsNoMatch.message"), res.getString("DExportPrivateKeyPvk.Simple.Title"), JOptionPane.WARNING_MESSAGE);
return;
}
}
String exportFileChars = jtfExportFile.getText().trim();
if (exportFileChars.length() == 0) {
JOptionPane.showMessageDialog(this, res.getString("DExportPrivateKeyPvk.ExportFileRequired.message"), res.getString("DExportPrivateKeyPvk.Simple.Title"), JOptionPane.WARNING_MESSAGE);
return;
}
File exportFile = new File(exportFileChars);
if (exportFile.isFile()) {
String message = MessageFormat.format(res.getString("DExportPrivateKeyPvk.OverWriteExportFile.message"), exportFile);
int selected = JOptionPane.showConfirmDialog(this, message, res.getString("DExportPrivateKeyPvk.Simple.Title"), JOptionPane.YES_NO_OPTION);
if (selected != JOptionPane.YES_OPTION) {
return;
}
}
this.exportFile = exportFile;
exportSelected = true;
closeDialog();
}
use of javax.swing.JPasswordField in project jmeter by apache.
the class SSLManager method getPassword.
/*
* The password can be defined as a property; this dialogue is provided to allow it
* to be entered at run-time.
*/
private String getPassword() {
String password = this.defaultpw;
if (null == password) {
final GuiPackage guiInstance = GuiPackage.getInstance();
if (guiInstance != null) {
JPanel panel = new JPanel(new MigLayout("fillx, wrap 2", "[][fill, grow]"));
JLabel passwordLabel = new JLabel("Password: ");
JPasswordField pwf = new JPasswordField(64);
pwf.setEchoChar('*');
passwordLabel.setLabelFor(pwf);
panel.add(passwordLabel);
panel.add(pwf);
int choice = JOptionPane.showConfirmDialog(guiInstance.getMainFrame(), panel, JMeterUtils.getResString("ssl_pass_prompt"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
if (choice == JOptionPane.OK_OPTION) {
char[] pwchars = pwf.getPassword();
this.defaultpw = new String(pwchars);
Arrays.fill(pwchars, '*');
}
System.setProperty(KEY_STORE_PASSWORD, this.defaultpw);
password = this.defaultpw;
}
} else {
log.warn("No password provided, and no GUI present so cannot prompt");
}
return password;
}
use of javax.swing.JPasswordField in project jmeter by apache.
the class HttpDefaultsGui method getProxyPassPanel.
private JPanel getProxyPassPanel() {
proxyPass = new JPasswordField(5);
// $NON-NLS-1$
JLabel label = new JLabel(JMeterUtils.getResString("password"));
label.setLabelFor(proxyPass);
JFactory.small(label);
JPanel panel = new JPanel(new BorderLayout(5, 0));
panel.add(label, BorderLayout.WEST);
panel.add(proxyPass, BorderLayout.CENTER);
return panel;
}
Aggregations