From 1e935eea66bb0ad46e5599619e77d995f538cdb6 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Fri, 15 Aug 2008 19:24:50 +0000 Subject: Client: Added change password Closes #35 --- .../fourisland/instadisc/ChangePasswordForm.form | 171 +++++++++++++++++ .../fourisland/instadisc/ChangePasswordForm.java | 207 +++++++++++++++++++++ .../com/fourisland/instadisc/FirstRun/Step2.java | 2 +- .../com/fourisland/instadisc/InstaDiscView.form | 9 + .../com/fourisland/instadisc/InstaDiscView.java | 20 +- .../resources/ChangePasswordForm.properties | 14 ++ .../instadisc/resources/InstaDiscView.properties | 1 + 7 files changed, 421 insertions(+), 3 deletions(-) create mode 100644 client/trunk/src/com/fourisland/instadisc/ChangePasswordForm.form create mode 100644 client/trunk/src/com/fourisland/instadisc/ChangePasswordForm.java create mode 100644 client/trunk/src/com/fourisland/instadisc/resources/ChangePasswordForm.properties diff --git a/client/trunk/src/com/fourisland/instadisc/ChangePasswordForm.form b/client/trunk/src/com/fourisland/instadisc/ChangePasswordForm.form new file mode 100644 index 0000000..93681ac --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/ChangePasswordForm.form @@ -0,0 +1,171 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/client/trunk/src/com/fourisland/instadisc/ChangePasswordForm.java b/client/trunk/src/com/fourisland/instadisc/ChangePasswordForm.java new file mode 100644 index 0000000..8af46ff --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/ChangePasswordForm.java @@ -0,0 +1,207 @@ +/* + * ChangePasswordForm.java + * + * Created on August 15, 2008, 2:56 PM + */ + +package com.fourisland.instadisc; + +import com.fourisland.instadisc.Database.Wrapper; +import com.fourisland.instadisc.Item.MD5; + +/** + * + * @author hatkirby + */ +public class ChangePasswordForm extends javax.swing.JDialog { + + /** Creates new form ChangePasswordForm */ + public ChangePasswordForm(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + jPasswordField1 = new javax.swing.JPasswordField(); + jPasswordField2 = new javax.swing.JPasswordField(); + jPasswordField3 = new javax.swing.JPasswordField(); + jButton1 = new javax.swing.JButton(); + jButton2 = new javax.swing.JButton(); + jLabel6 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setName("Form"); // NOI18N + + org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(com.fourisland.instadisc.InstaDiscApp.class).getContext().getResourceMap(ChangePasswordForm.class); + jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N + jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N + jLabel1.setName("jLabel1"); // NOI18N + + jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N + jLabel2.setName("jLabel2"); // NOI18N + + jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N + jLabel3.setName("jLabel3"); // NOI18N + + jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N + jLabel4.setName("jLabel4"); // NOI18N + + jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N + jLabel5.setName("jLabel5"); // NOI18N + + jPasswordField1.setText(resourceMap.getString("jPasswordField1.text")); // NOI18N + jPasswordField1.setName("jPasswordField1"); // NOI18N + + jPasswordField2.setText(resourceMap.getString("jPasswordField2.text")); // NOI18N + jPasswordField2.setName("jPasswordField2"); // NOI18N + + jPasswordField3.setText(resourceMap.getString("jPasswordField3.text")); // NOI18N + jPasswordField3.setName("jPasswordField3"); // NOI18N + + jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N + jButton1.setName("jButton1"); // NOI18N + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N + jButton2.setName("jButton2"); // NOI18N + jButton2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton2ActionPerformed(evt); + } + }); + + jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N + jLabel6.setName("jLabel6"); // NOI18N + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1) + .addGroup(layout.createSequentialGroup() + .addGap(12, 12, 12) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton1)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel5) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPasswordField3, javax.swing.GroupLayout.DEFAULT_SIZE, 203, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel3) + .addComponent(jLabel4)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jPasswordField2, javax.swing.GroupLayout.DEFAULT_SIZE, 257, Short.MAX_VALUE) + .addComponent(jPasswordField1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 257, Short.MAX_VALUE))) + .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 364, Short.MAX_VALUE)))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4) + .addComponent(jPasswordField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel5) + .addComponent(jPasswordField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jButton1) + .addComponent(jButton2) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + setVisible(false); + }//GEN-LAST:event_jButton1ActionPerformed + + private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed + MD5 old = new MD5(new String(jPasswordField1.getPassword())); + MD5 newP = new MD5(new String(jPasswordField2.getPassword())); + + if (Wrapper.getConfig("password").equals(old.hash())) + { + if (new String(jPasswordField2.getPassword()).equals(new String(jPasswordField3.getPassword()))) + { + Wrapper.setConfig("password",newP.hash()); + jLabel6.setText("Password changed"); + } else { + jLabel6.setText("Error: Passwords do not match"); + } + } else { + jLabel6.setText("Error: Old password is not correct"); + } + }//GEN-LAST:event_jButton2ActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + ChangePasswordForm dialog = new ChangePasswordForm(new javax.swing.JFrame(), true); + dialog.addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent e) { + System.exit(0); + } + }); + dialog.setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JPasswordField jPasswordField1; + private javax.swing.JPasswordField jPasswordField2; + private javax.swing.JPasswordField jPasswordField3; + // End of variables declaration//GEN-END:variables + +} diff --git a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.java b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.java index 01a3c02..0a8287b 100644 --- a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.java +++ b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.java @@ -150,7 +150,7 @@ public class Step2 extends javax.swing.JDialog { jLabel5.setText("Error: You forgot to enter a Central Server URL"); } else { try { - URL url = new URL(jTextField3.getText()); + new URL(jTextField3.getText()); MD5 md5 = new MD5(jPasswordField1.getPassword()); String password = md5.hash(); diff --git a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.form b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.form index 5050377..5ca439a 100644 --- a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.form +++ b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.form @@ -109,6 +109,15 @@ + + + + + + + + + diff --git a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java index b03ce07..a1d2b5e 100644 --- a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java +++ b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java @@ -147,6 +147,7 @@ public class InstaDiscView extends FrameView { jSeparator1 = new javax.swing.JSeparator(); javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem(); jMenu1 = new javax.swing.JMenu(); + jMenuItem7 = new javax.swing.JMenuItem(); jMenuItem3 = new javax.swing.JMenuItem(); jMenuItem4 = new javax.swing.JMenuItem(); jMenuItem5 = new javax.swing.JMenuItem(); @@ -225,6 +226,15 @@ public class InstaDiscView extends FrameView { jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N jMenu1.setName("jMenu1"); // NOI18N + jMenuItem7.setText(resourceMap.getString("jMenuItem7.text")); // NOI18N + jMenuItem7.setName("jMenuItem7"); // NOI18N + jMenuItem7.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem7ActionPerformed(evt); + } + }); + jMenu1.add(jMenuItem7); + jMenuItem3.setText(resourceMap.getString("jMenuItem3.text")); // NOI18N jMenuItem3.setName("jMenuItem3"); // NOI18N jMenuItem3.addActionListener(new java.awt.event.ActionListener() { @@ -363,7 +373,7 @@ public class InstaDiscView extends FrameView { private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed try - {//GEN-LAST:event_jMenuItem6ActionPerformed + { if (java.awt.Desktop.isDesktopSupported()) { java.awt.Desktop.getDesktop().browse(new URI("http://fourisland.com/projects/instadisc/")); @@ -377,7 +387,12 @@ public class InstaDiscView extends FrameView { { Logger.getLogger(InstaDiscView.class.getName()).log(Level.SEVERE, null, ex); } - } + }//GEN-LAST:event_jMenuItem6ActionPerformed + + private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed + ChangePasswordForm cpf = new ChangePasswordForm(new JFrame(), true); + cpf.setVisible(true); + }//GEN-LAST:event_jMenuItem7ActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JList jList1; @@ -388,6 +403,7 @@ public class InstaDiscView extends FrameView { private javax.swing.JMenuItem jMenuItem4; private javax.swing.JMenuItem jMenuItem5; private javax.swing.JMenuItem jMenuItem6; + private javax.swing.JMenuItem jMenuItem7; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JSeparator jSeparator1; private javax.swing.JPanel mainPanel; diff --git a/client/trunk/src/com/fourisland/instadisc/resources/ChangePasswordForm.properties b/client/trunk/src/com/fourisland/instadisc/resources/ChangePasswordForm.properties new file mode 100644 index 0000000..f02a2c8 --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/resources/ChangePasswordForm.properties @@ -0,0 +1,14 @@ + +jLabel1.text=Change Password +#NOI18N +jLabel1.font=DejaVu Sans-Plain-18 +jLabel2.text=If you wish to change your password, you can do so here. Remember, if you change your password, you must change it both here and at your Central Server. +jLabel3.text=Old Password: +jLabel4.text=New Password: +jLabel5.text=Confirm New Password: +jPasswordField1.text= +jPasswordField2.text= +jPasswordField3.text= +jButton1.text=Done +jButton2.text=OK +jLabel6.text= diff --git a/client/trunk/src/com/fourisland/instadisc/resources/InstaDiscView.properties b/client/trunk/src/com/fourisland/instadisc/resources/InstaDiscView.properties index 6908fcb..d7bcf10 100644 --- a/client/trunk/src/com/fourisland/instadisc/resources/InstaDiscView.properties +++ b/client/trunk/src/com/fourisland/instadisc/resources/InstaDiscView.properties @@ -37,3 +37,4 @@ jMenuItem3.text=Manage Filters jMenuItem4.text=Request Retained Items jMenuItem5.text=Advanced Settings jMenuItem6.text=InstaDisc Website +jMenuItem7.text=Change Password -- cgit 1.4.1