1 19 package org.lucane.applications.passwdchanger; 20 21 import org.lucane.client.*; 22 import org.lucane.client.widgets.*; 23 import org.lucane.common.*; 24 import org.lucane.common.crypto.MD5; 25 import org.lucane.common.net.ObjectConnection; 26 import java.awt.*; 27 import java.awt.event.*; 28 import javax.swing.*; 29 30 31 public class PasswdChanger extends StandalonePlugin 32 implements ActionListener 33 { 34 35 private ManagedWindow window; 36 private JTextField txtold; 37 private JTextField txtnew1; 38 private JTextField txtnew2; 39 private JButton btnChange; 40 41 42 private ConnectInfo cinfo; 43 44 47 public PasswdChanger() 48 { 49 } 50 51 57 public Plugin newInstance(ConnectInfo[] friends) 58 { 59 return new PasswdChanger(); 60 } 61 62 65 public void start() 66 { 67 this.cinfo = Communicator.getInstance().getConnectInfo("org.lucane.applications.passwdchanger"); 68 window = new ManagedWindow(this, getTitle()); 69 window.setExitPluginOnClose(true); 70 window.getContentPane().setLayout(new GridLayout(0, 2)); 71 txtold = new JPasswordField(); 72 txtnew1 = new JPasswordField(); 73 txtnew2 = new JPasswordField(); 74 btnChange = new JButton(tr("button")); 75 btnChange.addActionListener(this); 76 window.getContentPane().add(new JLabel(tr("old"))); 77 window.getContentPane().add(txtold); 78 window.getContentPane().add(new JLabel(tr("new"))); 79 window.getContentPane().add(txtnew1); 80 window.getContentPane().add(new JLabel(tr("check"))); 81 window.getContentPane().add(txtnew2); 82 window.getContentPane().add(new JLabel("")); 83 window.getContentPane().add(btnChange); 84 window.show(); 85 } 86 87 93 public void actionPerformed(ActionEvent ae) 94 { 95 if(txtnew1.getText().length() == 0) 96 { 97 DialogBox.info(tr("nullpasswd")); 98 return; 99 } 100 101 if(! txtnew1.getText().equals(txtnew2.getText())) 102 { 103 DialogBox.error(tr("typo")); 104 return; 105 } 106 107 try 108 { 109 ObjectConnection oc = Communicator.getInstance().sendMessageTo(cinfo, 110 "org.lucane.applications.passwdchanger", "CHANGE_PASSWD " + 111 MD5.encode(txtold.getText()) + " " + 112 MD5.encode(txtnew1.getText())); 113 String response = oc.readString(); 114 oc.close(); 115 116 if(response.equals("BAD_PASSWD")) 117 DialogBox.error(tr("invalid")); 118 else if(response.equals("PASSWD_CHANGED")) 119 { 120 DialogBox.info(tr("modified")); 121 window.dispose(); 122 exit(); 123 } 124 } 125 catch(Exception e) 126 { 127 DialogBox.error(tr("error") + e); 128 } 129 } 130 } 131 | Popular Tags |