import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.io.File;
public class MainFrame extends JFrame {
JPanel contentPane;
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JLabel jLabel5 = new JLabel();
JLabel jLabel6 = new JLabel();
JLabel jLabel7 = new JLabel();
JLabel jLabel8 = new JLabel();
JTextField hostAddress = new JTextField();
JTextField hostPort = new JTextField();
JTextField method = new JTextField();
JTextField path = new JTextField();
JTextField ssl = new JTextField();
JTextField userDN = new JTextField();
JPasswordField password = new JPasswordField();
JTextArea resultArea = new JTextArea();
JButton browseButton = new JButton();
JButton loginButton = new JButton();
JButton exitButton = new JButton();
Border border1;
JScrollPane jScrollPane1 = new JScrollPane();
public MainFrame() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
border1 = BorderFactory.createBevelBorder(BevelBorder.LOWERED,Color.white,Color.white,new Color(115, 114, 105),new Color(165, 163, 151));
this.setSize(new Dimension(510, 475));
this.setTitle("Java LCM Tester");
jLabel1.setText("Host Address");
jLabel1.setBounds(new Rectangle(45, 15, 150, 15));
jLabel2.setText("Host Port");
jLabel2.setBounds(new Rectangle(190, 15, 150, 15));
jLabel3.setText("Method");
jLabel3.setBounds(new Rectangle(335, 15, 150, 15));
jLabel4.setText("Method Class Path");
jLabel4.setBounds(new Rectangle(45, 60, 150, 15));
jLabel5.setText("Path to Java KeyStore (optional)");
jLabel5.setBounds(new Rectangle(45, 105, 250, 15));
jLabel6.setText("User DN");
jLabel6.setBounds(new Rectangle(45, 150, 150, 15));
jLabel7.setText("Clear Text Password");
jLabel7.setBounds(new Rectangle(270, 150, 150, 15));
jLabel8.setText("Results");
jLabel8.setBounds(new Rectangle(45, 195, 50, 15));
hostAddress.setText("127.0.0.1");
hostAddress.setBounds(new Rectangle(45, 30, 125, 20));
hostPort.setText("389");
hostPort.setBounds(new Rectangle(190, 30, 125, 20));
method.setText("lsmcpwdlin");
method.setBounds(new Rectangle(335, 30, 125, 20));
path.setText("com.novell.security.nmas.lcm.clrpwd.ClearPasswordLCM");
path.setBounds(new Rectangle(45, 75, 415, 20));
ssl.setBounds(new Rectangle(45, 120, 325, 20));
userDN.setBounds(new Rectangle(45, 165, 200, 20));
password.setBounds(new Rectangle(270, 165, 190, 20));
resultArea.setBorder(null);
resultArea.setEditable(true);
resultArea.setText("");
resultArea.setLineWrap(false);
resultArea.setRows(0);
jScrollPane1.setBorder(BorderFactory.createLoweredBevelBorder());
jScrollPane1.setBounds(new Rectangle(45, 210, 415, 125));
jScrollPane1.getViewport().add(resultArea, null);
browseButton.setBounds(new Rectangle(380, 120, 80, 20));
browseButton.setSelected(false);
browseButton.setText("Browse");
browseButton.addActionListener(new MainFrame_browseButton_actionAdapter(this));
loginButton.setBounds(new Rectangle(165, 370, 70, 23));
loginButton.setSelected(false);
loginButton.setText("Login");
loginButton.addActionListener(new MainFrame_loginButton_actionAdapter(this));
exitButton.setBounds(new Rectangle(280, 370, 70, 23));
exitButton.setText("Exit");
exitButton.addActionListener(new MainFrame_exitButton_actionAdapter(this));
contentPane.setLayout(null);
contentPane.setBackground(SystemColor.control);
contentPane.setBorder(BorderFactory.createRaisedBevelBorder());
contentPane.add(jLabel1, null);
contentPane.add(jLabel2, null);
contentPane.add(jLabel3, null);
contentPane.add(jLabel4, null);
contentPane.add(jLabel5, null);
contentPane.add(jLabel6, null);
contentPane.add(jLabel7, null);
contentPane.add(jLabel8, null);
contentPane.add(hostAddress, null);
contentPane.add(hostPort, null);
contentPane.add(method, null);
contentPane.add(path, null);
contentPane.add(ssl, null);
contentPane.add(userDN, null);
contentPane.add(password, null);
contentPane.add(jScrollPane1, null);
contentPane.add(browseButton, null);
contentPane.add(loginButton, null);
contentPane.add(exitButton, null);
}
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
void browseButton_actionPerformed(ActionEvent e) {
JFileChooser fc = new JFileChooser();
int rc = fc.showOpenDialog(this);
if(rc == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
ssl.setText(file.getPath());
hostPort.setText("636");
}
}
void loginButton_actionPerformed(ActionEvent e) {
String host = hostAddress.getText();
String port = hostPort.getText();
String methodName = method.getText();
String methodPath = path.getText();
String sslPath = ssl.getText();
String dn = userDN.getText();
char pass[]= password.getPassword();
String passwd = new String(pass);
int prt = Integer.parseInt(port);
LCMTester cn = new LCMTester(host, prt, methodName, methodPath, sslPath, dn, passwd);
cn.connectAndTest(resultArea);
}
void exitButton_actionPerformed(ActionEvent e) {
System.exit(0);
}
}
class MainFrame_browseButton_actionAdapter implements java.awt.event.ActionListener {
MainFrame adaptee;
MainFrame_browseButton_actionAdapter(MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.browseButton_actionPerformed(e);
}
}
class MainFrame_loginButton_actionAdapter implements java.awt.event.ActionListener {
MainFrame adaptee;
MainFrame_loginButton_actionAdapter(MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.loginButton_actionPerformed(e);
}
}
class MainFrame_exitButton_actionAdapter implements java.awt.event.ActionListener {
MainFrame adaptee;
MainFrame_exitButton_actionAdapter(MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.exitButton_actionPerformed(e);
}
}