Search in sources :

Example 1 with JPasswordField

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);
    }
}
Also used : ViewTrustBundlePKCS7(org.nhindirect.trustbundle.core.ViewTrustBundlePKCS7) JTextPane(javax.swing.JTextPane) CreateUnSignedPKCS7(org.nhindirect.trustbundle.core.CreateUnSignedPKCS7) JPasswordField(javax.swing.JPasswordField) CreateSignedPKCS7(org.nhindirect.trustbundle.core.CreateSignedPKCS7) Component(java.awt.Component) JTextField(javax.swing.JTextField) PreviewTrustBundle(org.nhindirect.trustbundle.ui.PreviewTrustBundle)

Example 2 with JPasswordField

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);
    }
}
Also used : JSchException(com.jcraft.jsch.JSchException) UserInfoPrompted(edu.umass.cs.aws.networktools.UserInfoPrompted) HeadlessException(java.awt.HeadlessException) InputStream(java.io.InputStream) Channel(com.jcraft.jsch.Channel) OutputStream(java.io.OutputStream) UserInfo(com.jcraft.jsch.UserInfo) IOException(java.io.IOException) JSch(com.jcraft.jsch.JSch) JTextField(javax.swing.JTextField) ChannelExec(com.jcraft.jsch.ChannelExec) IOException(java.io.IOException) HeadlessException(java.awt.HeadlessException) JSchException(com.jcraft.jsch.JSchException) JPasswordField(javax.swing.JPasswordField) Session(com.jcraft.jsch.Session)

Example 3 with JPasswordField

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();
}
Also used : JPanel(javax.swing.JPanel) PasswordCallback(javax.security.auth.callback.PasswordCallback) Callback(javax.security.auth.callback.Callback) JPasswordField(javax.swing.JPasswordField) PasswordCallback(javax.security.auth.callback.PasswordCallback) JLabel(javax.swing.JLabel)

Example 4 with JPasswordField

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");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) Choice(java.awt.Choice) JTextArea(javax.swing.JTextArea) TextArea(java.awt.TextArea) JTextArea(javax.swing.JTextArea) Label(java.awt.Label) JLabel(javax.swing.JLabel) JTableHeader(javax.swing.table.JTableHeader) JToggleButton(javax.swing.JToggleButton) JToggleButton(javax.swing.JToggleButton) Button(java.awt.Button) JRadioButton(javax.swing.JRadioButton) JButton(javax.swing.JButton) JFrame(javax.swing.JFrame) Checkbox(java.awt.Checkbox) JDialog(javax.swing.JDialog) FileDialog(java.awt.FileDialog) Dialog(java.awt.Dialog) JTextField(javax.swing.JTextField) TextField(java.awt.TextField) JFormattedTextField(javax.swing.JFormattedTextField) JSlider(javax.swing.JSlider) ArrayList(java.util.ArrayList) List(java.awt.List) Canvas(java.awt.Canvas) JWindow(javax.swing.JWindow) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) ScrollPane(java.awt.ScrollPane) JScrollPane(javax.swing.JScrollPane) JTable(javax.swing.JTable) JSpinner(javax.swing.JSpinner) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JDialog(javax.swing.JDialog) JFrame(javax.swing.JFrame) Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JTextPane(javax.swing.JTextPane) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) Scrollbar(java.awt.Scrollbar) Window(java.awt.Window) JWindow(javax.swing.JWindow) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) JPopupMenu(javax.swing.JPopupMenu) Panel(java.awt.Panel) JEditorPane(javax.swing.JEditorPane) JRootPane(javax.swing.JRootPane) FileDialog(java.awt.FileDialog) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Example 5 with JPasswordField

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);
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) JPasswordField(javax.swing.JPasswordField) JLabel(javax.swing.JLabel) Preferences(java.util.prefs.Preferences) JTextField(javax.swing.JTextField) PasswordAuthentication(java.net.PasswordAuthentication)

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