mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1103120 - Part 11: Client: Pass auth settings from advertisement. r=past
This commit is contained in:
parent
3d2a406872
commit
3c1e0ad2ec
@ -447,9 +447,8 @@ WiFiRuntime.prototype = {
|
||||
if (!service) {
|
||||
return promise.reject(new Error("Can't find device: " + this.name));
|
||||
}
|
||||
connection.host = service.host;
|
||||
connection.port = service.port;
|
||||
connection.encryption = service.encryption;
|
||||
connection.advertisement = service;
|
||||
// TODO: Customize client authentication UX
|
||||
connection.connect();
|
||||
return promise.resolve();
|
||||
},
|
||||
|
@ -53,6 +53,11 @@ DevToolsUtils.defineLazyModuleGetter(this, "Task",
|
||||
* . store Reference to a local data store (see below)
|
||||
* . keepConnecting Should the connection keep trying to connect?
|
||||
* . encryption Should the connection be encrypted?
|
||||
* . authentication What authentication scheme should be used?
|
||||
* . authenticator The |Authenticator| instance used. Overriding
|
||||
* properties of this instance may be useful to
|
||||
* customize authentication UX for a specific use case.
|
||||
* . advertisement The server's advertisement if found by discovery
|
||||
* . status Connection status:
|
||||
* Connection.Status.CONNECTED
|
||||
* Connection.Status.DISCONNECTED
|
||||
@ -179,9 +184,60 @@ Connection.prototype = {
|
||||
this.emit(Connection.Events.PORT_CHANGED);
|
||||
},
|
||||
|
||||
get authentication() {
|
||||
return this._authentication;
|
||||
},
|
||||
|
||||
set authentication(value) {
|
||||
this._authentication = value;
|
||||
// Create an |Authenticator| of this type
|
||||
if (!value) {
|
||||
this.authenticator = null;
|
||||
return;
|
||||
}
|
||||
let AuthenticatorType = DebuggerClient.Authenticators.get(value);
|
||||
this.authenticator = new AuthenticatorType.Client();
|
||||
},
|
||||
|
||||
get advertisement() {
|
||||
return this._advertisement;
|
||||
},
|
||||
|
||||
set advertisement(advertisement) {
|
||||
// The full advertisement may contain more info than just the standard keys
|
||||
// below, so keep a copy for use during connection later.
|
||||
this._advertisement = advertisement;
|
||||
if (advertisement) {
|
||||
["host", "port", "encryption", "authentication"].forEach(key => {
|
||||
this[key] = advertisement[key];
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Settings to be passed to |socketConnect| at connection time.
|
||||
*/
|
||||
get socketSettings() {
|
||||
let settings = {};
|
||||
if (this.advertisement) {
|
||||
// Use the advertisement as starting point if it exists, as it may contain
|
||||
// extra data, like the server's cert.
|
||||
Object.assign(settings, this.advertisement);
|
||||
}
|
||||
Object.assign(settings, {
|
||||
host: this.host,
|
||||
port: this.port,
|
||||
encryption: this.encryption,
|
||||
authenticator: this.authenticator
|
||||
});
|
||||
return settings;
|
||||
},
|
||||
|
||||
resetOptions() {
|
||||
this.keepConnecting = false;
|
||||
this.encryption = false;
|
||||
this.authentication = null;
|
||||
this.advertisement = null;
|
||||
},
|
||||
|
||||
disconnect: function(force) {
|
||||
@ -238,11 +294,8 @@ Connection.prototype = {
|
||||
if (!this.host) {
|
||||
return DebuggerServer.connectPipe();
|
||||
}
|
||||
let transport = yield DebuggerClient.socketConnect({
|
||||
host: this.host,
|
||||
port: this.port,
|
||||
encryption: this.encryption
|
||||
});
|
||||
let settings = this.socketSettings;
|
||||
let transport = yield DebuggerClient.socketConnect(settings);
|
||||
return transport;
|
||||
}),
|
||||
|
||||
|
@ -83,6 +83,9 @@ DevToolsUtils.defineLazyGetter(this, "DebuggerSocket", () => {
|
||||
let { DebuggerSocket } = devtools.require("devtools/toolkit/security/socket");
|
||||
return DebuggerSocket;
|
||||
});
|
||||
DevToolsUtils.defineLazyGetter(this, "Authentication", () => {
|
||||
return devtools.require("devtools/toolkit/security/auth");
|
||||
});
|
||||
|
||||
/**
|
||||
* TODO: Get rid of this API in favor of EventTarget (bug 1042642)
|
||||
@ -372,11 +375,17 @@ DebuggerClient.Argument.prototype.getArgument = function (aParams) {
|
||||
return aParams[this.position];
|
||||
};
|
||||
|
||||
// Expose this to save callers the trouble of importing DebuggerSocket
|
||||
// Expose these to save callers the trouble of importing DebuggerSocket
|
||||
DebuggerClient.socketConnect = function(options) {
|
||||
// Defined here instead of just copying the function to allow lazy-load
|
||||
return DebuggerSocket.connect(options);
|
||||
};
|
||||
DevToolsUtils.defineLazyGetter(DebuggerClient, "Authenticators", () => {
|
||||
return Authentication.Authenticators;
|
||||
});
|
||||
DevToolsUtils.defineLazyGetter(DebuggerClient, "AuthenticationResult", () => {
|
||||
return Authentication.AuthenticationResult;
|
||||
});
|
||||
|
||||
DebuggerClient.prototype = {
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user