used cached cert; generics

This commit is contained in:
zzz
2011-12-13 20:38:02 +00:00
parent 24c1473b1d
commit c92c664d3d
3 changed files with 12 additions and 10 deletions

View File

@ -19,7 +19,7 @@ import net.i2p.data.i2np.GarlicClove;
*
*/
class CloveSet {
private final List _cloves;
private final List<GarlicClove> _cloves;
private Certificate _cert;
private long _msgId;
private long _expiration;
@ -32,7 +32,7 @@ class CloveSet {
public int getCloveCount() { return _cloves.size(); }
public void addClove(GarlicClove clove) { _cloves.add(clove); }
public GarlicClove getClove(int index) { return (GarlicClove)_cloves.get(index); }
public GarlicClove getClove(int index) { return _cloves.get(index); }
public Certificate getCertificate() { return _cert; }
public void setCertificate(Certificate cert) { _cert = cert; }
@ -46,7 +46,7 @@ class CloveSet {
StringBuilder buf = new StringBuilder(128);
buf.append("{");
for (int i = 0; i < _cloves.size(); i++) {
GarlicClove clove = (GarlicClove)_cloves.get(i);
GarlicClove clove = _cloves.get(i);
if (clove.getData() != null)
buf.append(clove.getData().getClass().getName()).append(", ");
else

View File

@ -27,7 +27,7 @@ class GarlicConfig {
private Certificate _cert;
private long _id;
private long _expiration;
private final List _cloveConfigs;
private final List<GarlicConfig> _cloveConfigs;
private DeliveryInstructions _instructions;
private boolean _requestAck;
private RouterInfo _replyThroughRouter; // router through which any replies will be sent before delivery to us
@ -142,7 +142,7 @@ class GarlicConfig {
}
}
public int getCloveCount() { return _cloveConfigs.size(); }
public GarlicConfig getClove(int index) { return (GarlicConfig)_cloveConfigs.get(index); }
public GarlicConfig getClove(int index) { return _cloveConfigs.get(index); }
public void clearCloves() { _cloveConfigs.clear(); }

View File

@ -46,8 +46,9 @@ class GarlicMessageParser {
_log.warn("Error decrypting", dfe);
}
if (decrData == null) {
if (_log.shouldLog(Log.WARN))
_log.warn("Decryption of garlic message failed", new Exception("Decrypt fail"));
// This is the usual error path and it's logged at WARN level in GarlicMessageReceiver
if (_log.shouldLog(Log.INFO))
_log.info("Decryption of garlic message failed", new Exception("Decrypt fail"));
return null;
} else {
try {
@ -78,12 +79,13 @@ class GarlicMessageParser {
if (_log.shouldLog(Log.DEBUG))
_log.debug("After reading clove " + i);
}
Certificate cert = new Certificate();
offset += cert.readBytes(data, offset);
//Certificate cert = new Certificate();
//offset += cert.readBytes(data, offset);
Certificate cert = Certificate.create(data, offset);
offset += cert.size();
long msgId = DataHelper.fromLong(data, offset, 4);
offset += 4;
Date expiration = DataHelper.fromDate(data, offset);
offset += DataHelper.DATE_LENGTH;
set.setCertificate(cert);
set.setMessageId(msgId);