Author: dbkr
Date: 2006-06-08 22:39:53 +0000 (Thu, 08 Jun 2006)
New Revision: 9091
Modified:
trunk/apps/fnmail/src/fnmail/AccountManager.java
trunk/apps/fnmail/src/fnmail/MessageSender.java
trunk/apps/fnmail/src/fnmail/SingleAccountWatcher.java
trunk/apps/fnmail/src/fnmail/utils/PropsFile.java
Log:
Merge password into account properties file
Modified: trunk/apps/fnmail/src/fnmail/AccountManager.java
===================================================================
--- trunk/apps/fnmail/src/fnmail/AccountManager.java 2006-06-08 18:00:52 UTC
(rev 9090)
+++ trunk/apps/fnmail/src/fnmail/AccountManager.java 2006-06-08 22:39:53 UTC
(rev 9091)
@@ -2,10 +2,7 @@
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileReader;
-import java.io.BufferedReader;
import java.io.FileNotFoundException;
-import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -22,7 +19,6 @@
// this really doesn't matter a great deal
public static final String NIMDIR = "nim";
- public static final String PASSWDFILE = "passwd";
private static final String ACCOUNT_FILE = "accprops";
private static final int RTS_KEY_LENGTH = 32;
@@ -71,35 +67,43 @@
throw new Exception("No such account - "+username+".");
}
- File passwdfile = new File(accountdir, PASSWDFILE);
- FileOutputStream fos = new FileOutputStream(passwdfile);
+ PropsFile accfile = getAccountFile(accountdir);
byte[] md5passwd = md.digest(newpassword.getBytes());
String strmd5 = bytestoHex(md5passwd);
- fos.write(strmd5.getBytes());
- fos.close();
+ accfile.put("md5passwd", strmd5);
}
public static String getMailsitePubkey(File accdir) {
PropsFile accfile = getAccountFile(accdir);
- return accfile.get("mailsite.pubkey");
+ String retval = accfile.get("mailsite.pubkey");
+
+ if (retval == null) {
+ initAccFile(accfile);
+ retval = accfile.get("mailsite.pubkey");
+ }
+
+ return retval;
}
public static String getMailsitePrivkey(File accdir) {
PropsFile accfile = getAccountFile(accdir);
- return accfile.get("mailsite.privkey");
+ String retval = accfile.get("mailsite.pubkey");
+
+ if (retval == null) {
+ initAccFile(accfile);
+ retval = accfile.get("mailsite.privkey");
+ }
+
+ return retval;
}
private static PropsFile getAccountFile(File accdir) {
PropsFile accfile = new PropsFile(new File(accdir,
ACCOUNT_FILE));
- if (!accfile.exists()) {
- initAccFile(accfile);
- }
-
return accfile;
}
@@ -142,24 +146,17 @@
public static boolean authenticate(String username, String password) {
if (!validate_username(username)) return false;
- String sep = System.getProperty("file.separator");
+ //String sep = System.getProperty("file.separator");
- FileInputStream fin = null;
- try {
- fin = new
FileInputStream(DATADIR+sep+username+sep+PASSWDFILE);
- } catch (FileNotFoundException fnfe) {
+ File accountdir = new File(DATADIR, username);
+ if (!accountdir.exists()) {
return false;
}
+ PropsFile accfile = getAccountFile(accountdir);
- byte[] realmd5 = new byte[32];
- try {
- fin.read(realmd5);
- } catch (IOException ioe) {
- return false;
- }
+ String realmd5str = accfile.get("md5passwd");
+ if (realmd5str == null) return false;
- String realmd5str = new String(realmd5);
-
MessageDigest md = null;
try {
md = MessageDigest.getInstance("MD5");
Modified: trunk/apps/fnmail/src/fnmail/MessageSender.java
===================================================================
--- trunk/apps/fnmail/src/fnmail/MessageSender.java 2006-06-08 18:00:52 UTC
(rev 9090)
+++ trunk/apps/fnmail/src/fnmail/MessageSender.java 2006-06-08 22:39:53 UTC
(rev 9091)
@@ -8,7 +8,6 @@
import java.util.Vector;
import java.util.Enumeration;
-import fnmail.fcp.FCPConnection;
import fnmail.fcp.HighLevelFCPClient;
import fnmail.fcp.FCPInsertErrorMessage;
import fnmail.fcp.FCPBadFileException;
Modified: trunk/apps/fnmail/src/fnmail/SingleAccountWatcher.java
===================================================================
--- trunk/apps/fnmail/src/fnmail/SingleAccountWatcher.java 2006-06-08
18:00:52 UTC (rev 9090)
+++ trunk/apps/fnmail/src/fnmail/SingleAccountWatcher.java 2006-06-08
22:39:53 UTC (rev 9091)
@@ -1,15 +1,8 @@
package fnmail;
import java.io.File;
-import java.io.OutputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
import java.lang.InterruptedException;
-import fnmail.fcp.FCPConnection;
-import fnmail.fcp.HighLevelFCPClient;
-import fnmail.fcp.SSKKeyPair;
-
public class SingleAccountWatcher implements Runnable {
public static final String CONTACTS_DIR = "contacts";
private static final int MIN_POLL_DURATION = 60000; // in milliseconds
Modified: trunk/apps/fnmail/src/fnmail/utils/PropsFile.java
===================================================================
--- trunk/apps/fnmail/src/fnmail/utils/PropsFile.java 2006-06-08 18:00:52 UTC
(rev 9090)
+++ trunk/apps/fnmail/src/fnmail/utils/PropsFile.java 2006-06-08 22:39:53 UTC
(rev 9091)
@@ -17,6 +17,13 @@
public PropsFile(File f) {
this.file = f;
this.data = null;
+
+ if (f.exists()) {
+ try {
+ this.read();
+ } catch (IOException ioe) {
+ }
+ }
}
private void read() throws IOException {
@@ -50,14 +57,6 @@
}
public String get(String key) {
- if (this.data == null) {
- try {
- this.read();
- } catch (IOException ioe) {
- return null;
- }
- }
-
return (String)this.data.get(key);
}