Author: jflesch
Date: 2007-07-30 22:21:57 +0000 (Mon, 30 Jul 2007)
New Revision: 14445
Added:
trunk/apps/Thaw/src/thaw/core/Main.java
Removed:
trunk/apps/Thaw/src/thaw/core/Main.java
Modified:
trunk/apps/Thaw/src/frost/crypt/FrostCrypt.java
trunk/apps/Thaw/src/thaw/core/Core.java
trunk/apps/Thaw/src/thaw/core/MainWindow.java
trunk/apps/Thaw/src/thaw/gui/Table.java
trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
trunk/apps/Thaw/src/thaw/i18n/thaw.properties
trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
trunk/apps/Thaw/src/thaw/plugins/index/Index.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessage.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoardFactory.java
trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Message.java
trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java
Log:
Add the support for decrypting encrypted messages
Modified: trunk/apps/Thaw/src/frost/crypt/FrostCrypt.java
===================================================================
--- trunk/apps/Thaw/src/frost/crypt/FrostCrypt.java 2007-07-30 20:38:54 UTC
(rev 14444)
+++ trunk/apps/Thaw/src/frost/crypt/FrostCrypt.java 2007-07-30 22:21:57 UTC
(rev 14445)
@@ -25,11 +25,12 @@
import java.security.*;
import java.security.spec.*;
import java.util.*;
-import java.util.logging.*;
import javax.crypto.*;
import javax.crypto.spec.*;
+import thaw.core.Logger;
+
import org.bouncycastle.crypto.*;
import org.bouncycastle.crypto.digests.*;
import org.bouncycastle.crypto.engines.*;
@@ -44,7 +45,6 @@
*/
public final class FrostCrypt {
- private static final Logger logger =
Logger.getLogger(FrostCrypt.class.getName());
private PSSSigner signer;
private SecureRandom secureRandom = null;
@@ -128,7 +128,7 @@
stomach.doFinal(poop, 0);
return (new String(Base64.encode(poop))).substring(0, 27);
} catch(UnsupportedEncodingException ex) {
- logger.log(Level.SEVERE, "UTF-8 encoding is not supported.", ex);
+ Logger.error(this, "UTF-8 encoding is not supported : "+
ex.toString());
}
return null;
}
@@ -143,7 +143,7 @@
try {
chan = (new FileInputStream(file)).getChannel();
} catch (IOException e) {
- logger.log(Level.SEVERE, "Exception thrown in digest(File file)",
e);
+ Logger.error(this, "Exception thrown in digest(File file):
"+e.toString());
}
byte[] temp = new byte[4 * 1024];
ByteBuffer _temp = ByteBuffer.wrap(temp);
@@ -161,7 +161,7 @@
}
chan.close();
} catch (IOException e) {
- logger.log(Level.SEVERE, "Exception thrown in digest(File file)",
e);
+ Logger.error(this, "Exception thrown in digest(File file): "+
e.toString());
}
stomach.doFinal(poop, 0);
return (new String(Base64.encode(poop))).substring(0, 27);
@@ -174,7 +174,7 @@
String result = new String(Base64.encode(encryptedBytes),
"ISO-8859-1");
return result;
} catch(UnsupportedEncodingException ex) {
- logger.log(Level.SEVERE, "UTF-8 encoding is not supported.", ex);
+ Logger.error(this, "UTF-8 encoding is not supported:
"+ex.toString());
}
return null;
}
@@ -227,7 +227,7 @@
throw new Exception("block size invalid,
inSize="+cipherRSAinSize+"; outSize="+cipherRSAoutSize);
}
} catch(Throwable t) {
- logger.log(Level.SEVERE, "Error in encrypt, RSA preparation", t);
+ Logger.error(this, "Error in encrypt, RSA preparation : "+
t.toString());
return null;
}
@@ -247,7 +247,7 @@
throw new Exception("RSA out block size invalid:
"+rsaEncData.length);
}
} catch (Throwable t) {
- logger.log(Level.SEVERE, "Error in encrypt, RSA encryption", t);
+ Logger.error(this, "Error in encrypt, RSA encryption:"+
t.toString());
return null;
}
@@ -264,7 +264,7 @@
cOut.close();
} catch (IOException e) {
- logger.log(Level.SEVERE, "Error in encrypt, AES encryption", e);
+ Logger.error(this, "Error in encrypt, AES encryption: "+
e.toString());
return null;
}
return plainOut.toByteArray();
@@ -276,7 +276,7 @@
byte[] decBytes = decrypt(encBytes, privateKey);
return new String(decBytes, "UTF-8");
} catch(UnsupportedEncodingException ex) {
- logger.log(Level.SEVERE, "UTF-8 encoding is not supported.", ex);
+ Logger.error(this, "UTF-8 encoding is not supported :
"+ex.toString());
}
return null;
}
@@ -318,7 +318,7 @@
throw new Exception("RSA decryption block size invalid,
inSize="+cipherRSAinSize+"; outSize="+cipherRSAoutSize);
}
} catch(Throwable e) {
- logger.log(Level.SEVERE, "Error in decrypt, RSA preparation", e);
+ Logger.error(this, "Error in decrypt, RSA preparation: "+
e.toString());
return null;
}
@@ -337,7 +337,7 @@
aesKeyBytes = new byte[16];
System.arraycopy(sessionKeyBytes, 0, aesKeyBytes, 0,
aesKeyBytes.length);
} catch (Throwable e) {
- logger.log(Level.SEVERE, "Error in decrypt, RSA decryption", e);
+ Logger.debug(this, "Error in decrypt, RSA decryption: "+
e.toString());
return null;
}
@@ -364,7 +364,7 @@
}
cIn.close();
} catch (Throwable e) {
- logger.log(Level.SEVERE, "Error in decrypt, AES decryption", e);
+ Logger.error(this, "Error in decrypt, AES decryption: "+
e.toString());
return null;
}
return plainOut.toByteArray();
@@ -375,7 +375,7 @@
byte[] msgBytes = message.getBytes("UTF-8");
return detachedSign(msgBytes, key);
} catch(UnsupportedEncodingException ex) {
- logger.log(Level.SEVERE, "UTF-8 encoding is not supported.", ex);
+ Logger.error(this, "UTF-8 encoding is not supported:
"+ex.toString());
}
return null;
}
@@ -400,14 +400,14 @@
try {
signature = signer.generateSignature();
} catch (CryptoException e) {
- logger.log(Level.SEVERE, "Exception thrown in detachedSign(String
message, String key)", e);
+ Logger.error(this, "Exception thrown in detachedSign(String
message, String key): "+ e.toString());
}
signer.reset();
try {
String result = new String(Base64.encode(signature), "ISO-8859-1");
return result;
} catch(UnsupportedEncodingException ex) {
- logger.log(Level.SEVERE, "ISO-8859-1 encoding is not supported.",
ex);
+ Logger.error(this, "ISO-8859-1 encoding is not supported:
"+ex.toString());
}
return null;
}
@@ -417,7 +417,7 @@
byte[] msgBytes = message.getBytes("UTF-8");
return detachedVerify(msgBytes, key, sig);
} catch(UnsupportedEncodingException ex) {
- logger.log(Level.SEVERE, "UTF-8 encoding is not supported.", ex);
+ Logger.error(this, "UTF-8 encoding is not supported:
"+ex.toString());
}
return false;
}
@@ -436,7 +436,7 @@
signer.reset();
return result;
} catch(UnsupportedEncodingException ex) {
- logger.log(Level.SEVERE, "ISO-8859-1 encoding is not supported.",
ex);
+ Logger.error(this, "ISO-8859-1 encoding is not supported:
"+ex.toString());
}
return false;
}
@@ -450,7 +450,7 @@
byte[] whatBytes = what.getBytes("ISO-8859-1");
return new String(Base64.decode(whatBytes), "UTF-8");
} catch(UnsupportedEncodingException ex) {
- logger.log(Level.SEVERE, "UTF-8 or ISO-8859-1 encoding is not
supported.", ex);
+ Logger.error(this, "UTF-8 or ISO-8859-1 encoding is not supported:
"+ex.toString());
}
return null;
}
@@ -460,7 +460,7 @@
byte[] whatBytes = what.getBytes("UTF-8");
return new String(Base64.encode(whatBytes), "ISO-8859-1");
} catch(UnsupportedEncodingException ex) {
- logger.log(Level.SEVERE, "UTF-8 or ISO-8859-1 encoding is not
supported.", ex);
+ Logger.error(this, "UTF-8 or ISO-8859-1 encoding is not supported:
"+ex.toString());
}
return null;
}
@@ -477,7 +477,7 @@
try {
keyGeneratorAES = KeyGenerator.getInstance("AES");
} catch (NoSuchAlgorithmException e) {
- logger.log(Level.SEVERE, "Could not get a KeyGenerator for
AES.", e);
+ Logger.error(this, "Could not get a KeyGenerator for AES:
"+e.toString());
return null;
}
keyGeneratorAES.init(128); // 192 and 256 bits may not be
available!
@@ -501,7 +501,7 @@
cipherAES.init(mode, sessionKey);
} catch(Throwable t) {
- logger.log(Level.SEVERE, "Error in AES preparation", t);
+ Logger.error(this, "Error in AES preparation: "+ t.toString());
return null;
}
return cipherAES;
@@ -515,7 +515,7 @@
byte[] food = message.getBytes("UTF-8");
return computeChecksumSHA256(food);
} catch(UnsupportedEncodingException ex) {
- logger.log(Level.SEVERE, "UTF-8 encoding is not supported.", ex);
+ Logger.error(this, "UTF-8 encoding is not supported:
"+ex.toString());
}
return null;
}
@@ -537,9 +537,9 @@
}
return sb.toString().toUpperCase();
} catch (NoSuchAlgorithmException ex) {
- logger.log(Level.SEVERE, "Algorithm SHA256 not supported.", ex);
+ Logger.error(this, "Algorithm SHA256 not supported:
"+ex.toString());
} catch (NoSuchProviderException ex) {
- logger.log(Level.SEVERE, "Provider BC not supported.", ex);
+ Logger.error(this, "Provider BC not supported: "+ ex.toString());
}
return null;
}
@@ -553,7 +553,7 @@
try {
chan = (new FileInputStream(file)).getChannel();
} catch (Throwable e) {
- logger.log(Level.SEVERE, "Exception thrown 1", e);
+ Logger.error(this, "Exception thrown 1: "+e.toString());
return null;
}
@@ -575,7 +575,7 @@
}
chan.close();
} catch (Throwable e) {
- logger.log(Level.SEVERE, "Exception thrown 2", e);
+ Logger.error(this, "Exception thrown 2 : "+e.toString());
}
byte[] poop = sha256.digest();
@@ -587,9 +587,9 @@
return sb.toString().toUpperCase();
} catch (NoSuchAlgorithmException ex) {
- logger.log(Level.SEVERE, "Algorithm SHA256 not supported.", ex);
+ Logger.error(this, "Algorithm SHA256 not supported: "+
ex.toString());
} catch (NoSuchProviderException ex) {
- logger.log(Level.SEVERE, "Provider BC not supported.", ex);
+ Logger.error(this, "Provider BC not supported: "+ ex.toString());
}
return null;
}
Modified: trunk/apps/Thaw/src/thaw/core/Core.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Core.java 2007-07-30 20:38:54 UTC (rev
14444)
+++ trunk/apps/Thaw/src/thaw/core/Core.java 2007-07-30 22:21:57 UTC (rev
14445)
@@ -21,6 +21,7 @@
import thaw.gui.IconBox;
+
/**
* A "core" contains references to all the main parts of Thaw.
* The Core has all the functions needed to initialize Thaw / stop Thaw.
Deleted: trunk/apps/Thaw/src/thaw/core/Main.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Main.java 2007-07-30 20:38:54 UTC (rev
14444)
+++ trunk/apps/Thaw/src/thaw/core/Main.java 2007-07-30 22:21:57 UTC (rev
14445)
@@ -1,132 +0,0 @@
-package thaw.core;
-
-import java.util.Locale;
-
-import javax.swing.UIManager;
-import javax.swing.UIManager.LookAndFeelInfo;
-
-import java.util.Vector;
-import java.util.Iterator;
-
-/**
- * Main class. Only used to display some informations and init the core.
- *
- * @author <a href="mailto:jflesch at nerim.net">Jerome Flesch</a>
- */
-public class Main {
-
- public final static int
- _major = 0,
- _minor = 7,
- _update = 1;
- public final static String
- _svnBuildNumber = "@custom@";
-
- public final static String
- VERSION = Main._major + "." + Main._minor + "." + Main._update + "
r"+Main._svnBuildNumber;
-
-
- /**
- * Look & feel use by GUI front end
- */
- private static String lookAndFeel = null;
-
-
- /**
- * Locale (null = default)
- */
- private static String locale = null;
-
-
- /**
- * Used to start the program
- *
- * @param args "-?", "-help", "--help", "/?", "/help", "-lf lookandfeel"
- */
- public static void main(final String[] args) {
- Core core;
-
- Main.parseCommandLine(args);
-
- if(Main.locale != null)
- I18n.setLocale(new Locale(Main.locale));
-
- core = new Core();
-
- /* we specify to the core what lnf to use */
- core.setLookAndFeel(Main.lookAndFeel);
-
- /* and we force it to refresh change it right now */
- if (Main.lookAndFeel != null)
- core.setTheme(Main.lookAndFeel);
-
- core.initAll();
- }
-
-
-
-
- /**
- * This method parses the command line arguments
- *
- * @param args the arguments
- */
- private static void parseCommandLine(final String[] args) {
-
- int count = 0;
-
- try {
- while (args.length > count) {
- if ("-?".equals( args[count] ) ||
"-help".equals( args[count] )
- || "--help".equals( args[count]
)
- || "/?".equals( args[count] )
- || "/help".equals( args[count]
)) {
- Main.showHelp();
- count++;
- } else if ("-lf".equals( args[count] )) {
- Main.lookAndFeel = args[count + 1];
- count = count + 2;
- } else if ("-lc".equals( args[count] )) {
- Main.locale = args[count + 1];
- count = count + 2;
- } else {
- Main.showHelp();
- }
- }
- } catch (final ArrayIndexOutOfBoundsException exception) {
- Main.showHelp();
- }
-
- }
-
- /**
- * This method shows a help message on the standard output and exits the
- * program.
- */
- private static void showHelp() {
-
- System.out.println("java -jar thaw.jar [-lf lookAndFeel]\n");
- System.out.println("-lf Sets the 'Look and Feel' will
use.");
- System.out.println(" (overriden by the skins
preferences)\n");
- System.out.println(" These ones are currently
available:");
- Vector feels = thaw.plugins.ThemeSelector.getPossibleThemes();
-
- for (Iterator it = feels.iterator() ; it.hasNext(); ) {
- String str = (String)it.next();
-
- System.out.println(" " + str);
- }
- System.out.println("\n And this one is used by
default:");
- System.out.println(" " +
UIManager.getSystemLookAndFeelClassName() + "\n");
-
- System.out.println("\n-lc Sets the locale to use: 'en' for
english,");
- System.out.println(" 'fr' for french, etc.");
- System.out.println(" see
http://ftp.ics.uci.edu/pub/ietf/http/related/iso639.txt");
- System.out.println(" for the complete list");
-
- System.exit(0);
- }
-
-
-}
-
Added: trunk/apps/Thaw/src/thaw/core/Main.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Main.java (rev 0)
+++ trunk/apps/Thaw/src/thaw/core/Main.java 2007-07-30 22:21:57 UTC (rev
14445)
@@ -0,0 +1,132 @@
+package thaw.core;
+
+import java.util.Locale;
+
+import javax.swing.UIManager;
+import javax.swing.UIManager.LookAndFeelInfo;
+
+import java.util.Vector;
+import java.util.Iterator;
+
+/**
+ * Main class. Only used to display some informations and init the core.
+ *
+ * @author <a href="mailto:jflesch at nerim.net">Jerome Flesch</a>
+ */
+public class Main {
+
+ public final static int
+ _major = 0,
+ _minor = 7,
+ _update = 1;
+ public final static String
+ _svnBuildNumber = "@custom@";
+
+ public final static String
+ VERSION = Main._major + "." + Main._minor + "." + Main._update + "
r"+Main._svnBuildNumber;
+
+
+ /**
+ * Look & feel use by GUI front end
+ */
+ private static String lookAndFeel = null;
+
+
+ /**
+ * Locale (null = default)
+ */
+ private static String locale = null;
+
+
+ /**
+ * Used to start the program
+ *
+ * @param args "-?", "-help", "--help", "/?", "/help", "-lf lookandfeel"
+ */
+ public static void main(final String[] args) {
+ Core core;
+
+ Main.parseCommandLine(args);
+
+ if(Main.locale != null)
+ I18n.setLocale(new Locale(Main.locale));
+
+ core = new Core();
+
+ /* we specify to the core what lnf to use */
+ core.setLookAndFeel(Main.lookAndFeel);
+
+ /* and we force it to refresh change it right now */
+ if (Main.lookAndFeel != null)
+ core.setTheme(Main.lookAndFeel);
+
+ core.initAll();
+ }
+
+
+
+
+ /**
+ * This method parses the command line arguments
+ *
+ * @param args the arguments
+ */
+ private static void parseCommandLine(final String[] args) {
+
+ int count = 0;
+
+ try {
+ while (args.length > count) {
+ if ("-?".equals( args[count] ) ||
"-help".equals( args[count] )
+ || "--help".equals( args[count]
)
+ || "/?".equals( args[count] )
+ || "/help".equals( args[count]
)) {
+ Main.showHelp();
+ count++;
+ } else if ("-lf".equals( args[count] )) {
+ Main.lookAndFeel = args[count + 1];
+ count = count + 2;
+ } else if ("-lc".equals( args[count] )) {
+ Main.locale = args[count + 1];
+ count = count + 2;
+ } else {
+ Main.showHelp();
+ }
+ }
+ } catch (final ArrayIndexOutOfBoundsException exception) {
+ Main.showHelp();
+ }
+
+ }
+
+ /**
+ * This method shows a help message on the standard output and exits the
+ * program.
+ */
+ private static void showHelp() {
+
+ System.out.println("java -jar thaw.jar [-lf lookAndFeel]\n");
+ System.out.println("-lf Sets the 'Look and Feel' will
use.");
+ System.out.println(" (overriden by the skins
preferences)\n");
+ System.out.println(" These ones are currently
available:");
+ Vector feels = thaw.plugins.ThemeSelector.getPossibleThemes();
+
+ for (Iterator it = feels.iterator() ; it.hasNext(); ) {
+ String str = (String)it.next();
+
+ System.out.println(" " + str);
+ }
+ System.out.println("\n And this one is used by
default:");
+ System.out.println(" " +
UIManager.getSystemLookAndFeelClassName() + "\n");
+
+ System.out.println("\n-lc Sets the locale to use: 'en' for
english,");
+ System.out.println(" 'fr' for french, etc.");
+ System.out.println(" see
http://ftp.ics.uci.edu/pub/ietf/http/related/iso639.txt");
+ System.out.println(" for the complete list");
+
+ System.exit(0);
+ }
+
+
+}
+
Modified: trunk/apps/Thaw/src/thaw/core/MainWindow.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/MainWindow.java 2007-07-30 20:38:54 UTC
(rev 14444)
+++ trunk/apps/Thaw/src/thaw/core/MainWindow.java 2007-07-30 22:21:57 UTC
(rev 14445)
@@ -51,7 +51,8 @@
*
* @author <a href="mailto:jflesch at nerim.net">Jerome Flesch</a>
*/
-public class MainWindow implements java.awt.event.ActionListener,
WindowListener,
+public class MainWindow implements java.awt.event.ActionListener,
+ WindowListener,
java.util.Observer {
public final static int DEFAULT_SIZE_X = 790;
@@ -594,7 +595,9 @@
new JLabel(I18n.getMessage("thaw.about.l10")),
new JLabel(I18n.getMessage("thaw.about.l11")),
new JLabel(I18n.getMessage("thaw.about.l12")),
- new JLabel(I18n.getMessage("thaw.about.l13"))
+ new JLabel(I18n.getMessage("thaw.about.l13")),
+ new JLabel(I18n.getMessage("thaw.about.l14")),
+ new JLabel(I18n.getMessage("thaw.about.l15"))
};
Modified: trunk/apps/Thaw/src/thaw/gui/Table.java
===================================================================
--- trunk/apps/Thaw/src/thaw/gui/Table.java 2007-07-30 20:38:54 UTC (rev
14444)
+++ trunk/apps/Thaw/src/thaw/gui/Table.java 2007-07-30 22:21:57 UTC (rev
14445)
@@ -117,6 +117,8 @@
public void setDefaultRenderer() {
renderer = new DefaultRenderer();
setDefaultRenderer(getColumnClass(0), renderer);
+
+
((DefaultTableCellRenderer)getTableHeader().getDefaultRenderer()).setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
}
Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-30
20:38:54 UTC (rev 14444)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-07-30
22:21:57 UTC (rev 14445)
@@ -250,10 +250,11 @@
thaw.about.l09=- Le look&feel Liquid ( https://liquidlnf.dev.java.net/ ; LGPL )
thaw.about.l10=- Hsqldb ( http://hsqldb.org/ ; Hsqldb license )
thaw.about.l11=- JmDNS ( http://jmdns.sourceforge.net/ ; LGPL )
-thaw.about.l12=- Certaines parties du code source du noeud Freenet (
http://freenetproject.org/ ; GPL )
-thaw.about.l13=- Certaines parties du code source de Frost (
http://jtcfrost.sourceforge.net/ ; GPL )
+thaw.about.l10=- One-jar ( http://one-jar.sourceforge.net/ ; License one-jar )
+thaw.about.l13=- Certaines parties du code source du noeud Freenet (
http://freenetproject.org/ ; GPL )
+thaw.about.l14=- Certaines parties du code source de Frost (
http://jtcfrost.sourceforge.net/ ; GPL )
+thaw.about.l15=Toutes ces licenses sont incluses dans Thaw.jar
-
## HsqlDb
thaw.plugin.hsqldb.database=Base de donn?es
thaw.plugin.hsqldb.console=Console Sql
@@ -589,3 +590,6 @@
thaw.plugin.miniFrost.generateKeys=Generer les clefs
thaw.plugin.miniFrost.newWindow=Ouvrir une nouvelle fen?tre
thaw.plugin.miniFrost.draft=Brouillon
+thaw.plugin.miniFrost.encrypted=Crypt?
+thaw.plugin.miniFrost.encryptedBody=Crypt? pour 'X'
+
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-30 20:38:54 UTC
(rev 14444)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-07-30 22:21:57 UTC
(rev 14445)
@@ -259,10 +259,11 @@
thaw.about.l09=- Hsqldb ( http://hsqldb.org/ ; Hsqldb license )
thaw.about.l10=- BouncyCastle ( http://bouncycastle.org/ ; Bouncy castle
license )
thaw.about.l11=- JmDNS ( http://jmdns.sourceforge.net/ ; LGPL )
-thaw.about.l12=- Some parts of the Freenet node source code (
http://freenetproject.org/ ; GPL )
-thaw.about.l13=- Some parts of Frost source code (
http://jtcfrost.sourceforge.net/ ; GPL )
+thaw.about.l10=- One-jar ( http://one-jar.sourceforge.net/ ; One-jar license )
+thaw.about.l13=- Some parts of the Freenet node source code (
http://freenetproject.org/ ; GPL )
+thaw.about.l14=- Some parts of Frost source code (
http://jtcfrost.sourceforge.net/ ; GPL )
+thaw.about.l15=All the licenses are included in Thaw.jar
-
## HsqlDb
thaw.plugin.hsqldb.database=Database
thaw.plugin.hsqldb.console=Sql console
@@ -604,4 +605,8 @@
thaw.plugin.miniFrost.generateKeys=Generate keys
thaw.plugin.miniFrost.newWindow=Open a new window
-thaw.plugin.miniFrost.draft=Draft
\ No newline at end of file
+thaw.plugin.miniFrost.draft=Draft
+
+thaw.plugin.miniFrost.encrypted=Encrypted
+thaw.plugin.miniFrost.encryptedFor=[Encrypted for 'X']
+thaw.plugin.miniFrost.encryptedBody=Encrypted for 'X'
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-07-30 20:38:54 UTC
(rev 14444)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-07-30 22:21:57 UTC
(rev 14445)
@@ -250,10 +250,11 @@
thaw.about.l09=- Le look&feel Liquid ( https://liquidlnf.dev.java.net/ ; LGPL )
thaw.about.l10=- Hsqldb ( http://hsqldb.org/ ; Hsqldb license )
thaw.about.l11=- JmDNS ( http://jmdns.sourceforge.net/ ; LGPL )
-thaw.about.l12=- Certaines parties du code source du noeud Freenet (
http://freenetproject.org/ ; GPL )
-thaw.about.l13=- Certaines parties du code source de Frost (
http://jtcfrost.sourceforge.net/ ; GPL )
+thaw.about.l10=- One-jar ( http://one-jar.sourceforge.net/ ; License one-jar )
+thaw.about.l13=- Certaines parties du code source du noeud Freenet (
http://freenetproject.org/ ; GPL )
+thaw.about.l14=- Certaines parties du code source de Frost (
http://jtcfrost.sourceforge.net/ ; GPL )
+thaw.about.l15=Toutes ces licenses sont incluses dans Thaw.jar
-
## HsqlDb
thaw.plugin.hsqldb.database=Base de donn\u00e9es
thaw.plugin.hsqldb.console=Console Sql
@@ -589,3 +590,5 @@
thaw.plugin.miniFrost.generateKeys=Generer les clefs
thaw.plugin.miniFrost.newWindow=Ouvrir une nouvelle fen\u00eatre
thaw.plugin.miniFrost.draft=Brouillon
+thaw.plugin.miniFrost.encrypted=Crypt\u00e9
+thaw.plugin.miniFrost.encryptedBody=Crypt\u00e9 pour 'X'
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-07-30 20:38:54 UTC
(rev 14444)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-07-30 22:21:57 UTC
(rev 14445)
@@ -56,6 +56,7 @@
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
+import thaw.core.Main;
import thaw.core.I18n;
import thaw.core.Logger;
@@ -1156,7 +1157,7 @@
final Element thawVersion = xmlDoc.createElement("client");
- final Text versionText = xmlDoc.createTextNode("Thaw
"+thaw.core.Main.VERSION);
+ final Text versionText = xmlDoc.createTextNode("Thaw
"+Main.VERSION);
thawVersion.appendChild(versionText);
header.appendChild(thawVersion);
Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java
2007-07-30 20:38:54 UTC (rev 14444)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/MessagePanel.java
2007-07-30 22:21:57 UTC (rev 14445)
@@ -152,7 +152,7 @@
this.author = author;
- nick = new JLabel(author.toString(false));
+ nick = new JLabel(" "+author.toString(false));
add(nick, BorderLayout.CENTER);
@@ -356,7 +356,13 @@
}
+ public JPanel getEncryptedForPanel(Identity id) {
+ JPanel panel = new JPanel(new GridLayout(1, 1));
+ panel.add(new
JLabel(I18n.getMessage("thaw.plugin.miniFrost.encryptedBody").replaceAll("X",
id.toString())));
+ return panel;
+ }
+
public void refresh() {
subPanels = new Vector();
@@ -369,6 +375,11 @@
Logger.info(this, "Displaying
"+Integer.toString(subMsgs.size())+" sub-msgs");
+ if (msg.encryptedFor() != null) {
+ iPanel = getEncryptedForPanel(msg.encryptedFor());
+ Logger.info(this, "(Encrypted message)");
+ }
+
int i = 0;
/* sub messages */
@@ -393,6 +404,17 @@
}
+ if (msg.encryptedFor() != null) {
+ if (iPanel == null) {
+ iPanel =
getEncryptedForPanel(msg.encryptedFor());
+ } else {
+ JPanel newPanel = new JPanel(new
BorderLayout(0, 20));
+ newPanel.add(iPanel, BorderLayout.NORTH);
+
newPanel.add(getEncryptedForPanel(msg.encryptedFor()), BorderLayout.CENTER);
+ iPanel = newPanel;
+ }
+ }
+
/* attachments */
if (attachments != null) {
AttachmentPanel panel = new
AttachmentPanel(attachments);
Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java
2007-07-30 20:38:54 UTC (rev 14444)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java
2007-07-30 22:21:57 UTC (rev 14445)
@@ -156,6 +156,7 @@
" frostKSKMessages.read, "+
" frostKSKMessages.archived, "+
" frostKSKMessages.boardId, "+
+ " frostKSKMessages.encryptedFor,
"+
" signatures.nickName, "+
" signatures.publicKey, "+
" signatures.privateKey, "+
@@ -190,6 +191,12 @@
ResultSet set = st.executeQuery();
while(set.next()) {
+ Identity encryptedFor = null;
+
+ if (set.getInt("encryptedFor") > 0) {
+ encryptedFor =
Identity.getIdentity(db, set.getInt("encryptedFor"));
+ }
+
KSKBoard daBoard = ((board != null) ?
board :
factory.getBoard(set.getInt("boardId")));
@@ -213,6 +220,7 @@
set.getInt("rev"),
set.getBoolean("read"),
set.getBoolean("archived"),
+ encryptedFor,
daBoard));
}
}
@@ -266,7 +274,14 @@
ResultSet set = st.executeQuery();
+
if (set.next()) {
+ Identity encryptedFor = null;
+
+ if (set.getInt("encryptedFor") > 0) {
+ encryptedFor =
Identity.getIdentity(db, set.getInt("encryptedFor"));
+ }
+
int sigId = set.getInt("sigId");
return new KSKMessage(set.getInt("id"),
@@ -284,6 +299,7 @@
set.getTimestamp("date"),
set.getInt("rev"),
false, false,
+ encryptedFor,
this);
}
}
@@ -546,7 +562,7 @@
&& msg.isSuccessful();
if (successful) {
- if (msg.isParsable())
+ if (msg.isParsable() && !msg.isRead())
newMsgs++;
if (msg.getRev() > lastSuccessfulRev)
Modified:
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java
2007-07-30 20:38:54 UTC (rev 14444)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java
2007-07-30 22:21:57 UTC (rev 14445)
@@ -62,6 +62,8 @@
boolean firstStart =
(core.getConfig().getValue("frostKSKDatabaseVersion") == null);
+ convertExistingTables();
+
createTables();
if (firstStart)
@@ -100,8 +102,32 @@
}
+ protected void convertExistingTables() {
+ if (core.getConfig().getValue("frostKSKDatabaseVersion") ==
null)
+ return;
+
+ if
("0".equals(core.getConfig().getValue("frostKSKDatabaseVersion"))) {
+ if (convertDatabase_0_to_1())
+
core.getConfig().setValue("frostKSKDatabaseVersion", "2");
+ }
+ }
+
+ protected boolean convertDatabase_0_to_1() {
+ if (!sendQuery("ALTER TABLE frostKSKMessages ADD COLUMN
encryptedFor INTEGER DEFAULT NULL NULL")
+ || !sendQuery("ALTER TABLE frostKSKMessages ADD FOREIGN KEY
(encryptedFor) REFERENCES signatures (id)")) {
+
+ Logger.error(this, "Error while converting the board
database from version 0 to 1");
+ return false;
+
+ }
+
+ return true;
+ }
+
+
protected void createTables() {
- core.getConfig().setValue("frostKSKDatabaseVersion", "0");
+ if (core.getConfig().getValue("frostKSKDatabaseVersion") !=
null)
+ core.getConfig().setValue("frostKSKDatabaseVersion",
"1");
sendQuery("CREATE CACHED TABLE frostKSKBoards ("
+ "id INTEGER IDENTITY NOT NULL, "
@@ -128,10 +154,12 @@
+ "rev INTEGER NOT NULL, "
+ "read BOOLEAN DEFAULT FALSE NOT NULL, "
+ "archived BOOLEAN DEFAULT FALSE NOT NULL, "
+ + "encryptedFor INTEGER DEFAULT NULL NULL, "
+ "boardId INTEGER NOT NULL, "
+ "FOREIGN KEY (boardId) REFERENCES frostKSKBoards
(id), "
+ "FOREIGN KEY (inReplyTo) REFERENCES
frostKSKMessages (id), "
- + "FOREIGN KEY (sigId) REFERENCES signatures (id))");
+ + "FOREIGN KEY (sigId) REFERENCES signatures (id), "
+ + "FOREIGN KEY (encryptedFor) REFERENCES signatures
(id))");
sendQuery("CREATE CACHED TABLE frostKSKAttachmentFiles ("
+ "id INTEGER IDENTITY NOT NULL, "
@@ -154,7 +182,7 @@
protected void addDefaultBoards() {
for (int i = 0 ; i < DEFAULT_BOARDS.length ; i++) {
- createBoard(DEFAULT_BOARDS[i]);
+ createBoard(DEFAULT_BOARDS[i], false);
}
}
@@ -260,11 +288,15 @@
}
protected void createBoard(String name) {
+ createBoard(name, true);
+ }
+
+ protected void createBoard(String name, boolean warningIfExisting) {
try {
synchronized(db.dbLock) {
PreparedStatement st;
- st =
db.getConnection().prepareStatement("SELECT frostKSKBoards.id, "+
+ st =
db.getConnection().prepareStatement("SELECT frostKSKBoards.id "+
"FROM
frostKSKBoards LEFT OUTER JOIN frostSSKBoards "+
" ON
frostKSKBoards.id = frostSSKBoards.kskBoardId "+
"WHERE
frostSSKBoards.id IS NULL "+
@@ -276,7 +308,8 @@
ResultSet set = st.executeQuery();
if (set.next()) {
- Logger.warning(this, "Board already
added");
+ if (warningIfExisting)
+ Logger.warning(this, "Board
already added");
return;
}
@@ -292,10 +325,16 @@
}
+ protected void createBoard(String name, String publicKey, String
privateKey) {
+ createBoard(name, publicKey, privateKey, true);
+ }
+
/**
* Put here to make my life simpler with the KSKBoardAttachment.
*/
- protected void createBoard(String name, String publicKey, String
privateKey) {
+ protected void createBoard(String name, String publicKey, String
privateKey,
+ boolean warningIfExisting) {
+
if (!thaw.fcp.FreenetURIHelper.isAKey(publicKey)) {
Logger.error(this, "Invalid publicKey");
return;
@@ -316,7 +355,8 @@
ResultSet set = st.executeQuery();
if (set.next()) {
- Logger.warning(this, "Board already
added");
+ if (warningIfExisting)
+ Logger.warning(this, "Board
already added");
return;
}
Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
2007-07-30 20:38:54 UTC (rev 14444)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
2007-07-30 22:21:57 UTC (rev 14445)
@@ -247,8 +247,12 @@
if (put.getPutFailedCode() != 9) { /*
!Collision */
put.deleteObserver(this);
- Logger.error(this, "Can't insert the
message on the board '"+
- board.toString()+"' ;
Code: "+Integer.toString(put.getPutFailedCode()));
+ if (put.getPutFailedCode() < 0)
+ Logger.warning(this, "message
insertion on the board '"+
+
board.toString()+"' cancelled");
+ else
+ Logger.error(this, "Can't
insert the message on the board '"+
+
board.toString()+"' ; Code: "+Integer.toString(put.getPutFailedCode()));
waiting = false;
posting = false;
notifyPlugin();
Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessage.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessage.java
2007-07-30 20:38:54 UTC (rev 14444)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessage.java
2007-07-30 22:21:57 UTC (rev 14445)
@@ -45,6 +45,7 @@
private int rev;
private boolean read;
private boolean archived;
+ private Identity encryptedFor;
private KSKBoard board;
@@ -115,7 +116,7 @@
KSKMessageParser parser = new KSKMessageParser();
- if (parser.loadFile(new File(get.getPath()))
+ if (parser.loadFile(new File(get.getPath()), db)
&& parser.checkSignature(db)
&& parser.insert(db, board.getId(),
date, rev, board.getName())) {
@@ -126,12 +127,14 @@
successfullyDownloaded = true;
downloading = false;
successfullyParsed = true;
+ read = parser.mustBeDisplayedAsRead();
} else {
Logger.notice(this, "Unable to parse. File not
deleted");
successfullyDownloaded = true;
downloading = false;
successfullyParsed = false;
+ read = true;
}
}
@@ -166,6 +169,7 @@
int sigId, Identity identity,
java.util.Date date, int rev,
boolean read, boolean archived,
+ Identity encryptedFor,
KSKBoard board) {
this.id = id;
this.subject = subject;
@@ -178,6 +182,7 @@
this.read = read;
this.archived = archived;
this.board = board;
+ this.encryptedFor = encryptedFor;
}
public String getSubject() {
@@ -205,6 +210,10 @@
return read;
}
+ public Identity encryptedFor() {
+ return encryptedFor;
+ }
+
public thaw.plugins.miniFrost.interfaces.Board getBoard() {
return board;
}
Modified:
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
2007-07-30 20:38:54 UTC (rev 14444)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
2007-07-30 22:21:57 UTC (rev 14445)
@@ -11,15 +11,20 @@
import java.util.Vector;
import java.util.Iterator;
import java.util.List;
+import java.util.Date;
import frost.util.XMLTools;
+import org.bouncycastle.util.encoders.Base64;
+
import frost.crypt.FrostCrypt;
import thaw.plugins.signatures.Identity;
import thaw.plugins.Hsqldb;
import thaw.core.Logger;
+import thaw.core.I18n;
+
/**
* Dirty parser reusing some Frost functions
* (Note: dirty mainly because of the Frost format :p)
@@ -48,6 +53,11 @@
private Identity identity;
+ private boolean read = false;
+ private boolean archived = false;
+
+ private Identity encryptedFor = null;
+
private static FrostCrypt frostCrypt;
@@ -133,13 +143,15 @@
int boardId, java.util.Date boardDate, int rev,
String boardNameExpected) {
if (boardNameExpected == null) {
- Logger.error(this, "Board name expected == null ?!");
+ Logger.notice(this, "Board name expected == null ?!");
return false;
}
- if (board == null
- ||
!(boardNameExpected.toLowerCase().equals(board.toLowerCase())))
+ if (board != null
+ &&
!(boardNameExpected.toLowerCase().equals(board.toLowerCase()))) {
+ Logger.notice(this, "Board name doesn't match");
return false;
+ }
if (alreadyInTheDb(db, messageId)) {
Logger.info(this, "We have already this id in the db
?!");
@@ -150,20 +162,6 @@
time = time.trim();
- /*
- date = date.trim();
-
- date += " "+time;
-
- java.util.Date dateUtil = dateFormat.parse(date, new
java.text.ParsePosition(0));
-
- if (dateUtil == null) {
- if (date == null)
- date = "(null)";
- Logger.warning(this, "Unable to parse the date ?! :
"+date);
- }
- */
-
java.sql.Timestamp dateSql = new
java.sql.Timestamp(boardDate.getTime());
@@ -194,10 +192,10 @@
st =
db.getConnection().prepareStatement("INSERT INTO frostKSKMessages ("+
"subject, nick, sigId, content, "+
"date,
msgId, inReplyTo, inReplyToId, "+
- "rev,
read, archived, boardId) VALUES ("+
+ "rev,
read, archived, encryptedFor, boardId) VALUES ("+
"?, ?,
?, ?, "+
"?, ?,
?, ?, "+
- "?,
FALSE, FALSE, ?)");
+ "?, ?,
?, ?, ?)");
st.setString(1, subject);
st.setString(2, from); /* nick */
if (identity != null)
@@ -219,8 +217,17 @@
st.setNull(8, Types.VARCHAR);
st.setInt(9, rev);
- st.setInt(10, boardId);
+ st.setBoolean(10, read);
+ st.setBoolean(11, archived);
+
+ if (encryptedFor == null)
+ st.setNull(12, Types.INTEGER);
+ else
+ st.setInt(12, encryptedFor.getId());
+
+ st.setInt(13, boardId);
+
st.execute();
@@ -296,8 +303,10 @@
}
String[] split = from.split("@");
- if (split.length < 2 || "".equals(split[0].trim()))
+ if (split.length < 2 || "".equals(split[0].trim())) {
+ Logger.notice(this, "Unable to extract the nick name
from the message");
return false;
+ }
String nick = split[0].trim();
@@ -314,9 +323,11 @@
subject = XMLTools.getChildElementsCDATAValue(root,
"Subject");
date = XMLTools.getChildElementsCDATAValue(root,
"Date");
time = XMLTools.getChildElementsCDATAValue(root,
"Time");
+ if (time == null) time = "00:00:00GMT";
time = time.replaceAll("GMT", "");
recipient = XMLTools.getChildElementsCDATAValue(root,
"recipient");
board = XMLTools.getChildElementsCDATAValue(root,
"Board");
+ if (board == null) board = ""; /* won't validate a check in
insert() :p */
body = XMLTools.getChildElementsCDATAValue(root,
"Body");
signature = XMLTools.getChildElementsCDATAValue(root,
"SignatureV2");
publicKey = XMLTools.getChildElementsCDATAValue(root,
"pubKey");
@@ -339,25 +350,144 @@
}
}
+ if (from == null || subject == null || body == null) {
+ Logger.notice(this, "Field missing");
+ return false;
+ }
+
return true;
}
+
+
+ protected boolean decrypt(Hsqldb db, Element rootNode) {
+ Vector identities = Identity.getYourIdentities(db);
+
+ /**
+ * I prefer to not trust the recipient field ...
+ */
+
+ byte[] content;
+ String recipient =
XMLTools.getChildElementsCDATAValue(rootNode, "recipient");
+
+ try {
+ content =
Base64.decode(XMLTools.getChildElementsCDATAValue(rootNode,
+
"content").getBytes("UTF-8"));
+ } catch(Exception e) {
+ Logger.notice(this, "Unable to decode encrypted message
because : "+e.toString());
+ return false;
+ }
+
+ Identity identity = null;
+
+ for (Iterator it = identities.iterator();
+ it.hasNext();) {
+ Identity id = (Identity)it.next();
+ if (id.toString().equals(recipient)) {
+ identity = id;
+ break;
+ }
+ }
+
+
+ if (identity == null) {
+ Logger.info(this, "Not for us but for '"+recipient+"'");
+ }
+
+ byte[] decoded = null;
+
+ if (identity != null)
+ decoded = identity.decode(content);
+
+ if (decoded != null) {
+ /*** we are able to decrypt it ***/
+
+ /* Hm, there should be a better way (all in RAM) */
+
+ encryptedFor = identity;
+
+ File tmp = null;
+ boolean ret = false;
+
+ try {
+
+ tmp = File.createTempFile("thaw-",
"-decrypted-msg.xml");
+ tmp.deleteOnExit();
+
+ frost.util.FileAccess.writeFile(decoded, tmp);
+
+ /* recursivity (bad bad bad, but I'm lazy :) */
+ ret = loadFile(tmp, db);
+ } catch(Exception e) {
+ Logger.warning(this, "Unable to read the
decrypted message because: "+e.toString());
+ }
+
+ if (tmp != null)
+ tmp.delete();
+
+ return ret;
+ }
+
+
+ /*** Unable to decrypt the message, but we will store what we
know anyway ***
+ * to not fetch this message again
+ */
+ /* (I'm still thinking that mixing up Boards & private messages
is a BAD idea) */
+
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.M.d
HH:mm:ss");
+ dateFormat.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
+
+ inReplyTo = null;
+ from =
"["+I18n.getMessage("thaw.plugin.miniFrost.encrypted")+"]";
+ subject =
"["+I18n.getMessage("thaw.plugin.miniFrost.encryptedBody").replaceAll("X",
recipient)+"]";
+
+ String[] date = dateFormat.format(new
Date()).toString().split(" ");
+ this.date = date[0];
+ this.time = date[1];
+
+ /* not really used */
+ this.recipient = recipient;
+ /* will be ignored by the checks */
+ this.board = null;
+
+ this.body =
I18n.getMessage("thaw.plugin.miniFrost.encryptedBody").replaceAll("X",
recipient);
+ this.publicKey = null;
+ this.signature = null;
+ this.idLinePos = "0";
+ this.idLineLen = "0";
+ attachments = null;
+
+ identity = null;
+
+ if (frostCrypt == null)
+ frostCrypt = new FrostCrypt();
+ this.messageId = frostCrypt.computeChecksumSHA256(date[0] +
date[1]);
+
+ read = true;
+ archived = true;
+
+ /* because we have date to store: */
+ return true;
+ }
+
+
/**
* This function has been imported from FROST.
* Parses the XML file and passes the FrostMessage element to XMLize
load method.
+ * @param db require if the message is encrypted
*/
- public boolean loadFile(File file) {
+ public boolean loadFile(File file, Hsqldb db) {
try {
Document doc = null;
try {
doc = XMLTools.parseXmlFile(file, false);
} catch(Exception ex) { // xml format error
- Logger.warning(this, "Invalid Xml");
+ Logger.notice(this, "Invalid Xml");
return false;
}
if( doc == null ) {
- Logger.warning(this,
+ Logger.notice(this,
"Error: couldn't parse XML
Document - " +
"File name: '" + file.getName()
+ "'");
return false;
@@ -365,6 +495,15 @@
Element rootNode = doc.getDocumentElement();
+
if(rootNode.getTagName().equals("EncryptedFrostMessage")) {
+ if (db != null) {
+ return decrypt(db, rootNode);
+ } else {
+ Logger.error(this, "Can't decrypt the
message (no connection to the db available)");
+ return false;
+ }
+ }
+
// load the message itself
return loadXMLElements(rootNode);
@@ -460,4 +599,7 @@
return (XMLTools.writeXmlFile(doc, tmpFile.getPath()) ? tmpFile
: null);
}
+ protected boolean mustBeDisplayedAsRead() {
+ return read;
+ }
}
Modified:
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoardFactory.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoardFactory.java
2007-07-30 20:38:54 UTC (rev 14444)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoardFactory.java
2007-07-30 22:21:57 UTC (rev 14445)
@@ -65,7 +65,8 @@
for (int i = 0 ; i < DEFAULT_BOARDS_NAME.length ; i++)
createBoard(DEFAULT_BOARDS_NAME[i],
DEFAULT_BOARDS_PUBLICKEY[i],
- null);
+ null,
+ false /* warning */);
}
public Vector getBoards() {
Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Message.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Message.java
2007-07-30 20:38:54 UTC (rev 14444)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Message.java
2007-07-30 22:21:57 UTC (rev 14445)
@@ -19,6 +19,8 @@
public boolean isArchived();
public boolean isRead();
+ public Identity encryptedFor();
+
public void setRead(boolean read);
public void setArchived(boolean archived);
Modified: trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java 2007-07-30
20:38:54 UTC (rev 14444)
+++ trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java 2007-07-30
22:21:57 UTC (rev 14445)
@@ -608,6 +608,20 @@
return XMLTools.writeXmlFile(doc, file.getPath());
}
+
+ public byte[] decode(byte[] input) {
+ initFrostCrypt();
+
+ try {
+ return frostCrypt.decrypt(input, privateKey);
+ } catch(Exception e) {
+ Logger.info(this, "hm, '"+e.toString()+"' => probably
not for us ("+toString()+")");
+ }
+
+ return null;
+ }
+
+
public static Identity importIdentity(Hsqldb db, File file) {
try {
Document doc = null;