From 57ee15834b0f1c3d27b9f840bb7e4477e2d43994 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 7 Sep 2008 02:10:01 +0000 Subject: Client: Centralized Central Also modified the Client to work with Subscription Series (#28) Fixes #52; Refs #28 --- .../com/fourisland/instadisc/FirstRun/Step2.form | 37 +++------ .../com/fourisland/instadisc/FirstRun/Step2.java | 95 ++++++++-------------- .../instadisc/FirstRun/resources/Step2.properties | 4 +- .../instadisc/Item/SubscriptionFile.java | 60 +++++++++----- .../trunk/src/com/fourisland/instadisc/XmlRpc.java | 23 ++++-- 5 files changed, 98 insertions(+), 121 deletions(-) (limited to 'client/trunk/src/com/fourisland') diff --git a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.form b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.form index 666f518..ce8ae5c 100644 --- a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.form +++ b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.form @@ -33,26 +33,25 @@ - - + - - - - - - + + + + + + @@ -75,16 +74,12 @@ - - - - - - + - + + @@ -109,24 +104,12 @@ - - - - - - - - - - - - diff --git a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.java b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.java index e327271..292dbb1 100644 --- a/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.java +++ b/client/trunk/src/com/fourisland/instadisc/FirstRun/Step2.java @@ -34,9 +34,7 @@ public class Step2 extends javax.swing.JDialog { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); - jTextField3 = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); - jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); jLabel6 = new javax.swing.JLabel(); @@ -56,15 +54,9 @@ public class Step2 extends javax.swing.JDialog { jTextField1.setText(resourceMap.getString("jTextField1.text")); // NOI18N jTextField1.setName("jTextField1"); // NOI18N - jTextField3.setText(resourceMap.getString("jTextField3.text")); // NOI18N - jTextField3.setName("jTextField3"); // 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 @@ -96,20 +88,19 @@ public class Step2 extends javax.swing.JDialog { .addGap(12, 12, 12) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2) - .addComponent(jLabel3) - .addComponent(jLabel4)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel3)) + .addGap(66, 66, 66) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE) - .addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE) - .addComponent(jPasswordField1, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE))) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jButton1)))) + .addComponent(jPasswordField1, javax.swing.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE))))) .addGroup(layout.createSequentialGroup() .addGap(24, 24, 24) - .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 359, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 359, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton1))) .addContainerGap()) ); layout.setVerticalGroup( @@ -128,13 +119,10 @@ public class Step2 extends javax.swing.JDialog { .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(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel4)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jButton1))) + .addComponent(jButton1) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) ); pack(); @@ -146,41 +134,28 @@ public class Step2 extends javax.swing.JDialog { if (jPasswordField1.getPassword().length == 0) { jLabel5.setText("Error: You forgot to enter a password"); } else { - if (jTextField3.getText().equals("")) { - jLabel5.setText("Error: You forgot to enter a Central Server URL"); - } else { - try { - new URL(jTextField3.getText()); - - MD5 md5 = new MD5(jPasswordField1.getPassword()); - String password = md5.hash(); - - XmlRpc xmlrpc = new XmlRpc("checkRegistration", jTextField3.getText(), jTextField1.getText(), password); - Integer r = (Integer) xmlrpc.execute(); - - if (r == 1) - { - jLabel5.setText("Error: No registration exists on the specified Central Server with the specified UN/PW combination"); - } else { - Wrapper.setConfig("username", jTextField1.getText()); - Wrapper.setConfig("password", password); - Wrapper.setConfig("centralServerURL", jTextField3.getText()); - Wrapper.setConfig("itemBufferSize", "10"); - Wrapper.setConfig("verIDBufferSize", "10000"); - Wrapper.setConfig("nextFilterID", "0"); - Wrapper.setConfig("ipCheckValue", "1"); - Wrapper.setConfig("ipCheckUnit", "day"); - Wrapper.setConfig("useUnreadFlag", "true"); - Wrapper.setConfig("initCheck", "done"); - - StepEndResults.ok = true; - this.setVisible(false); - } - } catch (MalformedURLException ex) { - jLabel5.setText("Error: The Central Server URL is malformed"); - } catch (NullPointerException ex) { - jLabel5.setText("Error: The Central Server URL specified does not exist"); - } + MD5 md5 = new MD5(jPasswordField1.getPassword()); + String password = md5.hash(); + + XmlRpc xmlrpc = new XmlRpc("checkRegistration", jTextField1.getText(), password); + Integer r = (Integer) xmlrpc.execute(); + + if (r == 1) + { + jLabel5.setText("Error: No registration exists on the specified Central Server with the specified UN/PW combination"); + } else { + Wrapper.setConfig("username", jTextField1.getText()); + Wrapper.setConfig("password", password); + Wrapper.setConfig("itemBufferSize", "10"); + Wrapper.setConfig("verIDBufferSize", "10000"); + Wrapper.setConfig("nextFilterID", "0"); + Wrapper.setConfig("ipCheckValue", "1"); + Wrapper.setConfig("ipCheckUnit", "day"); + Wrapper.setConfig("useUnreadFlag", "true"); + Wrapper.setConfig("initCheck", "done"); + + StepEndResults.ok = true; + this.setVisible(false); } } } @@ -209,11 +184,9 @@ public class Step2 extends javax.swing.JDialog { 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.JTextField jTextField1; - private javax.swing.JTextField jTextField3; // End of variables declaration//GEN-END:variables } diff --git a/client/trunk/src/com/fourisland/instadisc/FirstRun/resources/Step2.properties b/client/trunk/src/com/fourisland/instadisc/FirstRun/resources/Step2.properties index eb8e058..9adb0b8 100644 --- a/client/trunk/src/com/fourisland/instadisc/FirstRun/resources/Step2.properties +++ b/client/trunk/src/com/fourisland/instadisc/FirstRun/resources/Step2.properties @@ -3,10 +3,8 @@ jLabel1.text=Central Server Details jLabel1.font=DejaVu Sans-Plain-18 jLabel2.text=Username: jTextField1.text= -jTextField3.text= jLabel3.text=Password: -jLabel4.text=Central Server URL: jLabel5.text= jButton1.text=Next -jLabel6.text=To use InstaDisc, you must have chosen and signed up for a Central Server. Please input below the details it gave you after registration. +jLabel6.text=To use InstaDisc, you must have signed up for the Four Island InstaDisc Central Server. Please input your member details here. jPasswordField1.text= diff --git a/client/trunk/src/com/fourisland/instadisc/Item/SubscriptionFile.java b/client/trunk/src/com/fourisland/instadisc/Item/SubscriptionFile.java index 0236c11..4d8976d 100644 --- a/client/trunk/src/com/fourisland/instadisc/Item/SubscriptionFile.java +++ b/client/trunk/src/com/fourisland/instadisc/Item/SubscriptionFile.java @@ -14,6 +14,8 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.util.HashMap; import java.util.logging.Level; @@ -139,42 +141,56 @@ class SubscriptionFileThread implements Runnable { s.setTitle(headerMap.get("Title")); s.setCategory(headerMap.get("Category")); - if (Functions.xor(headerMap.containsKey("Verification"),headerMap.containsKey("Verification-ID"))) + if (headerMap.containsKey("Series-Control-URL") && headerMap.containsKey("Password") && headerMap.containsKey("Subscription-ID")) { - if (headerMap.containsKey("Verification")) + if (headerMap.get("Password").endsWith("On")) { - AskForPasswordForm afpf = new AskForPasswordForm(new JFrame(),true); - afpf.setVisible(true); - - if (afpf.getEntered() || afpf.getPassword().equals("")) + try { - MD5 md5 = new MD5(afpf.getPassword()); - MD5 hash = new MD5(s.getTitle() + ":" + md5.hash() + ":" + headerMap.get("Verification-ID")); + URI url = new URI(headerMap.get("Series-Control-URL")); + XmlRpc xmlrpc = new XmlRpc(url.toString(), "getPasswordInfo"); + xmlrpc.addParam(headerMap.get("Subscription-ID")); + String resp = (String) xmlrpc.execute(); + String[] val = resp.split(":"); - if (hash.hash().equals(headerMap.get("Verification"))) + AskForPasswordForm afpf = new AskForPasswordForm(new JFrame(),true); + afpf.setVisible(true); + + if (afpf.getEntered() || afpf.getPassword().equals("")) { - s.setPassword(afpf.getPassword()); + MD5 md5 = new MD5(afpf.getPassword()); + MD5 hash = new MD5(s.getTitle() + ":" + md5.hash() + ":" + val[1]); + + if (hash.hash().equals(val[0])) + { + s.setPassword(afpf.getPassword()); + } else { + status.setText("Error: Incorrect password entered"); + return; + } } else { - status.setText("Error: Incorrect password entered"); + status.setText("Error: No password entered"); return; } - } else { - status.setText("Error: No password entered"); - return; + } catch (URISyntaxException ex) + { + Logger.getLogger(SubscriptionFileThread.class.getName()).log(Level.SEVERE, null, ex); } } else { s.setPassword(""); } - - Wrapper.addSubscription(s); + } else { + s.setPassword(""); + } - XmlRpc xmlrpc = new XmlRpc("addSubscription"); - xmlrpc.addParam(headerMap.get("Subscription")); - xmlrpc.addParam(headerMap.get("Category")); - xmlrpc.execute(); + Wrapper.addSubscription(s); - status.setText("You've sucessfully subscribed to that website"); - } + XmlRpc xmlrpc = new XmlRpc("addSubscription"); + xmlrpc.addParam(headerMap.get("Subscription")); + xmlrpc.addParam(headerMap.get("Category")); + xmlrpc.execute(); + + status.setText("You've sucessfully subscribed to that website"); } else { status.setText("Error: Subscription file is not well-formed"); } diff --git a/client/trunk/src/com/fourisland/instadisc/XmlRpc.java b/client/trunk/src/com/fourisland/instadisc/XmlRpc.java index 8c22155..4fe5b4b 100644 --- a/client/trunk/src/com/fourisland/instadisc/XmlRpc.java +++ b/client/trunk/src/com/fourisland/instadisc/XmlRpc.java @@ -23,14 +23,11 @@ public class XmlRpc { private String function; private Object[] params; private int step = 3; - private String url = ""; + private String url; public XmlRpc(String function) { this.function = function; - if (url.equals("")) - { - url = Wrapper.getConfig("centralServerURL"); - } + this.url = "http://central.fourisland.com/xmlrpc.php"; Verification ver = new Verification(); params = new Object[3]; @@ -39,11 +36,21 @@ public class XmlRpc { params[2] = ver.getID(); } - public XmlRpc(String function, String url, String username, String password) - { + public XmlRpc(String url, String function) { this.function = function; this.url = url; + Verification ver = new Verification(); + params = new Object[3]; + params[0] = ver.getUsername(); + params[1] = ver.getHash(); + params[2] = ver.getID(); + } + + public XmlRpc(String function, String username, String password) + { + this.function = function; + Verification ver = new Verification(username, password); params = new Object[3]; params[0] = ver.getUsername(); @@ -69,7 +76,7 @@ public class XmlRpc { Object result = null; try { XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); - config.setServerURL(new URL(url)); + config.setServerURL(new URL("http://central.fourisland.com/xmlrpc.php")); XmlRpcClient client = new XmlRpcClient(); client.setConfig(config); -- cgit 1.4.1