tempContext.maxTempLength = NodeUpdateManager.MAX_REVOCATION_KEY_TEMP_LENGTH;
tempContext.localRequestOnly = true;
final ArrayBucket cleanedBlob = new ArrayBucket();
ClientGetCallback myCallback = new ClientGetCallback() {
@Override
public void onFailure(FetchException e, ClientGetter state) {
if(e.mode == FetchExceptionMode.CANCELLED) {
// Eh?
Logger.error(this, "Cancelled fetch from store/blob of revocation certificate from " + source);
System.err.println("Cancelled fetch from store/blob of revocation certificate from " + source + " to " + temp + " - please report to developers");
// Probably best to keep files around for now.
} else if(e.isFatal()) {
// Blown: somebody inserted a revocation message, but it was corrupt as inserted
// However it had valid signatures etc.
System.err.println("Got revocation certificate from " + source + " (fatal error i.e. someone with the key inserted bad data) : "+e);
// Blow the update, and propagate the revocation certificate.
updateManager.revocationChecker.onFailure(e, state, cleanedBlob);
// Don't delete it if it's from disk, as it's already in the right place.
if(!fromDisk)
temp.free();
insertBlob(updateManager.revocationChecker.getBlobBucket(), "revocation");
} else {
String message = "Failed to fetch revocation certificate from blob from " +
source + " : "+e+
(fromDisk ? " : did you change the revocation key?" :
" : this is almost certainly bogus i.e. the auto-update is fine but the node is broken.");
Logger.error(this, message);
System.err.println(message);
// This is almost certainly bogus.
// Delete it, even if it's fromDisk.
temp.free();
cleanedBlob.free();
}
}
@Override
public void onSuccess(FetchResult result, ClientGetter state) {
System.err.println("Got revocation certificate from " + source);
updateManager.revocationChecker.onSuccess(result, state, cleanedBlob);
if(!fromDisk)
temp.free();
insertBlob(updateManager.revocationChecker.getBlobBucket(), "revocation");
}
@Override
public void onResume(ClientContext context) {
// Not persistent.
}
@Override
public RequestClient getRequestClient() {
return UpdateOverMandatoryManager.this;
}
};
ClientGetter cg = new ClientGetter(myCallback,
updateManager.getRevocationURI(), tempContext, (short) 0, null, new BinaryBlobWriter(cleanedBlob), null);
try {
updateManager.node.clientCore.clientContext.start(cg);
} catch(FetchException e1) {
System.err.println("Failed to decode UOM blob: " + e1);
e1.printStackTrace();
myCallback.onFailure(e1, cg);
} catch (PersistenceDisabledException e) {
// Impossible
}
}