Author: jflesch
Date: 2008-02-12 19:27:17 +0000 (Tue, 12 Feb 2008)
New Revision: 17843

Modified:
   trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
   trunk/apps/Thaw/src/thaw/plugins/MiniFrost.java
   trunk/apps/Thaw/src/thaw/plugins/WebOfTrust.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/KnownBoardListProvider.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/SpecialBoardFactory.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/KSKMessageParser.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoardFactory.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/BoardFactory.java
   trunk/apps/Thaw/src/thaw/plugins/webOfTrust/TrustListUploader.java
Log:
Minifrost / WebOfTrust : announce public key of the trust list in each frost 
message (+ sign it)

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2008-02-12 18:35:06 UTC 
(rev 17842)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2008-02-12 19:27:17 UTC 
(rev 17843)
@@ -626,7 +626,7 @@
 thaw.plugin.miniFrost.foldAll=Tout plier

 thaw.plugin.miniFrost.goBack=Retourner \u00e0 la liste des messages
-thaw.plugin.miniFrost.nextUnread=Prochain message non-lu sur cette board
+thaw.plugin.miniFrost.nextUnread=Prochain message non-lu sur cette board 
(Alt-N)

 thaw.plugin.miniFrost.selectAll=Tout s\u00e9lectionner
 thaw.plugin.miniFrost.selectNone=Ne plus rien s\u00e9lectionner

Modified: trunk/apps/Thaw/src/thaw/plugins/MiniFrost.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/MiniFrost.java     2008-02-12 18:35:06 UTC 
(rev 17842)
+++ trunk/apps/Thaw/src/thaw/plugins/MiniFrost.java     2008-02-12 19:27:17 UTC 
(rev 17843)
@@ -23,6 +23,7 @@

        private Core core;
        private Hsqldb hsqldb;
+       private WebOfTrust wot;

        private MiniFrostPanel miniFrostPanel;
        private MiniFrostConfigTab configTab;
@@ -89,14 +90,27 @@

                hsqldb = 
(Hsqldb)core.getPluginManager().getPlugin("thaw.plugins.Hsqldb");
                hsqldb.registerChild(this);
+               
+               if(core.getPluginManager().getPlugin("thaw.plugins.WebOfTrust") 
== null) {
+                       Logger.info(this, "Loading WoT plugin");

+                       
if(core.getPluginManager().loadPlugin("thaw.plugins.WebOfTrust") == null
+                          || 
!core.getPluginManager().runPlugin("thaw.plugins.WebOfTrust")) {
+                               Logger.error(this, "Unable to load 
thaw.plugins.WebOfTrust !");
+                               return false;
+                       }
+               }
+
+               wot = 
(WebOfTrust)core.getPluginManager().getPlugin("thaw.plugins.WebOfTrust");
+               wot.registerChild(this);
+
                return true;
        }


        protected boolean initFactories() {
                for (int i = 0 ; i < factories.length ; i++) {
-                       if (!factories[i].init(hsqldb, core, this))
+                       if (!factories[i].init(hsqldb, core, wot, this))
                                return false;
                }

@@ -168,6 +182,9 @@
                if (hsqldb != null)
                        hsqldb.unregisterChild(this);

+               if (wot != null)
+                       wot.unregisterChild(this);
+               
                miniFrostPanel.setVisible(false);
        }


Modified: trunk/apps/Thaw/src/thaw/plugins/WebOfTrust.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/WebOfTrust.java    2008-02-12 18:35:06 UTC 
(rev 17842)
+++ trunk/apps/Thaw/src/thaw/plugins/WebOfTrust.java    2008-02-12 19:27:17 UTC 
(rev 17843)
@@ -7,8 +7,10 @@
 import thaw.core.I18n;
 import thaw.core.ThawThread;
 import thaw.core.ThawRunnable;
+import thaw.fcp.FreenetURIHelper;
 import thaw.plugins.Hsqldb;
 import thaw.plugins.Signatures;
+import thaw.plugins.signatures.Identity;
 import thaw.plugins.webOfTrust.*;

 public class WebOfTrust extends thaw.core.LibraryPlugin {
@@ -162,6 +164,25 @@

                return true;
        }
