Move saveCryptoSetting in Cypher class beside getCryptoSetting
MODIFY
src/integration/asset/greencom/GreencomAssetIntegration.ts
src/integration/asset/greencom/GreencomAssetIntegration.ts
@@ -118,6 +118,7 @@ export default class GreencomAssetIntegration extends AssetIntegration<AssetSett
}
private async getAuthentication(): Promise<{grant_type: string; client_id: string; client_secret: string;}> {
+ console.log(JSON.stringify(this.connection.greencomConnection));
return {
'grant_type': 'client_credentials',
'client_id': this.connection.greencomConnection.clientId,

MODIFY
src/migration/tasks/MigrateCryptoSettingsFromConfigToDBTask.ts
src/migration/tasks/MigrateCryptoSettingsFromConfigToDBTask.ts
-import { CryptoKeyProperties, CryptoKeySetting, CryptoSettingsType } from '../../types/Setting';
+import { CryptoKeySetting, CryptoSettingsType } from '../../types/Setting';
import Configuration from '../../utils/Configuration';
import Constants from '../../utils/Constants';
+import Cypher from '../../utils/Cypher';
import MigrationTask from '../MigrationTask';
import SettingStorage from '../../storage/mongodb/SettingStorage';
import Tenant from '../../types/Tenant';
@@ -35,7 +36,7 @@ export default class MigrateCryptoSettingsFromConfigToDBTask extends MigrationTa
keyProperties: configCryptoKeyProperties,
}
} as CryptoKeySetting;
- await SettingStorage.saveCryptoSettings(tenant.id, keySettingToSave);
+ await Cypher.saveCryptoSetting(tenant.id, keySettingToSave);
}
}

MODIFY
src/server/rest/v1/service/TenantService.ts
src/server/rest/v1/service/TenantService.ts
@@ -9,6 +9,7 @@ import AppAuthError from '../../../../exception/AppAuthError';
import AppError from '../../../../exception/AppError';
import Authorizations from '../../../../authorization/Authorizations';
import Constants from '../../../../utils/Constants';
+import Cypher from '../../../../utils/Cypher';
import { LockEntity } from '../../../../types/Locking';
import LockingManager from '../../../../locking/LockingManager';
import Logging from '../../../../utils/Logging';
@@ -182,7 +183,7 @@ export default class TenantService {
}
} as CryptoKeySetting;
// Save Crypto Key Settings
- await SettingStorage.saveCryptoSettings(tenantID, keySettingToSave);
+ await Cypher.saveCryptoSetting(tenantID, keySettingToSave);
}
}

MODIFY
src/storage/mongodb/SettingStorage.ts
src/storage/mongodb/SettingStorage.ts
@@ -304,20 +304,6 @@ export default class SettingStorage {
}
}
- public static async saveCryptoSettings(tenantID: string, cryptoSettingToSave: CryptoKeySetting): Promise<void> {
- // Build internal structure
- const settingsToSave = {
- id: cryptoSettingToSave.id,
- identifier: 'crypto',
- lastChangedOn: new Date(),
- content: {
- crypto: cryptoSettingToSave.crypto
- },
- } as SettingDB;
- // Save
- await this.saveSettings(tenantID, settingsToSave);
- }
-
public static async getCryptoSettings(tenantID: string): Promise<CryptoKeySetting> {
// Get the Crypto Key settings
const settings = await SettingStorage.getSettings(tenantID,

MODIFY
src/utils/Cypher.ts
src/utils/Cypher.ts
+import { CryptoKeySetting, CryptoSetting, SettingDB } from '../types/Setting';
+
import BackendError from '../exception/BackendError';
import Constants from './Constants';
-import { CryptoSetting } from '../types/Setting';
import SettingStorage from '../storage/mongodb/SettingStorage';
import Utils from './Utils';
import _ from 'lodash';
@@ -146,4 +147,18 @@ export default class Cypher {
}
return cryptoSettings.crypto;
}
+
+ public static async saveCryptoSetting(tenantID: string, cryptoSettingToSave: CryptoKeySetting): Promise<void> {
+ // Build internal structure
+ const settingsToSave = {
+ id: cryptoSettingToSave.id,
+ identifier: 'crypto',
+ lastChangedOn: new Date(),
+ content: {
+ crypto: cryptoSettingToSave.crypto
+ },
+ } as SettingDB;
+ // Save
+ await SettingStorage.saveSettings(tenantID, settingsToSave);
+ }
}

Move saveCryptoSetting in Cypher class beside getCryptoSetting