Author: dbkr
Date: 2008-05-01 22:56:16 +0000 (Thu, 01 May 2008)
New Revision: 19668
Modified:
trunk/apps/Freemail/src/freemail/OutboundContact.java
Log:
D'oh - clearly that will happen the first time a contact is used.
Modified: trunk/apps/Freemail/src/freemail/OutboundContact.java
===================================================================
--- trunk/apps/Freemail/src/freemail/OutboundContact.java 2008-05-01
22:28:21 UTC (rev 19667)
+++ trunk/apps/Freemail/src/freemail/OutboundContact.java 2008-05-01
22:56:16 UTC (rev 19668)
@@ -304,21 +304,25 @@
if (retval != null) {
return retval;
} else {
- Logger.minor(this, "Generating first slot for contact");
- SecureRandom rnd = new SecureRandom();
- SHA256Digest sha256 = new SHA256Digest();
- byte[] buf = new byte[sha256.getDigestSize()];
-
- rnd.nextBytes(buf);
-
- String firstSlot = Base32.encode(buf);
-
- this.contactfile.put("nextslot", Base32.encode(buf));
-
- return firstSlot;
- }
+ return generateFirstSlot();
+ }
}
+ private String generateFirstSlot() {
+ Logger.minor(this, "Generating first slot for contact");
+ SecureRandom rnd = new SecureRandom();
+ SHA256Digest sha256 = new SHA256Digest();
+ byte[] buf = new byte[sha256.getDigestSize()];
+
+ rnd.nextBytes(buf);
+
+ String firstSlot = Base32.encode(buf);
+
+ this.contactfile.put("nextslot", Base32.encode(buf));
+
+ return firstSlot;
+ }
+
private byte[] getAESParams() {
String params = this.contactfile.get("aesparams");
if (params != null) {
@@ -562,8 +566,7 @@
private String popNextSlot() {
String slot = this.contactfile.get("nextslot");
if (slot == null) {
- Logger.error(this, "Contact has no 'nextslot' prop!
This shouldn't happen!");
- return null;
+ return generateFirstSlot();
}
SHA256Digest sha256 = new SHA256Digest();
sha256.update(Base32.decode(slot), 0,
Base32.decode(slot).length);