about summary refs log tree commit diff stats
path: root/client/trunk
diff options
context:
space:
mode:
Diffstat (limited to 'client/trunk')
-rw-r--r--client/trunk/src/com/fourisland/instadisc/Item/SubscriptionFile.java64
1 files changed, 24 insertions, 40 deletions
diff --git a/client/trunk/src/com/fourisland/instadisc/Item/SubscriptionFile.java b/client/trunk/src/com/fourisland/instadisc/Item/SubscriptionFile.java index 93c9843..95f7ae6 100644 --- a/client/trunk/src/com/fourisland/instadisc/Item/SubscriptionFile.java +++ b/client/trunk/src/com/fourisland/instadisc/Item/SubscriptionFile.java
@@ -14,8 +14,6 @@ import java.io.FileNotFoundException;
14import java.io.IOException; 14import java.io.IOException;
15import java.io.InputStream; 15import java.io.InputStream;
16import java.net.HttpURLConnection; 16import java.net.HttpURLConnection;
17import java.net.URI;
18import java.net.URISyntaxException;
19import java.net.URL; 17import java.net.URL;
20import java.util.HashMap; 18import java.util.HashMap;
21import java.util.logging.Level; 19import java.util.logging.Level;
@@ -53,7 +51,7 @@ public class SubscriptionFile {
53 for (i = 0; i < it.length; i++) 51 for (i = 0; i < it.length; i++)
54 { 52 {
55 if (it[i].getSubscription().equals(s.getURL())) 53 if (it[i].getSubscription().equals(s.getURL()))
56 { 54 {
57 Wrapper.deleteItem(it[i].getID()); 55 Wrapper.deleteItem(it[i].getID());
58 } 56 }
59 } 57 }
@@ -150,56 +148,42 @@ class SubscriptionFileThread implements Runnable {
150 s.setTitle(headerMap.get("Title")); 148 s.setTitle(headerMap.get("Title"));
151 s.setCategory(headerMap.get("Category")); 149 s.setCategory(headerMap.get("Category"));
152 150
153 if (headerMap.containsKey("Series-Control-URL") && headerMap.containsKey("Password") && headerMap.containsKey("Subscription-ID")) 151 if (Functions.xor(headerMap.containsKey("Verification"),headerMap.containsKey("Verification-ID")))
154 { 152 {
155 if (headerMap.get("Password").endsWith("On")) 153 if (headerMap.containsKey("Verification"))
156 { 154 {
157 try 155 AskForPasswordForm afpf = new AskForPasswordForm(new JFrame(),true);
156 afpf.setVisible(true);
157
158 if (afpf.getEntered() || afpf.getPassword().equals(""))
158 { 159 {
159 URI url = new URI(headerMap.get("Series-Control-URL")); 160 MD5 md5 = new MD5(afpf.getPassword());
160 XmlRpc xmlrpc = new XmlRpc(url.toString(), "getPasswordInfo"); 161 MD5 hash = new MD5(s.getTitle() + ":" + md5.hash() + ":" + headerMap.get("Verification-ID"));
161 xmlrpc.addParam(headerMap.get("Subscription-ID"));
162 String resp = (String) xmlrpc.execute();
163 String[] val = resp.split(":");
164 162
165 AskForPasswordForm afpf = new AskForPasswordForm(new JFrame(),true); 163 if (hash.hash().equals(headerMap.get("Verification")))
166 afpf.setVisible(true);
167
168 if (afpf.getEntered() || afpf.getPassword().equals(""))
169 { 164 {
170 MD5 md5 = new MD5(afpf.getPassword()); 165 s.setPassword(afpf.getPassword());
171 MD5 hash = new MD5(s.getTitle() + ":" + md5.hash() + ":" + val[1]);
172
173 if (hash.hash().equals(val[0]))
174 {
175 s.setPassword(afpf.getPassword());
176 } else {
177 status.setText("Error: Incorrect password entered");
178 return;
179 }
180 } else { 166 } else {
181 status.setText("Error: No password entered"); 167 status.setText("Error: Incorrect password entered");
182 return; 168 return;
183 } 169 }
184 } catch (URISyntaxException ex) 170 } else {
185 { 171 status.setText("Error: No password entered");
186 Logger.getLogger(SubscriptionFileThread.class.getName()).log(Level.SEVERE, null, ex); 172 return;
187 } 173 }
188 } else { 174 } else {
189 s.setPassword(""); 175 s.setPassword("");
190 } 176 }
191 } else { 177
192 s.setPassword(""); 178 Wrapper.addSubscription(s);
193 }
194 179
195 Wrapper.addSubscription(s); 180 XmlRpc xmlrpc = new XmlRpc("addSubscription");
181 xmlrpc.addParam(headerMap.get("Subscription"));
182 xmlrpc.addParam(headerMap.get("Category"));
183 xmlrpc.execute();
196 184
197 XmlRpc xmlrpc = new XmlRpc("addSubscription"); 185 status.setText("You've sucessfully subscribed to that website");
198 xmlrpc.addParam(headerMap.get("Subscription")); 186 }
199 xmlrpc.addParam(headerMap.get("Category"));
200 xmlrpc.execute();
201
202 status.setText("You've sucessfully subscribed to that website");
203 } else { 187 } else {
204 status.setText("Error: Subscription file is not well-formed"); 188 status.setText("Error: Subscription file is not well-formed");
205 } 189 }
@@ -226,4 +210,4 @@ class SubscriptionFileThread implements Runnable {
226 } 210 }
227 } 211 }
228 } 212 }
229} 213} \ No newline at end of file