use of javax.swing.JPasswordField in project nhin-d by DirectProject.
the class ButtonSelector method actionPerformed.
public void actionPerformed(ActionEvent event) {
//System.out.println("Event"+event.getActionCommand());
if (event.getActionCommand().equalsIgnoreCase("Create Bundle")) {
Component[] data = pane.getComponents();
JTextField anchorDir = (JTextField) data[4];
JTextField metaDataFile = (JTextField) data[7];
JTextField destDir = (JTextField) data[10];
JTextField bundleName = (JTextField) data[13];
CreateUnSignedPKCS7 unCert = new CreateUnSignedPKCS7();
error = unCert.getParameters(anchorDir.getText(), metaDataFile.getText(), destDir.getText(), bundleName.getText());
JTextPane feedback = (JTextPane) data[16];
feedback.setText(error);
} else if (event.getActionCommand().equalsIgnoreCase("Create Signed Bundle")) {
Component[] data = pane.getComponents();
JTextField anchorDir = (JTextField) data[4];
JTextField metaDataFile = (JTextField) data[7];
JTextField certificateDir = (JTextField) data[10];
JPasswordField passkey = (JPasswordField) data[13];
//String passVal=new String();
//System.out.println("The password:"+String.copyValueOf(passkey.getPassword()));
JTextField destDir = (JTextField) data[15];
JTextField bundleName = (JTextField) data[18];
CreateSignedPKCS7 unCert = new CreateSignedPKCS7();
error = unCert.getParameters(anchorDir.getText(), metaDataFile.getText(), certificateDir.getText(), String.copyValueOf(passkey.getPassword()), destDir.getText(), bundleName.getText());
//System.out.println("The destination file path is:"+error);
JTextPane feedback = (JTextPane) data[21];
feedback.setText(error);
} else {
Component[] data = pane.getComponents();
JTextField trustBundle = (JTextField) data[4];
ViewTrustBundlePKCS7 unCert = new ViewTrustBundlePKCS7();
error = unCert.getParameters(trustBundle.getText());
new PreviewTrustBundle(error);
PreviewTrustBundle.createAndShowGUI();
//JTextPane feedback = (JTextPane) data[8];
//feedback.setText(error);
}
}
use of javax.swing.JPasswordField in project GNS by MobilityFirst.
the class Sudo method main.
/**
*
* @param arg
*/
public static void main(String[] arg) {
try {
JSch jsch = new JSch();
Session session = SSHClient.authenticateWithKey(jsch, null, null, null);
UserInfo ui = new UserInfoPrompted();
session.setUserInfo(ui);
session.connect();
String command = JOptionPane.showInputDialog("Enter command, execed with sudo", "printenv SUDO_USER");
String sudo_pass = null;
{
JTextField passwordField = new JPasswordField(8);
Object[] ob = { passwordField };
int result = JOptionPane.showConfirmDialog(null, ob, "Enter password for sudo", JOptionPane.OK_CANCEL_OPTION);
if (result != JOptionPane.OK_OPTION) {
System.exit(-1);
}
sudo_pass = passwordField.getText();
}
Channel channel = session.openChannel("exec");
// man sudo
// -S The -S (stdin) option causes sudo to read the password from the
// standard input instead of the terminal device.
// -p The -p (prompt) option allows you to override the default
// password prompt and use a custom one.
((ChannelExec) channel).setCommand("sudo -S -p '' " + command);
InputStream in = channel.getInputStream();
OutputStream out = channel.getOutputStream();
((ChannelExec) channel).setErrStream(System.err);
((ChannelExec) channel).setPty(true);
channel.connect();
out.write((sudo_pass + "\n").getBytes());
out.flush();
byte[] tmp = new byte[1024];
while (true) {
while (in.available() > 0) {
int i = in.read(tmp, 0, 1024);
if (i < 0) {
break;
}
System.out.print(new String(tmp, 0, i));
}
if (channel.isClosed()) {
System.out.println("exit-status: " + channel.getExitStatus());
break;
}
try {
Thread.sleep(1000);
} catch (Exception ee) {
}
}
channel.disconnect();
session.disconnect();
} catch (JSchException | HeadlessException | IOException e) {
System.out.println(e);
}
}
use of javax.swing.JPasswordField in project nhin-d by DirectProject.
the class TokenLoginCallback method handle.
@Override
public synchronized void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (Callback callback : callbacks) {
if (callback instanceof PasswordCallback) {
final JPanel panel = new JPanel();
final JLabel label = new JLabel("Enter hardware token password:");
final JPasswordField pass = new JPasswordField(20);
panel.add(label);
panel.add(pass);
final String[] options = new String[] { "OK", "Cancel" };
int option = JOptionPane.showOptionDialog(null, panel, "Token ", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
if (// pressing OK button
option == JOptionPane.OK_OPTION) {
((PasswordCallback) callback).setPassword(pass.getPassword());
}
}
}
this.notifyAll();
}
use of javax.swing.JPasswordField in project jdk8u_jdk by JetBrains.
the class DimensionEncapsulation method run.
@Override
public void run() {
runTest(new Panel());
runTest(new Button());
runTest(new Checkbox());
runTest(new Canvas());
runTest(new Choice());
runTest(new Label());
runTest(new Scrollbar());
runTest(new TextArea());
runTest(new TextField());
runTest(new Dialog(new JFrame()));
runTest(new Frame());
runTest(new Window(new JFrame()));
runTest(new FileDialog(new JFrame()));
runTest(new List());
runTest(new ScrollPane());
runTest(new JFrame());
runTest(new JDialog(new JFrame()));
runTest(new JWindow(new JFrame()));
runTest(new JLabel("hi"));
runTest(new JMenu());
runTest(new JTree());
runTest(new JTable());
runTest(new JMenuItem());
runTest(new JCheckBoxMenuItem());
runTest(new JToggleButton());
runTest(new JSpinner());
runTest(new JSlider());
runTest(Box.createVerticalBox());
runTest(Box.createHorizontalBox());
runTest(new JTextField());
runTest(new JTextArea());
runTest(new JTextPane());
runTest(new JPasswordField());
runTest(new JFormattedTextField());
runTest(new JEditorPane());
runTest(new JButton());
runTest(new JColorChooser());
runTest(new JFileChooser());
runTest(new JCheckBox());
runTest(new JInternalFrame());
runTest(new JDesktopPane());
runTest(new JTableHeader());
runTest(new JLayeredPane());
runTest(new JRootPane());
runTest(new JMenuBar());
runTest(new JOptionPane());
runTest(new JRadioButton());
runTest(new JRadioButtonMenuItem());
runTest(new JPopupMenu());
//runTest(new JScrollBar()); --> don't test defines max and min in
// terms of preferred
runTest(new JScrollPane());
runTest(new JViewport());
runTest(new JSplitPane());
runTest(new JTabbedPane());
runTest(new JToolBar());
runTest(new JSeparator());
runTest(new JProgressBar());
if (!failures.isEmpty()) {
System.out.println("These classes failed");
for (final Component failure : failures) {
System.out.println(failure.getClass());
}
throw new RuntimeException("Test failed");
}
}
use of javax.swing.JPasswordField in project jgnash by ccavanaugh.
the class NetworkAuthenticator method getPasswordAuthentication.
@Override
protected PasswordAuthentication getPasswordAuthentication() {
Preferences auth = Preferences.userRoot().node(NODEHTTP);
char[] pass = null;
String user;
// get the password
String _pass = auth.get(HTTPPASS, null);
if (_pass != null) {
if (!_pass.isEmpty()) {
pass = _pass.toCharArray();
}
}
// get the user
user = auth.get(HTTPUSER, null);
if (user != null) {
if (user.length() <= 0) {
user = null;
}
}
// if either returns null, pop a dialog
if (user == null || pass == null) {
JTextField username = new JTextField();
JPasswordField password = new JPasswordField();
JPanel panel = new JPanel(new GridLayout(2, 2));
panel.add(new JLabel(ResourceUtils.getString("Label.UserName")));
panel.add(username);
panel.add(new JLabel(ResourceUtils.getString("Label.Password")));
panel.add(password);
int option = JOptionPane.showConfirmDialog(null, new Object[] { "Site: " + getRequestingHost(), "Realm: " + getRequestingPrompt(), panel }, "Enter Network Password", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
if (option == JOptionPane.OK_OPTION) {
user = username.getText();
pass = password.getPassword();
} else {
return null;
}
}
return new PasswordAuthentication(user, pass);
}
Aggregations