1 2 package org.enhydra.jawe.wfxml; 3 4 import java.awt.GridLayout ; 5 import java.net.Authenticator ; 6 import java.net.PasswordAuthentication ; 7 8 import javax.swing.*; 9 10 16 public class WfXMLAuthenticator extends Authenticator { 17 18 private JDialog parent; 19 20 private JTextField jtf; 21 22 private JTextField jpf; 23 24 private JPanel jp; 25 26 private JLabel jl; 27 28 31 public WfXMLAuthenticator(JDialog d) { 32 super(); 33 parent = d; 34 jtf = new JTextField(); 35 jpf = new JPasswordField(); 36 jl = new JLabel(); 37 jp = new JPanel(new GridLayout (3, 2, 5, 3)); 38 jp.add(new JLabel("Requesting Prompt:")); 39 jp.add(jl); 40 jp.add(new JLabel("Username:")); 41 jp.add(jtf); 42 jp.add(new JLabel("Password:")); 43 jp.add(jpf); 44 } 45 46 protected PasswordAuthentication getPasswordAuthentication() { 47 jl.setText(this.getRequestingPrompt()); 48 int a = JOptionPane.showConfirmDialog(parent, 49 jp, 50 "Enter credentials, please!", 51 JOptionPane.OK_CANCEL_OPTION, 52 JOptionPane.QUESTION_MESSAGE); 53 if (JOptionPane.OK_OPTION == a) { 55 return new PasswordAuthentication (jtf.getText(), jpf.getText() 56 .toCharArray()); 57 } else { 58 return null; 59 } 60 } 61 } | Popular Tags |