2005-09-05 jrandom

* Expose the HTTP headers to EepGet status listeners
    * Handle DSA key failures properly (if the signature is not invertable, it
      is obviously invalid)
This commit is contained in:
jrandom
2005-09-05 19:29:55 +00:00
committed by zzz
parent 8147cdf40c
commit 5a1f738505
5 changed files with 19 additions and 3 deletions

View File

@ -80,7 +80,12 @@ public class DSAEngine {
BigInteger s = new NativeBigInteger(1, sbytes); BigInteger s = new NativeBigInteger(1, sbytes);
BigInteger r = new NativeBigInteger(1, rbytes); BigInteger r = new NativeBigInteger(1, rbytes);
BigInteger y = new NativeBigInteger(1, verifyingKey.getData()); BigInteger y = new NativeBigInteger(1, verifyingKey.getData());
BigInteger w = s.modInverse(CryptoConstants.dsaq); BigInteger w = null;
try {
w = s.modInverse(CryptoConstants.dsaq);
} catch (ArithmeticException ae) {
return false;
}
byte data[] = hash.getData(); byte data[] = hash.getData();
NativeBigInteger bi = new NativeBigInteger(1, data); NativeBigInteger bi = new NativeBigInteger(1, data);
BigInteger u1 = bi.multiply(w).mod(CryptoConstants.dsaq); BigInteger u1 = bi.multiply(w).mod(CryptoConstants.dsaq);

View File

@ -217,7 +217,7 @@ public class DataHelper {
public static void loadProps(Properties props, InputStream inStr) throws IOException { public static void loadProps(Properties props, InputStream inStr) throws IOException {
BufferedReader in = null; BufferedReader in = null;
try { try {
in = new BufferedReader(new InputStreamReader(inStr), 16*1024); in = new BufferedReader(new InputStreamReader(inStr, "UTF-8"), 16*1024);
String line = null; String line = null;
while ( (line = in.readLine()) != null) { while ( (line = in.readLine()) != null) {
if (line.trim().length() <= 0) continue; if (line.trim().length() <= 0) continue;

View File

@ -168,6 +168,7 @@ public class EepGet {
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile); public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile);
public void attemptFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt, int numRetries, Exception cause); public void attemptFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt, int numRetries, Exception cause);
public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt); public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt);
public void headerReceived(String url, int currentAttempt, String key, String val);
} }
private class CLIStatusListener implements StatusListener { private class CLIStatusListener implements StatusListener {
private int _markSize; private int _markSize;
@ -270,6 +271,7 @@ public class EepGet {
buf.append("KBps"); buf.append("KBps");
System.out.println(buf.toString()); System.out.println(buf.toString());
} }
public void headerReceived(String url, int currentAttempt, String key, String val) {}
} }
public void addStatusListener(StatusListener lsnr) { public void addStatusListener(StatusListener lsnr) {
@ -489,6 +491,9 @@ public class EepGet {
} }
private void handle(String key, String val) { private void handle(String key, String val) {
for (int i = 0; i < _listeners.size(); i++)
((StatusListener)_listeners.get(i)).headerReceived(_url, _currentAttempt, key.trim(), val.trim());
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("Header line: [" + key + "] = [" + val + "]"); _log.debug("Header line: [" + key + "] = [" + val + "]");
if (key.equalsIgnoreCase("Content-length")) { if (key.equalsIgnoreCase("Content-length")) {

View File

@ -69,4 +69,5 @@ public class EepGetScheduler implements EepGet.StatusListener {
fetchNext(); fetchNext();
} }
public void headerReceived(String url, int attemptNum, String key, String val) {}
} }

View File

@ -1,4 +1,9 @@
$Id: history.txt,v 1.238 2005/09/04 14:15:51 jrandom Exp $ $Id: history.txt,v 1.239 2005/09/04 15:26:42 jrandom Exp $
2005-09-05 jrandom
* Expose the HTTP headers to EepGet status listeners
* Handle DSA key failures properly (if the signature is not invertable, it
is obviously invalid)
2005-09-04 jrandom 2005-09-04 jrandom
* Don't persist peer profiles until we are shutting down, as the * Don't persist peer profiles until we are shutting down, as the