Author: nextgens
Date: 2007-04-15 00:15:16 +0000 (Sun, 15 Apr 2007)
New Revision: 12742
Modified:
trunk/apps/Thaw/src/thaw/core/Logger.java
trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
trunk/apps/Thaw/src/thaw/fcp/SHA256Computer.java
Log:
Thaw fix obvious problem ... there is still something wrong though; the salt
seems to be correct
Modified: trunk/apps/Thaw/src/thaw/core/Logger.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Logger.java 2007-04-14 23:29:05 UTC (rev
12741)
+++ trunk/apps/Thaw/src/thaw/core/Logger.java 2007-04-15 00:15:16 UTC (rev
12742)
@@ -22,7 +22,7 @@
* 2 or more is recommanded.
* 4 or more is unhealthy
*/
- public final static int LOG_LEVEL = 3;
+ public final static int LOG_LEVEL = 5;
private static Vector logListeners = null;
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2007-04-14 23:29:05 UTC
(rev 12741)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java 2007-04-15 00:15:16 UTC
(rev 12742)
@@ -206,10 +206,14 @@
if
(queueManager.getQueryManager().getConnection().isLocalSocket() && localFile !=
null) {
status = "Computing hash to get approval from the node
...";
- sha = new
SHA256Computer(queueManager.getQueryManager().getConnection().getClientHello().getConnectionId()
- +"-"+ localFile.getPath() /*
Client token */
- +"-",
- localFile.getPath());
+ identifier = queueManager.getAnID() + "-"+
localFile.getName();
+
+ String salt =
queueManager.getQueryManager().getConnection().getClientHello().getConnectionId()
+ +"-"+ identifier
+ +"-";
+ System.out.println("~~~~~~~~~~~~~~~~" + salt);
+
+ sha = new SHA256Computer(salt, localFile.getPath());
sha.addObserver(this);
Thread th = new Thread(sha);
@@ -296,10 +300,12 @@
status = "Sending to the node";
- if (localFile != null)
- identifier = queueManager.getAnID() + "-"+
localFile.getName();
- else
- identifier = queueManager.getAnID();
+ if(identifier == null) {
+ if (localFile != null)
+ identifier = queueManager.getAnID() + "-"+
localFile.getName();
+ else
+ identifier = queueManager.getAnID();
+ }
setChanged();
this.notifyObservers();
Modified: trunk/apps/Thaw/src/thaw/fcp/SHA256Computer.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/SHA256Computer.java 2007-04-14 23:29:05 UTC
(rev 12741)
+++ trunk/apps/Thaw/src/thaw/fcp/SHA256Computer.java 2007-04-15 00:15:16 UTC
(rev 12742)
@@ -4,6 +4,7 @@
import java.util.Observable;
import java.io.FileInputStream;
+import java.io.File;
import java.security.MessageDigest;
@@ -18,34 +19,26 @@
* You shouldn't have to bother about it
*/
public class SHA256Computer extends Observable implements Runnable {
- private SHA256 sha;
private MessageDigest md;
- private String file;
private String hash;
+ private final String file;
+ private final String headers;
public final static int BLOCK_SIZE = 32768; /* 32 Ko */
public SHA256Computer(String header, String fileToHash) {
- file = fileToHash;
-
- sha = new SHA256();
-
- md = sha.getMessageDigest();
- md.reset();
-
- try {
- md.update(header.getBytes("UTF-8"));
- } catch(java.io.UnsupportedEncodingException e) {
- md.update(header.getBytes());
- }
+ this.file = fileToHash;
+ this.headers = header;
}
public void run() {
try {
- FileInputStream in = new FileInputStream(file);
-
+ FileInputStream in = new FileInputStream(new
File(file));
+ md = SHA256.getMessageDigest();
+ md.reset();
+ md.update(headers.getBytes("UTF-8"));
SHA256.hash(in, md);
hash = Base64.encode(md.digest());