2017-09-03 03:38:26 +07:00
|
|
|
import { IClientFactory } from "./IClientFactory";
|
|
|
|
import { IClient } from "./IClient";
|
|
|
|
import { Client } from "./Client";
|
2017-10-07 18:46:19 +07:00
|
|
|
import { ILdapClientFactory } from "./ILdapClientFactory";
|
2017-09-03 03:38:26 +07:00
|
|
|
import { LdapConfiguration } from "../configuration/Configuration";
|
|
|
|
|
|
|
|
import Ldapjs = require("ldapjs");
|
|
|
|
import Dovehash = require("dovehash");
|
|
|
|
import Winston = require("winston");
|
|
|
|
|
|
|
|
export class ClientFactory implements IClientFactory {
|
|
|
|
private config: LdapConfiguration;
|
2017-10-07 18:46:19 +07:00
|
|
|
private ldapClientFactory: ILdapClientFactory;
|
2017-09-03 03:38:26 +07:00
|
|
|
private dovehash: typeof Dovehash;
|
|
|
|
private logger: typeof Winston;
|
|
|
|
|
2017-10-07 18:46:19 +07:00
|
|
|
constructor(ldapConfiguration: LdapConfiguration, ldapClientFactory: ILdapClientFactory,
|
2017-09-03 03:38:26 +07:00
|
|
|
dovehash: typeof Dovehash, logger: typeof Winston) {
|
|
|
|
this.config = ldapConfiguration;
|
2017-10-07 18:46:19 +07:00
|
|
|
this.ldapClientFactory = ldapClientFactory;
|
2017-09-03 03:38:26 +07:00
|
|
|
this.dovehash = dovehash;
|
|
|
|
this.logger = logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
create(userDN: string, password: string): IClient {
|
2017-10-07 18:46:19 +07:00
|
|
|
return new Client(userDN, password, this.config, this.ldapClientFactory,
|
|
|
|
this.dovehash, this.logger);
|
2017-09-03 03:38:26 +07:00
|
|
|
}
|
|
|
|
}
|