2018-07-27 22:44:20 +02:00
|
|
|
import { PasswordHistoryData } from '../data/passwordHistoryData';
|
|
|
|
|
2018-10-04 20:38:15 +02:00
|
|
|
import Domain from './domainBase';
|
2021-04-21 02:16:19 +02:00
|
|
|
import { EncString } from './encString';
|
2018-07-27 22:44:20 +02:00
|
|
|
|
|
|
|
import { PasswordHistoryView } from '../view/passwordHistoryView';
|
2020-12-22 16:53:48 +01:00
|
|
|
import { SymmetricCryptoKey } from './symmetricCryptoKey';
|
2018-07-27 22:44:20 +02:00
|
|
|
|
|
|
|
export class Password extends Domain {
|
2021-04-21 02:16:19 +02:00
|
|
|
password: EncString;
|
2018-07-27 22:44:20 +02:00
|
|
|
lastUsedDate: Date;
|
|
|
|
|
|
|
|
constructor(obj?: PasswordHistoryData, alreadyEncrypted: boolean = false) {
|
|
|
|
super();
|
|
|
|
if (obj == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.buildDomainModel(this, obj, {
|
|
|
|
password: null,
|
2018-08-20 22:01:26 +02:00
|
|
|
}, alreadyEncrypted);
|
|
|
|
this.lastUsedDate = new Date(obj.lastUsedDate);
|
2018-07-27 22:44:20 +02:00
|
|
|
}
|
|
|
|
|
2020-12-22 16:53:48 +01:00
|
|
|
decrypt(orgId: string, encKey?: SymmetricCryptoKey): Promise<PasswordHistoryView> {
|
2019-04-14 03:20:04 +02:00
|
|
|
return this.decryptObj(new PasswordHistoryView(this), {
|
2018-07-27 22:44:20 +02:00
|
|
|
password: null,
|
2020-12-22 16:53:48 +01:00
|
|
|
}, orgId, encKey);
|
2018-07-27 22:44:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
toPasswordHistoryData(): PasswordHistoryData {
|
|
|
|
const ph = new PasswordHistoryData();
|
2018-08-20 22:01:26 +02:00
|
|
|
ph.lastUsedDate = this.lastUsedDate.toISOString();
|
2018-07-27 22:44:20 +02:00
|
|
|
this.buildDataModel(this, ph, {
|
|
|
|
password: null,
|
|
|
|
});
|
|
|
|
return ph;
|
|
|
|
}
|
|
|
|
}
|