Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions client/chrome/content/ssl/Notary.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,20 +263,22 @@ Notary.prototype.setPhysicalNotaries = function(physicalNotaries) {
this.physicalNotaries = physicalNotaries;
};

Notary.prototype.serializeForTransport = function() {
Notary.prototype.serializeForTransport = function(callback) {
var serializedPhysicalNotaries = new Array();
var count = this.physicalNotaries.length;
var self = this;

for (var i=0;i<this.physicalNotaries.length;i++) {
serializedPhysicalNotaries.push(this.physicalNotaries[i].serializeForTransport());
this.physicalNotaries[i].serializeForTransport(function(spn) {
serializedPhysicalNotaries.push(spn);
count--;
if(count === 0) callback({'name' : self.name,
'enabled' : self.enabled,
'bundle_location' : self.bundleLocation,
'region' : self.region,
'physical_notaries' : serializedPhysicalNotaries});
});
}

var serialized = {'name' : this.name,
'enabled' : this.enabled,
'bundle_location' : this.bundleLocation,
'region' : this.region,
'physical_notaries' : serializedPhysicalNotaries};

return serialized;
};


Expand Down Expand Up @@ -399,4 +401,4 @@ Notary.constructFromBundle = function(bundlePath) {
exception.version = notaryJson.version;
throw exception;
}
};
};
41 changes: 21 additions & 20 deletions client/chrome/content/ssl/PhysicalNotary.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ PhysicalNotary.prototype.setHTTPPort = function(port) {
this.httpPort = port;
};

PhysicalNotary.prototype.getProxiesForNotary = function() {
PhysicalNotary.prototype.getProxiesForNotary = function(callback) {
var result = { };
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);

Expand All @@ -90,26 +91,26 @@ PhysicalNotary.prototype.getProxiesForNotary = function() {
var httpUri = ioService.newURI("http://" + this.host + ":" + this.httpPort, null, null);
var sslUri = ioService.newURI("https://" + this.host + ":" + this.sslPort, null, null);

var httpProxy = proxyService.resolve(httpUri, null);
var sslProxy = proxyService.resolve(sslUri, null);

var serializedHttpProxy = Serialization.serializeProxyInfo(httpProxy);
var serializedSslProxy = Serialization.serializeProxyInfo(sslProxy);

return {'http_proxy' : serializedHttpProxy, 'ssl_proxy' : serializedSslProxy};
proxyService.asyncResolve(httpUri, null, { onProxyAvailable: function(aRequest, anURI, httpProxy, aStatus) {
result['http_proxy'] = Serialization.serializeProxyInfo(httpProxy);
if('ssl_proxy' in result) callback(result);
}});
proxyService.asyncResolve(sslUri, null, { onProxyAvailable: function(aRequest, anURI, sslProxy, aStatus) {
result['ssl_proxy'] = Serialization.serializeProxyInfo(sslProxy);
if('http_proxy' in result) callback(result);
}});
};

PhysicalNotary.prototype.serializeForTransport = function() {
var proxies = this.getProxiesForNotary();

var serialized = {'host' : this.host,
'ssl_port' : this.sslPort,
'http_port' : this.httpPort,
'fingerprint' : this.sha1Fingerprint,
'http_proxy' : proxies['http_proxy'],
'ssl_proxy' : proxies['ssl_proxy']};

return serialized;
PhysicalNotary.prototype.serializeForTransport = function(callback) {
var self = this;
this.getProxiesForNotary(function(proxies) {
callback({'host' : self.host,
'ssl_port' : self.sslPort,
'http_port' : self.httpPort,
'fingerprint' : self.sha1Fingerprint,
'http_proxy' : proxies['http_proxy'],
'ssl_proxy' : proxies['ssl_proxy']});
});
};

PhysicalNotary.prototype.serialize = function(xmlDocument) {
Expand All @@ -133,4 +134,4 @@ PhysicalNotary.prototype.deserialize = function(element) {
this.sha1Fingerprint = this.parseSha1Fingerprint(this.certificate);

dump("Deserialized physical notary: " + this.host + " : " + this.httpPort + "\n");
};
};
25 changes: 14 additions & 11 deletions client/components/ConnectionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,19 @@ ConnectionManager.prototype.spawnConnection = function(clientSocket) {
NSPR.lib.PR_Write(connectionManager.wakeupWrite, connectionManager.buffer, 5);
};

worker.postMessage({'nsprFile' : this.nsprFile.path,
'nssFile' : this.nssFile.path,
'sslFile' : this.sslFile.path,
'sqliteFile' : this.sqliteFile.path,
'cacheFile' : this.cacheFile.path,
'notaries' : this.settingsManager.getSerializedNotaryList(),
'clientSocket' : clientSocket,
'settings' : this.settingsManager.getSerializedSettings(),
'proxy' : this.proxyInfo,
'certificates' : this.certificateManager.serialize()});
var self = this;
this.settingsManager.getSerializedNotaryList(function(nl) {
worker.postMessage({'nsprFile' : self.nsprFile.path,
'nssFile' : self.nssFile.path,
'sslFile' : self.sslFile.path,
'sqliteFile' : self.sqliteFile.path,
'cacheFile' : self.cacheFile.path,
'notaries' : nl,
'clientSocket' : clientSocket,
'settings' : self.settingsManager.getSerializedSettings(),
'proxy' : self.proxyInfo,
'certificates' : self.certificateManager.serialize()});
});

dump("Posted message to ConnectionWorker!\n");
};
Expand Down Expand Up @@ -167,4 +170,4 @@ ConnectionManager.prototype.initializeShuffleWorker = function() {
dump("Posting error: " + e + " , " + e.stack + "\n");
}
return shuffleWorker;
};
};
12 changes: 8 additions & 4 deletions client/components/SettingsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,20 @@ SettingsManager.prototype.hasEnabledNotary = function() {
return false;
};

SettingsManager.prototype.getSerializedNotaryList = function() {
SettingsManager.prototype.getSerializedNotaryList = function(callback) {
var serialized = new Array();
var count = 0;

for (var i in this.notaries) {
if (this.notaries[i].enabled) {
serialized.push(this.notaries[i].serializeForTransport());
count++;
this.notaries[i].serializeForTransport(function(sn) {
serialized.push(sn);
count--;
if(count === 0) callback(serialized);
});
}
}

return serialized;
};

SettingsManager.prototype.getSerializedSettings = function() {
Expand Down