...
|
...
|
@@ -15,7 +15,7 @@ |
15
|
15
|
///
|
16
|
16
|
|
17
|
17
|
|
18
|
|
-import {Component, Inject, OnInit } from '@angular/core';
|
|
18
|
+import { Component, Inject, OnInit } from '@angular/core';
|
19
|
19
|
import { DialogComponent } from '@shared/components/dialog.component';
|
20
|
20
|
import { Store } from '@ngrx/store';
|
21
|
21
|
import { AppState } from '@core/core.state';
|
...
|
...
|
@@ -24,22 +24,22 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; |
24
|
24
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
25
|
25
|
import { TranslateService } from '@ngx-translate/core';
|
26
|
26
|
import {
|
27
|
|
- SECURITY_CONFIG_MODE_NAMES,
|
28
|
|
- SECURITY_CONFIG_MODE,
|
29
|
|
- SecurityConfigModels,
|
30
|
|
- ClientSecurityConfigPSK,
|
31
|
|
- ClientSecurityConfigRPK,
|
32
|
|
- JSON_ALL_CONFIG,
|
33
|
|
- KEY_REGEXP_HEX_DEC,
|
34
|
|
- DeviceCredentialsDialogLwm2mData,
|
35
|
27
|
BOOTSTRAP_SERVER,
|
36
|
28
|
BOOTSTRAP_SERVERS,
|
37
|
|
- LWM2M_SERVER,
|
38
|
|
- ClientSecurityConfigX509,
|
39
|
29
|
ClientSecurityConfigNoSEC,
|
|
30
|
+ ClientSecurityConfigPSK,
|
|
31
|
+ ClientSecurityConfigRPK,
|
|
32
|
+ ClientSecurityConfigX509,
|
|
33
|
+ DeviceCredentialsDialogLwm2mData,
|
40
|
34
|
getDefaultClientSecurityConfigType,
|
|
35
|
+ JSON_ALL_CONFIG,
|
|
36
|
+ KEY_REGEXP_HEX_DEC,
|
41
|
37
|
LEN_MAX_PSK,
|
42
|
|
- LEN_MAX_PUBLIC_KEY_RPK
|
|
38
|
+ LEN_MAX_PUBLIC_KEY_RPK,
|
|
39
|
+ LWM2M_SERVER,
|
|
40
|
+ SECURITY_CONFIG_MODE,
|
|
41
|
+ SECURITY_CONFIG_MODE_NAMES,
|
|
42
|
+ SecurityConfigModels
|
43
|
43
|
} from './security-config.models';
|
44
|
44
|
import { WINDOW } from '@core/services/window.service';
|
45
|
45
|
import { MatTabChangeEvent } from '@angular/material/tabs';
|
...
|
...
|
@@ -65,9 +65,9 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo |
65
|
65
|
bootstrapServer: string;
|
66
|
66
|
lwm2mServer: string;
|
67
|
67
|
jsonObserveData: {};
|
68
|
|
- lenMaxKeyClient = LEN_MAX_PSK as number;
|
|
68
|
+ lenMaxKeyClient = LEN_MAX_PSK;
|
69
|
69
|
tabPrevious: MatTab;
|
70
|
|
- tabIndexPrevious = 0 as number;
|
|
70
|
+ tabIndexPrevious = 0;
|
71
|
71
|
|
72
|
72
|
constructor(protected store: Store<AppState>,
|
73
|
73
|
protected router: Router,
|
...
|
...
|
@@ -111,23 +111,23 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo |
111
|
111
|
}
|
112
|
112
|
|
113
|
113
|
private initClientSecurityConfig = (jsonAllConfig: SecurityConfigModels): void => {
|
114
|
|
- switch (jsonAllConfig.client.securityConfigClientMode.toString()) {
|
115
|
|
- case SECURITY_CONFIG_MODE.NO_SEC.toString():
|
|
114
|
+ switch (jsonAllConfig.client.securityConfigClientMode) {
|
|
115
|
+ case SECURITY_CONFIG_MODE.NO_SEC:
|
116
|
116
|
break;
|
117
|
|
- case SECURITY_CONFIG_MODE.PSK.toString():
|
|
117
|
+ case SECURITY_CONFIG_MODE.PSK:
|
118
|
118
|
const clientSecurityConfigPSK = jsonAllConfig.client as ClientSecurityConfigPSK;
|
119
|
119
|
this.lwm2mConfigFormGroup.patchValue({
|
120
|
120
|
identityPSK: clientSecurityConfigPSK.identity,
|
121
|
121
|
clientKey: clientSecurityConfigPSK.key,
|
122
|
122
|
}, {emitEvent: false});
|
123
|
123
|
break;
|
124
|
|
- case SECURITY_CONFIG_MODE.RPK.toString():
|
|
124
|
+ case SECURITY_CONFIG_MODE.RPK:
|
125
|
125
|
const clientSecurityConfigRPK = jsonAllConfig.client as ClientSecurityConfigRPK;
|
126
|
126
|
this.lwm2mConfigFormGroup.patchValue({
|
127
|
127
|
clientKey: clientSecurityConfigRPK.key,
|
128
|
128
|
}, {emitEvent: false});
|
129
|
129
|
break;
|
130
|
|
- case SECURITY_CONFIG_MODE.X509.toString():
|
|
130
|
+ case SECURITY_CONFIG_MODE.X509:
|
131
|
131
|
const clientSecurityConfigX509 = jsonAllConfig.client as ClientSecurityConfigX509;
|
132
|
132
|
this.lwm2mConfigFormGroup.patchValue({
|
133
|
133
|
clientCertificate: clientSecurityConfigX509.x509
|
...
|
...
|
@@ -295,7 +295,7 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo |
295
|
295
|
|
296
|
296
|
private updateIdentityPSK = (): void => {
|
297
|
297
|
const securityMode = 'securityMode';
|
298
|
|
- if (this.lwm2mConfigFormGroup.get('bootstrapServer').value[securityMode] === SECURITY_CONFIG_MODE.PSK.toString()) {
|
|
298
|
+ if (this.lwm2mConfigFormGroup.get('bootstrapServer').value[securityMode] === SECURITY_CONFIG_MODE.PSK) {
|
299
|
299
|
this.lwm2mConfigFormGroup.get('bootstrapFormGroup').patchValue({
|
300
|
300
|
clientPublicKeyOrId: this.lwm2mConfigFormGroup.get('identityPSK').value
|
301
|
301
|
});
|
...
|
...
|
@@ -303,7 +303,7 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo |
303
|
303
|
this.jsonAllConfig.client[identity] = this.lwm2mConfigFormGroup.get('identityPSK').value;
|
304
|
304
|
this.upDateJsonAllConfig();
|
305
|
305
|
}
|
306
|
|
- if (this.lwm2mConfigFormGroup.get('lwm2mServer').value[securityMode] === SECURITY_CONFIG_MODE.PSK.toString()) {
|
|
306
|
+ if (this.lwm2mConfigFormGroup.get('lwm2mServer').value[securityMode] === SECURITY_CONFIG_MODE.PSK) {
|
307
|
307
|
this.lwm2mConfigFormGroup.get('lwm2mServerFormGroup').patchValue({
|
308
|
308
|
clientPublicKeyOrId: this.lwm2mConfigFormGroup.get('identityPSK').value
|
309
|
309
|
});
|
...
|
...
|
@@ -316,13 +316,13 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo |
316
|
316
|
const key = 'key';
|
317
|
317
|
const securityMode = 'securityMode';
|
318
|
318
|
this.jsonAllConfig.client[key] = this.lwm2mConfigFormGroup.get('clientKey').value;
|
319
|
|
- if (this.lwm2mConfigFormGroup.get('bootstrapServer').value[securityMode] === SECURITY_CONFIG_MODE.PSK.toString()) {
|
|
319
|
+ if (this.lwm2mConfigFormGroup.get('bootstrapServer').value[securityMode] === SECURITY_CONFIG_MODE.PSK) {
|
320
|
320
|
this.lwm2mConfigFormGroup.get('bootstrapServer').patchValue({
|
321
|
321
|
clientSecretKey: this.jsonAllConfig.client[key]
|
322
|
322
|
}, {emitEvent: false});
|
323
|
323
|
this.jsonAllConfig.bootstrap.bootstrapServer.clientSecretKey = this.jsonAllConfig.client[key];
|
324
|
324
|
}
|
325
|
|
- if (this.lwm2mConfigFormGroup.get('lwm2mServer').value[securityMode] === SECURITY_CONFIG_MODE.PSK.toString()) {
|
|
325
|
+ if (this.lwm2mConfigFormGroup.get('lwm2mServer').value[securityMode] === SECURITY_CONFIG_MODE.PSK) {
|
326
|
326
|
this.lwm2mConfigFormGroup.get('lwm2mServer').patchValue({
|
327
|
327
|
clientSecretKey: this.jsonAllConfig.client[key]
|
328
|
328
|
}, {emitEvent: false});
|
...
|
...
|
|