Commit 972f1516d04b41c817dc25c2d3737391a9550c1f
Committed by
Andrew Shvayka
1 parent
3bf48f0f
UI: Change maxlength key validation LWm2M security in PSK and x509 mode
Showing
10 changed files
with
36 additions
and
75 deletions
@@ -28,27 +28,18 @@ | @@ -28,27 +28,18 @@ | ||
28 | <mat-form-field class="mat-block"> | 28 | <mat-form-field class="mat-block"> |
29 | <mat-label>{{ 'device.lwm2m-security-config.client-publicKey-or-id' | translate }}</mat-label> | 29 | <mat-label>{{ 'device.lwm2m-security-config.client-publicKey-or-id' | translate }}</mat-label> |
30 | <textarea matInput | 30 | <textarea matInput |
31 | - #clientPublicKeyOrId | ||
32 | - [maxlength]="lenMaxClientPublicKeyOrId" | ||
33 | cdkTextareaAutosize | 31 | cdkTextareaAutosize |
34 | cdkAutosizeMinRows="1" | 32 | cdkAutosizeMinRows="1" |
35 | cols="1" | 33 | cols="1" |
36 | formControlName="clientPublicKeyOrId" | 34 | formControlName="clientPublicKeyOrId" |
37 | required> | 35 | required> |
38 | </textarea> | 36 | </textarea> |
39 | - <mat-hint align="end">{{clientPublicKeyOrId.value?.length || 0}}/{{lenMaxClientPublicKeyOrId}}</mat-hint> | ||
40 | <mat-error *ngIf="serverFormGroup.get('clientPublicKeyOrId').hasError('required')"> | 37 | <mat-error *ngIf="serverFormGroup.get('clientPublicKeyOrId').hasError('required')"> |
41 | {{ 'device.lwm2m-security-config.client-publicKey-or-id-required' | translate }} | 38 | {{ 'device.lwm2m-security-config.client-publicKey-or-id-required' | translate }} |
42 | </mat-error> | 39 | </mat-error> |
43 | <mat-error *ngIf="serverFormGroup.get('clientPublicKeyOrId').hasError('pattern')"> | 40 | <mat-error *ngIf="serverFormGroup.get('clientPublicKeyOrId').hasError('pattern')"> |
44 | {{ 'device.lwm2m-security-config.client-publicKey-or-id-pattern' | translate }} | 41 | {{ 'device.lwm2m-security-config.client-publicKey-or-id-pattern' | translate }} |
45 | </mat-error> | 42 | </mat-error> |
46 | - <mat-error *ngIf="(serverFormGroup.get('clientPublicKeyOrId').hasError('maxlength') || | ||
47 | - serverFormGroup.get('clientPublicKeyOrId').hasError('minlength'))"> | ||
48 | - {{ 'device.lwm2m-security-config.client-publicKey-or-id-length' | translate: { | ||
49 | - count: lenMaxClientPublicKeyOrId | ||
50 | - } }} | ||
51 | - </mat-error> | ||
52 | </mat-form-field> | 43 | </mat-form-field> |
53 | <mat-form-field class="mat-block"> | 44 | <mat-form-field class="mat-block"> |
54 | <mat-label>{{ 'device.lwm2m-security-config.client-secret-key' | translate }}</mat-label> | 45 | <mat-label>{{ 'device.lwm2m-security-config.client-secret-key' | translate }}</mat-label> |
@@ -61,17 +52,18 @@ | @@ -61,17 +52,18 @@ | ||
61 | formControlName="clientSecretKey" | 52 | formControlName="clientSecretKey" |
62 | required> | 53 | required> |
63 | </textarea> | 54 | </textarea> |
64 | - <mat-hint align="end">{{clientSecretKey.value?.length || 0}}/{{lengthClientSecretKey}}</mat-hint> | 55 | + <mat-hint [fxShow]="serverFormGroup.get('securityMode').value === securityConfigLwM2MType.PSK" align="end"> |
56 | + {{clientSecretKey.value?.length || 0}}/{{lengthClientSecretKey}} | ||
57 | + </mat-hint> | ||
65 | <mat-error *ngIf="serverFormGroup.get('clientSecretKey').hasError('required')"> | 58 | <mat-error *ngIf="serverFormGroup.get('clientSecretKey').hasError('required')"> |
66 | {{ 'device.lwm2m-security-config.client-secret-key-required' | translate }} | 59 | {{ 'device.lwm2m-security-config.client-secret-key-required' | translate }} |
67 | </mat-error> | 60 | </mat-error> |
68 | <mat-error *ngIf="serverFormGroup.get('clientSecretKey').hasError('pattern')"> | 61 | <mat-error *ngIf="serverFormGroup.get('clientSecretKey').hasError('pattern')"> |
69 | {{ 'device.lwm2m-security-config.client-secret-key-pattern' | translate }} | 62 | {{ 'device.lwm2m-security-config.client-secret-key-pattern' | translate }} |
70 | </mat-error> | 63 | </mat-error> |
71 | - <mat-error *ngIf="(serverFormGroup.get('clientSecretKey').hasError('maxlength') || | ||
72 | - serverFormGroup.get('clientSecretKey').hasError('minlength'))"> | 64 | + <mat-error *ngIf="serverFormGroup.get('clientSecretKey').hasError('length')"> |
73 | {{ 'device.lwm2m-security-config.client-secret-key-length' | translate: { | 65 | {{ 'device.lwm2m-security-config.client-secret-key-length' | translate: { |
74 | - count: lengthClientSecretKey | 66 | + count: allowLengthKey.join(', ') |
75 | } }} | 67 | } }} |
76 | </mat-error> | 68 | </mat-error> |
77 | </mat-form-field> | 69 | </mat-form-field> |
@@ -16,6 +16,7 @@ | @@ -16,6 +16,7 @@ | ||
16 | 16 | ||
17 | import { Component, forwardRef, OnDestroy } from '@angular/core'; | 17 | import { Component, forwardRef, OnDestroy } from '@angular/core'; |
18 | import { | 18 | import { |
19 | + AbstractControl, | ||
19 | ControlValueAccessor, | 20 | ControlValueAccessor, |
20 | FormBuilder, | 21 | FormBuilder, |
21 | FormGroup, | 22 | FormGroup, |
@@ -29,8 +30,6 @@ import { | @@ -29,8 +30,6 @@ import { | ||
29 | KEY_REGEXP_HEX_DEC, | 30 | KEY_REGEXP_HEX_DEC, |
30 | LEN_MAX_PRIVATE_KEY, | 31 | LEN_MAX_PRIVATE_KEY, |
31 | LEN_MAX_PSK, | 32 | LEN_MAX_PSK, |
32 | - LEN_MAX_PUBLIC_KEY_RPK, | ||
33 | - LEN_MAX_PUBLIC_KEY_X509, | ||
34 | Lwm2mSecurityType, | 33 | Lwm2mSecurityType, |
35 | Lwm2mSecurityTypeTranslationMap, | 34 | Lwm2mSecurityTypeTranslationMap, |
36 | ServerSecurityConfig | 35 | ServerSecurityConfig |
@@ -62,9 +61,8 @@ export class DeviceCredentialsLwm2mServerComponent implements OnDestroy, Control | @@ -62,9 +61,8 @@ export class DeviceCredentialsLwm2mServerComponent implements OnDestroy, Control | ||
62 | securityConfigLwM2MType = Lwm2mSecurityType; | 61 | securityConfigLwM2MType = Lwm2mSecurityType; |
63 | securityConfigLwM2MTypes = Object.values(Lwm2mSecurityType); | 62 | securityConfigLwM2MTypes = Object.values(Lwm2mSecurityType); |
64 | lwm2mSecurityTypeTranslationMap = Lwm2mSecurityTypeTranslationMap; | 63 | lwm2mSecurityTypeTranslationMap = Lwm2mSecurityTypeTranslationMap; |
65 | - lenMinClientPublicKeyOrId = 0; | ||
66 | - lenMaxClientPublicKeyOrId = LEN_MAX_PUBLIC_KEY_RPK; | ||
67 | lengthClientSecretKey = LEN_MAX_PRIVATE_KEY; | 64 | lengthClientSecretKey = LEN_MAX_PRIVATE_KEY; |
65 | + allowLengthKey = [32, 64, LEN_MAX_PSK]; | ||
68 | 66 | ||
69 | private destroy$ = new Subject(); | 67 | private destroy$ = new Subject(); |
70 | private propagateChange = (v: any) => {}; | 68 | private propagateChange = (v: any) => {}; |
@@ -134,21 +132,15 @@ export class DeviceCredentialsLwm2mServerComponent implements OnDestroy, Control | @@ -134,21 +132,15 @@ export class DeviceCredentialsLwm2mServerComponent implements OnDestroy, Control | ||
134 | this.serverFormGroup.get('clientSecretKey').disable(); | 132 | this.serverFormGroup.get('clientSecretKey').disable(); |
135 | break; | 133 | break; |
136 | case Lwm2mSecurityType.PSK: | 134 | case Lwm2mSecurityType.PSK: |
137 | - this.lenMinClientPublicKeyOrId = 0; | ||
138 | - this.lenMaxClientPublicKeyOrId = LEN_MAX_PUBLIC_KEY_RPK; | ||
139 | this.lengthClientSecretKey = LEN_MAX_PSK; | 135 | this.lengthClientSecretKey = LEN_MAX_PSK; |
140 | this.setValidatorsSecurity(securityMode); | 136 | this.setValidatorsSecurity(securityMode); |
141 | break; | 137 | break; |
142 | case Lwm2mSecurityType.RPK: | 138 | case Lwm2mSecurityType.RPK: |
143 | - this.lenMinClientPublicKeyOrId = LEN_MAX_PUBLIC_KEY_RPK; | ||
144 | - this.lenMaxClientPublicKeyOrId = LEN_MAX_PUBLIC_KEY_RPK; | ||
145 | - this.lengthClientSecretKey = LEN_MAX_PRIVATE_KEY; | 139 | + this.lengthClientSecretKey = null; |
146 | this.setValidatorsSecurity(securityMode); | 140 | this.setValidatorsSecurity(securityMode); |
147 | break; | 141 | break; |
148 | case Lwm2mSecurityType.X509: | 142 | case Lwm2mSecurityType.X509: |
149 | - this.lenMinClientPublicKeyOrId = 0; | ||
150 | - this.lenMaxClientPublicKeyOrId = LEN_MAX_PUBLIC_KEY_X509; | ||
151 | - this.lengthClientSecretKey = LEN_MAX_PRIVATE_KEY; | 143 | + this.lengthClientSecretKey = null; |
152 | this.setValidatorsSecurity(securityMode); | 144 | this.setValidatorsSecurity(securityMode); |
153 | break; | 145 | break; |
154 | } | 146 | } |
@@ -157,25 +149,28 @@ export class DeviceCredentialsLwm2mServerComponent implements OnDestroy, Control | @@ -157,25 +149,28 @@ export class DeviceCredentialsLwm2mServerComponent implements OnDestroy, Control | ||
157 | } | 149 | } |
158 | 150 | ||
159 | private setValidatorsSecurity = (securityMode: Lwm2mSecurityType): void => { | 151 | private setValidatorsSecurity = (securityMode: Lwm2mSecurityType): void => { |
152 | + const clientSecretKeyValidators = [Validators.required, Validators.pattern(KEY_REGEXP_HEX_DEC)]; | ||
153 | + const clientPublicKeyOrIdValidators = [Validators.required]; | ||
160 | if (securityMode === Lwm2mSecurityType.PSK) { | 154 | if (securityMode === Lwm2mSecurityType.PSK) { |
161 | - this.serverFormGroup.get('clientPublicKeyOrId').setValidators([Validators.required]); | 155 | + clientSecretKeyValidators.push(this.maxLength(this.allowLengthKey)); |
162 | } else { | 156 | } else { |
163 | - this.serverFormGroup.get('clientPublicKeyOrId').setValidators([ | ||
164 | - Validators.required, | ||
165 | - Validators.pattern(KEY_REGEXP_HEX_DEC), | ||
166 | - Validators.minLength(this.lenMinClientPublicKeyOrId), | ||
167 | - Validators.maxLength(this.lenMaxClientPublicKeyOrId) | ||
168 | - ]); | 157 | + clientPublicKeyOrIdValidators.push(Validators.pattern(KEY_REGEXP_HEX_DEC)); |
169 | } | 158 | } |
170 | 159 | ||
171 | - this.serverFormGroup.get('clientSecretKey').setValidators([ | ||
172 | - Validators.required, | ||
173 | - Validators.pattern(KEY_REGEXP_HEX_DEC), | ||
174 | - Validators.minLength(this.lengthClientSecretKey), | ||
175 | - Validators.maxLength(this.lengthClientSecretKey) | ||
176 | - ]); | 160 | + this.serverFormGroup.get('clientPublicKeyOrId').setValidators(clientPublicKeyOrIdValidators); |
161 | + this.serverFormGroup.get('clientSecretKey').setValidators(clientSecretKeyValidators); | ||
177 | 162 | ||
178 | this.serverFormGroup.get('clientPublicKeyOrId').enable({emitEvent: false}); | 163 | this.serverFormGroup.get('clientPublicKeyOrId').enable({emitEvent: false}); |
179 | this.serverFormGroup.get('clientSecretKey').enable(); | 164 | this.serverFormGroup.get('clientSecretKey').enable(); |
180 | } | 165 | } |
166 | + | ||
167 | + private maxLength(keyLengths: number[]) { | ||
168 | + return (control: AbstractControl): ValidationErrors | null => { | ||
169 | + const value = control.value; | ||
170 | + if (keyLengths.some(len => value.length === len)) { | ||
171 | + return null; | ||
172 | + } | ||
173 | + return {length: true}; | ||
174 | + }; | ||
175 | + } | ||
181 | } | 176 | } |
@@ -53,7 +53,8 @@ | @@ -53,7 +53,8 @@ | ||
53 | formControlName="key" | 53 | formControlName="key" |
54 | required> | 54 | required> |
55 | </textarea> | 55 | </textarea> |
56 | - <mat-hint align="end">{{key.value?.length || 0}}/{{lenMaxKeyClient}}</mat-hint> | 56 | + <mat-hint *ngIf="lwm2mConfigFormGroup.get('client.securityConfigClientMode').value === securityConfigLwM2MType.PSK" |
57 | + align="end">{{key.value?.length || 0}}/{{lenMaxKeyClient}}</mat-hint> | ||
57 | <mat-error *ngIf="lwm2mConfigFormGroup.get('client.key').hasError('required')"> | 58 | <mat-error *ngIf="lwm2mConfigFormGroup.get('client.key').hasError('required')"> |
58 | {{ 'device.lwm2m-security-config.client-key-required' | translate }} | 59 | {{ 'device.lwm2m-security-config.client-key-required' | translate }} |
59 | </mat-error> | 60 | </mat-error> |
@@ -31,7 +31,6 @@ import { | @@ -31,7 +31,6 @@ import { | ||
31 | getDefaultServerSecurityConfig, | 31 | getDefaultServerSecurityConfig, |
32 | KEY_REGEXP_HEX_DEC, | 32 | KEY_REGEXP_HEX_DEC, |
33 | LEN_MAX_PSK, | 33 | LEN_MAX_PSK, |
34 | - LEN_MAX_PUBLIC_KEY_RPK, | ||
35 | Lwm2mSecurityConfigModels, | 34 | Lwm2mSecurityConfigModels, |
36 | Lwm2mSecurityType, | 35 | Lwm2mSecurityType, |
37 | Lwm2mSecurityTypeTranslationMap | 36 | Lwm2mSecurityTypeTranslationMap |
@@ -65,7 +64,7 @@ export class DeviceCredentialsLwm2mComponent implements ControlValueAccessor, Va | @@ -65,7 +64,7 @@ export class DeviceCredentialsLwm2mComponent implements ControlValueAccessor, Va | ||
65 | securityConfigLwM2MTypes = Object.keys(Lwm2mSecurityType); | 64 | securityConfigLwM2MTypes = Object.keys(Lwm2mSecurityType); |
66 | credentialTypeLwM2MNamesMap = Lwm2mSecurityTypeTranslationMap; | 65 | credentialTypeLwM2MNamesMap = Lwm2mSecurityTypeTranslationMap; |
67 | lenMaxKeyClient = LEN_MAX_PSK; | 66 | lenMaxKeyClient = LEN_MAX_PSK; |
68 | - allowLengthKey: number[]; | 67 | + allowLengthKey = [32, 64, LEN_MAX_PSK]; |
69 | 68 | ||
70 | private destroy$ = new Subject(); | 69 | private destroy$ = new Subject(); |
71 | private propagateChange = (v: any) => {}; | 70 | private propagateChange = (v: any) => {}; |
@@ -137,13 +136,11 @@ export class DeviceCredentialsLwm2mComponent implements ControlValueAccessor, Va | @@ -137,13 +136,11 @@ export class DeviceCredentialsLwm2mComponent implements ControlValueAccessor, Va | ||
137 | break; | 136 | break; |
138 | case Lwm2mSecurityType.PSK: | 137 | case Lwm2mSecurityType.PSK: |
139 | this.lenMaxKeyClient = LEN_MAX_PSK; | 138 | this.lenMaxKeyClient = LEN_MAX_PSK; |
140 | - this.allowLengthKey = [32, 64, LEN_MAX_PSK]; | ||
141 | this.setValidatorsPskRpk(mode); | 139 | this.setValidatorsPskRpk(mode); |
142 | this.lwm2mConfigFormGroup.get('client.identity').enable({emitEvent: false}); | 140 | this.lwm2mConfigFormGroup.get('client.identity').enable({emitEvent: false}); |
143 | break; | 141 | break; |
144 | case Lwm2mSecurityType.RPK: | 142 | case Lwm2mSecurityType.RPK: |
145 | - this.lenMaxKeyClient = LEN_MAX_PUBLIC_KEY_RPK; | ||
146 | - this.allowLengthKey = [LEN_MAX_PUBLIC_KEY_RPK]; | 143 | + this.lenMaxKeyClient = null; |
147 | this.setValidatorsPskRpk(mode); | 144 | this.setValidatorsPskRpk(mode); |
148 | this.lwm2mConfigFormGroup.get('client.identity').disable({emitEvent: false}); | 145 | this.lwm2mConfigFormGroup.get('client.identity').disable({emitEvent: false}); |
149 | break; | 146 | break; |
@@ -160,16 +157,14 @@ export class DeviceCredentialsLwm2mComponent implements ControlValueAccessor, Va | @@ -160,16 +157,14 @@ export class DeviceCredentialsLwm2mComponent implements ControlValueAccessor, Va | ||
160 | } | 157 | } |
161 | 158 | ||
162 | private setValidatorsPskRpk = (mode: Lwm2mSecurityType): void => { | 159 | private setValidatorsPskRpk = (mode: Lwm2mSecurityType): void => { |
160 | + const keyValidators = [Validators.required, Validators.pattern(KEY_REGEXP_HEX_DEC)]; | ||
163 | if (mode === Lwm2mSecurityType.PSK) { | 161 | if (mode === Lwm2mSecurityType.PSK) { |
164 | this.lwm2mConfigFormGroup.get('client.identity').setValidators([Validators.required]); | 162 | this.lwm2mConfigFormGroup.get('client.identity').setValidators([Validators.required]); |
163 | + keyValidators.push(this.maxLength(this.allowLengthKey)); | ||
165 | } else { | 164 | } else { |
166 | this.lwm2mConfigFormGroup.get('client.identity').clearValidators(); | 165 | this.lwm2mConfigFormGroup.get('client.identity').clearValidators(); |
167 | } | 166 | } |
168 | - this.lwm2mConfigFormGroup.get('client.key').setValidators([ | ||
169 | - Validators.required, | ||
170 | - Validators.pattern(KEY_REGEXP_HEX_DEC), | ||
171 | - this.maxLength(this.allowLengthKey) | ||
172 | - ]); | 167 | + this.lwm2mConfigFormGroup.get('client.key').setValidators(keyValidators); |
173 | this.lwm2mConfigFormGroup.get('client.key').enable({emitEvent: false}); | 168 | this.lwm2mConfigFormGroup.get('client.key').enable({emitEvent: false}); |
174 | this.lwm2mConfigFormGroup.get('client.cert').disable({emitEvent: false}); | 169 | this.lwm2mConfigFormGroup.get('client.cert').disable({emitEvent: false}); |
175 | } | 170 | } |
@@ -95,24 +95,17 @@ | @@ -95,24 +95,17 @@ | ||
95 | <mat-form-field class="mat-block"> | 95 | <mat-form-field class="mat-block"> |
96 | <mat-label>{{ 'device-profile.lwm2m.server-public-key' | translate }}</mat-label> | 96 | <mat-label>{{ 'device-profile.lwm2m.server-public-key' | translate }}</mat-label> |
97 | <textarea matInput | 97 | <textarea matInput |
98 | - #serverPublicKey | ||
99 | - maxlength="{{maxLengthPublicKey}}" | ||
100 | cdkTextareaAutosize | 98 | cdkTextareaAutosize |
101 | cdkAutosizeMinRows="1" | 99 | cdkAutosizeMinRows="1" |
102 | cols="1" required | 100 | cols="1" required |
103 | formControlName="serverPublicKey" | 101 | formControlName="serverPublicKey" |
104 | ></textarea> | 102 | ></textarea> |
105 | - <mat-hint align="end">{{serverPublicKey.value?.length || 0}}/{{maxLengthPublicKey}}</mat-hint> | ||
106 | <mat-error *ngIf="serverFormGroup.get('serverPublicKey').hasError('required')"> | 103 | <mat-error *ngIf="serverFormGroup.get('serverPublicKey').hasError('required')"> |
107 | {{ 'device-profile.lwm2m.server-public-key-required' | translate }} | 104 | {{ 'device-profile.lwm2m.server-public-key-required' | translate }} |
108 | </mat-error> | 105 | </mat-error> |
109 | <mat-error *ngIf="serverFormGroup.get('serverPublicKey').hasError('pattern')"> | 106 | <mat-error *ngIf="serverFormGroup.get('serverPublicKey').hasError('pattern')"> |
110 | {{ 'device-profile.lwm2m.server-public-key-pattern' | translate }} | 107 | {{ 'device-profile.lwm2m.server-public-key-pattern' | translate }} |
111 | </mat-error> | 108 | </mat-error> |
112 | - <mat-error *ngIf="serverFormGroup.get('serverPublicKey').hasError('maxlength') || | ||
113 | - serverFormGroup.get('serverPublicKey').hasError('minlength')"> | ||
114 | - {{ 'device-profile.lwm2m.server-public-key-length' | translate: {count: maxLengthPublicKey } }} | ||
115 | - </mat-error> | ||
116 | </mat-form-field> | 109 | </mat-form-field> |
117 | </div> | 110 | </div> |
118 | </section> | 111 | </section> |
@@ -29,8 +29,6 @@ import { | @@ -29,8 +29,6 @@ import { | ||
29 | DEFAULT_PORT_BOOTSTRAP_NO_SEC, | 29 | DEFAULT_PORT_BOOTSTRAP_NO_SEC, |
30 | DEFAULT_PORT_SERVER_NO_SEC, | 30 | DEFAULT_PORT_SERVER_NO_SEC, |
31 | KEY_REGEXP_HEX_DEC, | 31 | KEY_REGEXP_HEX_DEC, |
32 | - LEN_MAX_PUBLIC_KEY_RPK, | ||
33 | - LEN_MAX_PUBLIC_KEY_X509, | ||
34 | securityConfigMode, | 32 | securityConfigMode, |
35 | securityConfigModeNames, | 33 | securityConfigModeNames, |
36 | ServerSecurityConfig | 34 | ServerSecurityConfig |
@@ -68,7 +66,6 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc | @@ -68,7 +66,6 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc | ||
68 | securityConfigLwM2MType = securityConfigMode; | 66 | securityConfigLwM2MType = securityConfigMode; |
69 | securityConfigLwM2MTypes = Object.keys(securityConfigMode); | 67 | securityConfigLwM2MTypes = Object.keys(securityConfigMode); |
70 | credentialTypeLwM2MNamesMap = securityConfigModeNames; | 68 | credentialTypeLwM2MNamesMap = securityConfigModeNames; |
71 | - maxLengthPublicKey = LEN_MAX_PUBLIC_KEY_RPK; | ||
72 | currentSecurityMode = null; | 69 | currentSecurityMode = null; |
73 | 70 | ||
74 | @Input() | 71 | @Input() |
@@ -147,12 +144,10 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc | @@ -147,12 +144,10 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc | ||
147 | this.clearValidators(); | 144 | this.clearValidators(); |
148 | break; | 145 | break; |
149 | case securityConfigMode.RPK: | 146 | case securityConfigMode.RPK: |
150 | - this.maxLengthPublicKey = LEN_MAX_PUBLIC_KEY_RPK; | ||
151 | - this.setValidators(LEN_MAX_PUBLIC_KEY_RPK); | 147 | + this.setValidators(); |
152 | break; | 148 | break; |
153 | case securityConfigMode.X509: | 149 | case securityConfigMode.X509: |
154 | - this.maxLengthPublicKey = LEN_MAX_PUBLIC_KEY_X509; | ||
155 | - this.setValidators(0); | 150 | + this.setValidators(); |
156 | break; | 151 | break; |
157 | } | 152 | } |
158 | this.serverFormGroup.get('serverPublicKey').updateValueAndValidity({emitEvent: false}); | 153 | this.serverFormGroup.get('serverPublicKey').updateValueAndValidity({emitEvent: false}); |
@@ -162,12 +157,10 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc | @@ -162,12 +157,10 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc | ||
162 | this.serverFormGroup.get('serverPublicKey').clearValidators(); | 157 | this.serverFormGroup.get('serverPublicKey').clearValidators(); |
163 | } | 158 | } |
164 | 159 | ||
165 | - private setValidators(minLengthKey: number): void { | 160 | + private setValidators(): void { |
166 | this.serverFormGroup.get('serverPublicKey').setValidators([ | 161 | this.serverFormGroup.get('serverPublicKey').setValidators([ |
167 | Validators.required, | 162 | Validators.required, |
168 | - Validators.pattern(KEY_REGEXP_HEX_DEC), | ||
169 | - Validators.minLength(minLengthKey), | ||
170 | - Validators.maxLength(this.maxLengthPublicKey) | 163 | + Validators.pattern(KEY_REGEXP_HEX_DEC) |
171 | ]); | 164 | ]); |
172 | } | 165 | } |
173 | 166 |
@@ -34,8 +34,6 @@ export const DEFAULT_MIN_PERIOD = 1; | @@ -34,8 +34,6 @@ export const DEFAULT_MIN_PERIOD = 1; | ||
34 | export const DEFAULT_NOTIF_IF_DESIBLED = true; | 34 | export const DEFAULT_NOTIF_IF_DESIBLED = true; |
35 | export const DEFAULT_BINDING = 'UQ'; | 35 | export const DEFAULT_BINDING = 'UQ'; |
36 | export const DEFAULT_BOOTSTRAP_SERVER_ACCOUNT_TIME_OUT = 0; | 36 | export const DEFAULT_BOOTSTRAP_SERVER_ACCOUNT_TIME_OUT = 0; |
37 | -export const LEN_MAX_PUBLIC_KEY_RPK = 182; | ||
38 | -export const LEN_MAX_PUBLIC_KEY_X509 = 3000; | ||
39 | export const KEY_REGEXP_HEX_DEC = /^[-+]?[0-9A-Fa-f]+\.?[0-9A-Fa-f]*?$/; | 37 | export const KEY_REGEXP_HEX_DEC = /^[-+]?[0-9A-Fa-f]+\.?[0-9A-Fa-f]*?$/; |
40 | export const INSTANCES_ID_VALUE_MIN = 0; | 38 | export const INSTANCES_ID_VALUE_MIN = 0; |
41 | export const INSTANCES_ID_VALUE_MAX = 65535; | 39 | export const INSTANCES_ID_VALUE_MAX = 65535; |
@@ -16,8 +16,6 @@ | @@ -16,8 +16,6 @@ | ||
16 | 16 | ||
17 | export const LEN_MAX_PSK = 128; | 17 | export const LEN_MAX_PSK = 128; |
18 | export const LEN_MAX_PRIVATE_KEY = 134; | 18 | export const LEN_MAX_PRIVATE_KEY = 134; |
19 | -export const LEN_MAX_PUBLIC_KEY_RPK = 182; | ||
20 | -export const LEN_MAX_PUBLIC_KEY_X509 = 3000; | ||
21 | export const KEY_REGEXP_HEX_DEC = /^[-+]?[0-9A-Fa-f]+\.?[0-9A-Fa-f]*?$/; | 19 | export const KEY_REGEXP_HEX_DEC = /^[-+]?[0-9A-Fa-f]+\.?[0-9A-Fa-f]*?$/; |
22 | 20 | ||
23 | export enum Lwm2mSecurityType { | 21 | export enum Lwm2mSecurityType { |
@@ -974,7 +974,6 @@ | @@ -974,7 +974,6 @@ | ||
974 | "client-publicKey-or-id": "Veřejný klíč nebo Id klienta", | 974 | "client-publicKey-or-id": "Veřejný klíč nebo Id klienta", |
975 | "client-publicKey-or-id-required": "Veřejný klíč nebo Id klienta jsou povinné.", | 975 | "client-publicKey-or-id-required": "Veřejný klíč nebo Id klienta jsou povinné.", |
976 | "client-publicKey-or-id-pattern": "Veřejný klíč klienta nebo Id musí být v hexadecimálním formátu.", | 976 | "client-publicKey-or-id-pattern": "Veřejný klíč klienta nebo Id musí být v hexadecimálním formátu.", |
977 | - "client-publicKey-or-id-length": "Veřejný klíč klienta nebo Id musí mít {{ count }} znaků.", | ||
978 | "client-secret-key": "Tajný klíč klienta", | 977 | "client-secret-key": "Tajný klíč klienta", |
979 | "client-secret-key-required": "Tajný klíč klienta je povinný.", | 978 | "client-secret-key-required": "Tajný klíč klienta je povinný.", |
980 | "client-secret-key-pattern": "Tajný klíč klienta musí být v hexadecimálním formátu.", | 979 | "client-secret-key-pattern": "Tajný klíč klienta musí být v hexadecimálním formátu.", |
@@ -1301,7 +1300,6 @@ | @@ -1301,7 +1300,6 @@ | ||
1301 | "server-public-key": "Veřejný klíč serveru", | 1300 | "server-public-key": "Veřejný klíč serveru", |
1302 | "server-public-key-required": "Veřejný klíč serveru je povinný.", | 1301 | "server-public-key-required": "Veřejný klíč serveru je povinný.", |
1303 | "server-public-key-pattern": "Veřejný klíč serveru musí být v hexadecimálním formátu.", | 1302 | "server-public-key-pattern": "Veřejný klíč serveru musí být v hexadecimálním formátu.", |
1304 | - "server-public-key-length": "Veřejný klíč serveru musí být {{ count }} znaků.", | ||
1305 | "client-hold-off-time": "Čas odložení", | 1303 | "client-hold-off-time": "Čas odložení", |
1306 | "client-hold-off-time-required": "Čas odloženíje povinný.", | 1304 | "client-hold-off-time-required": "Čas odloženíje povinný.", |
1307 | "client-hold-off-time-pattern": "Čas odložení musí být kladné celé číslo.", | 1305 | "client-hold-off-time-pattern": "Čas odložení musí být kladné celé číslo.", |
@@ -978,7 +978,6 @@ | @@ -978,7 +978,6 @@ | ||
978 | "client-publicKey-or-id": "Client Public Key or Id", | 978 | "client-publicKey-or-id": "Client Public Key or Id", |
979 | "client-publicKey-or-id-required": "Client Public Key or Id is required.", | 979 | "client-publicKey-or-id-required": "Client Public Key or Id is required.", |
980 | "client-publicKey-or-id-pattern": "Client Public Key or Id must be hexadecimal format.", | 980 | "client-publicKey-or-id-pattern": "Client Public Key or Id must be hexadecimal format.", |
981 | - "client-publicKey-or-id-length": "Client Public Key or Id must be {{ count }} characters.", | ||
982 | "client-secret-key": "Client Secret Key", | 981 | "client-secret-key": "Client Secret Key", |
983 | "client-secret-key-required": "Client Secret Key is required.", | 982 | "client-secret-key-required": "Client Secret Key is required.", |
984 | "client-secret-key-pattern": "Client Secret Key must be hexadecimal format.", | 983 | "client-secret-key-pattern": "Client Secret Key must be hexadecimal format.", |
@@ -1315,7 +1314,6 @@ | @@ -1315,7 +1314,6 @@ | ||
1315 | "server-public-key": "Server Public Key", | 1314 | "server-public-key": "Server Public Key", |
1316 | "server-public-key-required": "Server Public Key is required.", | 1315 | "server-public-key-required": "Server Public Key is required.", |
1317 | "server-public-key-pattern": "Server Public Key must be hex decimal format.", | 1316 | "server-public-key-pattern": "Server Public Key must be hex decimal format.", |
1318 | - "server-public-key-length": "Server Public Key must be {{ count }} characters.", | ||
1319 | "client-hold-off-time": "Hold Off Time", | 1317 | "client-hold-off-time": "Hold Off Time", |
1320 | "client-hold-off-time-required": "Hold Off Time is required.", | 1318 | "client-hold-off-time-required": "Hold Off Time is required.", |
1321 | "client-hold-off-time-pattern": "Hold Off Time must be a positive integer.", | 1319 | "client-hold-off-time-pattern": "Hold Off Time must be a positive integer.", |