+       
+       private Identity getUsedIdentity() {
+               return trustListUploader.getIdentityUsed();
+       }
+       
+       private String getTrustListPublicKey() {
+               String key;
+               
+               if ( (key = core.getConfig().getValue("wotPublicKey")) == null)
+                       return null;
+               
+               return 
FreenetURIHelper.convertSSKtoUSK(key)+"/trustList/0/trustList.xml";
+       }
+       
+       public String getTrustListPublicKeyFor(Identity id) {
+               if (id.equals(getUsedIdentity()))
+                       return getTrustListPublicKey();
+               return null;
+       }

        public void stop() {
                used--;

Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/KnownBoardListProvider.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/KnownBoardListProvider.java      
2008-02-12 18:35:06 UTC (rev 17842)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/KnownBoardListProvider.java      
2008-02-12 19:27:17 UTC (rev 17843)
@@ -10,6 +10,7 @@
 import thaw.core.I18n;
 import thaw.plugins.Hsqldb;
 import thaw.plugins.MiniFrost;
+import thaw.plugins.WebOfTrust;
 import thaw.plugins.miniFrost.interfaces.BoardAttachment;
 import thaw.plugins.miniFrost.interfaces.BoardFactory;

@@ -22,7 +23,7 @@

        }

-       public boolean init(Hsqldb db, Core core, MiniFrost miniFrost) {
+       public boolean init(Hsqldb db, Core core, WebOfTrust wot, MiniFrost 
miniFrost) {
                this.db = db;
                this.core = core;
                this.miniFrost = miniFrost;

Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/SpecialBoardFactory.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/SpecialBoardFactory.java 
2008-02-12 18:35:06 UTC (rev 17842)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/SpecialBoardFactory.java 
2008-02-12 19:27:17 UTC (rev 17843)
@@ -4,6 +4,7 @@
 import thaw.core.Logger;
 import thaw.plugins.Hsqldb;
 import thaw.plugins.MiniFrost;
+import thaw.plugins.WebOfTrust;
 import thaw.plugins.miniFrost.interfaces.BoardFactory;


@@ -22,7 +23,8 @@
         * Init
         */
        public boolean init(Hsqldb db, thaw.core.Core core,
-                           MiniFrost miniFrost) {
+                       WebOfTrust wot,
+                       MiniFrost miniFrost) {
                this.miniFrost = miniFrost;
                return true;
        }

Modified: 
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java    
2008-02-12 18:35:06 UTC (rev 17842)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoardFactory.java    
2008-02-12 19:27:17 UTC (rev 17843)
@@ -16,6 +16,7 @@

 import thaw.plugins.Hsqldb;
 import thaw.plugins.MiniFrost;
+import thaw.plugins.WebOfTrust;
 import thaw.plugins.signatures.Identity;


@@ -52,6 +53,7 @@

        private Hsqldb db;
        private Core core;
+       private WebOfTrust wot;
        private MiniFrost plugin;

        private HashMap boardsHashMap;
@@ -62,14 +64,15 @@
        }


-       public boolean init(Hsqldb db, Core core, MiniFrost plugin) {
-               return init(db, core, plugin, "frostKSKDatabaseVersion");
+       public boolean init(Hsqldb db, Core core, WebOfTrust wot, MiniFrost 
plugin) {
+               return init(db, core, wot, plugin, "frostKSKDatabaseVersion");
        }

-       public boolean init(Hsqldb db, Core core, MiniFrost plugin, String 
configOption) {
+       public boolean init(Hsqldb db, Core core, WebOfTrust wot, MiniFrost 
plugin, String configOption) {
                this.db = db;
                this.core = core;
                this.plugin = plugin;
+               this.wot = wot;

                boolean firstStart = (core.getConfig().getValue(configOption) 
== null);

@@ -160,6 +163,9 @@
                return true;
        }

+       public WebOfTrust getWoT() {
+               return wot;
+       }

        public MiniFrost getPlugin() {
                return plugin;

Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java   
2008-02-12 18:35:06 UTC (rev 17842)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java   
2008-02-12 19:27:17 UTC (rev 17843)
@@ -216,6 +216,7 @@
        }

        private void startInsertion() {
+               
                /* we generate first the XML message */
                KSKMessageParser generator = new 
KSKMessageParser(board.getFactory().getDb(),
                                                                        
((inReplyTo != null) ? inReplyTo.getMsgId() : null),
@@ -229,7 +230,8 @@
                                                                           
attachments,
                                                                           
identity,
                                                                           
idLinePos,
-                                                                          
idLineLen);
+                                                                          
idLineLen,
+                                                                          
board.getFactory().getWoT().getTrustListPublicKeyFor(identity));

                fileToInsert = generator.generateXML(board.getFactory().getDb() 
/* gruick */);


Modified: 
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java   
2008-02-12 18:35:06 UTC (rev 17842)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java   
2008-02-12 19:27:17 UTC (rev 17843)
@@ -56,6 +56,8 @@
        private String signature;
        private String idLinePos;
        private String idLineLen;
+       private String wotPublicKey;
+       private String wotPublicKeySignature;

        private Vector attachments;

@@ -63,7 +65,7 @@

        private boolean read = false;
        private boolean archived = false;
-
+       
        private Identity encryptedFor = null;

        private static FrostCrypt frostCrypt;
@@ -82,7 +84,8 @@
                                Vector attachments,
                                Identity identity,
                                int idLinePos,
-                               int idLineLen) {
+                               int idLineLen,
+                               String wotPublicKey) {
                this();

                this.messageId = ""; /* will be generated from the SHA1 of the 
content */
@@ -114,13 +117,27 @@

                /* frost wants a SHA256 hash, but can't check from what is 
comes :p */
                this.messageId = 
frostCrypt.computeChecksumSHA256(getSignedContent(false));
+               
+               
+               this.wotPublicKey = wotPublicKey;

-               if (identity == null)
+               if (identity == null) {
                        signature = null;
-               else {
+               } else {
                        signature = identity.sign(getSignedContent(true));
                }
+
+               wotPublicKeySignature = getWotPublicKeySignature(identity, 
wotPublicKey);
        }
+       
+       private String getWotPublicKeySignature(Identity identity, String 
wotPublicKey) {
+               if (identity == null || wotPublicKey == null)
+                       return null;
+               
+               String toSign = wotPublicKey+"|"+date+"|"+time+"|"+messageId;
+               
+               return identity.sign(toSign);
+       }


        private boolean alreadyInTheDb(Hsqldb db, String msgId) {
@@ -732,6 +749,14 @@

                if ((el = makeText( doc, "client",    "Thaw 
"+thaw.core.Main.VERSION)) != null)
                        root.appendChild(el);
+               
+               if (wotPublicKey != null) {
+                       if ((el = makeText(doc, "trustListPublicKey", 
wotPublicKey)) != null)
+                               root.appendChild(el);
+                       if ((el = makeText(doc, "trustListPublicKeySignature", 
wotPublicKeySignature)) != null)
+                               root.appendChild(el);
+               }       
+
                if ((el = makeCDATA(doc, "MessageId", messageId)) != null)   
root.appendChild(el);
                if ((el = makeCDATA(doc, "InReplyTo", inReplyToFull)) != null)  
 root.appendChild(el);
                if ((el = makeText( doc, "IdLinePos", idLinePos)) != null)   
root.appendChild(el);

Modified: 
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoardFactory.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoardFactory.java    
2008-02-12 18:35:06 UTC (rev 17842)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/SSKBoardFactory.java    
2008-02-12 19:27:17 UTC (rev 17843)
@@ -29,6 +29,7 @@
 import thaw.core.I18n;
 import thaw.plugins.Hsqldb;
 import thaw.plugins.MiniFrost;
+import thaw.plugins.WebOfTrust;


 public class SSKBoardFactory extends KSKBoardFactory {
@@ -54,11 +55,11 @@
                super();
        }

-       public boolean init(Hsqldb db, Core core, MiniFrost plugin) {
+       public boolean init(Hsqldb db, Core core, WebOfTrust wot, MiniFrost 
plugin) {
                this.db = db;
                this.core = core;
                this.boards = new HashMap();
-               return super.init(db, core, plugin, "frostSSKInitialized");
+               return super.init(db, core, wot, plugin, "frostSSKInitialized");
        }

        protected void addDefaultBoards() {

Modified: 
trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/BoardFactory.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/BoardFactory.java     
2008-02-12 18:35:06 UTC (rev 17842)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/BoardFactory.java     
2008-02-12 19:27:17 UTC (rev 17843)
@@ -1,6 +1,7 @@
 package thaw.plugins.miniFrost.interfaces;

 import thaw.plugins.MiniFrost;
+import thaw.plugins.WebOfTrust;

 import java.util.Vector;

@@ -13,6 +14,7 @@
         * Init
         */
        public boolean init(Hsqldb db, thaw.core.Core core,
+                               WebOfTrust webOfTrust,
                            MiniFrost miniFrost);



Modified: trunk/apps/Thaw/src/thaw/plugins/webOfTrust/TrustListUploader.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/webOfTrust/TrustListUploader.java  
2008-02-12 18:35:06 UTC (rev 17842)
+++ trunk/apps/Thaw/src/thaw/plugins/webOfTrust/TrustListUploader.java  
2008-02-12 19:27:17 UTC (rev 17843)
@@ -69,6 +69,10 @@
                privateKey = null;
        }

+       public Identity getIdentityUsed() {
+               return identity;
+       }
+       
        public void init() {
                lastUpload = null;



Reply via email to