Files
azuredatastudio/src/sql/workbench/api/node/mainThreadCredentialManagement.ts
Karl Burtram dafb780987 Merge VS Code 1.21 source code (#1067)
* Initial VS Code 1.21 file copy with patches

* A few more merges

* Post npm install

* Fix batch of build breaks

* Fix more build breaks

* Fix more build errors

* Fix more build breaks

* Runtime fixes 1

* Get connection dialog working with some todos

* Fix a few packaging issues

* Copy several node_modules to package build to fix loader issues

* Fix breaks from master

* A few more fixes

* Make tests pass

* First pass of license header updates

* Second pass of license header updates

* Fix restore dialog issues

* Remove add additional themes menu items

* fix select box issues where the list doesn't show up

* formatting

* Fix editor dispose issue

* Copy over node modules to correct location on all platforms
2018-04-04 15:27:51 -07:00

67 lines
2.4 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { TPromise } from 'vs/base/common/winjs.base';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import {
SqlExtHostContext, ExtHostCredentialManagementShape,
MainThreadCredentialManagementShape, SqlMainContext
} from 'sql/workbench/api/node/sqlExtHost.protocol';
import { ICredentialsService } from 'sql/services/credentials/credentialsService';
import * as sqlops from 'sqlops';
import { IExtHostContext } from 'vs/workbench/api/node/extHost.protocol';
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
@extHostNamedCustomer(SqlMainContext.MainThreadCredentialManagement)
export class MainThreadCredentialManagement implements MainThreadCredentialManagementShape {
private _proxy: ExtHostCredentialManagementShape;
private _toDispose: IDisposable[];
private _registrations: { [handle: number]: IDisposable; } = Object.create(null);
constructor(
extHostContext: IExtHostContext,
@ICredentialsService private credentialService: ICredentialsService
) {
if (extHostContext) {
this._proxy = extHostContext.getProxy(SqlExtHostContext.ExtHostCredentialManagement);
}
}
public dispose(): void {
this._toDispose = dispose(this._toDispose);
}
public $registerCredentialProvider(handle: number): TPromise<any> {
let self = this;
this._registrations[handle] = this.credentialService.addEventListener(handle, {
onSaveCredential(credentialId: string, password: string): Thenable<boolean> {
return self._proxy.$saveCredential(credentialId, password);
},
onReadCredential(credentialId: string): Thenable<sqlops.Credential> {
return self._proxy.$readCredential(credentialId);
},
onDeleteCredential(credentialId: string): Thenable<boolean> {
return self._proxy.$deleteCredential(credentialId);
}
});
return undefined;
}
public $unregisterCredentialProvider(handle: number): TPromise<any> {
let registration = this._registrations[handle];
if (registration) {
registration.dispose();
delete this._registrations[handle];
}
return undefined;
}
}